Skip to contentSkip to conversation

Add support for NAND on the socrates board and oob size 128

PATCH In review Wolfgang Grandegger 2 participants 5 messages Mar 25, 2009 – Mar 30, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add support for NAND on the socrates board and oob size 128

The following patch series adds support for the NAND flash on the Socrates board (MPC8544) including the required support for an oob size of 128.

Please consider these patches for inclusion into the kernel version 2.6.30.

Thanks,

Wolfgang

#1 lore raw

PATCH 1/2 NAND: Add support for oob size 128

---
 drivers/mtd/nand/nand_base.c |   17 +++++++++++++++++
 include/linux/mtd/nand.h     |    2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +17 -0
Index: linux-2.6/drivers/mtd/nand/nand_base.c
===================================================================
@@ -82,6 +82,20 @@ static struct nand_ecclayout nand_oob_64
 		 .length = 38}}
 };
 
+static struct nand_ecclayout nand_oob_128 = {
+	.eccbytes = 48,
+	.eccpos = {
+		    80,  81,  82,  83,  84,  85,  86,  87,
+		    88,  89,  90,  91,  92,  93,  94,  95,
+		    96,  97,  98,  99, 100, 101, 102, 103,
+		   104, 105, 106, 107, 108, 109, 110, 111,
+		   112, 113, 114, 115, 116, 117, 118, 119,
+		   120, 121, 122, 123, 124, 125, 126, 127},
+	.oobfree = {
+		{.offset = 2,
+		 .length = 78}}
+};
+
 static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
 			   int new_state);
 
@@ -2555,6 +2569,9 @@ int nand_scan_tail(struct mtd_info *mtd)
 		case 64:
 			chip->ecc.layout = &nand_oob_64;
 			break;
+		case 128:
+			chip->ecc.layout = &nand_oob_128;
+			break;
 		default:
 			printk(KERN_WARNING "No oob scheme defined for "
 			       "oobsize %d\n", mtd->oobsize);
