diff --git a/src/hal/sstar.c b/src/hal/sstar.c index 4a6aad5..e48aa27 100644 --- a/src/hal/sstar.c +++ b/src/hal/sstar.c @@ -57,11 +57,28 @@ bool sstar_detect_cpu(char *chip_name) { switch (val) { case INFINITY2M: - /* SSD201/SSD202 and the SSR62x NVR parts are one generation and - * nothing read here tells them apart, so the name is the group's, - * as for the others. An SSR621Q (Jooan JA-8108 NVR) with the BROM - * tag ...I2m_ROM... was reported as "unknown" before this case. */ + /* SSD201/SSD202 and the SSR62x NVR parts are one generation; + * the bond strap tells the package. The IPL reads its low byte + * and prints it after "D-": an SSR621Q (Xiongmai NBD80S16S) + * prints "D-1b"; 0x1D and 0x1E are the SSD201's and SSD202D's. + * Any other package, or a strap that cannot be read, keeps the + * group's name, as for the other generations. An SSR621Q (Jooan + * JA-8108 NVR) with the BROM tag ...I2m_ROM... was reported as + * "unknown" before this case. */ strcpy(chip_name, "SSD20X"); + if (mem_reg(SSTAR_BOND_ADDR, &val, OP_READ)) { + switch (val & 0xFF) { + case I2M_BOND_SSR621Q: + strcpy(chip_name, "SSR621Q"); + break; + case I2M_BOND_SSD201: + strcpy(chip_name, "SSD201"); + break; + case I2M_BOND_SSD202D: + strcpy(chip_name, "SSD202D"); + break; + } + } break; case INFINITY5: strcpy(chip_name, "SSC32X"); diff --git a/src/hal/sstar.h b/src/hal/sstar.h index 579149e..d737a59 100644 --- a/src/hal/sstar.h +++ b/src/hal/sstar.h @@ -13,6 +13,9 @@ #define CHIP_ADDR2 0x1F004058 #define MSTAR_ADDR 0x1F2025A4 #define SSTAR_ADDR 0x1F003C00 +/* CHIPTOP's bond strap (bank 0x101E, reg 0x48): the package, from which the + * IPL picks its DDR setting and prints it after "D-" in its first lines. */ +#define SSTAR_BOND_ADDR 0x1F203D20 #define INFINITY3 0xC2 // Infinity3 #define INFINITY5 0xED // Pretzel @@ -26,6 +29,12 @@ #define INFINITY6C 0xF9 // Maruko #define INFINITY6F 0xFB // Souffle +/* Infinity2M packages by their bond strap (its low byte, as the IPL reads + * it). 0x1F also has a DDR setting in both IPLs, but no part is known by it. */ +#define I2M_BOND_SSR621Q 0x1B +#define I2M_BOND_SSD201 0x1D +#define I2M_BOND_SSD202D 0x1E + bool mstar_detect_cpu(char *chip_name); bool sstar_detect_cpu(char *chip_name); void sstar_setup_hal(); diff --git a/src/hal/sstar_test.c b/src/hal/sstar_test.c index cb11ae7..7192a18 100644 --- a/src/hal/sstar_test.c +++ b/src/hal/sstar_test.c @@ -3,7 +3,7 @@ * Each generation's name is pinned here: dropping or renaming a case puts that * generation back to "unknown" in every report, which is what Infinity2M * (0xF0) did until it had one (an SSR621Q in a Jooan JA-8108 NVR, BROM tag - * ...I2m_ROM...). + * ...I2m_ROM...). Infinity2M's parts are named by their bond strap. * * CHECK rather than assert(), because the release flags carry -DNDEBUG and * would compile an assert-based test into one that passes unconditionally. @@ -28,13 +28,22 @@ static int failures; } while (0) static uint32_t generation_reg; /* what SSTAR_ADDR reads */ +static uint32_t bond_reg; /* what SSTAR_BOND_ADDR reads */ +static bool bond_fails; /* the strap alone unreadable */ static bool mmio_fails; /* /dev/mem withheld */ bool mem_reg(uint32_t addr, uint32_t *data, enum REG_OPS op) { - if (mmio_fails || op != OP_READ || addr != SSTAR_ADDR) + if (mmio_fails || op != OP_READ) return false; - *data = generation_reg; - return true; + if (addr == SSTAR_ADDR) { + *data = generation_reg; + return true; + } + if (addr == SSTAR_BOND_ADDR && !bond_fails) { + *data = bond_reg; + return true; + } + return false; } /* The rest of sstar.c's externals; nothing below reads a file. */ @@ -60,8 +69,33 @@ static bool detects(uint32_t reg, const char *want) { return true; } +/* An Infinity2M part by its bond strap. */ +static bool i2m_detects(uint32_t bond, const char *want) { + bond_reg = bond; + bool ok = detects(INFINITY2M, want); + if (!ok) + fprintf(stderr, " bond 0x%X\n", bond); + bond_reg = 0; + return ok; +} + int main(void) { - CHECK(detects(INFINITY2M, "SSD20X")); + /* The packages the IPLs name a DDR setting for, by the low byte the + * IPL reads; the rest of the register is ignored, as there. */ + CHECK(i2m_detects(0x1B, "SSR621Q")); + CHECK(i2m_detects(0x1D, "SSD201")); + CHECK(i2m_detects(0x1E, "SSD202D")); + CHECK(i2m_detects(0x11B, "SSR621Q")); + /* 0x1F has a DDR setting but no known part; anything else is not a + * package: the group's name. */ + CHECK(i2m_detects(0x1F, "SSD20X")); + CHECK(i2m_detects(0x00, "SSD20X")); + CHECK(i2m_detects(0x3B, "SSD20X")); + /* The strap unreadable: still the generation, by the group's name. */ + bond_fails = true; + CHECK(i2m_detects(0x1B, "SSD20X")); + bond_fails = false; + CHECK(detects(INFINITY5, "SSC32X")); CHECK(detects(INFINITY6, "SSC32X")); CHECK(detects(INFINITY6B, "SSC33X"));