diff mbox

[U-Boot,v2,1/4] spl: nand: simple: replace readb() with chip specific read_buf()

Message ID 1437173231-28528-1-git-send-email-vz@mleia.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Vladimir Zapolskiy July 17, 2015, 10:47 p.m. UTC
Some NAND controllers define custom functions to read data out,
respect this in order to correctly support bad block handling in
simple SPL NAND framework.

NAND controller specific read_buf() is used even to read 1 byte in
case of connected 8-bit NAND device, it turns out that read_byte()
may become outdated.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Tom Warren <twarren@nvidia.com>
---
Changes from v1 to v2:
* no changes, added Tom and Tom to Cc list for review and/or regression
  testing on Tegra, TI OMAP and TI DaVinci platforms

Previous discussion can be found here:
  http://lists.denx.de/pipermail/u-boot/2015-July/219250.html

 drivers/mtd/nand/nand_spl_simple.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Scott Wood July 28, 2015, 1:22 a.m. UTC | #1
On Sat, 2015-07-18 at 01:47 +0300, Vladimir Zapolskiy wrote:
> Some NAND controllers define custom functions to read data out,
> respect this in order to correctly support bad block handling in
> simple SPL NAND framework.
> 
> NAND controller specific read_buf() is used even to read 1 byte in
> case of connected 8-bit NAND device, it turns out that read_byte()
> may become outdated.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Tom Warren <twarren@nvidia.com>
> ---
> Changes from v1 to v2:
> * no changes, added Tom and Tom to Cc list for review and/or regression
>   testing on Tegra, TI OMAP and TI DaVinci platforms
> 
> Previous discussion can be found here:
>   http://lists.denx.de/pipermail/u-boot/2015-July/219250.html
> 
>  drivers/mtd/nand/nand_spl_simple.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Acked-by: Scott Wood <scottwood@freescale.com>

-Scott
Tom Rini Aug. 13, 2015, 1:18 p.m. UTC | #2
On Sat, Jul 18, 2015 at 01:47:08AM +0300, Vladimir Zapolskiy wrote:

> Some NAND controllers define custom functions to read data out,
> respect this in order to correctly support bad block handling in
> simple SPL NAND framework.
> 
> NAND controller specific read_buf() is used even to read 1 byte in
> case of connected 8-bit NAND device, it turns out that read_byte()
> may become outdated.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Tom Warren <twarren@nvidia.com>
> Acked-by: Scott Wood <scottwood@freescale.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_spl_simple.c b/drivers/mtd/nand/nand_spl_simple.c
index 700ca32..e69f662 100644
--- a/drivers/mtd/nand/nand_spl_simple.c
+++ b/drivers/mtd/nand/nand_spl_simple.c
@@ -115,6 +115,7 @@  static int nand_command(int block, int page, uint32_t offs,
 static int nand_is_bad_block(int block)
 {
 	struct nand_chip *this = mtd.priv;
+	u_char bb_data[2];
 
 	nand_command(block, 0, CONFIG_SYS_NAND_BAD_BLOCK_POS,
 		NAND_CMD_READOOB);
@@ -123,10 +124,12 @@  static int nand_is_bad_block(int block)
 	 * Read one byte (or two if it's a 16 bit chip).
 	 */
 	if (this->options & NAND_BUSWIDTH_16) {
-		if (readw(this->IO_ADDR_R) != 0xffff)
+		this->read_buf(&mtd, bb_data, 2);
+		if (bb_data[0] != 0xff || bb_data[1] != 0xff)
 			return 1;
 	} else {
-		if (readb(this->IO_ADDR_R) != 0xff)
+		this->read_buf(&mtd, bb_data, 1);
+		if (bb_data[0] != 0xff)
 			return 1;
 	}