From patchwork Fri Dec 13 09:12:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pekon gupta X-Patchwork-Id: 300960 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5C8BA2C009C for ; Fri, 13 Dec 2013 20:32:59 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 23C8C4AA08; Fri, 13 Dec 2013 10:32:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y7flo0P6a17h; Fri, 13 Dec 2013 10:32:51 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65D284A9E8; Fri, 13 Dec 2013 10:32:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD8514A9E4 for ; Fri, 13 Dec 2013 10:14:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ijigHacRha3h for ; Fri, 13 Dec 2013 10:14:02 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by theia.denx.de (Postfix) with ESMTPS id 83F4E4A9B4 for ; Fri, 13 Dec 2013 10:14:00 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBD9Dkft011188; Fri, 13 Dec 2013 03:13:46 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBD9DkZY005565; Fri, 13 Dec 2013 03:13:46 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Fri, 13 Dec 2013 03:13:46 -0600 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBD9DQ6D008709; Fri, 13 Dec 2013 03:13:40 -0600 From: Pekon Gupta To: Brian Norris , Artem Bityutskiy , Scott Wood , Tom Rini Date: Fri, 13 Dec 2013 14:42:58 +0530 Message-ID: <1386925978-23705-3-git-send-email-pekon@ti.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1386925978-23705-1-git-send-email-pekon@ti.com> References: <1386925978-23705-1-git-send-email-pekon@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2013 10:32:37 +0100 Cc: Thomas Petazzoni , Stefan Roese , r-woodruff2@ti.com, avinashphilipk@gmail.com, jp.francois@cynove.com, u-boot@lists.denx.de, balbi@ti.com, Enric Balletbo Serra , linux-mtd@lists.infradead.org, Ezequiel Garcia , linux-omap , ivan.djelic@parrot.com Subject: [U-Boot] [PATCH v1 2/2] mtd: nand: omap: fix ecclayout to be in sync with u-boot NAND driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch mainly fixes ecc-layout for following ecc-schemes, to bring them in sync with u-boot omap_gpmc NAND driver: - BCH4_SW: OMAP_ECC_BCH4_CODE_HW_DETECTION_SW This ecc-scheme is mainly used on AM35xx and other legacy platforms. - BCH8_SW: OMAP_ECC_BCH8_CODE_HW_DETECTION_SW This ecc-scheme is mainly used on OMAP3x and other legacy platforms. Apart from above, this patch also touches other ecc-schemes as the fix required refactoring common code, into ecc-scheme specific code. Hence, end-to-end NAND boot sequence was tested on AM335x-EVM to avoid any further regression on legacy or current platforms. (BCH8_HW) (HAM1_HW) (HAM1_HW) (HAM1_HW) (UBIFS) ROM ---------> SPL ---------> U-Boot ---------> Kernel ---------> File-System (BCH8_HW) (BCH8_SW) (BCH8_SW) (BCH8_SW) (UBIFS) ROM ---------> SPL ---------> U-Boot ---------> Kernel ---------> File-System (BCH8_HW) (BCH8_HW) (BCH8_HW) (BCH8_HW) (UBIFS) ROM ---------> SPL ---------> U-Boot ---------> Kernel ---------> File-System *Configurations used to build u-boot and kernel for end-to-end NAND boot* +------------+--------------------------------------------+------------------+ | ecc-scheme | u-boot/SPL configs | kernel DTS | +------------+--------------------------------------------+------------------+ | | | | | HAM1_HW | #define CONFIG_NAND_OMAP_ECCSCHEME \ |ti,nand-ecc-opts= | | | OMAP_ECC_HAM1_CODE_HW | "ham1" | | (1-bit | #define CONFIG_SYS_NAND_ECCBYTES 3 | | | Hamming | #define CONFIG_SYS_NAND_ECCPOS \ | | | using h/w) | { 1, 2, 3, 4, 5, 6, 7, 8, 9, \ | | | | 10, 11, 12 } | | | | (for NAND page-size=2048) | | | | | | +------------+--------------------------------------------+------------------+ | | | | | BCH8_SW | #define CONFIG_NAND_OMAP_ECCSCHEME \ |ti,nand-ecc-opts= | | | OMAP_ECC_BCH8_CODE_HW_DETECTION_SW | "bch8" | |(8-bit BCH | #define CONFIG_SYS_NAND_ECCBYTES 13 |(without ELM node)| | using s/w | #define CONFIG_BCH | | |library for | #undef CONFIG_SPL_NAND_AM33XX_BCH | | |for ECC | #define CONFIG_SPL_NAND_SIMPLE | | | error | #define CONFIG_SYS_NAND_ECCPOS \ | | |correction) | {2, 3, 4, 5, 6, 7, 8, 9, 10, \ | | | | 11, 12, 13, 14, \ | | | | 16, 17, 18, 19, 20, 21, 22, 23, 24, \ | | | | 25, 26, 27, 28, \ | | | | 30, 31, 32, 33, 34, 35, 36, 37, 38, \ | | | | 39, 40, 41, 42, \ | | | | 44, 45, 46, 47, 48, 49, 50, 51, 52, \ | | | | 53, 54, 55, 56, } | | | | (for NAND page-size=2048) | | | | #define CONFIG_SYS_NAND_ECCSIZE 512 | | | | | | +------------+--------------------------------------------+------------------+ | | | | | BCH8_HW | #define CONFIG_NAND_OMAP_ECCSCHEME \ |ti,nand-ecc-opts= | | | OMAP_ECC_BCH8_CODE_HW | "bch8" | |(8-bit BCH | #define CONFIG_SYS_NAND_ECCBYTES 14 | | | using ELM | #define CONFIG_SPL_NAND_AM33XX_BCH |(with ELM node) | | h/w engine | #define CONFIG_SYS_NAND_ECCPOS \ |ti,elm-id=<&elm> | |for ECC | {2, 3, 4, 5, 6, 7, 8, 9, \ | | | error | 10, 11, 12, 13, 14, 15, 16, 17, \ | | |correction) | 18, 19, 20, 21, 22, 23, 24, 25, \ | | | | 26, 27, 28, 29, 30, 31, 32, 33, \ | | | | 34, 35, 36, 37, 38, 39, 40, 41, \ | | | | 42, 43, 44, 45, 46, 47, 48, 49, \ | | | | 50, 51, 52, 53, 54, 55, 56, 57, } | | | | (for NAND page-size=2048) | | | | #define CONFIG_SYS_NAND_ECCSIZE 512 | | | | | | +------------+--------------------------------------------+------------------+ Test1: flash ubi image from u-boot and boot the kernel U-boot> mw 0x82000000 0xff U-boot> fatload mmc 0 0x82000000 u-boot.img U-boot> nand erase U-boot> nand write 0x82000000 U-boot> setenv bootargs 'console=ttyO0,115200n8 noinitrd mem=256M \ root=ubi0 rw rootfstype=ubifs ubi.mtd=,\ ip=off init=/init' U-boot> bootm Test2: update u-boot.img from kernel and re-boot Kernel> flash_erase /dev/ 0 0 Kernel> nandwrite -s 0 /dev/ u-boot.img Kernel> reboot Signed-off-by: Pekon Gupta --- drivers/mtd/nand/omap2.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index bbdb5e8..e7836bf 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -1633,6 +1633,7 @@ static int omap_nand_probe(struct platform_device *pdev) int i; dma_cap_mask_t mask; unsigned sig; + unsigned oob_index; struct resource *res; struct mtd_part_parser_data ppdata = {}; @@ -1832,9 +1833,11 @@ static int omap_nand_probe(struct platform_device *pdev) (mtd->writesize / nand_chip->ecc.size); if (nand_chip->options & NAND_BUSWIDTH_16) - ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; + oob_index = BADBLOCK_MARKER_LENGTH; else - ecclayout->eccpos[0] = 1; + oob_index = 1; + for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) + ecclayout->eccpos[i] = oob_index; break; case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW: @@ -1851,7 +1854,13 @@ static int omap_nand_probe(struct platform_device *pdev) ecclayout->eccbytes = nand_chip->ecc.bytes * (mtd->writesize / nand_chip->ecc.size); - ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; + oob_index = BADBLOCK_MARKER_LENGTH; + for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) { + if ((i % nand_chip->ecc.bytes) || (i == 0)) + ecclayout->eccpos[i] = oob_index; + else + ecclayout->eccpos[i] = ++oob_index; + } /* software bch library is used for locating errors */ nand_chip->ecc.priv = nand_bch_init(mtd, nand_chip->ecc.size, @@ -1885,7 +1894,9 @@ static int omap_nand_probe(struct platform_device *pdev) ecclayout->eccbytes = nand_chip->ecc.bytes * (mtd->writesize / nand_chip->ecc.size); - ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; + oob_index = BADBLOCK_MARKER_LENGTH; + for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) + ecclayout->eccpos[i] = oob_index; /* This ECC scheme requires ELM H/W block */ if (is_elm_present(info, pdata->elm_of_node, BCH4_ECC) < 0) { pr_err("nand: error: could not initialize ELM\n"); @@ -1913,7 +1924,13 @@ static int omap_nand_probe(struct platform_device *pdev) ecclayout->eccbytes = nand_chip->ecc.bytes * (mtd->writesize / nand_chip->ecc.size); - ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; + oob_index = BADBLOCK_MARKER_LENGTH; + for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) { + if ((i % nand_chip->ecc.bytes) || (i == 0)) + ecclayout->eccpos[i] = oob_index; + else + ecclayout->eccpos[i] = ++oob_index; + } /* software bch library is used for locating errors */ nand_chip->ecc.priv = nand_bch_init(mtd, nand_chip->ecc.size, @@ -1954,7 +1971,9 @@ static int omap_nand_probe(struct platform_device *pdev) ecclayout->eccbytes = nand_chip->ecc.bytes * (mtd->writesize / nand_chip->ecc.size); - ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; + oob_index = BADBLOCK_MARKER_LENGTH; + for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) + ecclayout->eccpos[i] = oob_index; break; #else pr_err("nand: error: CONFIG_MTD_NAND_OMAP_BCH not enabled\n"); @@ -1968,8 +1987,6 @@ static int omap_nand_probe(struct platform_device *pdev) goto return_error; } - for (i = 1; i < ecclayout->eccbytes; i++) - ecclayout->eccpos[i] = ecclayout->eccpos[0] + i; /* check if NAND device's OOB is enough to store ECC signatures */ if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) { pr_err("not enough OOB bytes required = %d, available=%d\n",