Skip to content

Commit

Permalink
drivers: flash: skip broken sfdp flash
Browse files Browse the repository at this point in the history
some flash not support sfdp.

skip sfdp process and depend on JESDID to configure flash size.

Signed-off-by: cpchiang <[email protected]>
  • Loading branch information
cpchiang authored and maxdog988 committed Apr 9, 2024
1 parent a0a0107 commit 2d8da08
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/flash/spi_nor_multi_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,26 @@ static int sfdp_post_fixup(const struct device *dev)
return ret;
}

static int sfdp_broken_skip(const struct device *dev)
{
int ret = 0;
struct spi_nor_data *data = dev->data;

switch (data->jedec_id[0]) {
case SPI_NOR_MFR_ID_WINBOND:
if (SPI_NOR_GET_JESDID(data->jedec_id) == 0x3013) {
data->flash_size = 0x80000;
return 1;
}
break;

default:
break;
}

return ret;
}

static int setup_pages_layout(const struct device *dev)
{
int rv = 0;
Expand Down Expand Up @@ -1624,13 +1644,18 @@ static int spi_nor_configure(const struct device *dev)

if (!cfg->broken_sfdp) {
rc = spi_nor_process_sfdp(dev);

if ((rc != 0) && sfdp_broken_skip(dev))
goto broken_skip;

if (rc != 0) {
LOG_ERR("[%d]SFDP read failed: %d", __LINE__, rc);
ret = -ENODEV;
goto end;
}
}

broken_skip:
rc = sfdp_post_fixup(dev);
if (rc != 0) {
ret = -ENODEV;
Expand Down

0 comments on commit 2d8da08

Please sign in to comment.