summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-07 10:35:03 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-07 10:35:03 -0600
commit86c2ff8031c4c5ff2b35c4dd416fa0ab3752192b (patch)
tree2af4ab98fdbbdc4ea5338a1fde4aaebf32c219fc
parentb50cd425f73164a4e4d88dc783d623faa7ae8b6d (diff)
downloadnuttx-86c2ff8031c4c5ff2b35c4dd416fa0ab3752192b.tar.gz
nuttx-86c2ff8031c4c5ff2b35c4dd416fa0ab3752192b.tar.bz2
nuttx-86c2ff8031c4c5ff2b35c4dd416fa0ab3752192b.zip
Extend MTD support to M25P16. From Sébastien Lorquet
-rw-r--r--nuttx/drivers/mtd/m25px.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/nuttx/drivers/mtd/m25px.c b/nuttx/drivers/mtd/m25px.c
index c49585ebb..6bab204a2 100644
--- a/nuttx/drivers/mtd/m25px.c
+++ b/nuttx/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 */