Since this component doesn't support read id command, matching
is done by comparing the name of the component to the dts compatible
string. It also doesn't support erase command too so it depends on
the previous commit too.

Signed-off-by: Yasir Kilic <[email protected]>
---
 drivers/mtd/spi/Kconfig        |  6 ++++++
 drivers/mtd/spi/spi-nor-core.c | 10 +++++++++-
 drivers/mtd/spi/spi-nor-ids.c  |  4 ++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
index 4ff58380b59..4f35856846a 100644
--- a/drivers/mtd/spi/Kconfig
+++ b/drivers/mtd/spi/Kconfig
@@ -304,4 +304,10 @@ config SPI_FRAM_FUJITSU
          Add support for the Fujitsu MB85RS256TY FRAM chip. It's treated the 
same
          as SPI NOR flash at the moment.
 
+config SPI_MRAM_EVERSPIN
+       bool "Everspin SPI MRAM support"
+       help
+         Add support for the Everspin MR25H40 MRAM chip. It's treated the same
+         as SPI NOR flash at the moment.
+
 endmenu # menu "SPI Flash Support"
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 937d79af64e..f8588f9f9f5 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -1570,12 +1570,20 @@ static const struct flash_info *spi_nor_read_id(struct 
spi_nor *nor)
                return ERR_PTR(tmp);
        }
 
+       // some devices like spi mrams do not support jedec read id
+       const char *compat = NULL;
+
+       tmp = dev_read_string_index(nor->dev, "compatible", 0, &compat);
+       if (!tmp)
+               dev_dbg(nor->dev, "compatible string is %s\n", compat);
+
        info = spi_nor_ids;
        for (; info->name; info++) {
                if (info->id_len) {
                        if (!memcmp(info->id, id, info->id_len))
                                return info;
-               }
+                       if (!strcmp(info->name, compat))
+                               return info;
        }
 
        dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %02x, %02x\n",
diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 31a2ba49a87..1e1b86c89ad 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -357,6 +357,10 @@ const struct flash_info spi_nor_ids[] = {
        { INFO("mx25uw6445g",    0xc28137, 0, 64 * 1024, 128, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
        { INFO("mx25uw6345g",    0xc28437, 0, 64 * 1024, 128, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
 #endif
+#ifdef CONFIG_SPI_MRAM_EVERSPIN                /* EVERSPIN */
+       /* Everspin */
+       { INFO("everspin,mr25h40", 0, 0, 512 * 1024, 1, SPI_NOR_NO_ERASE | 
SPI_NOR_NO_FR) },
+#endif
 #ifdef CONFIG_SPI_FLASH_PUYA
        /* Puya Semiconductor (Shanghai) Co., Ltd */
        { INFO

-- 
2.43.0

Reply via email to