All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Ziswiler <marcel@ziswiler.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 08/13] tegra: nand: fix read_byte required for proper onfi detection
Date: Mon,  6 Jul 2015 10:20:34 +0200	[thread overview]
Message-ID: <735c3c8ca0086dc0f5d8657baf3633bbcc4a22f2.1436170106.git.marcel.ziswiler@toradex.com> (raw)
In-Reply-To: <cover.1436170106.git.marcel.ziswiler@toradex.com>

From: Marcel Ziswiler <marcel.ziswiler@toradex.com>

Fix PIO read_byte() implementation not only used for the legacy READ ID
but also the PARAM command now required for proper ONFI detection.

This fix is inspired by Lucas Stach's Linux Tegra NAND driver of late.

While at it also disable subpage writes.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
---
 drivers/mtd/nand/tegra_nand.c | 39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c
index b660f3b..9c90634 100644
--- a/drivers/mtd/nand/tegra_nand.c
+++ b/drivers/mtd/nand/tegra_nand.c
@@ -86,16 +86,6 @@ struct fdt_nand {
 
 struct nand_drv {
 	struct nand_ctlr *reg;
-
-	/*
-	* When running in PIO mode to get READ ID bytes from register
-	* RESP_0, we need this variable as an index to know which byte in
-	* register RESP_0 should be read.
-	* Because common code in nand_base.c invokes read_byte function two
-	* times for NAND_CMD_READID.
-	* And our controller returns 4 bytes at once in register RESP_0.
-	*/
-	int pio_byte_index;
 	struct fdt_nand config;
 };
 
@@ -181,25 +171,16 @@ static int nand_waitfor_cmd_completion(struct nand_ctlr *reg)
 static uint8_t read_byte(struct mtd_info *mtd)
 {
 	struct nand_chip *chip = mtd->priv;
-	u32 dword_read;
 	struct nand_drv *info;
 
 	info = (struct nand_drv *)chip->priv;
 
-	/* In PIO mode, only 4 bytes can be transferred with single CMD_GO. */
-	if (info->pio_byte_index > 3) {
-		info->pio_byte_index = 0;
-		writel(CMD_GO | CMD_PIO
-			| CMD_RX | CMD_CE0,
-			&info->reg->command);
-		if (!nand_waitfor_cmd_completion(info->reg))
-			printf("Command timeout\n");
-	}
+	writel(CMD_GO | CMD_PIO | CMD_RX | CMD_CE0 | CMD_A_VALID,
+	       &info->reg->command);
+	if (!nand_waitfor_cmd_completion(info->reg))
+		printf("Command timeout\n");
 
-	dword_read = readl(&info->reg->resp);
-	dword_read = dword_read >> (8 * info->pio_byte_index);
-	info->pio_byte_index++;
-	return (uint8_t)dword_read;
+	return (uint8_t)readl(&info->reg->resp);
 }
 
 /**
@@ -314,6 +295,9 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
 	if (column != -1 && (chip->options & NAND_BUSWIDTH_16))
 		column >>= 1;
 
+	/* Disable subpage writes as we do not provide ecc->hwctl */
+	chip->options |= NAND_NO_SUBPAGE_WRITE;
+
 	nand_clear_interrupt_status(info->reg);
 
 	/* Stop DMA engine, clear DMA completion status */
@@ -330,12 +314,8 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_READID:
 		writel(NAND_CMD_READID, &info->reg->cmd_reg1);
 		writel(column & 0xFF, &info->reg->addr_reg1);
-		writel(CMD_GO | CMD_CLE | CMD_ALE | CMD_PIO
-			| CMD_RX |
-			((4 - 1) << CMD_TRANS_SIZE_SHIFT)
-			| CMD_CE0,
+		writel(CMD_GO | CMD_CLE | CMD_ALE | CMD_CE0,
 			&info->reg->command);
-		info->pio_byte_index = 0;
 		break;
 	case NAND_CMD_PARAM:
 		writel(NAND_CMD_PARAM, &info->reg->cmd_reg1);
@@ -376,7 +356,6 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,
 			| ((1 - 0) << CMD_TRANS_SIZE_SHIFT)
 			| CMD_CE0,
 			&info->reg->command);
-		info->pio_byte_index = 0;
 		break;
 	case NAND_CMD_RESET:
 		writel(NAND_CMD_RESET, &info->reg->cmd_reg1);
-- 
1.9.3

  parent reply	other threads:[~2015-07-06  8:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06  8:20 [U-Boot] [PATCH 00/13] assortment of tegra fixes/enhancements Marcel Ziswiler
2015-07-06  8:20 ` [U-Boot] [PATCH 01/13] ARM: tegra: allow custom usb manufacturer/product/vendor ids/strings Marcel Ziswiler
2015-07-06 16:39   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 02/13] ARM: tegra: allow reading recovery mode boot type Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 03/13] apalis/colibri_t20/t30: integrate recovery mode detection Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-07  6:04     ` Marcel Ziswiler
2015-07-08 20:57       ` Stephen Warren
2015-07-09 13:02         ` Marcel Ziswiler
2015-07-09 15:02         ` Stefan Agner
2015-07-09 15:51           ` Stephen Warren
2015-07-06  8:20 ` [U-Boot] [PATCH 04/13] colibri_t20: fix device-tree compatible node Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 05/13] colibri_t20: add LCD display support Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-07  8:54     ` Marcel Ziswiler
2015-07-06  8:20 ` [U-Boot] [PATCH 06/13] colibri_t20: add i2c support Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 07/13] colibri_t20: disable PMIC sleep mode on low supply voltage Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` Marcel Ziswiler [this message]
2015-07-06  8:20 ` [U-Boot] [PATCH 09/13] colibri_t20: enable nand onfi detection Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 10/13] mtd/nand/tegra: alignment workaround Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 11/13] colibri_t20: enable mtdparts support Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 12/13] apalis/colibri_t20/t30: enable raw initrd support Marcel Ziswiler
2015-07-06 16:39   ` Simon Glass
2015-07-06  8:20 ` [U-Boot] [PATCH 13/13] apalis/colibri_t20/t30: increase tftp blocksize Marcel Ziswiler
2015-07-06 16:38   ` Simon Glass
2015-07-08 21:03   ` Stephen Warren
2015-07-09 13:26     ` Marcel Ziswiler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=735c3c8ca0086dc0f5d8657baf3633bbcc4a22f2.1436170106.git.marcel.ziswiler@toradex.com \
    --to=marcel@ziswiler.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.