diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-09-15 01:34:09 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2012-10-14 22:03:15 -0400 |
commit | 4d62435f0601ecec379fdc48749a10353fee8217 (patch) | |
tree | ae6b8397b554700283b86150dd852763d39bbe5d /drivers | |
parent | 5bdfba29f18f0a36df8e28328315213ea47eb529 (diff) |
mtd: mxc_nand: remove cpu_is_xxx by using platform_device_id
It changes the driver to use platform_device_id rather than cpu_is_xxx
to determine the controller type, and updates the platform code
accordingly.
As the result, mach/hardware.h inclusion gets removed from the driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: linux-mtd@lists.infradead.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 96 |
1 files changed, 60 insertions, 36 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 72e31d86030d..022dcdc256fb 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -37,15 +37,9 @@ | |||
37 | 37 | ||
38 | #include <asm/mach/flash.h> | 38 | #include <asm/mach/flash.h> |
39 | #include <linux/platform_data/mtd-mxc_nand.h> | 39 | #include <linux/platform_data/mtd-mxc_nand.h> |
40 | #include <mach/hardware.h> | ||
41 | 40 | ||
42 | #define DRIVER_NAME "mxc_nand" | 41 | #define DRIVER_NAME "mxc_nand" |
43 | 42 | ||
44 | #define nfc_is_v21() (cpu_is_mx25() || cpu_is_mx35()) | ||
45 | #define nfc_is_v1() (cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21()) | ||
46 | #define nfc_is_v3_2a() cpu_is_mx51() | ||
47 | #define nfc_is_v3_2b() cpu_is_mx53() | ||
48 | |||
49 | /* Addresses for NFC registers */ | 43 | /* Addresses for NFC registers */ |
50 | #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00) | 44 | #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00) |
51 | #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04) | 45 | #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04) |
@@ -1283,6 +1277,53 @@ static const struct mxc_nand_devtype_data imx53_nand_devtype_data = { | |||
1283 | .ppb_shift = 8, | 1277 | .ppb_shift = 8, |
1284 | }; | 1278 | }; |
1285 | 1279 | ||
1280 | static inline int is_imx21_nfc(struct mxc_nand_host *host) | ||
1281 | { | ||
1282 | return host->devtype_data == &imx21_nand_devtype_data; | ||
1283 | } | ||
1284 | |||
1285 | static inline int is_imx27_nfc(struct mxc_nand_host *host) | ||
1286 | { | ||
1287 | return host->devtype_data == &imx27_nand_devtype_data; | ||
1288 | } | ||
1289 | |||
1290 | static inline int is_imx25_nfc(struct mxc_nand_host *host) | ||
1291 | { | ||
1292 | return host->devtype_data == &imx25_nand_devtype_data; | ||
1293 | } | ||
1294 | |||
1295 | static inline int is_imx51_nfc(struct mxc_nand_host *host) | ||
1296 | { | ||
1297 | return host->devtype_data == &imx51_nand_devtype_data; | ||
1298 | } | ||
1299 | |||
1300 | static inline int is_imx53_nfc(struct mxc_nand_host *host) | ||
1301 | { | ||
1302 | return host->devtype_data == &imx53_nand_devtype_data; | ||
1303 | } | ||
1304 | |||
1305 | static struct platform_device_id mxcnd_devtype[] = { | ||
1306 | { | ||
1307 | .name = "imx21-nand", | ||
1308 | .driver_data = (kernel_ulong_t) &imx21_nand_devtype_data, | ||
1309 | }, { | ||
1310 | .name = "imx27-nand", | ||
1311 | .driver_data = (kernel_ulong_t) &imx27_nand_devtype_data, | ||
1312 | }, { | ||
1313 | .name = "imx25-nand", | ||
1314 | .driver_data = (kernel_ulong_t) &imx25_nand_devtype_data, | ||
1315 | }, { | ||
1316 | .name = "imx51-nand", | ||
1317 | .driver_data = (kernel_ulong_t) &imx51_nand_devtype_data, | ||
1318 | }, { | ||
1319 | .name = "imx53-nand", | ||
1320 | .driver_data = (kernel_ulong_t) &imx53_nand_devtype_data, | ||
1321 | }, { | ||
1322 | /* sentinel */ | ||
1323 | } | ||
1324 | }; | ||
1325 | MODULE_DEVICE_TABLE(platform, mxcnd_devtype); | ||
1326 | |||
1286 | #ifdef CONFIG_OF_MTD | 1327 | #ifdef CONFIG_OF_MTD |
1287 | static const struct of_device_id mxcnd_dt_ids[] = { | 1328 | static const struct of_device_id mxcnd_dt_ids[] = { |
1288 | { | 1329 | { |
@@ -1337,32 +1378,6 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) | |||
1337 | } | 1378 | } |
1338 | #endif | 1379 | #endif |
1339 | 1380 | ||
1340 | static int __init mxcnd_probe_pdata(struct mxc_nand_host *host) | ||
1341 | { | ||
1342 | struct mxc_nand_platform_data *pdata = host->dev->platform_data; | ||
1343 | |||
1344 | if (!pdata) | ||
1345 | return -ENODEV; | ||
1346 | |||
1347 | host->pdata = *pdata; | ||
1348 | |||
1349 | if (nfc_is_v1()) { | ||
1350 | if (cpu_is_mx21()) | ||
1351 | host->devtype_data = &imx21_nand_devtype_data; | ||
1352 | else | ||
1353 | host->devtype_data = &imx27_nand_devtype_data; | ||
1354 | } else if (nfc_is_v21()) { | ||
1355 | host->devtype_data = &imx25_nand_devtype_data; | ||
1356 | } else if (nfc_is_v3_2a()) { | ||
1357 | host->devtype_data = &imx51_nand_devtype_data; | ||
1358 | } else if (nfc_is_v3_2b()) { | ||
1359 | host->devtype_data = &imx53_nand_devtype_data; | ||
1360 | } else | ||
1361 | BUG(); | ||
1362 | |||
1363 | return 0; | ||
1364 | } | ||
1365 | |||
1366 | static int __devinit mxcnd_probe(struct platform_device *pdev) | 1381 | static int __devinit mxcnd_probe(struct platform_device *pdev) |
1367 | { | 1382 | { |
1368 | struct nand_chip *this; | 1383 | struct nand_chip *this; |
@@ -1404,8 +1419,16 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1404 | return PTR_ERR(host->clk); | 1419 | return PTR_ERR(host->clk); |
1405 | 1420 | ||
1406 | err = mxcnd_probe_dt(host); | 1421 | err = mxcnd_probe_dt(host); |
1407 | if (err > 0) | 1422 | if (err > 0) { |
1408 | err = mxcnd_probe_pdata(host); | 1423 | struct mxc_nand_platform_data *pdata = pdev->dev.platform_data; |
1424 | if (pdata) { | ||
1425 | host->pdata = *pdata; | ||
1426 | host->devtype_data = (struct mxc_nand_devtype_data *) | ||
1427 | pdev->id_entry->driver_data; | ||
1428 | } else { | ||
1429 | err = -ENODEV; | ||
1430 | } | ||
1431 | } | ||
1409 | if (err < 0) | 1432 | if (err < 0) |
1410 | return err; | 1433 | return err; |
1411 | 1434 | ||
@@ -1494,7 +1517,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1494 | } | 1517 | } |
1495 | 1518 | ||
1496 | /* first scan to find the device and get the page size */ | 1519 | /* first scan to find the device and get the page size */ |
1497 | if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) { | 1520 | if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) { |
1498 | err = -ENXIO; | 1521 | err = -ENXIO; |
1499 | goto escan; | 1522 | goto escan; |
1500 | } | 1523 | } |
@@ -1508,7 +1531,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1508 | this->ecc.layout = host->devtype_data->ecclayout_4k; | 1531 | this->ecc.layout = host->devtype_data->ecclayout_4k; |
1509 | 1532 | ||
1510 | if (this->ecc.mode == NAND_ECC_HW) { | 1533 | if (this->ecc.mode == NAND_ECC_HW) { |
1511 | if (nfc_is_v1()) | 1534 | if (is_imx21_nfc(host) || is_imx27_nfc(host)) |
1512 | this->ecc.strength = 1; | 1535 | this->ecc.strength = 1; |
1513 | else | 1536 | else |
1514 | this->ecc.strength = (host->eccsize == 4) ? 4 : 8; | 1537 | this->ecc.strength = (host->eccsize == 4) ? 4 : 8; |
@@ -1555,6 +1578,7 @@ static struct platform_driver mxcnd_driver = { | |||
1555 | .owner = THIS_MODULE, | 1578 | .owner = THIS_MODULE, |
1556 | .of_match_table = of_match_ptr(mxcnd_dt_ids), | 1579 | .of_match_table = of_match_ptr(mxcnd_dt_ids), |
1557 | }, | 1580 | }, |
1581 | .id_table = mxcnd_devtype, | ||
1558 | .probe = mxcnd_probe, | 1582 | .probe = mxcnd_probe, |
1559 | .remove = __devexit_p(mxcnd_remove), | 1583 | .remove = __devexit_p(mxcnd_remove), |
1560 | }; | 1584 | }; |