include/linux/mtd/nand.h +1 -1
Index: linux-2.6/include/linux/mtd/nand.h
===================================================================
@@ -43,7 +43,7 @@ extern void nand_wait_ready(struct mtd_i
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE	64
+#define NAND_MAX_OOBSIZE	128
 #define NAND_MAX_PAGESIZE	2048
 
 /*
#2 lore raw

Re: [PATCH 1/2] NAND: Add support for oob size 128

Quoted 2 lines · * Wolfgang Grandegger | 2009-03-25 11:48:37 [+0100]:

You seem to forgot a few bits (subpage_sft & max page size). I had this patch in my tree like for ever and forgot post it here. I did however merge the mtd-utils bits allready :)

From: Thomas Gleixner <[email protected]>
Date: Wed, 12 Dec 2007 17:27:03 +0100
Subject: [PATCH] [MTD] Add support for 4k pages.

---
 drivers/mtd/nand/nand_base.c |   18 ++++++++++++++++++
 include/linux/mtd/nand.h     |    4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +18 -0
index 0a9c9cd..c3266fd 100644
@@ -82,6 +82,20 @@ static struct nand_ecclayout nand_oob_64 = {
 		 .length = 38}}
 };
 
+static struct nand_ecclayout nand_oob_128 = {
+	.eccbytes = 48,
+	.eccpos = {
+		   80, 81, 82, 83, 84, 85, 86, 87,
+		   88, 89, 90, 91, 92, 93, 94, 95,
+		   96, 97, 98, 99, 100, 101, 102, 103,
+		   104, 105, 106, 107, 108, 109, 110, 111,
+		   112, 113, 114, 115, 116, 117, 118, 119,
+		   120, 121, 122, 123, 124, 125, 126, 127},
+	.oobfree = {
+		{.offset = 2,
+		 .length = 78}}
+};
+
 static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
 			   int new_state);
 
@@ -2550,6 +2564,9 @@ int nand_scan_tail(struct mtd_info *mtd)
 		case 64:
 			chip->ecc.layout = &nand_oob_64;
 			break;
+		case 128:
+			chip->ecc.layout = &nand_oob_128;
+			break;
 		default:
 			printk(KERN_WARNING "No oob scheme defined for "
 			       "oobsize %d\n", mtd->oobsize);
@@ -2671,6 +2688,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 			break;
 		case 4:
 		case 8:
+		case 16:
 			mtd->subpage_sft = 2;
 			break;
 		}
include/linux/mtd/nand.h +2 -2
index 733d3f3..b90e683 100644
@@ -43,8 +43,8 @@ extern void nand_wait_ready(struct mtd_info *mtd);
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE	64
-#define NAND_MAX_PAGESIZE	2048
+#define NAND_MAX_OOBSIZE	128
+#define NAND_MAX_PAGESIZE	4096
 
 /*
  * Constants for hardware specific CLE/ALE/NCE function
Signature · 1 line
1.6.0.6
author Acked-by
#3 lore raw

Re: [PATCH 1/2] NAND: Add support for oob size 128

Hi Sebastian,

Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 2 lines · * Wolfgang Grandegger | 2009-03-25 11:48:37 [+0100]:

You seem to forgot a few bits (subpage_sft & max page size). I had this patch in my tree like for ever and forgot post it here. I did however merge the mtd-utils bits allready :)

I see. Your patch works fine for my board as well and I have added my "acked-by" line below. David, could you please consider this patch for kernel inclusion.

Thanks,

Wolfgang.

Quoted 6 lines

From: Thomas Gleixner <[email protected]>
Date: Wed, 12 Dec 2007 17:27:03 +0100
Subject: [PATCH] [MTD] Add support for 4k pages.

Quoted 63 lines
---
 drivers/mtd/nand/nand_base.c |   18 ++++++++++++++++++
 include/linux/mtd/nand.h     |    4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +18 -0
index 0a9c9cd..c3266fd 100644
@@ -82,6 +82,20 @@ static struct nand_ecclayout nand_oob_64 = {
 		 .length = 38}}
 };
 
+static struct nand_ecclayout nand_oob_128 = {
+	.eccbytes = 48,
+	.eccpos = {
+		   80, 81, 82, 83, 84, 85, 86, 87,
+		   88, 89, 90, 91, 92, 93, 94, 95,
+		   96, 97, 98, 99, 100, 101, 102, 103,
+		   104, 105, 106, 107, 108, 109, 110, 111,
+		   112, 113, 114, 115, 116, 117, 118, 119,
+		   120, 121, 122, 123, 124, 125, 126, 127},
+	.oobfree = {
+		{.offset = 2,
+		 .length = 78}}
+};
+
 static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
 			   int new_state);
 
@@ -2550,6 +2564,9 @@ int nand_scan_tail(struct mtd_info *mtd)
 		case 64:
 			chip->ecc.layout = &nand_oob_64;
 			break;
+		case 128:
+			chip->ecc.layout = &nand_oob_128;
+			break;
 		default:
 			printk(KERN_WARNING "No oob scheme defined for "
 			       "oobsize %d\n", mtd->oobsize);
@@ -2671,6 +2688,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 			break;
 		case 4:
 		case 8:
+		case 16:
 			mtd->subpage_sft = 2;
 			break;
 		}
include/linux/mtd/nand.h +2 -2
index 733d3f3..b90e683 100644
@@ -43,8 +43,8 @@ extern void nand_wait_ready(struct mtd_info *mtd);
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE	64
-#define NAND_MAX_PAGESIZE	2048
+#define NAND_MAX_OOBSIZE	128
+#define NAND_MAX_PAGESIZE	4096
 
 /*
  * Constants for hardware specific CLE/ALE/NCE function
#4 lore raw

PATCH 2/2 NAND: Add support for NAND on the Socrates board

In reply to Wolfgang Grandegger
---
 drivers/mtd/nand/Kconfig         |    6 
 drivers/mtd/nand/Makefile        |    1 
 drivers/mtd/nand/socrates_nand.c |  324 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 331 insertions(+)
drivers/mtd/nand/Kconfig +6 -0
Index: linux-2.6/drivers/mtd/nand/Kconfig
===================================================================
@@ -427,4 +427,10 @@
 	  Several Renesas SuperH CPU has FLCTL. This option enables support
 	  for NAND Flash using FLCTL. This driver support SH7723.
 
+config MTD_NAND_SOCRATES
+	tristate "Support for NAND on Socrates board"
+	depends on MTD_NAND && SOCRATES
+	help
+	  Enables support for NAND Flash chips wired onto Socrates board.
+
 endif # MTD_NAND
drivers/mtd/nand/Makefile +1 -0
Index: linux-2.6/drivers/mtd/nand/Makefile
===================================================================
@@ -36,5 +36,6 @@
 obj-$(CONFIG_MTD_NAND_FSL_UPM)		+= fsl_upm.o
 obj-$(CONFIG_MTD_NAND_SH_FLCTL)		+= sh_flctl.o
 obj-$(CONFIG_MTD_NAND_MXC)		+= mxc_nand.o
+obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
 
 nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/socrates_nand.c new file +324 -0

324 lines not on this page · raw message