hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
diff --git a/hw/drivers/flash/spiflash/src/spiflash.c b/hw/drivers/flash/spiflash/src/spiflash.c
index 6879b7e..4a59ee0 100644
--- a/hw/drivers/flash/spiflash/src/spiflash.c
+++ b/hw/drivers/flash/spiflash/src/spiflash.c
@@ -1374,12 +1374,24 @@
* different pins, or of different type.
* It is unlikely that flash depended packaged will work correctly.
*/
- assert(manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer &&
- memory_type == supported_chips[0].fc_jedec_id.ji_type &&
- capacity == supported_chips[0].fc_jedec_id.ji_capacity);
- if (manufacturer != supported_chips[0].fc_jedec_id.ji_manufacturer ||
- memory_type != supported_chips[0].fc_jedec_id.ji_type ||
- capacity != supported_chips[0].fc_jedec_id.ji_capacity) {
+ assert(MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer);
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer)) {
+ rc = -1;
+ goto err;
+ }
+ assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ memory_type == supported_chips[0].fc_jedec_id.ji_type);
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ memory_type == supported_chips[0].fc_jedec_id.ji_type)) {
+ rc = -1;
+ goto err;
+ }
+ assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ capacity == supported_chips[0].fc_jedec_id.ji_capacity);
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ capacity == supported_chips[0].fc_jedec_id.ji_capacity)) {
rc = -1;
goto err;
}
@@ -1413,9 +1425,12 @@
}
}
for (i = 0; supported_chips[i].fc_jedec_id.ji_manufacturer != 0; ++i) {
- if (manufacturer == supported_chips[i].fc_jedec_id.ji_manufacturer &&
- memory_type == supported_chips[i].fc_jedec_id.ji_type &&
- capacity == supported_chips[i].fc_jedec_id.ji_capacity) {
+ if ((MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ manufacturer == supported_chips[i].fc_jedec_id.ji_manufacturer) &&
+ (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ memory_type == supported_chips[i].fc_jedec_id.ji_type) &&
+ (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ capacity == supported_chips[i].fc_jedec_id.ji_capacity)) {
/* Device is supported */
dev->flash_chip = &supported_chips[i];
break;
diff --git a/hw/drivers/flash/spiflash/syscfg.yml b/hw/drivers/flash/spiflash/syscfg.yml
index 1a0c822..205fb3f 100644
--- a/hw/drivers/flash/spiflash/syscfg.yml
+++ b/hw/drivers/flash/spiflash/syscfg.yml
@@ -68,14 +68,26 @@
values found in hw/drivers/flash/spiflash/chips/syscfg.yml should be
set to 1 for desired chips.
value: 0
+ SPIFLASH_IGNORE_MANUFACTURER:
+ description: >
+ Ignore the SpiFlash manufacturer as read by Read JEDEC ID command 9FH
+ value: 0
SPIFLASH_MEMORY_TYPE:
description: >
Expected SpiFlash memory type as read by Read JEDEC ID command 9FH
value: 0
+ SPIFLASH_IGNORE_MEMORY_TYPE:
+ description: >
+ Ignore SpiFlash memory type as read by Read JEDEC ID command 9FH
+ value: 0
SPIFLASH_MEMORY_CAPACITY:
description: >
Expected SpiFlash memory capactity as read by Read JEDEC ID command 9FH
value: 0
+ SPIFLASH_IGNORE_MEMORY_CAPACITY:
+ description: >
+ Ignore SpiFlash memory capactity as read by Read JEDEC ID command 9FH
+ value: 0
SPIFLASH_READ_STATUS_INTERVAL:
description: >