devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: [PATCH 05/10] mtd: mxc_nand: put ecc layout into devtype structs
Date: Mon, 23 Apr 2012 11:23:37 +0200	[thread overview]
Message-ID: <1335173022-22371-5-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20120423092240.GA18013-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

This commit makes problems on v1 and v2 regarding 4k pages more obvious.
As I don't have a 4k flash handy I just keep the status quo.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mtd/nand/mxc_nand.c |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c9cdec2..1389d40 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -152,6 +152,7 @@ struct mxc_nand_devtype_data {
 	int (*check_int)(struct mxc_nand_host *);
 	void (*irq_control)(struct mxc_nand_host *, int);
 	u32 (*get_ecc_status)(struct mxc_nand_host *);
+	struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k;
 };
 
 struct mxc_nand_host {
@@ -1114,6 +1115,9 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
 	.check_int = check_int_v1_v2,
 	.irq_control = irq_control_v1_v2,
 	.get_ecc_status = get_ecc_status_v1,
+	.ecclayout_512 = &nandv1_hw_eccoob_smallpage,
+	.ecclayout_2k = &nandv1_hw_eccoob_largepage,
+	.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
 };
 
 /* v21: 25, 35 */
@@ -1127,6 +1131,9 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
 	.check_int = check_int_v1_v2,
 	.irq_control = irq_control_v1_v2,
 	.get_ecc_status = get_ecc_status_v2,
+	.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
+	.ecclayout_2k = &nandv2_hw_eccoob_largepage,
+	.ecclayout_4k = &nandv2_hw_eccoob_4k,
 };
 
 /* v3: 51, 53 */
@@ -1140,6 +1147,9 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
 	.check_int = check_int_v3,
 	.irq_control = irq_control_v3,
 	.get_ecc_status = get_ecc_status_v3,
+	.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
+	.ecclayout_2k = &nandv2_hw_eccoob_largepage,
+	.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
 };
 
 static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1150,7 +1160,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 	struct mxc_nand_host *host;
 	struct resource *res;
 	int err = 0;
-	struct nand_ecclayout *oob_smallpage, *oob_largepage;
 
 	/* Allocate memory for MTD device structure and private data */
 	host = kzalloc(sizeof(struct mxc_nand_host) + NAND_MAX_PAGESIZE +
@@ -1212,8 +1221,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 		host->regs = host->base + 0xe00;
 		host->spare0 = host->base + 0x800;
 		host->spare_len = 16;
-		oob_smallpage = &nandv1_hw_eccoob_smallpage;
-		oob_largepage = &nandv1_hw_eccoob_largepage;
 		this->ecc.bytes = 3;
 		host->eccsize = 1;
 	} else if (nfc_is_v21()) {
@@ -1221,8 +1228,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 		host->regs = host->base + 0x1e00;
 		host->spare0 = host->base + 0x1000;
 		host->spare_len = 64;
-		oob_smallpage = &nandv2_hw_eccoob_smallpage;
-		oob_largepage = &nandv2_hw_eccoob_largepage;
 		this->ecc.bytes = 9;
 	} else if (nfc_is_v3_2()) {
 		host->devtype_data = &imx51_nand_devtype_data;
@@ -1239,13 +1244,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 		host->regs_axi = host->base + 0x1e00;
 		host->spare0 = host->base + 0x1000;
 		host->spare_len = 64;
-		oob_smallpage = &nandv2_hw_eccoob_smallpage;
-		oob_largepage = &nandv2_hw_eccoob_largepage;
 	} else
 		BUG();
 
 	this->ecc.size = 512;
-	this->ecc.layout = oob_smallpage;
+	this->ecc.layout = host->devtype_data->ecclayout_512;
 
 	if (pdata->hw_ecc) {
 		this->ecc.calculate = mxc_nand_calculate_ecc;
@@ -1305,9 +1308,9 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 	host->devtype_data->preset(mtd);
 
 	if (mtd->writesize == 2048)
-		this->ecc.layout = oob_largepage;
-	if (nfc_is_v21() && mtd->writesize == 4096)
-		this->ecc.layout = &nandv2_hw_eccoob_4k;
+		this->ecc.layout = host->devtype_data->ecclayout_2k;
+	else if (mtd->writesize == 4096)
+		this->ecc.layout = host->devtype_data->ecclayout_4k;
 
 	/* second phase scan */
 	if (nand_scan_tail(mtd)) {
-- 
1.7.10

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2012-04-23  9:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23  9:22 [PATCH 00/10] allow mxc_nand to be probed via device tree Uwe Kleine-König
     [not found] ` <20120423092240.GA18013-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-23  9:23   ` [PATCH 01/10] mtd: mxc_nand: set owner field to prevent module unloading when in use Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 02/10] mtd: mxc_nand: use a flag to detect if the mx21 quirk is necessary Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct Uwe Kleine-König
     [not found]     ` <1335173022-22371-3-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-24  7:24       ` Sascha Hauer
     [not found]         ` <20120424072457.GL3852-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-24  8:10           ` Uwe Kleine-König
2012-04-24  8:12             ` [PATCH] mtd: mxc_nand: fix several sparse warnings about incorrect address space Uwe Kleine-König
2012-04-23  9:23   ` Uwe Kleine-König [this message]
2012-04-23  9:23   ` [PATCH 06/10] mtd: mxc_nand: split chip_select function and put it into devtype struct Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 07/10] mtd: mxc_nand: put callback for data correction " Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 08/10] mtd: mxc_nand: put several more fields into devtype_data Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 09/10] mtd: mxc_nand: implement device tree probing Uwe Kleine-König
2012-04-23  9:23   ` [PATCH 10/10] ARM: imx: add mxc_nand to imx27 device tree Uwe Kleine-König
2012-04-28 12:20   ` [PATCH 00/10] allow mxc_nand to be probed via " Artem Bityutskiy
2012-04-29  9:27     ` Uwe Kleine-König
     [not found]       ` <20120429092701.GS20039-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-04-29 11:10         ` Artem Bityutskiy
2012-04-23  9:23 ` [PATCH 04/10] mtd: mxc_nand: split some functions to get rid of more nfc_is_vX() Uwe Kleine-König

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=1335173022-22371-5-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).