From 76e72f167aeed1c1bd271980ebbdd36be772a16b Mon Sep 17 00:00:00 2001 From: AI Dev Date: Thu, 3 Dec 2026 08:34:25 +0000 Subject: [PATCH 1/2] gm: the GM8126 and GM8128 on the vendor 2.6.28 kernel That kernel says "Hardware : Faraday GM8126" for every die and has no /proc/pmu/chipver, so no row matched. It names the die on its boot line ("IC: GM8128 MP") from the PMU ID word, 0x99000000 >> 8: 0x812610 GM8126, 0x812620 GM8126 MP, 0x812621 GM8128 MP. /proc/pmu/attribute shows the same word as pmuver, so it is read from there, without /dev/mem. ipctool only, as the rest of the GM8126 support: ipcinfo is unchanged. Closes #305 --- src/chipid.c | 2 ++ src/hal/gm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/hal/gm.h | 1 + 3 files changed, 48 insertions(+) diff --git a/src/chipid.c b/src/chipid.c index 1dfcff4..3cfe95c 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -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 diff --git a/src/hal/gm.c b/src/hal/gm.c index a57bcb5..a60d290 100644 --- a/src/hal/gm.c +++ b/src/hal/gm.c @@ -59,6 +59,51 @@ 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. */ +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: + sprintf(chip_name, "GM%.4s", buf); + } + return true; +} #endif static unsigned long gm_media_mem() { diff --git a/src/hal/gm.h b/src/hal/gm.h index 98933c1..e415a0a 100644 --- a/src/hal/gm.h +++ b/src/hal/gm.h @@ -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(); From fbcd2f8e1940b8ad8018ce83ecf75cd40e8f9b46 Mon Sep 17 00:00:00 2001 From: AI Dev Date: Thu, 3 Dec 2026 08:38:42 +0000 Subject: [PATCH 2/2] gm: an unlisted PMU ID names the generation, GM812x, not the GM8126 The Hardware line reads GM8126 on the GM8128 too, so with no pmuver, or one the kernel itself does not know, it cannot name the die. --- src/hal/gm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hal/gm.c b/src/hal/gm.c index a60d290..aa803bf 100644 --- a/src/hal/gm.c +++ b/src/hal/gm.c @@ -83,7 +83,9 @@ static unsigned long gm_pmuver() { /* 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. */ + * 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]; @@ -100,7 +102,7 @@ bool gm_faraday_detect_cpu(char *chip_name) { strcpy(chip_name, "GM8126"); break; default: - sprintf(chip_name, "GM%.4s", buf); + strcpy(chip_name, "GM812x"); } return true; }