Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ static const manufacturers_t manufacturers[] = {
#ifdef IPCHW_VENDOR_GM
{"Grain", gm_detect_cpu, VENDOR_GM, gm_setup_hal},
#ifndef STANDALONE_LIBRARY
/* GM8126 / GM8128 on the vendor 2.6.28 kernel */
{"Faraday", gm_faraday_detect_cpu, VENDOR_GM, gm_setup_hal},
{NULL /* Generic */, gm_dt_detect_cpu, VENDOR_GM, gm_setup_hal},
#endif
#endif
Expand Down
47 changes: 47 additions & 0 deletions src/hal/gm.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,53 @@ bool gm_dt_detect_cpu(char *chip_name) {
}
return false;
}

/* The PMU's ID word (0x99000000 >> 8) as the vendor 2.6.28 kernel shows it:
* the value under "Attribute name : pmuver" in /proc/pmu/attribute. */
static unsigned long gm_pmuver() {
char line[128], name[32];
bool ours = false;
unsigned long ver = 0;

FILE *f = fopen("/proc/pmu/attribute", "r");
if (!f)
return 0;
while (fgets(line, sizeof(line), f)) {
if (sscanf(line, "Attribute name : %31s", name) == 1)
ours = !strcmp(name, "pmuver");
else if (ours && sscanf(line, "Attribute value: %lu", &ver) == 1)
break;
}
fclose(f);
return ver;
}

/* The vendor 2.6.28 kernel of the GM8126 generation says "Hardware :
* Faraday GM8126" whatever the die, and has no /proc/pmu/chipver. It tells
* the dies apart on its boot line ("IC: GM8128 MP") from the PMU ID word:
* 0x812610 GM8126, 0x812620 GM8126 MP, 0x812621 GM8128 MP. Without one of
* those the Hardware line names only the generation, so that is all the
* report claims. */
bool gm_faraday_detect_cpu(char *chip_name) {
char buf[256];

if (!line_from_file("/proc/cpuinfo", "Hardware.+:.Faraday.GM([0-9]+)", buf,
sizeof(buf)))
return false;

switch (gm_pmuver()) {
case 0x812621:
strcpy(chip_name, "GM8128");
break;
case 0x812610:
case 0x812620:
strcpy(chip_name, "GM8126");
break;
default:
strcpy(chip_name, "GM812x");
}
return true;
}
#endif

static unsigned long gm_media_mem() {
Expand Down
1 change: 1 addition & 0 deletions src/hal/gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
bool gm_detect_cpu(char *chip_name);
#ifndef STANDALONE_LIBRARY
bool gm_dt_detect_cpu(char *chip_name);
bool gm_faraday_detect_cpu(char *chip_name);
#endif
unsigned long gm_totalmem(unsigned long *media_mem);
void gm_setup_hal();
Expand Down