From d9b238b002b7abc8df566a57c2bdac115571976c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Nov 2014 10:35:03 -0600 Subject: [PATCH] =?UTF-8?q?Extend=20MTD=20support=20to=20M25P16.=20From=20?= =?UTF-8?q?S=C3=A9bastien=20Lorquet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/mtd/m25px.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index c49585ebb0..6bab204a26 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -90,6 +90,7 @@ #define M25P_RES_ID 0x13 #define M25P_M25P1_CAPACITY 0x11 /* 1 M-bit */ #define M25P_EN25F80_CAPACITY 0x14 /* 8 M-bit */ +#define M25P_M25P16_CAPACITY 0x15 /* 16 M-bit */ #define M25P_M25P32_CAPACITY 0x16 /* 32 M-bit */ #define M25P_M25P64_CAPACITY 0x17 /* 64 M-bit */ #define M25P_M25P128_CAPACITY 0x18 /* 128 M-bit */ @@ -116,6 +117,16 @@ #define M25P_EN25F80_SUBSECT_SHIFT 12 /* Sub-Sector size 1 << 12 = 4,096 */ #define M25P_EN25F80_NSUBSECTORS 256 +/* M25P16 capacity is 2,097,152 bytes: + * (32 sectors) * (65,536 bytes per sector) + * (8192 pages) * (256 bytes per page) + */ + +#define M25P_M25P16_SECTOR_SHIFT 16 /* Sector size 1 << 16 = 65,536 */ +#define M25P_M25P16_NSECTORS 32 +#define M25P_M25P16_PAGE_SHIFT 8 /* Page size 1 << 8 = 256 */ +#define M25P_M25P16_NPAGES 8192 + /* M25P32 capacity is 4,194,304 bytes: * (64 sectors) * (65,536 bytes per sector) * (16384 pages) * (256 bytes per page) @@ -349,6 +360,16 @@ static inline int m25p_readid(struct m25p_dev_s *priv) #endif return OK; } + else if (capacity == M25P_M25P16_CAPACITY) + { + /* Save the FLASH geometry */ + + priv->sectorshift = M25P_M25P16_SECTOR_SHIFT; + priv->nsectors = M25P_M25P16_NSECTORS; + priv->pageshift = M25P_M25P16_PAGE_SHIFT; + priv->npages = M25P_M25P16_NPAGES; + return OK; + } else if (capacity == M25P_M25P32_CAPACITY) { /* Save the FLASH geometry */