mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] nand_write: initialize OOB buffer for each page
@ 2013-01-29  9:58 Jan Luebbe
  2013-01-29  9:58 ` [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode Jan Luebbe
  2013-01-30 21:52 ` [PATCH 1/2] nand_write: initialize OOB buffer for each page Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Luebbe @ 2013-01-29  9:58 UTC (permalink / raw)
  To: barebox

Previously, during a multi-page write, chip->oob_poi would not be
reinitialized.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/mtd/nand/nand_write.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c
index 9997127..f4f2fed 100644
--- a/drivers/mtd/nand/nand_write.c
+++ b/drivers/mtd/nand/nand_write.c
@@ -296,15 +296,15 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 	    (chip->pagebuf << chip->page_shift) < (to + ops->len))
 		chip->pagebuf = -1;
 
-	/* Initialize to all 0xFF, to avoid the possibility of
-	   left over OOB data from a previous OOB read. */
-	memset(chip->oob_poi, 0xff, mtd->oobsize);
-
 	while(1) {
 		int bytes = mtd->writesize;
 		int cached = writelen > bytes && page != blockmask;
 		uint8_t *wbuf = buf;
 
+		/* Initialize to all 0xFF, to avoid the possibility of
+		   left over OOB data from a previous OOB read or write. */
+		memset(chip->oob_poi, 0xff, mtd->oobsize);
+
 		/* Partial page write ? */
 		if (unlikely(column || writelen < (mtd->writesize - 1))) {
 			cached = 0;
-- 
1.7.10.4


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

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

* [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode
  2013-01-29  9:58 [PATCH 1/2] nand_write: initialize OOB buffer for each page Jan Luebbe
@ 2013-01-29  9:58 ` Jan Luebbe
  2013-01-30 21:52   ` Sascha Hauer
  2013-01-30 21:52 ` [PATCH 1/2] nand_write: initialize OOB buffer for each page Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Luebbe @ 2013-01-29  9:58 UTC (permalink / raw)
  To: barebox

The kernel uses these bytes to differentiate between erased/programmed
pages.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 9050a8d..b81ad53 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -751,6 +751,35 @@ static int omap_gpmc_read_page_bch_rom_mode(struct mtd_info *mtd,
 	return 0;
 }
 
+static void omap_gpmc_write_page_bch_rom_mode(struct mtd_info *mtd, struct nand_chip *chip,
+				  const uint8_t *buf)
+{
+	int i, eccsize = chip->ecc.size;
+	int eccbytes = chip->ecc.bytes;
+	int eccsteps = chip->ecc.steps;
+	uint8_t *ecc_calc = chip->buffers->ecccalc;
+	const uint8_t *p = buf;
+	uint32_t *eccpos = chip->ecc.layout->eccpos;
+
+	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+		chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
+		chip->write_buf(mtd, p, eccsize);
+		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
+	}
+
+	for (i = 0; i < chip->ecc.total; i++)
+		chip->oob_poi[eccpos[i]] = ecc_calc[i];
+
+	/*
+	 * set padding byte for each subpage to 0x00, so the kernel
+	 * can detect erased pages
+	 */
+	for (i = 0; i < 4; i++) {
+		chip->oob_poi[1+14*(i+1)] = 0x00;
+	}
+
+	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
+}
 static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
 		enum gpmc_ecc_mode mode)
 {
@@ -823,6 +852,7 @@ static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
 		oinfo->nand.ecc.bytes    = 4 * 13;
 		oinfo->nand.ecc.size     = 4 * 512;
 		nand->ecc.read_page = omap_gpmc_read_page_bch_rom_mode;
+		nand->ecc.write_page = omap_gpmc_write_page_bch_rom_mode;
 		omap_oobinfo.oobfree->length = 0;
 		j = 0;
 		for (i = 2; i < 15; i++)
-- 
1.7.10.4


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

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

* Re: [PATCH 1/2] nand_write: initialize OOB buffer for each page
  2013-01-29  9:58 [PATCH 1/2] nand_write: initialize OOB buffer for each page Jan Luebbe
  2013-01-29  9:58 ` [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode Jan Luebbe
@ 2013-01-30 21:52 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-01-30 21:52 UTC (permalink / raw)
  To: Jan Luebbe; +Cc: barebox

On Tue, Jan 29, 2013 at 10:58:01AM +0100, Jan Luebbe wrote:
> Previously, during a multi-page write, chip->oob_poi would not be
> reinitialized.
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
>  drivers/mtd/nand/nand_write.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c
> index 9997127..f4f2fed 100644
> --- a/drivers/mtd/nand/nand_write.c
> +++ b/drivers/mtd/nand/nand_write.c
> @@ -296,15 +296,15 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
>  	    (chip->pagebuf << chip->page_shift) < (to + ops->len))
>  		chip->pagebuf = -1;
>  
> -	/* Initialize to all 0xFF, to avoid the possibility of
> -	   left over OOB data from a previous OOB read. */
> -	memset(chip->oob_poi, 0xff, mtd->oobsize);
> -
>  	while(1) {
>  		int bytes = mtd->writesize;
>  		int cached = writelen > bytes && page != blockmask;
>  		uint8_t *wbuf = buf;
>  
> +		/* Initialize to all 0xFF, to avoid the possibility of
> +		   left over OOB data from a previous OOB read or write. */
> +		memset(chip->oob_poi, 0xff, mtd->oobsize);
> +

/*
 * Can you please fix the comment format while here?
 */

Does this fix a problem you found?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode
  2013-01-29  9:58 ` [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode Jan Luebbe
@ 2013-01-30 21:52   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-01-30 21:52 UTC (permalink / raw)
  To: Jan Luebbe; +Cc: barebox

On Tue, Jan 29, 2013 at 10:58:02AM +0100, Jan Luebbe wrote:
> The kernel uses these bytes to differentiate between erased/programmed
> pages.
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
>  drivers/mtd/nand/nand_omap_gpmc.c |   30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
> index 9050a8d..b81ad53 100644
> --- a/drivers/mtd/nand/nand_omap_gpmc.c
> +++ b/drivers/mtd/nand/nand_omap_gpmc.c
> @@ -751,6 +751,35 @@ static int omap_gpmc_read_page_bch_rom_mode(struct mtd_info *mtd,
>  	return 0;
>  }
>  
> +static void omap_gpmc_write_page_bch_rom_mode(struct mtd_info *mtd, struct nand_chip *chip,
> +				  const uint8_t *buf)
> +{
> +	int i, eccsize = chip->ecc.size;
> +	int eccbytes = chip->ecc.bytes;
> +	int eccsteps = chip->ecc.steps;
> +	uint8_t *ecc_calc = chip->buffers->ecccalc;
> +	const uint8_t *p = buf;
> +	uint32_t *eccpos = chip->ecc.layout->eccpos;
> +
> +	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
> +		chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
> +		chip->write_buf(mtd, p, eccsize);
> +		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
> +	}
> +
> +	for (i = 0; i < chip->ecc.total; i++)
> +		chip->oob_poi[eccpos[i]] = ecc_calc[i];
> +
> +	/*
> +	 * set padding byte for each subpage to 0x00, so the kernel
> +	 * can detect erased pages
> +	 */
> +	for (i = 0; i < 4; i++) {
> +		chip->oob_poi[1+14*(i+1)] = 0x00;
> +	}
> +
> +	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
> +}
>  static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
>  		enum gpmc_ecc_mode mode)
>  {

Nit: Missing blank line.

Sascha

> @@ -823,6 +852,7 @@ static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
>  		oinfo->nand.ecc.bytes    = 4 * 13;
>  		oinfo->nand.ecc.size     = 4 * 512;
>  		nand->ecc.read_page = omap_gpmc_read_page_bch_rom_mode;
> +		nand->ecc.write_page = omap_gpmc_write_page_bch_rom_mode;
>  		omap_oobinfo.oobfree->length = 0;
>  		j = 0;
>  		for (i = 2; i < 15; i++)
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

end of thread, other threads:[~2013-01-30 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29  9:58 [PATCH 1/2] nand_write: initialize OOB buffer for each page Jan Luebbe
2013-01-29  9:58 ` [PATCH 2/2] nand_omap_gpmc: use 0x00 for ECC padding in BCH ROM mode Jan Luebbe
2013-01-30 21:52   ` Sascha Hauer
2013-01-30 21:52 ` [PATCH 1/2] nand_write: initialize OOB buffer for each page Sascha Hauer

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