You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/09/24 08:09:56 UTC

[incubator-nuttx] branch master updated: Add support for MT25Q1G SPI NOR

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b7a5b24  Add support for MT25Q1G SPI NOR
b7a5b24 is described below

commit b7a5b248e04eeec0a6ea214e76de5038dad4b948
Author: Jani Paalijarvi <ja...@unikie.com>
AuthorDate: Wed Sep 15 16:28:56 2021 +0300

    Add support for MT25Q1G SPI NOR
---
 drivers/mtd/m25px.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c
index 6b3e198..f551b15 100644
--- a/drivers/mtd/m25px.c
+++ b/drivers/mtd/m25px.c
@@ -98,6 +98,7 @@
 #define M25P_M25P64_CAPACITY       0x17 /* 64 M-bit */
 #define M25P_M25P128_CAPACITY      0x18 /* 128 M-bit */
 #define M25P_MT25Q128_CAPACITY     0x18 /* 128 M-bit */
+#define M25P_MT25Q1G_CAPACITY      0x21 /* 1 G-bit */
 
 /*  M25P1 capacity is 131,072 bytes:
  *  (4 sectors) * (32,768 bytes per sector)
@@ -174,6 +175,17 @@
 #define M25P_MT25Q128_NPAGES        65536
 #define M25P_MT25Q128_SUBSECT_SHIFT 12    /* Sub-Sector size 1 << 12 = 4,096 */
 
+/*  MT25Q1G capacity is 134,217,728  bytes:
+ *  (2048 sectors) * (65,536 bytes per sector)
+ *  (524288 pages) * (256 bytes per page)
+ */
+
+#define M25P_MT25Q1G_SECTOR_SHIFT  16    /* Sector size 1 << 16 = 65,536 */
+#define M25P_MT25Q1G_NSECTORS      2048
+#define M25P_MT25Q1G_PAGE_SHIFT    8     /* Page size 1 << 8 = 256 */
+#define M25P_MT25Q1G_NPAGES        524288
+#define M25P_MT25Q1G_SUBSECT_SHIFT 12    /* Sub-Sector size 1 << 12 = 4,096 */
+
 /* Instructions */
 
 /*    Command          Value    N Description             Addr Dummy Data   */
@@ -462,6 +474,19 @@ static inline int m25p_readid(struct m25p_dev_s *priv)
 #endif
           return OK;
         }
+      else if (capacity == M25P_MT25Q1G_CAPACITY)
+        {
+          /* Save the FLASH geometry */
+
+          priv->sectorshift    = M25P_MT25Q1G_SECTOR_SHIFT;
+          priv->nsectors       = M25P_MT25Q1G_NSECTORS;
+          priv->pageshift      = M25P_MT25Q1G_PAGE_SHIFT;
+          priv->npages         = M25P_MT25Q1G_NPAGES;
+#ifdef CONFIG_M25P_SUBSECTOR_ERASE
+          priv->subsectorshift = M25P_MT25Q1G_SUBSECT_SHIFT;
+#endif
+          return OK;
+        }
     }
 
   return -ENODEV;