Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw/drivers/flash/spiflash: Add option to ignore JEDEC ID #2858

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions hw/drivers/flash/spiflash/src/spiflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,12 +1374,24 @@ spiflash_identify(struct spiflash_dev *dev)
* 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;
}
Expand Down Expand Up @@ -1413,9 +1425,12 @@ spiflash_identify(struct spiflash_dev *dev)
}
}
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;
Expand Down
12 changes: 12 additions & 0 deletions hw/drivers/flash/spiflash/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,26 @@ syscfg.defs:
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: >
Expand Down