From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Date: Fri, 25 Feb 2011 10:59:09 +0100 Subject: [U-Boot] [PATCH v3] NAND: add support for reading ONFI page table In-Reply-To: <20110214174607.2b56dca8@schlenkerla.am.freescale.net> References: <1292019402-25433-1-git-send-email-florian@openwrt.org> <201102141648.01214.florian@openwrt.org> <20110214174607.2b56dca8@schlenkerla.am.freescale.net> Message-ID: <201102251059.09719.florian@openwrt.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Scott, (sorry for the lag in answering) On Tuesday 15 February 2011 00:46:07 Scott Wood wrote: > On Mon, 14 Feb 2011 16:48:01 +0100 > > Florian Fainelli wrote: > > From: Florian Fainelli > > > > This patch adds support for reading an ONFI page parameter from a NAND > > device supporting it. If this is the case, struct nand_chip onfi_version > > member contains the supported ONFI version, 0 otherwise. > > > > This allows NAND drivers past nand_scan_ident to set the best timings for > > the NAND chip. > > > > Signed-off-by: Florian Fainelli > > --- > > Patch against your 'next' branch > > The 'next' branch is old, since I haven't pushed anything to it yet this > cycle. Base it on Wolfgang's 'next'. > > > Changes since v1: > > - ifdef out ONFI detection code around CONFIG_SYS_NAND_ONFI_DETECTION > > - removed bogus comment > > - fixed busw variable usage > > - move non-ONFI detection code to its own function > > - fixed stylistic issues spotted by Scott > > > > Changes since v2: > > - reduce lenght of some lines down to 80 columns > > - change chip->options consistently wrt to ONFI detected or not > > - removed extra spaces > > > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > > index 5239c1f..7becb99 100644 > > --- a/drivers/mtd/nand/nand_base.c > > +++ b/drivers/mtd/nand/nand_base.c > > @@ -2409,15 +2409,137 @@ static void nand_set_defaults(struct nand_chip > > *chip, int busw) > > > > chip->controller = &chip->hwcontrol; > > > > } > > > > +#ifdef CONFIG_SYS_NAND_ONFI_DETECTION > > +static u16 onfi_crc16(u16 crc, u8 const *p, size_t len) > > +{ > > + int i; > > + > > + while (len--) { > > + crc ^= *p++ << 8; > > + for (i = 0; i < 8; i++) > > + crc = (crc << 1) ^ ((crc & 0x8000) ? 0x8005 : 0); > > + } > > + > > + return crc; > > +} > > Is this different from what's in lib/crc16.c (other than appearing to have > made a different speed/size tradeoff)? Yes it is a different version of the CRC16 function. > > > +#define ONFI_CRC_BASE 0x4F4E > > Is this ONFI-specific, or standard for crc16? > > > + > > +/* > > + * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 > > otherwise + */ > > +static int nand_flash_detect_onfi(struct mtd_info *mtd, > > + struct nand_chip *chip, > > + int *busw) > > +{ > > [snip] > > > + chip->options &= ~NAND_CHIPOPTIONS_MSK; > > + chip->options |= NAND_NO_READRDY & NAND_CHIPOPTIONS_MSK; > > Won't this get overwritten by this later? It will, thanks for spotting. -- Florian