From: Scott Wood Date: Tue, 8 Oct 2013 16:08:40 -0500 Subject: [U-Boot] [PATCH v2 1/4] mtd: nand: add NAND_BUSWIDTH_AUTO to autodetect bus width In-Reply-To: <1380565372-4312-2-git-send-email-pekon@ti.com> References: <1380565372-4312-1-git-send-email-pekon@ti.com> <1380565372-4312-2-git-send-email-pekon@ti.com> Message-ID: <1381266520.7979.266.camel@snotra.buserror.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 2013-09-30 at 23:52 +0530, Pekon Gupta wrote: > From: Matthieu CASTET > > This patch is modified version from following linux patch > http://lists.infradead.org/pipermail/linux-mtd/2012-November/044803.html > So retaining the authorship to Matthieu CASTET > > *Modifications from original patch* > (1) use CONFIG_SYS_NAND_ONFI_DETECTION instead of (chip->options & NAND_BUSWIDTH_AUTO) > (2) allow re-assigning of callbacks in nand_set_defaults() depending on bus-width > > *Original patch message* > The driver call nand_scan_ident in 8 bit mode, then > readid or onfi detection are done (and detect bus width). > The driver should update its bus width before calling nand_scan_tail. > > This work because readid and onfi are read work 8 byte mode. > > Note that nand_scan_ident send command (NAND_CMD_RESET, NAND_CMD_READID, NAND_CMD_PARAM), address and read data > The ONFI specificication is not very clear for x16 device if high byte of address should be driven to 0, > but according to [1] it should be ok to not drive it during autodetection. > > [1] > 3.3.2. Target Initialization > > [...] > The Read ID and Read Parameter Page commands only use the lower 8-bits of the data bus. > The host shall not issue commands that use a word data width on x16 devices until the host > determines the device supports a 16-bit data bus width in the parameter page. > > Signed-off-by: Pekon Gupta > --- > drivers/mtd/nand/nand_base.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index 9e05cef..4ef0edb 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -2514,7 +2514,7 @@ static void nand_set_defaults(struct nand_chip *chip, int busw) > > if (!chip->select_chip) > chip->select_chip = nand_select_chip; > - if (!chip->read_byte) > + if ((!chip->read_byte) || (chip->read_byte == nand_read_byte)) > chip->read_byte = busw ? nand_read_byte16 : nand_read_byte; Unnecessary parens (and doesn't match equivalent Linux code). This change corresponds to Linux commit 68e8078072e802e77134664f11d2ffbfbd2f8fbe. -Scott