mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* omap nand patches
@ 2011-04-11 14:10 Sascha Hauer
  2011-04-11 14:10 ` [PATCH 1/5] nand omap: fix hamming romcode ecc code Sascha Hauer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

Some more omap nand patches.

Sascha Hauer (5):
      nand omap: fix hamming romcode ecc code
      nand omap: turn debug messages into dev_dbg
      nand omap: use standard debug functions
      nand omap: use xzalloc instead of calloc
      nand omap: handle erased pages correctly in hamming ecc mode

 drivers/mtd/nand/nand_omap_gpmc.c |   70 ++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 35 deletions(-)


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] nand omap: fix hamming romcode ecc code
  2011-04-11 14:10 omap nand patches Sascha Hauer
@ 2011-04-11 14:10 ` Sascha Hauer
  2011-04-11 14:10 ` [PATCH 2/5] nand omap: turn debug messages into dev_dbg Sascha Hauer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

This got broken in commit:

6943635 mtd nand omap: make ecc mode runtime configurable

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 1599603..74ef1ac 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -470,7 +470,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
 	struct gpmc_nand_info *oinfo = (struct gpmc_nand_info *)(nand->priv);
 	unsigned int bch_mod = 0, bch_wrapmode = 0, eccsize1 = 0, eccsize0 = 0;
 	unsigned int ecc_conf_val = 0, ecc_size_conf_val = 0;
-	int dev_width = 0;
+	int dev_width = nand->options & NAND_BUSWIDTH_16 ? 0 : 1;
 	int ecc_size = nand->ecc.size;
 	int cs = 0;
 
@@ -508,7 +508,11 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
 	/* clear ecc and enable bits */
 	if (oinfo->ecc_mode == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
 		writel(0x00000101, oinfo->gpmc_base + GPMC_ECC_CONTROL);
-		ecc_size_conf_val = (eccsize1 << 22) | 0x0000000F;
+		/* Size 0 = 0xFF, Size1 is 0xFF - both are 512 bytes
+		 * tell all regs to generate size0 sized regs
+		 * we just have a single ECC engine for all CS
+		 */
+		ecc_size_conf_val = 0x3FCFF000;
 		ecc_conf_val = (dev_width << 7) | (cs << 1) | (0x1);
 	} else {
 		writel(0x1, oinfo->gpmc_base + GPMC_ECC_CONTROL);
@@ -557,6 +561,14 @@ static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
 	case OMAP_ECC_HAMMING_CODE_HW_ROMCODE:
 		oinfo->nand.ecc.bytes    = 3;
 		oinfo->nand.ecc.size     = 512;
+		oinfo->ecc_parity_pairs  = 12;
+		if (oinfo->nand.options & NAND_BUSWIDTH_16) {
+			offset = 2;
+		} else {
+			offset = 1;
+			oinfo->nand.badblock_pattern = &bb_descrip_flashbased;
+		}
+		omap_oobinfo.eccbytes = 3 * (minfo->oobsize / 16);
 		for (i = 0; i < omap_oobinfo.eccbytes; i++)
 			omap_oobinfo.eccpos[i] = i + offset;
 		omap_oobinfo.oobfree->offset = offset + omap_oobinfo.eccbytes;
@@ -613,8 +625,6 @@ static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
 		return -EINVAL;
 	}
 
-	omap_oobinfo.eccbytes = oinfo->nand.ecc.bytes;
-
 	oinfo->ecc_mode = mode;
 
 	if (nand->buffers)
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/5] nand omap: turn debug messages into dev_dbg
  2011-04-11 14:10 omap nand patches Sascha Hauer
  2011-04-11 14:10 ` [PATCH 1/5] nand omap: fix hamming romcode ecc code Sascha Hauer
@ 2011-04-11 14:10 ` Sascha Hauer
  2011-04-11 14:10 ` [PATCH 3/5] nand omap: use standard debug functions Sascha Hauer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

The information from the probe function is useful for developers
only, so turn them into dev_dbg to safe binary space.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 74ef1ac..74f2da6 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -682,13 +682,13 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	gpmcnand_dbg("pdev=%x", (unsigned int)pdev);
 	pdata = (struct gpmc_nand_platform_data *)pdev->platform_data;
 	if (pdata == NULL) {
-		gpmcnand_err("platform data missing\n");
+		dev_dbg(pdev, "platform data missing\n");
 		return -ENODEV;
 	}
 
 	oinfo = calloc(1, sizeof(struct gpmc_nand_info));
 	if (!oinfo) {
-		gpmcnand_err("oinfo alloc failed!\n");
+		dev_dbg(pdev, "oinfo alloc failed!\n");
 		return -ENOMEM;
 	}
 
@@ -705,7 +705,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	minfo->priv = (void *)nand;
 
 	if (pdata->cs >= GPMC_NUM_CS) {
-		gpmcnand_err("Invalid CS!\n");
+		dev_dbg(pdev, "Invalid CS!\n");
 		err = -EINVAL;
 		goto out_release_mem;
 	}
