diff options
Diffstat (limited to 'src/target/firmware/board/gtm900b/init.c')
-rw-r--r-- | src/target/firmware/board/gtm900b/init.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/target/firmware/board/gtm900b/init.c b/src/target/firmware/board/gtm900b/init.c index 8de99563..934e96e8 100644 --- a/src/target/firmware/board/gtm900b/init.c +++ b/src/target/firmware/board/gtm900b/init.c @@ -56,6 +56,8 @@ #define LPG_LCR_REG 0xfffe7800 #define LPG_PM_REG 0xfffe7801 +int gtm900_hw_is_mg01gsmt; + static void board_io_init(void) { uint16_t reg; @@ -85,6 +87,68 @@ static void board_io_init(void) writew(reg, ARM_CONF_REG); } +/* + * There exist two firmware-incompatible versions of GTM900-B hardware: + * MG01GSMT and MGCxGSMT. They have different flash chip types (8 MiB + * vs. 4 MiB) with correspondingly different TIFFS configurations + * (and we need TIFFS in order to read factory RF calibration values), + * and they have different (incompatible) RFFE control signals. + * + * We are going to check the flash chip type and use it to decide which + * hw variant we are running on. + */ +static void board_flash_init(void) +{ + uint16_t manufacturer_id, device_id[3]; + + /* Use an address above the Calypso boot ROM + * so we don't need to unmap it to access the flash. */ + flash_get_id((void *)0x40000, &manufacturer_id, device_id); + + switch (manufacturer_id) { + case CFI_MANUF_SPANSION: + /* is it S71PL064J? */ + if (device_id[0] == 0x227E && device_id[1] == 0x2202 && + device_id[2] == 0x2201) { + gtm900_hw_is_mg01gsmt = 1; + break; + } + /* is it S71PL032J? */ + if (device_id[0] == 0x227E && device_id[1] == 0x220A && + device_id[2] == 0x2201) { + gtm900_hw_is_mg01gsmt = 0; + break; + } + goto bad; + case CFI_MANUF_SAMSUNG: + /* is it K5A3281CTM? */ + if (device_id[0] == 0x22A0) { + gtm900_hw_is_mg01gsmt = 0; + break; + } + /* is it K5L3316CAM? */ + if (device_id[0] == 0x257E && device_id[1] == 0x2503 && + device_id[2] == 0x2501) { + gtm900_hw_is_mg01gsmt = 0; + break; + } + /* FALL THRU */ + default: + bad: + printf("Unknown module detected, " + "flash ID 0x%04x 0x%04x 0x%04x 0x%04x\n" + "Please contact mailing list!\n\n", manufacturer_id, + device_id[0], device_id[1], device_id[2]); + return; + } + + /* Initialize TIFFS reader */ + if (gtm900_hw_is_mg01gsmt) + tiffs_init(0x700000, 0x10000, 15); + else + tiffs_init(0x380000, 0x10000, 7); +} + void board_init(int with_irq) { /* @@ -151,4 +215,7 @@ https://www.freecalypso.org/hg/freecalypso-docs/file/tip/MEMIF-wait-states /* Initialize ABB driver (uses SPI) */ twl3025_init(); + + /* Initialize board flash */ + board_flash_init(); } |