diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2012-04-23 05:23:37 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-05-14 00:02:08 -0400 |
commit | 6dcdf99dfab15bebf71ae66ed04cdce05b20779c (patch) | |
tree | 0cdda694cc190edff56d044f55fe999ba24e6d24 /drivers/mtd/nand/mxc_nand.c | |
parent | 6d38af255a106fe921762c5c5de32dac92647af9 (diff) |
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@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/mxc_nand.c')
-rw-r--r-- | 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 fbd94f00e0ab..e02d27a937c8 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -152,6 +152,7 @@ struct mxc_nand_devtype_data { | |||
152 | int (*check_int)(struct mxc_nand_host *); | 152 | int (*check_int)(struct mxc_nand_host *); |
153 | void (*irq_control)(struct mxc_nand_host *, int); | 153 | void (*irq_control)(struct mxc_nand_host *, int); |
154 | u32 (*get_ecc_status)(struct mxc_nand_host *); | 154 | u32 (*get_ecc_status)(struct mxc_nand_host *); |
155 | struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k; | ||
155 | }; | 156 | }; |
156 | 157 | ||
157 | struct mxc_nand_host { | 158 | struct mxc_nand_host { |
@@ -1113,6 +1114,9 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = { | |||
1113 | .check_int = check_int_v1_v2, | 1114 | .check_int = check_int_v1_v2, |
1114 | .irq_control = irq_control_v1_v2, | 1115 | .irq_control = irq_control_v1_v2, |
1115 | .get_ecc_status = get_ecc_status_v1, | 1116 | .get_ecc_status = get_ecc_status_v1, |
1117 | .ecclayout_512 = &nandv1_hw_eccoob_smallpage, | ||
1118 | .ecclayout_2k = &nandv1_hw_eccoob_largepage, | ||
1119 | .ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */ | ||
1116 | }; | 1120 | }; |
1117 | 1121 | ||
1118 | /* v21: i.MX25, i.MX35 */ | 1122 | /* v21: i.MX25, i.MX35 */ |
@@ -1126,6 +1130,9 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = { | |||
1126 | .check_int = check_int_v1_v2, | 1130 | .check_int = check_int_v1_v2, |
1127 | .irq_control = irq_control_v1_v2, | 1131 | .irq_control = irq_control_v1_v2, |
1128 | .get_ecc_status = get_ecc_status_v2, | 1132 | .get_ecc_status = get_ecc_status_v2, |
1133 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, | ||
1134 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, | ||
1135 | .ecclayout_4k = &nandv2_hw_eccoob_4k, | ||
1129 | }; | 1136 | }; |
1130 | 1137 | ||
1131 | /* v3: i.MX51, i.MX53 */ | 1138 | /* v3: i.MX51, i.MX53 */ |
@@ -1139,6 +1146,9 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = { | |||
1139 | .check_int = check_int_v3, | 1146 | .check_int = check_int_v3, |
1140 | .irq_control = irq_control_v3, | 1147 | .irq_control = irq_control_v3, |
1141 | .get_ecc_status = get_ecc_status_v3, | 1148 | .get_ecc_status = get_ecc_status_v3, |
1149 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, | ||
1150 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, | ||
1151 | .ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */ | ||
1142 | }; | 1152 | }; |
1143 | 1153 | ||
1144 | static int __init mxcnd_probe(struct platform_device *pdev) | 1154 | static int __init mxcnd_probe(struct platform_device *pdev) |
@@ -1149,7 +1159,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1149 | struct mxc_nand_host *host; | 1159 | struct mxc_nand_host *host; |
1150 | struct resource *res; | 1160 | struct resource *res; |
1151 | int err = 0; | 1161 | int err = 0; |
1152 | struct nand_ecclayout *oob_smallpage, *oob_largepage; | ||
1153 | 1162 | ||
1154 | /* Allocate memory for MTD device structure and private data */ | 1163 | /* Allocate memory for MTD device structure and private data */ |
1155 | host = kzalloc(sizeof(struct mxc_nand_host) + NAND_MAX_PAGESIZE + | 1164 | host = kzalloc(sizeof(struct mxc_nand_host) + NAND_MAX_PAGESIZE + |
@@ -1211,8 +1220,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1211 | host->regs = host->base + 0xe00; | 1220 | host->regs = host->base + 0xe00; |
1212 | host->spare0 = host->base + 0x800; | 1221 | host->spare0 = host->base + 0x800; |
1213 | host->spare_len = 16; | 1222 | host->spare_len = 16; |
1214 | oob_smallpage = &nandv1_hw_eccoob_smallpage; | ||
1215 | oob_largepage = &nandv1_hw_eccoob_largepage; | ||
1216 | this->ecc.bytes = 3; | 1223 | this->ecc.bytes = 3; |
1217 | host->eccsize = 1; | 1224 | host->eccsize = 1; |
1218 | } else if (nfc_is_v21()) { | 1225 | } else if (nfc_is_v21()) { |
@@ -1220,8 +1227,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1220 | host->regs = host->base + 0x1e00; | 1227 | host->regs = host->base + 0x1e00; |
1221 | host->spare0 = host->base + 0x1000; | 1228 | host->spare0 = host->base + 0x1000; |
1222 | host->spare_len = 64; | 1229 | host->spare_len = 64; |
1223 | oob_smallpage = &nandv2_hw_eccoob_smallpage; | ||
1224 | oob_largepage = &nandv2_hw_eccoob_largepage; | ||
1225 | this->ecc.bytes = 9; | 1230 | this->ecc.bytes = 9; |
1226 | } else if (nfc_is_v3_2()) { | 1231 | } else if (nfc_is_v3_2()) { |
1227 | host->devtype_data = &imx51_nand_devtype_data; | 1232 | host->devtype_data = &imx51_nand_devtype_data; |
@@ -1238,13 +1243,11 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1238 | host->regs_axi = host->base + 0x1e00; | 1243 | host->regs_axi = host->base + 0x1e00; |
1239 | host->spare0 = host->base + 0x1000; | 1244 | host->spare0 = host->base + 0x1000; |
1240 | host->spare_len = 64; | 1245 | host->spare_len = 64; |
1241 | oob_smallpage = &nandv2_hw_eccoob_smallpage; | ||
1242 | oob_largepage = &nandv2_hw_eccoob_largepage; | ||
1243 | } else | 1246 | } else |
1244 | BUG(); | 1247 | BUG(); |
1245 | 1248 | ||
1246 | this->ecc.size = 512; | 1249 | this->ecc.size = 512; |
1247 | this->ecc.layout = oob_smallpage; | 1250 | this->ecc.layout = host->devtype_data->ecclayout_512; |
1248 | 1251 | ||
1249 | if (pdata->hw_ecc) { | 1252 | if (pdata->hw_ecc) { |
1250 | this->ecc.calculate = mxc_nand_calculate_ecc; | 1253 | this->ecc.calculate = mxc_nand_calculate_ecc; |
@@ -1304,9 +1307,9 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1304 | host->devtype_data->preset(mtd); | 1307 | host->devtype_data->preset(mtd); |
1305 | 1308 | ||
1306 | if (mtd->writesize == 2048) | 1309 | if (mtd->writesize == 2048) |
1307 | this->ecc.layout = oob_largepage; | 1310 | this->ecc.layout = host->devtype_data->ecclayout_2k; |
1308 | if (nfc_is_v21() && mtd->writesize == 4096) | 1311 | else if (mtd->writesize == 4096) |
1309 | this->ecc.layout = &nandv2_hw_eccoob_4k; | 1312 | this->ecc.layout = host->devtype_data->ecclayout_4k; |
1310 | 1313 | ||
1311 | /* second phase scan */ | 1314 | /* second phase scan */ |
1312 | if (nand_scan_tail(mtd)) { | 1315 | if (nand_scan_tail(mtd)) { |