@@ -729,7 +729,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 
 	/* If we are 16 bit dev, our gpmc config tells us that */
 	if ((readl(cs_base) & 0x3000) == 0x1000) {
-		debug("16 bit dev\n");
+		dev_dbg(pdev, "16 bit dev\n");
 		nand->options |= NAND_BUSWIDTH_16;
 	}
 
@@ -744,7 +744,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	 * until you get a failure or success
 	 */
 	if (pdata->wait_mon_pin > 4) {
-		gpmcnand_err("Invalid wait monitoring pin\n");
+		dev_dbg(pdev, "Invalid wait monitoring pin\n");
 		err = -EINVAL;
 		goto out_release_mem;
 	}
@@ -774,7 +774,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	if (pdata->nand_setup) {
 		err = pdata->nand_setup(pdata);
 		if (err) {
-			gpmcnand_err("pdataform setup failed\n");
+			dev_dbg(pdev, "pdataform setup failed\n");
 			goto out_release_mem;
 		}
 	}
@@ -826,7 +826,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	/* We are all set to register with the system now! */
 	err = add_mtd_device(minfo);
 	if (err) {
-		gpmcnand_err("device registration failed\n");
+		dev_dbg(pdev, "device registration failed\n");
 		goto out_release_mem;
 	}
 
@@ -838,7 +838,7 @@ out_release_mem:
 	if (oinfo)
 		free(oinfo);
 
-	gpmcnand_err("Failed!!\n");
+	dev_dbg(pdev, "Failed!!\n");
 	return err;
 }
 
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/5] nand omap: use standard debug functions
  2011-04-11 14:10 omap nand patches Sascha Hauer
  2011-04-11 14:10 ` [PATCH 1/5] nand omap: fix hamming romcode ecc code Sascha Hauer
  2011-04-11 14:10 ` [PATCH 2/5] nand omap: turn debug messages into dev_dbg Sascha Hauer
