aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2013-11-07 10:17:14 -0500
committerBrian Norris <computersforpeace@gmail.com>2014-01-03 14:22:10 -0500
commitc7e9c7e71b5a76adf42bf10e059ae1d63bcd5e1a (patch)
tree9fd295f345cf970cb765fac99d78dd88da01bf4c
parent4e86fd22af2c930e741536e8637bca9355fa8bb5 (diff)
mtd: nand: pxa3xx: Early variant detection
In order to customize early settings depending on the detected SoC variant, move the detection to be before the nand_chip struct filling. In a follow-up patch, this change is needed to detect the variant *before* the call to alloc_nand_resource(), which allows to set a different cmdfunc() for each variant. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Tested-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index f25d71b20931..64e01cfe1a9b 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -258,6 +258,25 @@ static struct pxa3xx_nand_flash builtin_flash_types[] = {
258/* convert nano-seconds to nand flash controller clock cycles */ 258/* convert nano-seconds to nand flash controller clock cycles */
259#define ns2cycle(ns, clk) (int)((ns) * (clk / 1000000) / 1000) 259#define ns2cycle(ns, clk) (int)((ns) * (clk / 1000000) / 1000)
260 260
261static struct of_device_id pxa3xx_nand_dt_ids[] = {
262 {
263 .compatible = "marvell,pxa3xx-nand",
264 .data = (void *)PXA3XX_NAND_VARIANT_PXA,
265 },
266 {}
267};
268MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
269
270static enum pxa3xx_nand_variant
271pxa3xx_nand_get_variant(struct platform_device *pdev)
272{
273 const struct of_device_id *of_id =
274 of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
275 if (!of_id)
276 return PXA3XX_NAND_VARIANT_PXA;
277 return (enum pxa3xx_nand_variant)of_id->data;
278}
279
261static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host, 280static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host,
262 const struct pxa3xx_nand_timing *t) 281 const struct pxa3xx_nand_timing *t)
263{ 282{
@@ -1125,6 +1144,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
1125 return -ENOMEM; 1144 return -ENOMEM;
1126 1145
1127 info->pdev = pdev; 1146 info->pdev = pdev;
1147 info->variant = pxa3xx_nand_get_variant(pdev);
1128 for (cs = 0; cs < pdata->num_cs; cs++) { 1148 for (cs = 0; cs < pdata->num_cs; cs++) {
1129 mtd = (struct mtd_info *)((unsigned int)&info[1] + 1149 mtd = (struct mtd_info *)((unsigned int)&info[1] +
1130 (sizeof(*mtd) + sizeof(*host)) * cs); 1150 (sizeof(*mtd) + sizeof(*host)) * cs);
@@ -1259,25 +1279,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
1259 return 0; 1279 return 0;
1260} 1280}
1261 1281
1262static struct of_device_id pxa3xx_nand_dt_ids[] = {
1263 {
1264 .compatible = "marvell,pxa3xx-nand",
1265 .data = (void *)PXA3XX_NAND_VARIANT_PXA,
1266 },
1267 {}
1268};
1269MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
1270
1271static enum pxa3xx_nand_variant
1272pxa3xx_nand_get_variant(struct platform_device *pdev)
1273{
1274 const struct of_device_id *of_id =
1275 of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
1276 if (!of_id)
1277 return PXA3XX_NAND_VARIANT_PXA;
1278 return (enum pxa3xx_nand_variant)of_id->data;
1279}
1280
1281static int pxa3xx_nand_probe_dt(struct platform_device *pdev) 1282static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
1282{ 1283{
1283 struct pxa3xx_nand_platform_data *pdata; 1284 struct pxa3xx_nand_platform_data *pdata;
@@ -1334,7 +1335,6 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
1334 } 1335 }
1335 1336
1336 info = platform_get_drvdata(pdev); 1337 info = platform_get_drvdata(pdev);
1337 info->variant = pxa3xx_nand_get_variant(pdev);
1338 probe_success = 0; 1338 probe_success = 0;
1339 for (cs = 0; cs < pdata->num_cs; cs++) { 1339 for (cs = 0; cs < pdata->num_cs; cs++) {
1340 struct mtd_info *mtd = info->host[cs]->mtd; 1340 struct mtd_info *mtd = info->host[cs]->mtd;