From: Baruch Siach <baruch@tkos.co.il> To: David Woodhouse <dwmw2@infradead.org>, Brian Norris <computersforpeace@gmail.com> Cc: "Baruch Siach" <baruch@tkos.co.il>, linux-mtd@lists.infradead.org, "Sascha Hauer" <kernel@pengutronix.de>, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "Shawn Guo" <shawn.guo@linaro.org>, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC Date: Sun, 26 Apr 2015 11:16:51 +0300 [thread overview] Message-ID: <c70c70dfe01be9356eeb238072fda699f30672fc.1430034929.git.baruch@tkos.co.il> (raw) In-Reply-To: <cover.1430034929.git.baruch@tkos.co.il> Hardware 8 bit ECC requires a different nand_ecclayout. Instead of adding yet another static struct nand_ecclayout, generate it in code. Signed-off-by: Baruch Siach <baruch@tkos.co.il> --- drivers/mtd/nand/mxc_nand.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index c05f5e8fef17..07493f0d9eb4 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -934,6 +934,22 @@ static int get_eccsize(struct mtd_info *mtd) return 8; } +static void ecc_8bit_layout(struct nand_ecclayout *layout) +{ + int i, j; + + for (i = 0; i < 8; i++) + for (j = 0; j < 18; j++) + layout->eccpos[i*18 + j] = i*26 + j + 7; + + layout->oobfree[0].offset = 2; + layout->oobfree[0].length = 4; + for (i = 1; i < 8; i++) { + layout->oobfree[i].offset = i*26; + layout->oobfree[i].length = 7; + } +} + static void preset_v1(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd->priv; @@ -1610,8 +1626,11 @@ static int mxcnd_probe(struct platform_device *pdev) if (mtd->writesize == 2048) this->ecc.layout = host->devtype_data->ecclayout_2k; - else if (mtd->writesize == 4096) + else if (mtd->writesize == 4096) { this->ecc.layout = host->devtype_data->ecclayout_4k; + if (get_eccsize(mtd) == 8) + ecc_8bit_layout(this->ecc.layout); + } if (this->ecc.mode == NAND_ECC_HW) { if (is_imx21_nfc(host) || is_imx27_nfc(host)) -- 2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: baruch@tkos.co.il (Baruch Siach) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC Date: Sun, 26 Apr 2015 11:16:51 +0300 [thread overview] Message-ID: <c70c70dfe01be9356eeb238072fda699f30672fc.1430034929.git.baruch@tkos.co.il> (raw) In-Reply-To: <cover.1430034929.git.baruch@tkos.co.il> Hardware 8 bit ECC requires a different nand_ecclayout. Instead of adding yet another static struct nand_ecclayout, generate it in code. Signed-off-by: Baruch Siach <baruch@tkos.co.il> --- drivers/mtd/nand/mxc_nand.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index c05f5e8fef17..07493f0d9eb4 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -934,6 +934,22 @@ static int get_eccsize(struct mtd_info *mtd) return 8; } +static void ecc_8bit_layout(struct nand_ecclayout *layout) +{ + int i, j; + + for (i = 0; i < 8; i++) + for (j = 0; j < 18; j++) + layout->eccpos[i*18 + j] = i*26 + j + 7; + + layout->oobfree[0].offset = 2; + layout->oobfree[0].length = 4; + for (i = 1; i < 8; i++) { + layout->oobfree[i].offset = i*26; + layout->oobfree[i].length = 7; + } +} + static void preset_v1(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd->priv; @@ -1610,8 +1626,11 @@ static int mxcnd_probe(struct platform_device *pdev) if (mtd->writesize == 2048) this->ecc.layout = host->devtype_data->ecclayout_2k; - else if (mtd->writesize == 4096) + else if (mtd->writesize == 4096) { this->ecc.layout = host->devtype_data->ecclayout_4k; + if (get_eccsize(mtd) == 8) + ecc_8bit_layout(this->ecc.layout); + } if (this->ecc.mode == NAND_ECC_HW) { if (is_imx21_nfc(host) || is_imx27_nfc(host)) -- 2.1.4
next prev parent reply other threads:[~2015-04-26 8:16 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-04-26 8:16 [PATCH 0/4] mtd: mxc_nand: fix 8 bit ECC and large oob Baruch Siach 2015-04-26 8:16 ` Baruch Siach 2015-04-26 8:16 ` [PATCH 1/4] mtd: nand: mxc_nand: cleanup copy_spare function Baruch Siach 2015-04-26 8:16 ` Baruch Siach 2015-04-26 8:16 ` [PATCH 2/4] mtd: mxc_nand: limit the size of used oob Baruch Siach 2015-04-26 8:16 ` Baruch Siach 2015-04-26 20:07 ` Uwe Kleine-König 2015-04-26 20:07 ` Uwe Kleine-König 2015-04-27 4:39 ` Baruch Siach 2015-04-27 4:39 ` Baruch Siach 2015-04-27 7:12 ` Uwe Kleine-König 2015-04-27 7:12 ` Uwe Kleine-König 2015-04-27 7:20 ` Baruch Siach 2015-04-27 7:20 ` Baruch Siach 2015-04-27 7:50 ` Uwe Kleine-König 2015-04-27 7:50 ` Uwe Kleine-König 2015-04-27 11:43 ` Baruch Siach 2015-04-27 11:43 ` Baruch Siach 2015-04-27 19:31 ` Uwe Kleine-König 2015-04-27 19:31 ` Uwe Kleine-König 2015-04-29 6:18 ` Baruch Siach 2015-04-29 6:18 ` Baruch Siach 2015-04-29 6:35 ` Uwe Kleine-König 2015-04-29 6:35 ` Uwe Kleine-König 2015-04-30 15:20 ` Fabio Estevam 2015-04-30 15:20 ` Fabio Estevam 2015-05-03 7:55 ` Baruch Siach 2015-05-03 7:55 ` Baruch Siach 2015-04-26 8:16 ` [PATCH 3/4] mtd: mxc_nand: fix truncate of unaligned oob copying Baruch Siach 2015-04-26 8:16 ` Baruch Siach 2015-04-26 19:52 ` Uwe Kleine-König 2015-04-26 19:52 ` Uwe Kleine-König 2015-04-27 4:46 ` Baruch Siach 2015-04-27 4:46 ` Baruch Siach 2015-04-27 6:56 ` Uwe Kleine-König 2015-04-27 6:56 ` Uwe Kleine-König 2015-04-26 8:16 ` Baruch Siach [this message] 2015-04-26 8:16 ` [PATCH 4/4] mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC Baruch Siach
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=c70c70dfe01be9356eeb238072fda699f30672fc.1430034929.git.baruch@tkos.co.il \ --to=baruch@tkos.co.il \ --cc=computersforpeace@gmail.com \ --cc=dwmw2@infradead.org \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-mtd@lists.infradead.org \ --cc=shawn.guo@linaro.org \ --cc=u.kleine-koenig@pengutronix.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: linkBe 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.