mtd: mxc_nand: put ecc layout into devtype structs
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Mon May 28 07:59:05 EDT 2012
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=6dcdf99dfab15bebf71ae66ed04cdce05b20779c
Commit: 6dcdf99dfab15bebf71ae66ed04cdce05b20779c
Parent: 6d38af255a106fe921762c5c5de32dac92647af9
Author: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
AuthorDate: Mon Apr 23 11:23:37 2012 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sun May 13 23:02:08 2012 -0500
mtd: mxc_nand: put ecc layout into devtype structs
This commit makes problems on v1 and v2 regarding 4KiBpages more obvious.
As I don't have a 4KiB flash handy I just keep the status quo.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/nand/mxc_nand.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index fbd94f0..e02d27a 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 {
@@ -1113,6 +1114,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: i.MX25, i.MX35 */
@@ -1126,6 +1130,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: i.MX51, i.MX53 */
@@ -1139,6 +1146,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)
@@ -1149,7 +1159,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 +
@@ -1211,8 +1220,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()) {
@@ -1220,8 +1227,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;
@@ -1238,13 +1243,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;
@@ -1304,9 +1307,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)) {
More information about the linux-mtd-cvs
mailing list