[U-Boot] [PATCH] tegra: nand: make ONFI detection work

Lucas Stach dev at lynxeye.de
Sat Sep 29 13:20:53 CEST 2012


Am Freitag, den 28.09.2012, 17:35 -0500 schrieb Scott Wood:
> On 09/28/2012 10:56:51 AM, Lucas Stach wrote:
> > Add the missing bits to the Tegra NAND driver to make ONFI detection  
> > work
> > properly.
> > 
> > Also add it to the Tegra default config, as it seems to be a  
> > reasonable thing
> > to have it available on all boards that use any kind of NAND.
> > 
> > Signed-off-by: Lucas Stach <dev at lynxeye.de>
> > ---
> >  drivers/mtd/nand/tegra_nand.c    | 36  
> > ++++++++++++++++++++++++++++++++++++
> >  include/configs/tegra20-common.h |  1 +
> >  2 Dateien geändert, 37 Zeilen hinzugefügt(+)
> > 
> > diff --git a/drivers/mtd/nand/tegra_nand.c  
> > b/drivers/mtd/nand/tegra_nand.c
> > index 2c1b533..0d7ca5d 100644
> > --- a/drivers/mtd/nand/tegra_nand.c
> > +++ b/drivers/mtd/nand/tegra_nand.c
> > @@ -219,6 +219,34 @@ static uint8_t read_byte(struct mtd_info *mtd)
> >  }
> > 
> >  /**
> > + * Read len bytes from the chip into a buffer
> > + *
> > + * @param mtd	MTD device structure
> > + * @param buf	buffer to store data to
> > + * @param len	number of bytes to read
> > + *
> > + * Read function for 8bit bus-width
> > + */
> > +static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
> > +{
> > +	int i, s;
> > +	unsigned int reg;
> > +	struct nand_chip *chip = mtd->priv;
> > +	struct nand_drv *info = (struct nand_drv *)chip->priv;
> > +
> > +	for (i = 0; i < len; i += 4) {
> > +		s = (len - i) > 4 ? 4 : len - i;
> > +		writel(CMD_PIO | CMD_RX | CMD_A_VALID | CMD_CE0 |
> > +			((s - 1) << CMD_TRANS_SIZE_SHIFT) | CMD_GO,
> > +			&info->reg->command);
> > +		if (!nand_waitfor_cmd_completion(info->reg))
> > +			printf("Command timeout during read_buf\n");
> > +		reg = readl(&info->reg->resp);
> > +		memcpy(buf + i, &reg, s);
> > +	}
> > +}
> 
> Out of curiousity, what is it about this that needed a custom  
> read_buf() where you didn't need one before?

The ONFI parameter page is read before everything is initialized
correctly. Because of this we can not use the common way of reading a
page with the DMA functionality of the Tegra NAND controller. So for
ONFI detection to work we have to implement a readbuf function which
uses PIO to read the page.

Note that I'm still no NAND expert, this is just what I could figure out
from reading the ONFI spec and the programming information for the NAND
controller in the Tegra TRM.

Lucas



More information about the U-Boot mailing list