Change in osmocom-bb[master]: firmware: gtm900b: fix flash-based hardware variant autodetection
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/20329 ) Change subject: firmware: gtm900b: fix flash-based hardware variant autodetection .. firmware: gtm900b: fix flash-based hardware variant autodetection The original code used simplified logic whereby it assumed that Spansion flash means MG01GSMT and Samsung flash means MGCxGSMT. However, there exist MGC2GSMT hw variants with Spansion S71PL032J flash in them, thus it is necessary to check the complete device ID rather than just the flash manufacturer ID to distinguish between MG01GSMT with 8 MiB flash (S71PL064J) and MGCxGSMT with 4 MiB flash (S71PL032J, K5A3281CTM or K5L3316CAM). Distinguishing between 4 MiB and 8 MiB flash chip types is also necessary in order to configure TIFFS reader for the correct FFS location matching that used by the original firmware, which is in turn necessary in order to read factory RF calibration values. Closes: OS#4769 Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd --- M src/target/firmware/board/gtm900b/init.c M src/target/firmware/board/gtm900b/rffe_gtm900b.c 2 files changed, 72 insertions(+), 33 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve Vadim Yanitskiy: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/target/firmware/board/gtm900b/init.c b/src/target/firmware/board/gtm900b/init.c index 8de9956..934e96e 100644 --- a/src/target/firmware/board/gtm900b/init.c +++ b/src/target/firmware/board/gtm900b/init.c @@ -56,6 +56,8 @@ #define LPG_LCR_REG0xfffe7800 #define LPG_PM_REG 0xfffe7801 +int gtm900_hw_is_mg01gsmt; + static void board_io_init(void) { uint16_t reg; @@ -85,6 +87,68 @@ 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 *)0x4, &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(0x70, 0x1, 15); + else + tiffs_init(0x38, 0x1, 7); +} + void board_init(int with_irq) { /* @@ -151,4 +215,7 @@ /* Initialize ABB driver (uses SPI) */ twl3025_init(); + + /* Initialize board flash */ + board_flash_init(); } diff --git a/src/target/firmware/board/gtm900b/rffe_gtm900b.c b/src/target/firmware/board/gtm900b/rffe_gtm900b.c index 633c637..3efb5e2 100644 --- a/src/target/firmware/board/gtm900b/rffe_gtm900b.c +++ b/src/target/firmware/board/gtm900b/rffe_gtm900b.c @@ -1,5 +1,5 @@ /* RF frontend driver for Huawei GTM900-B modems, supporting both - * MG01GSMT and MG01GSMT hardware variants */ + * MG01GSMT and MGCxGSMT hardware variants */ /* (C) 2019 by Steve Markgraf * @@ -63,12 +63,7 @@ * Tx2: high band PA output */ -typedef enum rffe_var { - RFFE_MGC2GSMT, - RFFE_MG01
Change in osmocom-bb[master]: firmware: gtm900b: fix flash-based hardware variant autodetection
Vadim Yanitskiy has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/20329 ) Change subject: firmware: gtm900b: fix flash-based hardware variant autodetection .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/20329 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd Gerrit-Change-Number: 20329 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: laforge Gerrit-Comment-Date: Wed, 07 Oct 2020 18:05:10 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmocom-bb[master]: firmware: gtm900b: fix flash-based hardware variant autodetection
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/20329 ) Change subject: firmware: gtm900b: fix flash-based hardware variant autodetection .. Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/20329 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd Gerrit-Change-Number: 20329 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Thu, 01 Oct 2020 00:02:17 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmocom-bb[master]: firmware: gtm900b: fix flash-based hardware variant autodetection
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmocom-bb/+/20329 to look at the new patch set (#2). Change subject: firmware: gtm900b: fix flash-based hardware variant autodetection .. firmware: gtm900b: fix flash-based hardware variant autodetection The original code used simplified logic whereby it assumed that Spansion flash means MG01GSMT and Samsung flash means MGCxGSMT. However, there exist MGC2GSMT hw variants with Spansion S71PL032J flash in them, thus it is necessary to check the complete device ID rather than just the flash manufacturer ID to distinguish between MG01GSMT with 8 MiB flash (S71PL064J) and MGCxGSMT with 4 MiB flash (S71PL032J, K5A3281CTM or K5L3316CAM). Distinguishing between 4 MiB and 8 MiB flash chip types is also necessary in order to configure TIFFS reader for the correct FFS location matching that used by the original firmware, which is in turn necessary in order to read factory RF calibration values. Closes: OS#4769 Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd --- M src/target/firmware/board/gtm900b/init.c M src/target/firmware/board/gtm900b/rffe_gtm900b.c 2 files changed, 72 insertions(+), 33 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/29/20329/2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/20329 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd Gerrit-Change-Number: 20329 Gerrit-PatchSet: 2 Gerrit-Owner: laforge Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: newpatchset
Change in osmocom-bb[master]: firmware: gtm900b: fix flash-based hardware variant autodetection
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/20329 ) Change subject: firmware: gtm900b: fix flash-based hardware variant autodetection .. firmware: gtm900b: fix flash-based hardware variant autodetection The original code used simplified logic whereby it assumed that Spansion flash means MG01GSMT and Samsung flash means MGCxGSMT. However, there exist MGC2GSMT hw variants with Spansion S71PL032J flash in them, thus it is necessary to check the complete device ID rather than just the flash manufacturer ID to distinguish between MG01GSMT with 8 MiB flash (S71PL064J) and MGCxGSMT with 4 MiB flash (S71PL032J, K5A3281CTM or K5L3316CAM). Distinguishing between 4 MiB and 8 MiB flash chip types is also necessary in order to configure TIFFS reader for the correct FFS location matching that used by the original firmware, which is in turn necessary in order to read factory RF calibration values. Closes: OS#4769 Change-Id: Iaa5bd295e9cbf6b525fa385f9d6cd7fcd7f8a4dd --- M src/target/firmware/board/gtm900b/init.c M src/target/firmware/board/gtm900b/rffe_gtm900b.c 2 files changed, 72 insertions(+), 33 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/29/20329/1 diff --git a/src/target/firmware/board/gtm900b/init.c b/src/target/firmware/board/gtm900b/init.c index 8de9956..934e96e 100644 --- a/src/target/firmware/board/gtm900b/init.c +++ b/src/target/firmware/board/gtm900b/init.c @@ -56,6 +56,8 @@ #define LPG_LCR_REG0xfffe7800 #define LPG_PM_REG 0xfffe7801 +int gtm900_hw_is_mg01gsmt; + static void board_io_init(void) { uint16_t reg; @@ -85,6 +87,68 @@ 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 *)0x4, &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(0x70, 0x1, 15); + else + tiffs_init(0x38, 0x1, 7); +} + void board_init(int with_irq) { /* @@ -151,4 +215,7 @@ /* Initialize ABB driver (uses SPI) */ twl3025_init(); + + /* Initialize board flash */ + board_flash_init(); } diff --git a/src/target/firmware/board/gtm900b/rffe_gtm900b.c b/src/target/firmware/board/gtm900b/rffe_gtm900b.c index 633c637..3efb5e2 100644 --- a/src/target/firmware/board/gtm900b/rffe_gtm900b.c +++ b/src/target/firmware/board/gtm900b/rffe_gtm900b.c @@ -1,5 +1,5 @@ /* RF frontend driver for Huawei GTM900-B modems, supporting both - * MG01GSMT and MG01GSMT hardware variants */ + * MG01GSMT and MGCxGSMT hardware variants */ /* (C) 2019 by Steve Markgraf * @@ -63,12 +63,7 @@ * Tx2: high band PA output */ -typedef enum rffe_var { - RFFE_MGC2GSMT, - RFFE_MG01GSMT -} rffe_var_t; - -static rffe_var_t rffe_variant =