|
@@ -37,15 +37,9 @@
|
|
|
|
|
|
#include <asm/mach/flash.h>
|
|
|
#include <linux/platform_data/mtd-mxc_nand.h>
|
|
|
-#include <mach/hardware.h>
|
|
|
|
|
|
#define DRIVER_NAME "mxc_nand"
|
|
|
|
|
|
-#define nfc_is_v21() (cpu_is_mx25() || cpu_is_mx35())
|
|
|
-#define nfc_is_v1() (cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21())
|
|
|
-#define nfc_is_v3_2a() cpu_is_mx51()
|
|
|
-#define nfc_is_v3_2b() cpu_is_mx53()
|
|
|
-
|
|
|
/* Addresses for NFC registers */
|
|
|
#define NFC_V1_V2_BUF_SIZE (host->regs + 0x00)
|
|
|
#define NFC_V1_V2_BUF_ADDR (host->regs + 0x04)
|
|
@@ -1283,6 +1277,53 @@ static const struct mxc_nand_devtype_data imx53_nand_devtype_data = {
|
|
|
.ppb_shift = 8,
|
|
|
};
|
|
|
|
|
|
+static inline int is_imx21_nfc(struct mxc_nand_host *host)
|
|
|
+{
|
|
|
+ return host->devtype_data == &imx21_nand_devtype_data;
|
|
|
+}
|
|
|
+
|
|
|
+static inline int is_imx27_nfc(struct mxc_nand_host *host)
|
|
|
+{
|
|
|
+ return host->devtype_data == &imx27_nand_devtype_data;
|
|
|
+}
|
|
|
+
|
|
|
+static inline int is_imx25_nfc(struct mxc_nand_host *host)
|
|
|
+{
|
|
|
+ return host->devtype_data == &imx25_nand_devtype_data;
|
|
|
+}
|
|
|
+
|
|
|
+static inline int is_imx51_nfc(struct mxc_nand_host *host)
|
|
|
+{
|
|
|
+ return host->devtype_data == &imx51_nand_devtype_data;
|
|
|
+}
|
|
|
+
|
|
|
+static inline int is_imx53_nfc(struct mxc_nand_host *host)
|
|
|
+{
|
|
|
+ return host->devtype_data == &imx53_nand_devtype_data;
|
|
|
+}
|
|
|
+
|
|
|
+static struct platform_device_id mxcnd_devtype[] = {
|
|
|
+ {
|
|
|
+ .name = "imx21-nand",
|
|
|
+ .driver_data = (kernel_ulong_t) &imx21_nand_devtype_data,
|
|
|
+ }, {
|
|
|
+ .name = "imx27-nand",
|
|
|
+ .driver_data = (kernel_ulong_t) &imx27_nand_devtype_data,
|
|
|
+ }, {
|
|
|
+ .name = "imx25-nand",
|
|
|
+ .driver_data = (kernel_ulong_t) &imx25_nand_devtype_data,
|
|
|
+ }, {
|
|
|
+ .name = "imx51-nand",
|
|
|
+ .driver_data = (kernel_ulong_t) &imx51_nand_devtype_data,
|
|
|
+ }, {
|
|
|
+ .name = "imx53-nand",
|
|
|
+ .driver_data = (kernel_ulong_t) &imx53_nand_devtype_data,
|
|
|
+ }, {
|
|
|
+ /* sentinel */
|
|
|
+ }
|
|
|
+};
|
|
|
+MODULE_DEVICE_TABLE(platform, mxcnd_devtype);
|
|
|
+
|
|
|
#ifdef CONFIG_OF_MTD
|
|
|
static const struct of_device_id mxcnd_dt_ids[] = {
|
|
|
{
|
|
@@ -1337,32 +1378,6 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-static int __init mxcnd_probe_pdata(struct mxc_nand_host *host)
|
|
|
-{
|
|
|
- struct mxc_nand_platform_data *pdata = host->dev->platform_data;
|
|
|
-
|
|
|
- if (!pdata)
|
|
|
- return -ENODEV;
|
|
|
-
|
|
|
- host->pdata = *pdata;
|
|
|
-
|
|
|
- if (nfc_is_v1()) {
|
|
|
- if (cpu_is_mx21())
|
|
|
- host->devtype_data = &imx21_nand_devtype_data;
|
|
|
- else
|
|
|
- host->devtype_data = &imx27_nand_devtype_data;
|
|
|
- } else if (nfc_is_v21()) {
|
|
|
- host->devtype_data = &imx25_nand_devtype_data;
|
|
|
- } else if (nfc_is_v3_2a()) {
|
|
|
- host->devtype_data = &imx51_nand_devtype_data;
|
|
|
- } else if (nfc_is_v3_2b()) {
|
|
|
- host->devtype_data = &imx53_nand_devtype_data;
|
|
|
- } else
|
|
|
- BUG();
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
static int __devinit mxcnd_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
struct nand_chip *this;
|
|
@@ -1404,8 +1419,16 @@ static int __devinit mxcnd_probe(struct platform_device *pdev)
|
|
|
return PTR_ERR(host->clk);
|
|
|
|
|
|
err = mxcnd_probe_dt(host);
|
|
|
- if (err > 0)
|
|
|
- err = mxcnd_probe_pdata(host);
|
|
|
+ if (err > 0) {
|
|
|
+ struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
|
|
|
+ if (pdata) {
|
|
|
+ host->pdata = *pdata;
|
|
|
+ host->devtype_data = (struct mxc_nand_devtype_data *)
|
|
|
+ pdev->id_entry->driver_data;
|
|
|
+ } else {
|
|
|
+ err = -ENODEV;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (err < 0)
|
|
|
return err;
|
|
|
|
|
@@ -1494,7 +1517,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev)
|
|
|
}
|
|
|
|
|
|
/* first scan to find the device and get the page size */
|
|
|
- if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) {
|
|
|
+ if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) {
|
|
|
err = -ENXIO;
|
|
|
goto escan;
|
|
|
}
|
|
@@ -1508,7 +1531,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev)
|
|
|
this->ecc.layout = host->devtype_data->ecclayout_4k;
|
|
|
|
|
|
if (this->ecc.mode == NAND_ECC_HW) {
|
|
|
- if (nfc_is_v1())
|
|
|
+ if (is_imx21_nfc(host) || is_imx27_nfc(host))
|
|
|
this->ecc.strength = 1;
|
|
|
else
|
|
|
this->ecc.strength = (host->eccsize == 4) ? 4 : 8;
|
|
@@ -1555,6 +1578,7 @@ static struct platform_driver mxcnd_driver = {
|
|
|
.owner = THIS_MODULE,
|
|
|
.of_match_table = of_match_ptr(mxcnd_dt_ids),
|
|
|
},
|
|
|
+ .id_table = mxcnd_devtype,
|
|
|
.probe = mxcnd_probe,
|
|
|
.remove = __devexit_p(mxcnd_remove),
|
|
|
};
|