@ 2011-04-11 14:10 ` Sascha Hauer
  2011-04-11 14:10 ` [PATCH 4/5] nand omap: use xzalloc instead of calloc Sascha Hauer
  2011-04-11 14:10 ` [PATCH 5/5] nand omap: handle erased pages correctly in hamming ecc mode Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 74f2da6..7874810 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -76,16 +76,6 @@
 #include <mach/gpmc.h>
 #include <mach/gpmc_nand.h>
 
-/* Enable me to get tons of debug messages -for use without jtag */
-#if 0
-#define gpmcnand_dbg(FORMAT, ARGS...) fprintf(stdout,\
-		"gpmc_nand:%s:%d:Entry:"FORMAT"\n",\
-		__func__, __LINE__, ARGS)
-#else
-#define gpmcnand_dbg(FORMAT, ARGS...)
-#endif
-#define gpmcnand_err(ARGS...) fprintf(stderr, "omapnand: " ARGS);
-
 int decode_bch(int select_4_8, unsigned char *ecc, unsigned int *err_loc);
 
 static char *ecc_mode_strings[] = {
@@ -190,14 +180,14 @@ static int omap_dev_ready(struct mtd_info *mtd)
 	uint64_t start = get_time_ns();
 	unsigned long comp;
 
-	gpmcnand_dbg("mtd=%x", (unsigned int)mtd);
+	debug("mtd=%x", (unsigned int)mtd);
 	/* What do we mean by assert and de-assert? */
 	comp = (oinfo->wait_pol == NAND_WAITPOL_HIGH) ?
 	    oinfo->wait_mon_mask : 0x0;
 	while (1) {
 		/* Breakout condition */
 		if (is_timeout(start, oinfo->timeout)) {
-			gpmcnand_err("timedout\n");
+			debug("timedout\n");
 			return -ETIMEDOUT;
 		}
 		/* if the wait is released, we are good to go */
@@ -222,7 +212,7 @@ static void gpmc_nand_wp(struct gpmc_nand_info *oinfo, int mode)
 {
 	unsigned long config = readl(oinfo->gpmc_base + GPMC_CFG);
 
-	gpmcnand_dbg("mode=%x", mode);
+	debug("mode=%x", mode);
 	if (mode)
 		config &= ~(NAND_WP_BIT);	/* WP is ON */
 	else
@@ -247,7 +237,7 @@ static void omap_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
 	struct nand_chip *nand = (struct nand_chip *)(mtd->priv);
 	struct gpmc_nand_info *oinfo = (struct gpmc_nand_info *)(nand->priv);
-	gpmcnand_dbg("mtd=%x nand=%x cmd=%x ctrl = %x", (unsigned int)mtd, nand,
+	debug("mtd=%x nand=%x cmd=%x ctrl = %x", (unsigned int)mtd, nand,
 		  cmd, ctrl);
 	switch (ctrl) {
 	case NAND_CTRL_CHANGE | NAND_CTRL_CLE:
@@ -281,7 +271,7 @@ static void omap_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  */
 static unsigned int gen_true_ecc(u8 *ecc_buf)
 {
-	gpmcnand_dbg("ecc_buf=%x 1, 2 3 = %x %x %x", (unsigned int)ecc_buf,
+	debug("ecc_buf=%x 1, 2 3 = %x %x %x", (unsigned int)ecc_buf,
 		  ecc_buf[0], ecc_buf[1], ecc_buf[2]);
 	return ecc_buf[0] | (ecc_buf[1] << 16) | ((ecc_buf[2] & 0xF0) << 20) |
 	    ((ecc_buf[2] & 0x0F) << 8);
@@ -375,7 +365,7 @@ static int omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	int blockCnt = 0;
 	int select_4_8;
 
-	gpmcnand_dbg("mtd=%x dat=%x read_ecc=%x calc_ecc=%x", (unsigned int)mtd,
+	debug("mtd=%x dat=%x read_ecc=%x calc_ecc=%x", (unsigned int)mtd,
 		  (unsigned int)dat, (unsigned int)read_ecc,
 		  (unsigned int)calc_ecc);
 
@@ -404,11 +394,11 @@ static int omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
 				/* Flip the bit to correct */
 				dat[byte] ^= (0x1 << bit);
 			} else if (hm == 1) {
-				gpmcnand_err("Ecc is wrong\n");
+				printf("Ecc is wrong\n");
 				/* ECC itself is corrupted */
 				return 2;
 			} else {
-				gpmcnand_err("bad compare! failed\n");
+				printf("bad compare! failed\n");
 				/* detected 2 bit error */
 				return -1;
 			}
@@ -679,7 +669,6 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	int err;
 	struct nand_ecclayout *layout, *lsp, *llp;
 
-	gpmcnand_dbg("pdev=%x", (unsigned int)pdev);
 	pdata = (struct gpmc_nand_platform_data *)pdev->platform_data;
 	if (pdata == NULL) {
 		dev_dbg(pdev, "platform data missing\n");
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/5] nand omap: use xzalloc instead of calloc
  2011-04-11 14:10 omap nand patches Sascha Hauer
                   ` (2 preceding siblings ...)
  2011-04-11 14:10 ` [PATCH 3/5] nand omap: use standard debug functions Sascha Hauer
@ 2011-04-11 14:10 ` Sascha Hauer
  2011-04-11 14:10 ` [PATCH 5/5] nand omap: handle erased pages correctly in hamming ecc mode Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 7874810..d61f7d9 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -675,11 +675,7 @@ static int gpmc_nand_probe(struct device_d *pdev)
 		return -ENODEV;
 	}
 
-	oinfo = calloc(1, sizeof(struct gpmc_nand_info));
-	if (!oinfo) {
-		dev_dbg(pdev, "oinfo alloc failed!\n");
-		return -ENOMEM;
-	}
+	oinfo = xzalloc(sizeof(*oinfo));
 
 	/* fill up my data structures */
 	oinfo->pdev = pdev;
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/5] nand omap: handle erased pages correctly in hamming ecc mode
  2011-04-11 14:10 omap nand patches Sascha Hauer
                   ` (3 preceding siblings ...)
  2011-04-11 14:10 ` [PATCH 4/5] nand omap: use xzalloc instead of calloc Sascha Hauer
@ 2011-04-11 14:10 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2011-04-11 14:10 UTC (permalink / raw)
  To: barebox

do not throw ecc errors on erased pages.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index d61f7d9..9d375aa 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -377,6 +377,11 @@ static int omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
 
 	switch (oinfo->ecc_mode) {
 	case OMAP_ECC_HAMMING_CODE_HW_ROMCODE:
+		if (read_ecc[0] == 0xff && read_ecc[1] == 0xff &&
+				read_ecc[2] == 0xff && calc_ecc[0] == 0x0 &&
+				calc_ecc[1] == 0x0 && calc_ecc[0] == 0x0)
+			break;
+
 		/* Regenerate the orginal ECC */
 		orig_ecc = gen_true_ecc(read_ecc);
 		new_ecc = gen_true_ecc(calc_ecc);
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-11 14:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-11 14:10 omap nand patches Sascha Hauer
2011-04-11 14:10 ` [PATCH 1/5] nand omap: fix hamming romcode ecc code Sascha Hauer
2011-04-11 14:10 ` [PATCH 2/5] nand omap: turn debug messages into dev_dbg Sascha Hauer
2011-04-11 14:10 ` [PATCH 3/5] nand omap: use standard debug functions Sascha Hauer
2011-04-11 14:10 ` [PATCH 4/5] nand omap: use xzalloc instead of calloc Sascha Hauer
2011-04-11 14:10 ` [PATCH 5/5] nand omap: handle erased pages correctly in hamming ecc mode Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox