diff options
-rw-r--r-- | drivers/mtd/spi/spi-nor-core.c | 17 | ||||
-rw-r--r-- | include/dm/device.h | 3 | ||||
-rw-r--r-- | include/linux/mtd/spi-nor.h | 2 | ||||
-rw-r--r-- | include/mtd.h | 5 |
4 files changed, 23 insertions, 4 deletions
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index d5d905fa5a1..f1b4e5ea8e3 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -10,6 +10,7 @@ */ #include <common.h> +#include <flash.h> #include <log.h> #include <watchdog.h> #include <dm.h> @@ -26,6 +27,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/spi-nor.h> +#include <mtd/cfi_flash.h> #include <spi-mem.h> #include <spi.h> @@ -3664,6 +3666,11 @@ int spi_nor_scan(struct spi_nor *nor) struct mtd_info *mtd = &nor->mtd; struct spi_slave *spi = nor->spi; int ret; + int cfi_mtd_nb = 0; + +#ifdef CONFIG_SYS_MAX_FLASH_BANKS + cfi_mtd_nb = CONFIG_SYS_MAX_FLASH_BANKS; +#endif /* Reset SPI protocol for all commands. */ nor->reg_proto = SNOR_PROTO_1_1_1; @@ -3715,8 +3722,12 @@ int spi_nor_scan(struct spi_nor *nor) if (ret) return ret; - if (!mtd->name) - mtd->name = info->name; + if (!mtd->name) { + sprintf(nor->mtd_name, "%s%d", + MTD_DEV_TYPE(MTD_DEV_TYPE_NOR), + cfi_mtd_nb + dev_seq(nor->dev)); + mtd->name = nor->mtd_name; + } mtd->dev = nor->dev; mtd->priv = nor; mtd->type = MTD_NORFLASH; @@ -3821,7 +3832,7 @@ int spi_nor_scan(struct spi_nor *nor) nor->rdsr_dummy = params.rdsr_dummy; nor->rdsr_addr_nbytes = params.rdsr_addr_nbytes; - nor->name = mtd->name; + nor->name = info->name; nor->size = mtd->size; nor->erase_size = mtd->erasesize; nor->sector_size = mtd->erasesize; diff --git a/include/dm/device.h b/include/dm/device.h index 0a9718a5b81..9d0ca6a550e 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -207,8 +207,9 @@ struct udevice_rt { u32 flags_; }; -/* Maximum sequence number supported */ +/* Maximum sequence number supported and associated string length */ #define DM_MAX_SEQ 999 +#define DM_MAX_SEQ_STR 3 /* Returns the operations for a device */ #define device_get_ops(dev) (dev->driver->ops) diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 7ddc4ba2bf2..4ceeae623de 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -7,6 +7,7 @@ #ifndef __LINUX_MTD_SPI_NOR_H #define __LINUX_MTD_SPI_NOR_H +#include <mtd.h> #include <linux/bitops.h> #include <linux/mtd/cfi.h> #include <linux/mtd/mtd.h> @@ -561,6 +562,7 @@ struct spi_nor { int (*ready)(struct spi_nor *nor); void *priv; + char mtd_name[MTD_NAME_SIZE(MTD_DEV_TYPE_NOR)]; /* Compatibility for spi_flash, remove once sf layer is merged with mtd */ const char *name; u32 size; diff --git a/include/mtd.h b/include/mtd.h index b569331edb0..f9e5082446a 100644 --- a/include/mtd.h +++ b/include/mtd.h @@ -6,10 +6,15 @@ #ifndef _MTD_H_ #define _MTD_H_ +#include <dm/device.h> +#include <jffs2/load_kernel.h> #include <linux/mtd/mtd.h> int mtd_probe_devices(void); void board_mtdparts_default(const char **mtdids, const char **mtdparts); +/* compute the max size for the string associated to a dev type */ +#define MTD_NAME_SIZE(type) (sizeof(MTD_DEV_TYPE(type)) + DM_MAX_SEQ_STR) + #endif /* _MTD_H_ */ |