[RFC PATCH 22/27] mtd: spinand: Let the SPI-NAND core flag a SPI-NAND chip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As of today there is no way to make the distinction between a raw NAND
chip and a SPI-NAND chip. The ABI is stable and we cannot add a
"SPI-NAND" tag to the MTD type, but we can add a special SPINAND
capability to the flags instead. A helper is also provided to retrieve
if whether or not the chip is working over SPI or not.

Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
 drivers/mtd/nand/core.c    | 2 +-
 include/linux/mtd/mtd.h    | 5 +++++
 include/uapi/mtd/mtd-abi.h | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index a76d206d233a..872d46b5fc0f 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -245,7 +245,7 @@ int nanddev_init(struct nand_device *nand, const struct nand_ops *ops,
 
 	mtd->type = memorg->bits_per_cell == 1 ?
 		    MTD_NANDFLASH : MTD_MLCNANDFLASH;
-	mtd->flags = MTD_CAP_NANDFLASH;
+	mtd->flags = MTD_SPINAND | MTD_CAP_NANDFLASH;
 	mtd->erasesize = memorg->pagesize * memorg->pages_per_eraseblock;
 	mtd->writesize = memorg->pagesize;
 	mtd->writebufsize = memorg->pagesize;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 677768b21a1d..7c245d109524 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -551,6 +551,11 @@ static inline int mtd_type_is_nand(const struct mtd_info *mtd)
 	return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
 }
 
+static inline int mtd_type_is_spinand(const struct mtd_info *mtd)
+{
+	return mtd_type_is_nand(mtd) && (mtd->flags & MTD_SPINAND);
+}
+
 static inline int mtd_can_have_bb(const struct mtd_info *mtd)
 {
 	return !!mtd->_block_isbad;
diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h
index aff5b5e59845..7c7124c88fe0 100644
--- a/include/uapi/mtd/mtd-abi.h
+++ b/include/uapi/mtd/mtd-abi.h
@@ -104,6 +104,7 @@ struct mtd_write_req {
 #define MTD_BIT_WRITEABLE	0x800	/* Single bits can be flipped */
 #define MTD_NO_ERASE		0x1000	/* No erase necessary */
 #define MTD_POWERUP_LOCK	0x2000	/* Always locked after reset */
+#define MTD_SPINAND		0x4000	/* Device works over SPI */
 
 /* Some common devices / combinations of capabilities */
 #define MTD_CAP_ROM		0
-- 
2.19.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux