From d835207c76f86849faa2f4ca01741e570cf2a8b4 Mon Sep 17 00:00:00 2001 From: Dmitry Ermakov <7954832+dimerr@users.noreply.github.com> Date: Wed, 18 Nov 2026 08:32:10 +0000 Subject: [PATCH 1/3] hisi: tell GK7206V11A from V11 by the eFuse model code Both report chip ID 0x72060110, so a GK7206V11A was shown as 7206V11. What differs is the model code in the low byte of eFuse word 0x10090030, whose high half is "GK" (0x474B): the vendor modules check it (xm_common accepts only 0x474B00B7..0x474B00DD; xm_vi and xm_venc single out 0xCA among other codes). Nothing in the SDK or in XM's firmware names the codes -- XM's own image hard-codes its product name -- so only the code read on a known part is listed: 0xCA on an IVG-K8 (XM IPC_GK7206V11A). Any other code stays 7206V11 until one is confirmed. The eFuse reads 0x2 while its clock (CRG 0x1BC bit 1) is off; it is turned on for the read and back off if it was off. On the camera: model 7206V11A, CRG 0x1BC 0x284 before and after. Co-authored-by: OpenIPC AI team --- src/hal/hisi/hal_hisi.c | 39 +++++++++++++++++++++++++++++++++++- src/hal/hisi/hal_hisi_test.c | 22 ++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/hal/hisi/hal_hisi.c b/src/hal/hisi/hal_hisi.c index 48ce079..e792bdd 100644 --- a/src/hal/hisi/hal_hisi.c +++ b/src/hal/hisi/hal_hisi.c @@ -988,6 +988,43 @@ static const char *get_chip_V3(uint8_t scsysid0) { } #endif /* IPCHW_HISI_V3 */ +#ifdef IPCHW_HISI_GOKE7206 +/* GK7206V11 and V11A share the chip ID 0x72060110. What tells them apart is + * the model code in the low byte of eFuse word 0x10090030, whose high half is + * "GK" (0x474B). The vendor modules check it (xm_common refuses a word outside + * 0x474B00B7..0x474B00DD; xm_vi and xm_venc single out 0xCA among others), but + * nothing in the SDK or XM's firmware names the codes, so only the ones read + * on a known part are listed. The eFuse reads 0x2 until its clock (CRG 0x1BC + * bit 1) is on; it is turned back off if it was off. */ +#define GK7206_CRG_OTP 0x120101BC +#define GK7206_CRG_OTP_CKEN (1u << 1) +#define GK7206_EFUSE_MODEL 0x10090030 + +static const char *gk7206_v11_variant() { + uint32_t crg, word = 0; + + if (!mem_reg(GK7206_CRG_OTP, &crg, OP_READ)) + return "7206V11"; + if (!(crg & GK7206_CRG_OTP_CKEN)) { + uint32_t on = crg | GK7206_CRG_OTP_CKEN; + if (!mem_reg(GK7206_CRG_OTP, &on, OP_WRITE)) + return "7206V11"; + } + mem_reg(GK7206_EFUSE_MODEL, &word, OP_READ); + if (!(crg & GK7206_CRG_OTP_CKEN)) + mem_reg(GK7206_CRG_OTP, &crg, OP_WRITE); + + if (word >> 16 != 0x474B) + return "7206V11"; + switch (word & 0xff) { + case 0xCA: /* IVG-K8 (XM IPC_GK7206V11A), 0x474B00CA */ + return "7206V11A"; + default: + return "7206V11"; + } +} +#endif + static const char *get_hisi_chip_id(uint32_t family_id, uint8_t scsysid0) { switch (family_id) { #ifdef IPCHW_HISI_V2A @@ -1177,7 +1214,7 @@ static const char *get_hisi_chip_id(uint32_t family_id, uint8_t scsysid0) { return "7206V10"; case 0x72060110: chip_generation = GOKE_7206; - return "7206V11"; + return gk7206_v11_variant(); case 0x72060120: // expected by the SDK's numbering, unseen chip_generation = GOKE_7206; diff --git a/src/hal/hisi/hal_hisi_test.c b/src/hal/hisi/hal_hisi_test.c index ee870cb..cb57f7e 100644 --- a/src/hal/hisi/hal_hisi_test.c +++ b/src/hal/hisi/hal_hisi_test.c @@ -421,6 +421,28 @@ int main(void) { seed(GK7206_TSENSOR_RECORD, 0); CHECK(isnan(hisi_get_temp())); + /* GK7206V11 vs V11A: one chip ID, told apart by the eFuse model code. + * The eFuse clock is turned on to read it and off again if it was off. */ + fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); + seed(GK7206_EFUSE_MODEL, 0x474B00CA); + CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11A") == 0); + CHECK(peek(GK7206_CRG_OTP) == 0x284); + CHECK(illegal == NULL); + + fresh(GK7206_CRG_OTP, 0x286, GOKE_7206); /* clock already on: left on */ + seed(GK7206_EFUSE_MODEL, 0x474B00CA); + CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11A") == 0); + CHECK(peek(GK7206_CRG_OTP) == 0x286); + CHECK(writes == 0); + + fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); /* a code not yet seen */ + seed(GK7206_EFUSE_MODEL, 0x474B00B7); + CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11") == 0); + + fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); /* gated read, no "GK" */ + seed(GK7206_EFUSE_MODEL, 0x2); + CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11") == 0); + if (failures) fprintf(stderr, "hal_hisi_test: %d failure(s)\n", failures); else From 3debe205fa235c94c5f20d615fe49621e0aae789 Mon Sep 17 00:00:00 2001 From: Dmitry Ermakov <7954832+dimerr@users.noreply.github.com> Date: Wed, 18 Nov 2026 08:58:15 +0000 Subject: [PATCH 2/3] hisi: name the whole GK7206 family from the eFuse model code (guessed) Extends the V11A check to every GK7206 chip ID, with a table that is guessed except for 0xCA. xm_vi and xm_venc sort the valid codes into capability classes (their limits are stored as (x ^ 0xA64BD) - 11): {B7, BC, C7, CC} 3840x2160 with a 3840 line, {CA, D8..DB, DD} 3840x2160 with a 4032 line, everything else 3840x3840. Nothing names them. Taking the high nibble as the DDR tier the SDK's load script gives each part (B 64 MB: V10, V10B; C 128 MB: V11, V11A, V11AT; D 256 MB: V12A) and the low nibble as the part in the tier (7 base, C the other, A the A part) fits both classes and the one known code: B7 V10, BC V10B, C7 V11, CA V11A (confirmed), CC V11AT, D8..DB/DD V12A The 3840x3840 class matches no SDK part and keeps the chip-ID name. The source comment and each case say which are guessed. Co-authored-by: OpenIPC AI team --- src/hal/hisi/hal_hisi.c | 56 +++++++++++++++++++++++++----------- src/hal/hisi/hal_hisi_test.c | 32 +++++++++++++++------ 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/hal/hisi/hal_hisi.c b/src/hal/hisi/hal_hisi.c index e792bdd..c3038da 100644 --- a/src/hal/hisi/hal_hisi.c +++ b/src/hal/hisi/hal_hisi.c @@ -989,38 +989,62 @@ static const char *get_chip_V3(uint8_t scsysid0) { #endif /* IPCHW_HISI_V3 */ #ifdef IPCHW_HISI_GOKE7206 -/* GK7206V11 and V11A share the chip ID 0x72060110. What tells them apart is - * the model code in the low byte of eFuse word 0x10090030, whose high half is - * "GK" (0x474B). The vendor modules check it (xm_common refuses a word outside - * 0x474B00B7..0x474B00DD; xm_vi and xm_venc single out 0xCA among others), but - * nothing in the SDK or XM's firmware names the codes, so only the ones read - * on a known part are listed. The eFuse reads 0x2 until its clock (CRG 0x1BC - * bit 1) is on; it is turned back off if it was off. */ +/* The GK7206 family (SDK names: V10, V10B, V11, V11A, V11AT, V12A) is told + * apart by the model code in the low byte of eFuse word 0x10090030, whose high + * half is "GK" (0x474B); V11 and V11A, at least, share chip ID 0x72060110. + * The vendor modules accept 0x474B00B7..BD, C7..CD and D7..DD (xm_common), + * and xm_vi/xm_venc sort them into capability classes: {B7, BC, C7, CC} with + * 3840x2160 and a 3840 line, {CA, D8..DB, DD} with 3840x2160 and a 4032 line, + * and every other code with 3840x3840. + * + * Nothing in the SDK or in XM's firmware names the codes. Only 0xCA is + * confirmed (an IVG-K8, XM IPC_GK7206V11A). THE REST IS GUESSED from that + * pattern: the high nibble taken as the DDR tier the SDK's load script gives + * each part (B 64 MB: V10, V10B; C 128 MB: V11, V11A, V11AT; D 256 MB: V12A), + * the low nibble 7 as the base part, C as the tier's other part, A as the A + * part. The 3840x3840 class matches no SDK part and is left to the chip ID. + * + * The eFuse reads 0x2 until its clock (CRG 0x1BC bit 1) is on; it is turned + * back off if it was off. */ #define GK7206_CRG_OTP 0x120101BC #define GK7206_CRG_OTP_CKEN (1u << 1) #define GK7206_EFUSE_MODEL 0x10090030 -static const char *gk7206_v11_variant() { +static const char *gk7206_variant(const char *by_chip_id) { uint32_t crg, word = 0; if (!mem_reg(GK7206_CRG_OTP, &crg, OP_READ)) - return "7206V11"; + return by_chip_id; if (!(crg & GK7206_CRG_OTP_CKEN)) { uint32_t on = crg | GK7206_CRG_OTP_CKEN; if (!mem_reg(GK7206_CRG_OTP, &on, OP_WRITE)) - return "7206V11"; + return by_chip_id; } mem_reg(GK7206_EFUSE_MODEL, &word, OP_READ); if (!(crg & GK7206_CRG_OTP_CKEN)) mem_reg(GK7206_CRG_OTP, &crg, OP_WRITE); if (word >> 16 != 0x474B) - return "7206V11"; + return by_chip_id; switch (word & 0xff) { - case 0xCA: /* IVG-K8 (XM IPC_GK7206V11A), 0x474B00CA */ + case 0xB7: /* guessed */ + return "7206V10"; + case 0xBC: /* guessed */ + return "7206V10B"; + case 0xC7: /* guessed */ + return "7206V11"; + case 0xCA: /* confirmed: IVG-K8 (XM IPC_GK7206V11A), 0x474B00CA */ return "7206V11A"; + case 0xCC: /* guessed */ + return "7206V11AT"; + case 0xD8: /* guessed, all five */ + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDD: + return "7206V12A"; default: - return "7206V11"; + return by_chip_id; } } #endif @@ -1211,14 +1235,14 @@ static const char *get_hisi_chip_id(uint32_t family_id, uint8_t scsysid0) { case 0x72060100: // expected by the SDK's numbering (XM7605V11 is 0x76050110), unseen chip_generation = GOKE_7206; - return "7206V10"; + return gk7206_variant("7206V10"); case 0x72060110: chip_generation = GOKE_7206; - return gk7206_v11_variant(); + return gk7206_variant("7206V11"); case 0x72060120: // expected by the SDK's numbering, unseen chip_generation = GOKE_7206; - return "7206V12"; + return gk7206_variant("7206V12"); #endif default: diff --git a/src/hal/hisi/hal_hisi_test.c b/src/hal/hisi/hal_hisi_test.c index cb57f7e..ac85f90 100644 --- a/src/hal/hisi/hal_hisi_test.c +++ b/src/hal/hisi/hal_hisi_test.c @@ -421,8 +421,8 @@ int main(void) { seed(GK7206_TSENSOR_RECORD, 0); CHECK(isnan(hisi_get_temp())); - /* GK7206V11 vs V11A: one chip ID, told apart by the eFuse model code. - * The eFuse clock is turned on to read it and off again if it was off. */ + /* GK7206 variants by the eFuse model code. The eFuse clock is turned on + * to read it and off again if it was off. */ fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); seed(GK7206_EFUSE_MODEL, 0x474B00CA); CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11A") == 0); @@ -435,13 +435,27 @@ int main(void) { CHECK(peek(GK7206_CRG_OTP) == 0x286); CHECK(writes == 0); - fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); /* a code not yet seen */ - seed(GK7206_EFUSE_MODEL, 0x474B00B7); - CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11") == 0); - - fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); /* gated read, no "GK" */ - seed(GK7206_EFUSE_MODEL, 0x2); - CHECK(strcmp(get_hisi_chip_id(0x72060110, 0), "7206V11") == 0); + static const struct { + uint32_t chip_id, efuse; + const char *model; + } gk7206[] = { + {0x72060110, 0x474B00B7, "7206V10"}, /* guessed codes */ + {0x72060110, 0x474B00BC, "7206V10B"}, + {0x72060110, 0x474B00C7, "7206V11"}, + {0x72060110, 0x474B00CC, "7206V11AT"}, + {0x72060120, 0x474B00DA, "7206V12A"}, + {0x72060110, 0x474B00DD, "7206V12A"}, + {0x72060110, 0x474B00BB, "7206V11"}, /* 3840x3840 class: chip ID */ + {0x72060100, 0x474B00C8, "7206V10"}, + {0x72060120, 0x2, "7206V12"}, /* gated read, no "GK" */ + }; + for (size_t i = 0; i < ARRCNT(gk7206); i++) { + fresh(GK7206_CRG_OTP, 0x284, GOKE_7206); + seed(GK7206_EFUSE_MODEL, gk7206[i].efuse); + CHECK(strcmp(get_hisi_chip_id(gk7206[i].chip_id, 0), + gk7206[i].model) == 0); + CHECK(peek(GK7206_CRG_OTP) == 0x284); + } if (failures) fprintf(stderr, "hal_hisi_test: %d failure(s)\n", failures); From f3bce33c1a3db4f1c1af6c83d4f8e22d6d454c42 Mon Sep 17 00:00:00 2001 From: Dmitry Ermakov <7954832+dimerr@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:04:12 +0000 Subject: [PATCH 3/3] hisi: GK7206 eFuse read restores the clock only if it still holds our word Re-read CRG 0x1BC before turning the eFuse clock back off, and leave it if it no longer holds the word written for the read: whoever changed it in between owns it now, as sensor_crg_restore() does. (Qodo) Co-authored-by: OpenIPC AI team --- src/hal/hisi/hal_hisi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hal/hisi/hal_hisi.c b/src/hal/hisi/hal_hisi.c index c3038da..0e834e4 100644 --- a/src/hal/hisi/hal_hisi.c +++ b/src/hal/hisi/hal_hisi.c @@ -1011,17 +1011,17 @@ static const char *get_chip_V3(uint8_t scsysid0) { #define GK7206_EFUSE_MODEL 0x10090030 static const char *gk7206_variant(const char *by_chip_id) { - uint32_t crg, word = 0; + uint32_t crg, on, cur, word = 0; if (!mem_reg(GK7206_CRG_OTP, &crg, OP_READ)) return by_chip_id; - if (!(crg & GK7206_CRG_OTP_CKEN)) { - uint32_t on = crg | GK7206_CRG_OTP_CKEN; - if (!mem_reg(GK7206_CRG_OTP, &on, OP_WRITE)) - return by_chip_id; - } + on = crg | GK7206_CRG_OTP_CKEN; + if (on != crg && !mem_reg(GK7206_CRG_OTP, &on, OP_WRITE)) + return by_chip_id; mem_reg(GK7206_EFUSE_MODEL, &word, OP_READ); - if (!(crg & GK7206_CRG_OTP_CKEN)) + /* Undo only our own ungate: if the register changed meanwhile, whoever + * changed it owns it now (as sensor_crg_restore() does). */ + if (on != crg && mem_reg(GK7206_CRG_OTP, &cur, OP_READ) && cur == on) mem_reg(GK7206_CRG_OTP, &crg, OP_WRITE); if (word >> 16 != 0x474B)