* [PATCH 01/10] mtd: mxc_nand: set owner field to prevent module unloading when in use
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index cc0678a..7d82cc4 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1275,6 +1275,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
+ .owner = THIS_MODULE,
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 01/10] mtd: mxc_nand: set owner field to prevent module unloading when in use
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index cc0678a..7d82cc4 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1275,6 +1275,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
+ .owner = THIS_MODULE,
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 01/10] mtd: mxc_nand: set owner field to prevent module unloading when in use
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index cc0678a..7d82cc4 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -1275,6 +1275,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
+ .owner = THIS_MODULE,
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 02/10] mtd: mxc_nand: use a flag to detect if the mx21 quirk is necessary
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
This gets rid of several instances of cpu_is_mx21() in the driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 72 +++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 7d82cc4..a78e763 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -173,6 +173,13 @@ struct mxc_nand_host {
uint16_t (*get_dev_status)(struct mxc_nand_host *);
int (*check_int)(struct mxc_nand_host *);
void (*irq_control)(struct mxc_nand_host *, int);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -251,7 +258,7 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
if (!host->check_int(host))
return IRQ_NONE;
- host->irq_control(host, 0);
+ irq_control(host, 0);
complete(&host->op_completion);
@@ -280,26 +287,12 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
}
-/*
- * It has been observed that the i.MX21 cannot read the CONFIG2:INT bit
- * if interrupts are masked (CONFIG1:INT_MSK is set). To handle this, the
- * driver can enable/disable the irq line rather than simply masking the
- * interrupts.
- */
-static void irq_control_mx21(struct mxc_nand_host *host, int activate)
-{
- if (activate)
- enable_irq(host->irq);
- else
- disable_irq_nosync(host->irq);
-}
-
static void irq_control_v1_v2(struct mxc_nand_host *host, int activate)
{
uint16_t tmp;
@@ -328,6 +321,18 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
writel(tmp, NFC_V3_CONFIG2);
}
+static void irq_control(struct mxc_nand_host *host, int activate)
+{
+ if (host->irqpending_quirk) {
+ if (activate)
+ enable_irq(host->irq);
+ else
+ disable_irq_nosync(host->irq);
+ } else {
+ host->irq_control(host, activate);
+ }
+}
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -338,7 +343,7 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
if (useirq) {
if (!host->check_int(host)) {
INIT_COMPLETION(host->op_completion);
- host->irq_control(host, 1);
+ irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
@@ -374,7 +379,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
+ if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -812,7 +817,7 @@ static void preset_v1_v2(struct mtd_info *mtd)
if (nfc_is_v21())
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (nfc_is_v21() && mtd->writesize) {
@@ -1103,10 +1108,9 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->send_read_id = send_read_id_v1_v2;
host->get_dev_status = get_dev_status_v1_v2;
host->check_int = check_int_v1_v2;
+ host->irq_control = irq_control_v1_v2;
if (cpu_is_mx21())
- host->irq_control = irq_control_mx21;
- else
- host->irq_control = irq_control_v1_v2;
+ host->irqpending_quirk = 1;
}
if (nfc_is_v21()) {
@@ -1182,28 +1186,24 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * mask the interrupt. For i.MX21 explicitely call
- * irq_control_v1_v2 to use the mask bit. We can't call
- * disable_irq_nosync() for an interrupt we do not own yet.
+ * Use host->irq_control here instead of irq_control because we must not
+ * disable_irq_nosync without having requested the irq
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 0);
- else
- host->irq_control(host, 0);
+ host->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
goto eirq;
- host->irq_control(host, 0);
-
/*
- * Now that the interrupt is disabled make sure the interrupt
- * mask bit is cleared on i.MX21. Otherwise we can't read
- * the interrupt status bit on this machine.
+ * Now that we "own" the interrupt make sure the interrupt mask bit is
+ * cleared on i.MX21. Otherwise we can't read the interrupt status bit
+ * on this machine.
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 1);
+ if (host->irqpending_quirk) {
+ disable_irq_nosync(host->irq);
+ host->irq_control(host, 1);
+ }
/* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) {
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 02/10] mtd: mxc_nand: use a flag to detect if the mx21 quirk is necessary
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
This gets rid of several instances of cpu_is_mx21() in the driver.
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 72 +++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 7d82cc4..a78e763 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -173,6 +173,13 @@ struct mxc_nand_host {
uint16_t (*get_dev_status)(struct mxc_nand_host *);
int (*check_int)(struct mxc_nand_host *);
void (*irq_control)(struct mxc_nand_host *, int);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -251,7 +258,7 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
if (!host->check_int(host))
return IRQ_NONE;
- host->irq_control(host, 0);
+ irq_control(host, 0);
complete(&host->op_completion);
@@ -280,26 +287,12 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
}
-/*
- * It has been observed that the i.MX21 cannot read the CONFIG2:INT bit
- * if interrupts are masked (CONFIG1:INT_MSK is set). To handle this, the
- * driver can enable/disable the irq line rather than simply masking the
- * interrupts.
- */
-static void irq_control_mx21(struct mxc_nand_host *host, int activate)
-{
- if (activate)
- enable_irq(host->irq);
- else
- disable_irq_nosync(host->irq);
-}
-
static void irq_control_v1_v2(struct mxc_nand_host *host, int activate)
{
uint16_t tmp;
@@ -328,6 +321,18 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
writel(tmp, NFC_V3_CONFIG2);
}
+static void irq_control(struct mxc_nand_host *host, int activate)
+{
+ if (host->irqpending_quirk) {
+ if (activate)
+ enable_irq(host->irq);
+ else
+ disable_irq_nosync(host->irq);
+ } else {
+ host->irq_control(host, activate);
+ }
+}
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -338,7 +343,7 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
if (useirq) {
if (!host->check_int(host)) {
INIT_COMPLETION(host->op_completion);
- host->irq_control(host, 1);
+ irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
@@ -374,7 +379,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
+ if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -812,7 +817,7 @@ static void preset_v1_v2(struct mtd_info *mtd)
if (nfc_is_v21())
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (nfc_is_v21() && mtd->writesize) {
@@ -1103,10 +1108,9 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->send_read_id = send_read_id_v1_v2;
host->get_dev_status = get_dev_status_v1_v2;
host->check_int = check_int_v1_v2;
+ host->irq_control = irq_control_v1_v2;
if (cpu_is_mx21())
- host->irq_control = irq_control_mx21;
- else
- host->irq_control = irq_control_v1_v2;
+ host->irqpending_quirk = 1;
}
if (nfc_is_v21()) {
@@ -1182,28 +1186,24 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * mask the interrupt. For i.MX21 explicitely call
- * irq_control_v1_v2 to use the mask bit. We can't call
- * disable_irq_nosync() for an interrupt we do not own yet.
+ * Use host->irq_control here instead of irq_control because we must not
+ * disable_irq_nosync without having requested the irq
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 0);
- else
- host->irq_control(host, 0);
+ host->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
goto eirq;
- host->irq_control(host, 0);
-
/*
- * Now that the interrupt is disabled make sure the interrupt
- * mask bit is cleared on i.MX21. Otherwise we can't read
- * the interrupt status bit on this machine.
+ * Now that we "own" the interrupt make sure the interrupt mask bit is
+ * cleared on i.MX21. Otherwise we can't read the interrupt status bit
+ * on this machine.
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 1);
+ if (host->irqpending_quirk) {
+ disable_irq_nosync(host->irq);
+ host->irq_control(host, 1);
+ }
/* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) {
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 02/10] mtd: mxc_nand: use a flag to detect if the mx21 quirk is necessary
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
This gets rid of several instances of cpu_is_mx21() in the driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 72 +++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 7d82cc4..a78e763 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -173,6 +173,13 @@ struct mxc_nand_host {
uint16_t (*get_dev_status)(struct mxc_nand_host *);
int (*check_int)(struct mxc_nand_host *);
void (*irq_control)(struct mxc_nand_host *, int);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -251,7 +258,7 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
if (!host->check_int(host))
return IRQ_NONE;
- host->irq_control(host, 0);
+ irq_control(host, 0);
complete(&host->op_completion);
@@ -280,26 +287,12 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
}
-/*
- * It has been observed that the i.MX21 cannot read the CONFIG2:INT bit
- * if interrupts are masked (CONFIG1:INT_MSK is set). To handle this, the
- * driver can enable/disable the irq line rather than simply masking the
- * interrupts.
- */
-static void irq_control_mx21(struct mxc_nand_host *host, int activate)
-{
- if (activate)
- enable_irq(host->irq);
- else
- disable_irq_nosync(host->irq);
-}
-
static void irq_control_v1_v2(struct mxc_nand_host *host, int activate)
{
uint16_t tmp;
@@ -328,6 +321,18 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
writel(tmp, NFC_V3_CONFIG2);
}
+static void irq_control(struct mxc_nand_host *host, int activate)
+{
+ if (host->irqpending_quirk) {
+ if (activate)
+ enable_irq(host->irq);
+ else
+ disable_irq_nosync(host->irq);
+ } else {
+ host->irq_control(host, activate);
+ }
+}
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -338,7 +343,7 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
if (useirq) {
if (!host->check_int(host)) {
INIT_COMPLETION(host->op_completion);
- host->irq_control(host, 1);
+ irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
@@ -374,7 +379,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
+ if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -812,7 +817,7 @@ static void preset_v1_v2(struct mtd_info *mtd)
if (nfc_is_v21())
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!cpu_is_mx21())
+ if (!host->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (nfc_is_v21() && mtd->writesize) {
@@ -1103,10 +1108,9 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->send_read_id = send_read_id_v1_v2;
host->get_dev_status = get_dev_status_v1_v2;
host->check_int = check_int_v1_v2;
+ host->irq_control = irq_control_v1_v2;
if (cpu_is_mx21())
- host->irq_control = irq_control_mx21;
- else
- host->irq_control = irq_control_v1_v2;
+ host->irqpending_quirk = 1;
}
if (nfc_is_v21()) {
@@ -1182,28 +1186,24 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * mask the interrupt. For i.MX21 explicitely call
- * irq_control_v1_v2 to use the mask bit. We can't call
- * disable_irq_nosync() for an interrupt we do not own yet.
+ * Use host->irq_control here instead of irq_control because we must not
+ * disable_irq_nosync without having requested the irq
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 0);
- else
- host->irq_control(host, 0);
+ host->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
goto eirq;
- host->irq_control(host, 0);
-
/*
- * Now that the interrupt is disabled make sure the interrupt
- * mask bit is cleared on i.MX21. Otherwise we can't read
- * the interrupt status bit on this machine.
+ * Now that we "own" the interrupt make sure the interrupt mask bit is
+ * cleared on i.MX21. Otherwise we can't read the interrupt status bit
+ * on this machine.
*/
- if (cpu_is_mx21())
- irq_control_v1_v2(host, 1);
+ if (host->irqpending_quirk) {
+ disable_irq_nosync(host->irq);
+ host->irq_control(host, 1);
+ }
/* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) {
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
This prepares switching to platform ids and of-tree probing.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
1 file changed, 118 insertions(+), 79 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index a78e763..1672e4b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -140,6 +140,19 @@
#define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
+struct mxc_nand_host;
+
+struct mxc_nand_devtype_data {
+ void (*preset)(struct mtd_info *);
+ void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_page)(struct mtd_info *, unsigned int);
+ void (*send_read_id)(struct mxc_nand_host *);
+ uint16_t (*get_dev_status)(struct mxc_nand_host *);
+ int (*check_int)(struct mxc_nand_host *);
+ void (*irq_control)(struct mxc_nand_host *, int);
+};
+
struct mxc_nand_host {
struct mtd_info mtd;
struct nand_chip nand;
@@ -165,14 +178,7 @@ struct mxc_nand_host {
unsigned int buf_start;
int spare_len;
- void (*preset)(struct mtd_info *);
- void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
- void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
- void (*send_page)(struct mtd_info *, unsigned int);
- void (*send_read_id)(struct mxc_nand_host *);
- uint16_t (*get_dev_status)(struct mxc_nand_host *);
- int (*check_int)(struct mxc_nand_host *);
- void (*irq_control)(struct mxc_nand_host *, int);
+ const struct mxc_nand_devtype_data *devtype_data;
/*
* On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
@@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
-static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
-{
- struct mxc_nand_host *host = dev_id;
-
- if (!host->check_int(host))
- return IRQ_NONE;
-
- irq_control(host, 0);
-
- complete(&host->op_completion);
-
- return IRQ_HANDLED;
-}
-
static int check_int_v3(struct mxc_nand_host *host)
{
uint32_t tmp;
@@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
else
disable_irq_nosync(host->irq);
} else {
- host->irq_control(host, activate);
+ host->devtype_data->irq_control(host, activate);
}
}
+static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
+{
+ struct mxc_nand_host *host = dev_id;
+
+ if (!host->devtype_data->check_int(host))
+ return IRQ_NONE;
+
+ irq_control(host, 0);
+
+ complete(&host->op_completion);
+
+ return IRQ_HANDLED;
+}
+
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -341,14 +348,14 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
int max_retries = 8000;
if (useirq) {
- if (!host->check_int(host)) {
+ if (!host->devtype_data->check_int(host)) {
INIT_COMPLETION(host->op_completion);
irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
while (max_retries-- > 0) {
- if (host->check_int(host))
+ if (host->devtype_data->check_int(host))
break;
udelay(1);
@@ -621,7 +628,7 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)
/* Check for status request */
if (host->status_request)
- return host->get_dev_status(host) & 0xFF;
+ return host->devtype_data->get_dev_status(host) & 0xFF;
ret = *(uint8_t *)(host->data_buf + host->buf_start);
host->buf_start++;
@@ -756,34 +763,44 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
* perform a read/write buf operation, the saved column
* address is used to index into the full page.
*/
- host->send_addr(host, 0, page_addr == -1);
+ host->devtype_data->send_addr(host, 0, page_addr == -1);
if (mtd->writesize > 512)
/* another col addr cycle for 2k page */
- host->send_addr(host, 0, false);
+ host->devtype_data->send_addr(host, 0, false);
}
/* Write out page address, if necessary */
if (page_addr != -1) {
/* paddr_0 - p_addr_7 */
- host->send_addr(host, (page_addr & 0xff), false);
+ host->devtype_data->send_addr(host, (page_addr & 0xff), false);
if (mtd->writesize > 512) {
if (mtd->size >= 0x10000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
} else {
/* One more address cycle for higher density devices */
if (mtd->size >= 0x4000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
}
}
}
@@ -942,15 +959,15 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
/* Command pre-processing step */
switch (command) {
case NAND_CMD_RESET:
- host->preset(mtd);
- host->send_cmd(host, command, false);
+ host->devtype_data->preset(mtd);
+ host->devtype_data->send_cmd(host, command, false);
break;
case NAND_CMD_STATUS:
host->buf_start = 0;
host->status_request = true;
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -963,13 +980,14 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
command = NAND_CMD_READ0; /* only READ0 is valid */
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
if (mtd->writesize > 512)
- host->send_cmd(host, NAND_CMD_READSTART, true);
+ host->devtype_data->send_cmd(host,
+ NAND_CMD_READSTART, true);
- host->send_page(mtd, NFC_OUTPUT);
+ host->devtype_data->send_page(mtd, NFC_OUTPUT);
memcpy(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
@@ -982,28 +1000,28 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->buf_start = column;
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_PAGEPROG:
memcpy(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
- host->send_page(mtd, NFC_INPUT);
- host->send_cmd(host, command, true);
+ host->devtype_data->send_page(mtd, NFC_INPUT);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_READID:
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
- host->send_read_id(host);
+ host->devtype_data->send_read_id(host);
host->buf_start = column;
break;
case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -1037,6 +1055,42 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
+/* v1: 21, 27, 31 */
+static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v21: 25, 35 */
+static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v3: 51, 53 */
+static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
+ .preset = preset_v3,
+ .send_cmd = send_cmd_v3,
+ .send_addr = send_addr_v3,
+ .send_page = send_page_v3,
+ .send_read_id = send_read_id_v3,
+ .get_dev_status = get_dev_status_v3,
+ .check_int = check_int_v3,
+ .irq_control = irq_control_v3,
+};
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
@@ -1100,27 +1154,10 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- if (nfc_is_v1() || nfc_is_v21()) {
- host->preset = preset_v1_v2;
- host->send_cmd = send_cmd_v1_v2;
- host->send_addr = send_addr_v1_v2;
- host->send_page = send_page_v1_v2;
- host->send_read_id = send_read_id_v1_v2;
- host->get_dev_status = get_dev_status_v1_v2;
- host->check_int = check_int_v1_v2;
- host->irq_control = irq_control_v1_v2;
+ if (nfc_is_v1()) {
+ host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
host->irqpending_quirk = 1;
- }
-
- if (nfc_is_v21()) {
- 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_v1()) {
host->regs = host->base + 0xe00;
host->spare0 = host->base + 0x800;
host->spare_len = 16;
@@ -1128,7 +1165,16 @@ static int __init mxcnd_probe(struct platform_device *pdev)
oob_largepage = &nandv1_hw_eccoob_largepage;
this->ecc.bytes = 3;
host->eccsize = 1;
+ } else if (nfc_is_v21()) {
+ host->devtype_data = &imx25_nand_devtype_data;
+ 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;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1142,14 +1188,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->regs_axi = host->base + 0x1e00;
host->spare0 = host->base + 0x1000;
host->spare_len = 64;
- host->preset = preset_v3;
- host->send_cmd = send_cmd_v3;
- host->send_addr = send_addr_v3;
- host->send_page = send_page_v3;
- host->send_read_id = send_read_id_v3;
- host->check_int = check_int_v3;
- host->get_dev_status = get_dev_status_v3;
- host->irq_control = irq_control_v3;
oob_smallpage = &nandv2_hw_eccoob_smallpage;
oob_largepage = &nandv2_hw_eccoob_largepage;
} else
@@ -1186,10 +1224,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * Use host->irq_control here instead of irq_control because we must not
- * disable_irq_nosync without having requested the irq
+ * Use host->devtype_data->irq_control() here instead of irq_control()
+ * because we must not disable_irq_nosync without having requested the
+ * irq.
*/
- host->irq_control(host, 0);
+ host->devtype_data->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
@@ -1202,7 +1241,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
*/
if (host->irqpending_quirk) {
disable_irq_nosync(host->irq);
- host->irq_control(host, 1);
+ host->devtype_data->irq_control(host, 1);
}
/* first scan to find the device and get the page size */
@@ -1212,7 +1251,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Call preset again, with correct writesize this time */
- host->preset(mtd);
+ host->devtype_data->preset(mtd);
if (mtd->writesize == 2048)
this->ecc.layout = oob_largepage;
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
This prepares switching to platform ids and of-tree probing.
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
1 file changed, 118 insertions(+), 79 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index a78e763..1672e4b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -140,6 +140,19 @@
#define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
+struct mxc_nand_host;
+
+struct mxc_nand_devtype_data {
+ void (*preset)(struct mtd_info *);
+ void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_page)(struct mtd_info *, unsigned int);
+ void (*send_read_id)(struct mxc_nand_host *);
+ uint16_t (*get_dev_status)(struct mxc_nand_host *);
+ int (*check_int)(struct mxc_nand_host *);
+ void (*irq_control)(struct mxc_nand_host *, int);
+};
+
struct mxc_nand_host {
struct mtd_info mtd;
struct nand_chip nand;
@@ -165,14 +178,7 @@ struct mxc_nand_host {
unsigned int buf_start;
int spare_len;
- void (*preset)(struct mtd_info *);
- void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
- void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
- void (*send_page)(struct mtd_info *, unsigned int);
- void (*send_read_id)(struct mxc_nand_host *);
- uint16_t (*get_dev_status)(struct mxc_nand_host *);
- int (*check_int)(struct mxc_nand_host *);
- void (*irq_control)(struct mxc_nand_host *, int);
+ const struct mxc_nand_devtype_data *devtype_data;
/*
* On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
@@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
-static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
-{
- struct mxc_nand_host *host = dev_id;
-
- if (!host->check_int(host))
- return IRQ_NONE;
-
- irq_control(host, 0);
-
- complete(&host->op_completion);
-
- return IRQ_HANDLED;
-}
-
static int check_int_v3(struct mxc_nand_host *host)
{
uint32_t tmp;
@@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
else
disable_irq_nosync(host->irq);
} else {
- host->irq_control(host, activate);
+ host->devtype_data->irq_control(host, activate);
}
}
+static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
+{
+ struct mxc_nand_host *host = dev_id;
+
+ if (!host->devtype_data->check_int(host))
+ return IRQ_NONE;
+
+ irq_control(host, 0);
+
+ complete(&host->op_completion);
+
+ return IRQ_HANDLED;
+}
+
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -341,14 +348,14 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
int max_retries = 8000;
if (useirq) {
- if (!host->check_int(host)) {
+ if (!host->devtype_data->check_int(host)) {
INIT_COMPLETION(host->op_completion);
irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
while (max_retries-- > 0) {
- if (host->check_int(host))
+ if (host->devtype_data->check_int(host))
break;
udelay(1);
@@ -621,7 +628,7 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)
/* Check for status request */
if (host->status_request)
- return host->get_dev_status(host) & 0xFF;
+ return host->devtype_data->get_dev_status(host) & 0xFF;
ret = *(uint8_t *)(host->data_buf + host->buf_start);
host->buf_start++;
@@ -756,34 +763,44 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
* perform a read/write buf operation, the saved column
* address is used to index into the full page.
*/
- host->send_addr(host, 0, page_addr == -1);
+ host->devtype_data->send_addr(host, 0, page_addr == -1);
if (mtd->writesize > 512)
/* another col addr cycle for 2k page */
- host->send_addr(host, 0, false);
+ host->devtype_data->send_addr(host, 0, false);
}
/* Write out page address, if necessary */
if (page_addr != -1) {
/* paddr_0 - p_addr_7 */
- host->send_addr(host, (page_addr & 0xff), false);
+ host->devtype_data->send_addr(host, (page_addr & 0xff), false);
if (mtd->writesize > 512) {
if (mtd->size >= 0x10000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
} else {
/* One more address cycle for higher density devices */
if (mtd->size >= 0x4000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
}
}
}
@@ -942,15 +959,15 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
/* Command pre-processing step */
switch (command) {
case NAND_CMD_RESET:
- host->preset(mtd);
- host->send_cmd(host, command, false);
+ host->devtype_data->preset(mtd);
+ host->devtype_data->send_cmd(host, command, false);
break;
case NAND_CMD_STATUS:
host->buf_start = 0;
host->status_request = true;
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -963,13 +980,14 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
command = NAND_CMD_READ0; /* only READ0 is valid */
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
if (mtd->writesize > 512)
- host->send_cmd(host, NAND_CMD_READSTART, true);
+ host->devtype_data->send_cmd(host,
+ NAND_CMD_READSTART, true);
- host->send_page(mtd, NFC_OUTPUT);
+ host->devtype_data->send_page(mtd, NFC_OUTPUT);
memcpy(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
@@ -982,28 +1000,28 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->buf_start = column;
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_PAGEPROG:
memcpy(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
- host->send_page(mtd, NFC_INPUT);
- host->send_cmd(host, command, true);
+ host->devtype_data->send_page(mtd, NFC_INPUT);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_READID:
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
- host->send_read_id(host);
+ host->devtype_data->send_read_id(host);
host->buf_start = column;
break;
case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -1037,6 +1055,42 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
+/* v1: 21, 27, 31 */
+static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v21: 25, 35 */
+static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v3: 51, 53 */
+static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
+ .preset = preset_v3,
+ .send_cmd = send_cmd_v3,
+ .send_addr = send_addr_v3,
+ .send_page = send_page_v3,
+ .send_read_id = send_read_id_v3,
+ .get_dev_status = get_dev_status_v3,
+ .check_int = check_int_v3,
+ .irq_control = irq_control_v3,
+};
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
@@ -1100,27 +1154,10 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- if (nfc_is_v1() || nfc_is_v21()) {
- host->preset = preset_v1_v2;
- host->send_cmd = send_cmd_v1_v2;
- host->send_addr = send_addr_v1_v2;
- host->send_page = send_page_v1_v2;
- host->send_read_id = send_read_id_v1_v2;
- host->get_dev_status = get_dev_status_v1_v2;
- host->check_int = check_int_v1_v2;
- host->irq_control = irq_control_v1_v2;
+ if (nfc_is_v1()) {
+ host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
host->irqpending_quirk = 1;
- }
-
- if (nfc_is_v21()) {
- 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_v1()) {
host->regs = host->base + 0xe00;
host->spare0 = host->base + 0x800;
host->spare_len = 16;
@@ -1128,7 +1165,16 @@ static int __init mxcnd_probe(struct platform_device *pdev)
oob_largepage = &nandv1_hw_eccoob_largepage;
this->ecc.bytes = 3;
host->eccsize = 1;
+ } else if (nfc_is_v21()) {
+ host->devtype_data = &imx25_nand_devtype_data;
+ 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;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1142,14 +1188,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->regs_axi = host->base + 0x1e00;
host->spare0 = host->base + 0x1000;
host->spare_len = 64;
- host->preset = preset_v3;
- host->send_cmd = send_cmd_v3;
- host->send_addr = send_addr_v3;
- host->send_page = send_page_v3;
- host->send_read_id = send_read_id_v3;
- host->check_int = check_int_v3;
- host->get_dev_status = get_dev_status_v3;
- host->irq_control = irq_control_v3;
oob_smallpage = &nandv2_hw_eccoob_smallpage;
oob_largepage = &nandv2_hw_eccoob_largepage;
} else
@@ -1186,10 +1224,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * Use host->irq_control here instead of irq_control because we must not
- * disable_irq_nosync without having requested the irq
+ * Use host->devtype_data->irq_control() here instead of irq_control()
+ * because we must not disable_irq_nosync without having requested the
+ * irq.
*/
- host->irq_control(host, 0);
+ host->devtype_data->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
@@ -1202,7 +1241,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
*/
if (host->irqpending_quirk) {
disable_irq_nosync(host->irq);
- host->irq_control(host, 1);
+ host->devtype_data->irq_control(host, 1);
}
/* first scan to find the device and get the page size */
@@ -1212,7 +1251,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Call preset again, with correct writesize this time */
- host->preset(mtd);
+ host->devtype_data->preset(mtd);
if (mtd->writesize == 2048)
this->ecc.layout = oob_largepage;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
This prepares switching to platform ids and of-tree probing.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
1 file changed, 118 insertions(+), 79 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index a78e763..1672e4b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -140,6 +140,19 @@
#define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
+struct mxc_nand_host;
+
+struct mxc_nand_devtype_data {
+ void (*preset)(struct mtd_info *);
+ void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
+ void (*send_page)(struct mtd_info *, unsigned int);
+ void (*send_read_id)(struct mxc_nand_host *);
+ uint16_t (*get_dev_status)(struct mxc_nand_host *);
+ int (*check_int)(struct mxc_nand_host *);
+ void (*irq_control)(struct mxc_nand_host *, int);
+};
+
struct mxc_nand_host {
struct mtd_info mtd;
struct nand_chip nand;
@@ -165,14 +178,7 @@ struct mxc_nand_host {
unsigned int buf_start;
int spare_len;
- void (*preset)(struct mtd_info *);
- void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
- void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
- void (*send_page)(struct mtd_info *, unsigned int);
- void (*send_read_id)(struct mxc_nand_host *);
- uint16_t (*get_dev_status)(struct mxc_nand_host *);
- int (*check_int)(struct mxc_nand_host *);
- void (*irq_control)(struct mxc_nand_host *, int);
+ const struct mxc_nand_devtype_data *devtype_data;
/*
* On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
@@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
-static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
-{
- struct mxc_nand_host *host = dev_id;
-
- if (!host->check_int(host))
- return IRQ_NONE;
-
- irq_control(host, 0);
-
- complete(&host->op_completion);
-
- return IRQ_HANDLED;
-}
-
static int check_int_v3(struct mxc_nand_host *host)
{
uint32_t tmp;
@@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
else
disable_irq_nosync(host->irq);
} else {
- host->irq_control(host, activate);
+ host->devtype_data->irq_control(host, activate);
}
}
+static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
+{
+ struct mxc_nand_host *host = dev_id;
+
+ if (!host->devtype_data->check_int(host))
+ return IRQ_NONE;
+
+ irq_control(host, 0);
+
+ complete(&host->op_completion);
+
+ return IRQ_HANDLED;
+}
+
+
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -341,14 +348,14 @@ static void wait_op_done(struct mxc_nand_host *host, int useirq)
int max_retries = 8000;
if (useirq) {
- if (!host->check_int(host)) {
+ if (!host->devtype_data->check_int(host)) {
INIT_COMPLETION(host->op_completion);
irq_control(host, 1);
wait_for_completion(&host->op_completion);
}
} else {
while (max_retries-- > 0) {
- if (host->check_int(host))
+ if (host->devtype_data->check_int(host))
break;
udelay(1);
@@ -621,7 +628,7 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)
/* Check for status request */
if (host->status_request)
- return host->get_dev_status(host) & 0xFF;
+ return host->devtype_data->get_dev_status(host) & 0xFF;
ret = *(uint8_t *)(host->data_buf + host->buf_start);
host->buf_start++;
@@ -756,34 +763,44 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
* perform a read/write buf operation, the saved column
* address is used to index into the full page.
*/
- host->send_addr(host, 0, page_addr == -1);
+ host->devtype_data->send_addr(host, 0, page_addr == -1);
if (mtd->writesize > 512)
/* another col addr cycle for 2k page */
- host->send_addr(host, 0, false);
+ host->devtype_data->send_addr(host, 0, false);
}
/* Write out page address, if necessary */
if (page_addr != -1) {
/* paddr_0 - p_addr_7 */
- host->send_addr(host, (page_addr & 0xff), false);
+ host->devtype_data->send_addr(host, (page_addr & 0xff), false);
if (mtd->writesize > 512) {
if (mtd->size >= 0x10000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
} else {
/* One more address cycle for higher density devices */
if (mtd->size >= 0x4000000) {
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, false);
- host->send_addr(host, (page_addr >> 16) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff,
+ false);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 16) & 0xff,
+ true);
} else
/* paddr_8 - paddr_15 */
- host->send_addr(host, (page_addr >> 8) & 0xff, true);
+ host->devtype_data->send_addr(host,
+ (page_addr >> 8) & 0xff, true);
}
}
}
@@ -942,15 +959,15 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
/* Command pre-processing step */
switch (command) {
case NAND_CMD_RESET:
- host->preset(mtd);
- host->send_cmd(host, command, false);
+ host->devtype_data->preset(mtd);
+ host->devtype_data->send_cmd(host, command, false);
break;
case NAND_CMD_STATUS:
host->buf_start = 0;
host->status_request = true;
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -963,13 +980,14 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
command = NAND_CMD_READ0; /* only READ0 is valid */
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
if (mtd->writesize > 512)
- host->send_cmd(host, NAND_CMD_READSTART, true);
+ host->devtype_data->send_cmd(host,
+ NAND_CMD_READSTART, true);
- host->send_page(mtd, NFC_OUTPUT);
+ host->devtype_data->send_page(mtd, NFC_OUTPUT);
memcpy(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
@@ -982,28 +1000,28 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->buf_start = column;
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_PAGEPROG:
memcpy(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
- host->send_page(mtd, NFC_INPUT);
- host->send_cmd(host, command, true);
+ host->devtype_data->send_page(mtd, NFC_INPUT);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
case NAND_CMD_READID:
- host->send_cmd(host, command, true);
+ host->devtype_data->send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr);
- host->send_read_id(host);
+ host->devtype_data->send_read_id(host);
host->buf_start = column;
break;
case NAND_CMD_ERASE1:
case NAND_CMD_ERASE2:
- host->send_cmd(host, command, false);
+ host->devtype_data->send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr);
break;
@@ -1037,6 +1055,42 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
+/* v1: 21, 27, 31 */
+static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v21: 25, 35 */
+static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
+ .preset = preset_v1_v2,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1_v2,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .check_int = check_int_v1_v2,
+ .irq_control = irq_control_v1_v2,
+};
+
+/* v3: 51, 53 */
+static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
+ .preset = preset_v3,
+ .send_cmd = send_cmd_v3,
+ .send_addr = send_addr_v3,
+ .send_page = send_page_v3,
+ .send_read_id = send_read_id_v3,
+ .get_dev_status = get_dev_status_v3,
+ .check_int = check_int_v3,
+ .irq_control = irq_control_v3,
+};
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
@@ -1100,27 +1154,10 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- if (nfc_is_v1() || nfc_is_v21()) {
- host->preset = preset_v1_v2;
- host->send_cmd = send_cmd_v1_v2;
- host->send_addr = send_addr_v1_v2;
- host->send_page = send_page_v1_v2;
- host->send_read_id = send_read_id_v1_v2;
- host->get_dev_status = get_dev_status_v1_v2;
- host->check_int = check_int_v1_v2;
- host->irq_control = irq_control_v1_v2;
+ if (nfc_is_v1()) {
+ host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
host->irqpending_quirk = 1;
- }
-
- if (nfc_is_v21()) {
- 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_v1()) {
host->regs = host->base + 0xe00;
host->spare0 = host->base + 0x800;
host->spare_len = 16;
@@ -1128,7 +1165,16 @@ static int __init mxcnd_probe(struct platform_device *pdev)
oob_largepage = &nandv1_hw_eccoob_largepage;
this->ecc.bytes = 3;
host->eccsize = 1;
+ } else if (nfc_is_v21()) {
+ host->devtype_data = &imx25_nand_devtype_data;
+ 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;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1142,14 +1188,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->regs_axi = host->base + 0x1e00;
host->spare0 = host->base + 0x1000;
host->spare_len = 64;
- host->preset = preset_v3;
- host->send_cmd = send_cmd_v3;
- host->send_addr = send_addr_v3;
- host->send_page = send_page_v3;
- host->send_read_id = send_read_id_v3;
- host->check_int = check_int_v3;
- host->get_dev_status = get_dev_status_v3;
- host->irq_control = irq_control_v3;
oob_smallpage = &nandv2_hw_eccoob_smallpage;
oob_largepage = &nandv2_hw_eccoob_largepage;
} else
@@ -1186,10 +1224,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->irq = platform_get_irq(pdev, 0);
/*
- * Use host->irq_control here instead of irq_control because we must not
- * disable_irq_nosync without having requested the irq
+ * Use host->devtype_data->irq_control() here instead of irq_control()
+ * because we must not disable_irq_nosync without having requested the
+ * irq.
*/
- host->irq_control(host, 0);
+ host->devtype_data->irq_control(host, 0);
err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
if (err)
@@ -1202,7 +1241,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
*/
if (host->irqpending_quirk) {
disable_irq_nosync(host->irq);
- host->irq_control(host, 1);
+ host->devtype_data->irq_control(host, 1);
}
/* first scan to find the device and get the page size */
@@ -1212,7 +1251,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Call preset again, with correct writesize this time */
- host->preset(mtd);
+ host->devtype_data->preset(mtd);
if (mtd->writesize == 2048)
this->ecc.layout = oob_largepage;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
[parent not found: <1335173022-22371-3-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
2012-04-23 9:23 ` Uwe Kleine-König
(?)
@ 2012-04-24 7:24 ` Sascha Hauer
-1 siblings, 0 replies; 51+ messages in thread
From: Sascha Hauer @ 2012-04-24 7:24 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-König wrote:
> This prepares switching to platform ids and of-tree probing.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
> drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> 1 file changed, 118 insertions(+), 79 deletions(-)
>
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index a78e763..1672e4b 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -140,6 +140,19 @@
>
> #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
>
> +struct mxc_nand_host;
> +
> +struct mxc_nand_devtype_data {
> + void (*preset)(struct mtd_info *);
> + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_page)(struct mtd_info *, unsigned int);
> + void (*send_read_id)(struct mxc_nand_host *);
> + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> + int (*check_int)(struct mxc_nand_host *);
> + void (*irq_control)(struct mxc_nand_host *, int);
> +};
> +
> struct mxc_nand_host {
> struct mtd_info mtd;
> struct nand_chip nand;
> @@ -165,14 +178,7 @@ struct mxc_nand_host {
> unsigned int buf_start;
> int spare_len;
>
> - void (*preset)(struct mtd_info *);
> - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_page)(struct mtd_info *, unsigned int);
> - void (*send_read_id)(struct mxc_nand_host *);
> - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> - int (*check_int)(struct mxc_nand_host *);
> - void (*irq_control)(struct mxc_nand_host *, int);
> + const struct mxc_nand_devtype_data *devtype_data;
>
> /*
> * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>
> static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
>
> -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> -{
> - struct mxc_nand_host *host = dev_id;
> -
> - if (!host->check_int(host))
> - return IRQ_NONE;
> -
> - irq_control(host, 0);
> -
> - complete(&host->op_completion);
> -
> - return IRQ_HANDLED;
> -}
> -
> static int check_int_v3(struct mxc_nand_host *host)
> {
> uint32_t tmp;
> @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> else
> disable_irq_nosync(host->irq);
> } else {
> - host->irq_control(host, activate);
> + host->devtype_data->irq_control(host, activate);
> }
> }
>
> +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> +{
> + struct mxc_nand_host *host = dev_id;
> +
> + if (!host->devtype_data->check_int(host))
> + return IRQ_NONE;
> +
> + irq_control(host, 0);
> +
> + complete(&host->op_completion);
> +
> + return IRQ_HANDLED;
> +}
> +
> +
The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
>
> +/* v1: 21, 27, 31 */
Can we have imx21 here? People familiar with i.MX may instantly
recognize these numbers, others do not.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-24 7:24 ` Sascha Hauer
0 siblings, 0 replies; 51+ messages in thread
From: Sascha Hauer @ 2012-04-24 7:24 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-K?nig wrote:
> This prepares switching to platform ids and of-tree probing.
>
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> 1 file changed, 118 insertions(+), 79 deletions(-)
>
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index a78e763..1672e4b 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -140,6 +140,19 @@
>
> #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
>
> +struct mxc_nand_host;
> +
> +struct mxc_nand_devtype_data {
> + void (*preset)(struct mtd_info *);
> + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_page)(struct mtd_info *, unsigned int);
> + void (*send_read_id)(struct mxc_nand_host *);
> + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> + int (*check_int)(struct mxc_nand_host *);
> + void (*irq_control)(struct mxc_nand_host *, int);
> +};
> +
> struct mxc_nand_host {
> struct mtd_info mtd;
> struct nand_chip nand;
> @@ -165,14 +178,7 @@ struct mxc_nand_host {
> unsigned int buf_start;
> int spare_len;
>
> - void (*preset)(struct mtd_info *);
> - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_page)(struct mtd_info *, unsigned int);
> - void (*send_read_id)(struct mxc_nand_host *);
> - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> - int (*check_int)(struct mxc_nand_host *);
> - void (*irq_control)(struct mxc_nand_host *, int);
> + const struct mxc_nand_devtype_data *devtype_data;
>
> /*
> * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>
> static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
>
> -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> -{
> - struct mxc_nand_host *host = dev_id;
> -
> - if (!host->check_int(host))
> - return IRQ_NONE;
> -
> - irq_control(host, 0);
> -
> - complete(&host->op_completion);
> -
> - return IRQ_HANDLED;
> -}
> -
> static int check_int_v3(struct mxc_nand_host *host)
> {
> uint32_t tmp;
> @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> else
> disable_irq_nosync(host->irq);
> } else {
> - host->irq_control(host, activate);
> + host->devtype_data->irq_control(host, activate);
> }
> }
>
> +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> +{
> + struct mxc_nand_host *host = dev_id;
> +
> + if (!host->devtype_data->check_int(host))
> + return IRQ_NONE;
> +
> + irq_control(host, 0);
> +
> + complete(&host->op_completion);
> +
> + return IRQ_HANDLED;
> +}
> +
> +
The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
>
> +/* v1: 21, 27, 31 */
Can we have imx21 here? People familiar with i.MX may instantly
recognize these numbers, others do not.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-24 7:24 ` Sascha Hauer
0 siblings, 0 replies; 51+ messages in thread
From: Sascha Hauer @ 2012-04-24 7:24 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss, linux-mtd, linux-arm-kernel, kernel
On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-König wrote:
> This prepares switching to platform ids and of-tree probing.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> 1 file changed, 118 insertions(+), 79 deletions(-)
>
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index a78e763..1672e4b 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -140,6 +140,19 @@
>
> #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
>
> +struct mxc_nand_host;
> +
> +struct mxc_nand_devtype_data {
> + void (*preset)(struct mtd_info *);
> + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> + void (*send_page)(struct mtd_info *, unsigned int);
> + void (*send_read_id)(struct mxc_nand_host *);
> + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> + int (*check_int)(struct mxc_nand_host *);
> + void (*irq_control)(struct mxc_nand_host *, int);
> +};
> +
> struct mxc_nand_host {
> struct mtd_info mtd;
> struct nand_chip nand;
> @@ -165,14 +178,7 @@ struct mxc_nand_host {
> unsigned int buf_start;
> int spare_len;
>
> - void (*preset)(struct mtd_info *);
> - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> - void (*send_page)(struct mtd_info *, unsigned int);
> - void (*send_read_id)(struct mxc_nand_host *);
> - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> - int (*check_int)(struct mxc_nand_host *);
> - void (*irq_control)(struct mxc_nand_host *, int);
> + const struct mxc_nand_devtype_data *devtype_data;
>
> /*
> * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>
> static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
>
> -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> -{
> - struct mxc_nand_host *host = dev_id;
> -
> - if (!host->check_int(host))
> - return IRQ_NONE;
> -
> - irq_control(host, 0);
> -
> - complete(&host->op_completion);
> -
> - return IRQ_HANDLED;
> -}
> -
> static int check_int_v3(struct mxc_nand_host *host)
> {
> uint32_t tmp;
> @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> else
> disable_irq_nosync(host->irq);
> } else {
> - host->irq_control(host, activate);
> + host->devtype_data->irq_control(host, activate);
> }
> }
>
> +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> +{
> + struct mxc_nand_host *host = dev_id;
> +
> + if (!host->devtype_data->check_int(host))
> + return IRQ_NONE;
> +
> + irq_control(host, 0);
> +
> + complete(&host->op_completion);
> +
> + return IRQ_HANDLED;
> +}
> +
> +
The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
>
> +/* v1: 21, 27, 31 */
Can we have imx21 here? People familiar with i.MX may instantly
recognize these numbers, others do not.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 51+ messages in thread
[parent not found: <20120424072457.GL3852-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
2012-04-24 7:24 ` Sascha Hauer
(?)
@ 2012-04-24 8:10 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:10 UTC (permalink / raw)
To: Sascha Hauer
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Hello Sascha,
On Tue, Apr 24, 2012 at 09:24:57AM +0200, Sascha Hauer wrote:
> On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-König wrote:
> > This prepares switching to platform ids and of-tree probing.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > ---
> > drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 118 insertions(+), 79 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > index a78e763..1672e4b 100644
> > --- a/drivers/mtd/nand/mxc_nand.c
> > +++ b/drivers/mtd/nand/mxc_nand.c
> > @@ -140,6 +140,19 @@
> >
> > #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
> >
> > +struct mxc_nand_host;
> > +
> > +struct mxc_nand_devtype_data {
> > + void (*preset)(struct mtd_info *);
> > + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_page)(struct mtd_info *, unsigned int);
> > + void (*send_read_id)(struct mxc_nand_host *);
> > + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > + int (*check_int)(struct mxc_nand_host *);
> > + void (*irq_control)(struct mxc_nand_host *, int);
> > +};
> > +
> > struct mxc_nand_host {
> > struct mtd_info mtd;
> > struct nand_chip nand;
> > @@ -165,14 +178,7 @@ struct mxc_nand_host {
> > unsigned int buf_start;
> > int spare_len;
> >
> > - void (*preset)(struct mtd_info *);
> > - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_page)(struct mtd_info *, unsigned int);
> > - void (*send_read_id)(struct mxc_nand_host *);
> > - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > - int (*check_int)(struct mxc_nand_host *);
> > - void (*irq_control)(struct mxc_nand_host *, int);
> > + const struct mxc_nand_devtype_data *devtype_data;
> >
> > /*
> > * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> > @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
> >
> > static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
> >
> > -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > -{
> > - struct mxc_nand_host *host = dev_id;
> > -
> > - if (!host->check_int(host))
> > - return IRQ_NONE;
> > -
> > - irq_control(host, 0);
> > -
> > - complete(&host->op_completion);
> > -
> > - return IRQ_HANDLED;
> > -}
> > -
> > static int check_int_v3(struct mxc_nand_host *host)
> > {
> > uint32_t tmp;
> > @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> > else
> > disable_irq_nosync(host->irq);
> > } else {
> > - host->irq_control(host, activate);
> > + host->devtype_data->irq_control(host, activate);
> > }
> > }
> >
> > +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > +{
> > + struct mxc_nand_host *host = dev_id;
> > +
> > + if (!host->devtype_data->check_int(host))
> > + return IRQ_NONE;
> > +
> > + irq_control(host, 0);
> > +
> > + complete(&host->op_completion);
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > +
>
> The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
It's necessary, but already in patch 2. And there is another hunk in
patch 9 that belongs into patch 8.
> >
> > +/* v1: 21, 27, 31 */
>
> Can we have imx21 here? People familiar with i.MX may instantly
> recognize these numbers, others do not.
yeah, right.
While updating the series and doing found another issue that resulted in
a new patch sent as reply to this mail.
I updated the series and pushed it to
git://git.pengutronix.de/git/ukl/linux.git ofconvert/mxc_nand
. The overall diff (not including the new patch) compared to the initial
post is:
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 2e4b953..1041bb1 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -370,7 +370,6 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -1137,7 +1136,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1 + irqpending_quirk: 21 */
+/* v1 + irqpending_quirk: i.MX21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1162,7 +1161,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.eccsize = 1,
};
-/* v1 + !irqpending_quirk: 27, 31 */
+/* v1 + !irqpending_quirk: i.MX27, i.MX31 */
static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1188,7 +1187,7 @@ static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.eccsize = 1,
};
-/* v21: 25, 35 */
+/* v21: i.MX25, i.MX35 */
static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.preset = preset_v2,
.send_cmd = send_cmd_v1_v2,
@@ -1214,7 +1213,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.eccsize = 0,
};
-/* v3: 51, 53 */
+/* v3: i.MX51, i.MX53 */
static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.preset = preset_v3,
.send_cmd = send_cmd_v3,
I will resend later (well unless someone pulls the tree before :-).
Best regards and thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-24 8:10 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:10 UTC (permalink / raw)
To: linux-arm-kernel
Hello Sascha,
On Tue, Apr 24, 2012 at 09:24:57AM +0200, Sascha Hauer wrote:
> On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-K?nig wrote:
> > This prepares switching to platform ids and of-tree probing.
> >
> > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
> > ---
> > drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 118 insertions(+), 79 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > index a78e763..1672e4b 100644
> > --- a/drivers/mtd/nand/mxc_nand.c
> > +++ b/drivers/mtd/nand/mxc_nand.c
> > @@ -140,6 +140,19 @@
> >
> > #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
> >
> > +struct mxc_nand_host;
> > +
> > +struct mxc_nand_devtype_data {
> > + void (*preset)(struct mtd_info *);
> > + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_page)(struct mtd_info *, unsigned int);
> > + void (*send_read_id)(struct mxc_nand_host *);
> > + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > + int (*check_int)(struct mxc_nand_host *);
> > + void (*irq_control)(struct mxc_nand_host *, int);
> > +};
> > +
> > struct mxc_nand_host {
> > struct mtd_info mtd;
> > struct nand_chip nand;
> > @@ -165,14 +178,7 @@ struct mxc_nand_host {
> > unsigned int buf_start;
> > int spare_len;
> >
> > - void (*preset)(struct mtd_info *);
> > - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_page)(struct mtd_info *, unsigned int);
> > - void (*send_read_id)(struct mxc_nand_host *);
> > - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > - int (*check_int)(struct mxc_nand_host *);
> > - void (*irq_control)(struct mxc_nand_host *, int);
> > + const struct mxc_nand_devtype_data *devtype_data;
> >
> > /*
> > * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> > @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
> >
> > static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
> >
> > -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > -{
> > - struct mxc_nand_host *host = dev_id;
> > -
> > - if (!host->check_int(host))
> > - return IRQ_NONE;
> > -
> > - irq_control(host, 0);
> > -
> > - complete(&host->op_completion);
> > -
> > - return IRQ_HANDLED;
> > -}
> > -
> > static int check_int_v3(struct mxc_nand_host *host)
> > {
> > uint32_t tmp;
> > @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> > else
> > disable_irq_nosync(host->irq);
> > } else {
> > - host->irq_control(host, activate);
> > + host->devtype_data->irq_control(host, activate);
> > }
> > }
> >
> > +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > +{
> > + struct mxc_nand_host *host = dev_id;
> > +
> > + if (!host->devtype_data->check_int(host))
> > + return IRQ_NONE;
> > +
> > + irq_control(host, 0);
> > +
> > + complete(&host->op_completion);
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > +
>
> The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
It's necessary, but already in patch 2. And there is another hunk in
patch 9 that belongs into patch 8.
> >
> > +/* v1: 21, 27, 31 */
>
> Can we have imx21 here? People familiar with i.MX may instantly
> recognize these numbers, others do not.
yeah, right.
While updating the series and doing found another issue that resulted in
a new patch sent as reply to this mail.
I updated the series and pushed it to
git://git.pengutronix.de/git/ukl/linux.git ofconvert/mxc_nand
. The overall diff (not including the new patch) compared to the initial
post is:
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 2e4b953..1041bb1 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -370,7 +370,6 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -1137,7 +1136,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1 + irqpending_quirk: 21 */
+/* v1 + irqpending_quirk: i.MX21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1162,7 +1161,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.eccsize = 1,
};
-/* v1 + !irqpending_quirk: 27, 31 */
+/* v1 + !irqpending_quirk: i.MX27, i.MX31 */
static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1188,7 +1187,7 @@ static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.eccsize = 1,
};
-/* v21: 25, 35 */
+/* v21: i.MX25, i.MX35 */
static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.preset = preset_v2,
.send_cmd = send_cmd_v1_v2,
@@ -1214,7 +1213,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.eccsize = 0,
};
-/* v3: 51, 53 */
+/* v3: i.MX51, i.MX53 */
static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.preset = preset_v3,
.send_cmd = send_cmd_v3,
I will resend later (well unless someone pulls the tree before :-).
Best regards and thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply related [flat|nested] 51+ messages in thread
* Re: [PATCH 03/10] mtd: mxc_nand: move function pointers to a per-SOC struct
@ 2012-04-24 8:10 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:10 UTC (permalink / raw)
To: Sascha Hauer; +Cc: devicetree-discuss, linux-mtd, linux-arm-kernel, kernel
Hello Sascha,
On Tue, Apr 24, 2012 at 09:24:57AM +0200, Sascha Hauer wrote:
> On Mon, Apr 23, 2012 at 11:23:35AM +0200, Uwe Kleine-König wrote:
> > This prepares switching to platform ids and of-tree probing.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > drivers/mtd/nand/mxc_nand.c | 197 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 118 insertions(+), 79 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > index a78e763..1672e4b 100644
> > --- a/drivers/mtd/nand/mxc_nand.c
> > +++ b/drivers/mtd/nand/mxc_nand.c
> > @@ -140,6 +140,19 @@
> >
> > #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
> >
> > +struct mxc_nand_host;
> > +
> > +struct mxc_nand_devtype_data {
> > + void (*preset)(struct mtd_info *);
> > + void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > + void (*send_page)(struct mtd_info *, unsigned int);
> > + void (*send_read_id)(struct mxc_nand_host *);
> > + uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > + int (*check_int)(struct mxc_nand_host *);
> > + void (*irq_control)(struct mxc_nand_host *, int);
> > +};
> > +
> > struct mxc_nand_host {
> > struct mtd_info mtd;
> > struct nand_chip nand;
> > @@ -165,14 +178,7 @@ struct mxc_nand_host {
> > unsigned int buf_start;
> > int spare_len;
> >
> > - void (*preset)(struct mtd_info *);
> > - void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
> > - void (*send_page)(struct mtd_info *, unsigned int);
> > - void (*send_read_id)(struct mxc_nand_host *);
> > - uint16_t (*get_dev_status)(struct mxc_nand_host *);
> > - int (*check_int)(struct mxc_nand_host *);
> > - void (*irq_control)(struct mxc_nand_host *, int);
> > + const struct mxc_nand_devtype_data *devtype_data;
> >
> > /*
> > * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
> > @@ -251,20 +257,6 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
> >
> > static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
> >
> > -static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > -{
> > - struct mxc_nand_host *host = dev_id;
> > -
> > - if (!host->check_int(host))
> > - return IRQ_NONE;
> > -
> > - irq_control(host, 0);
> > -
> > - complete(&host->op_completion);
> > -
> > - return IRQ_HANDLED;
> > -}
> > -
> > static int check_int_v3(struct mxc_nand_host *host)
> > {
> > uint32_t tmp;
> > @@ -329,10 +321,25 @@ static void irq_control(struct mxc_nand_host *host, int activate)
> > else
> > disable_irq_nosync(host->irq);
> > } else {
> > - host->irq_control(host, activate);
> > + host->devtype_data->irq_control(host, activate);
> > }
> > }
> >
> > +static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
> > +{
> > + struct mxc_nand_host *host = dev_id;
> > +
> > + if (!host->devtype_data->check_int(host))
> > + return IRQ_NONE;
> > +
> > + irq_control(host, 0);
> > +
> > + complete(&host->op_completion);
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > +
>
> The move of mxc_nfc_irq seems unnecessary. Also one blank line too much.
It's necessary, but already in patch 2. And there is another hunk in
patch 9 that belongs into patch 8.
> >
> > +/* v1: 21, 27, 31 */
>
> Can we have imx21 here? People familiar with i.MX may instantly
> recognize these numbers, others do not.
yeah, right.
While updating the series and doing found another issue that resulted in
a new patch sent as reply to this mail.
I updated the series and pushed it to
git://git.pengutronix.de/git/ukl/linux.git ofconvert/mxc_nand
. The overall diff (not including the new patch) compared to the initial
post is:
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 2e4b953..1041bb1 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -370,7 +370,6 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-
/* This function polls the NANDFC to wait for the basic operation to
* complete by checking the INT bit of config2 register.
*/
@@ -1137,7 +1136,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1 + irqpending_quirk: 21 */
+/* v1 + irqpending_quirk: i.MX21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1162,7 +1161,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.eccsize = 1,
};
-/* v1 + !irqpending_quirk: 27, 31 */
+/* v1 + !irqpending_quirk: i.MX27, i.MX31 */
static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1188,7 +1187,7 @@ static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
.eccsize = 1,
};
-/* v21: 25, 35 */
+/* v21: i.MX25, i.MX35 */
static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.preset = preset_v2,
.send_cmd = send_cmd_v1_v2,
@@ -1214,7 +1213,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.eccsize = 0,
};
-/* v3: 51, 53 */
+/* v3: i.MX51, i.MX53 */
static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.preset = preset_v3,
.send_cmd = send_cmd_v3,
I will resend later (well unless someone pulls the tree before :-).
Best regards and thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH] mtd: mxc_nand: fix several sparse warnings about incorrect address space
2012-04-24 8:10 ` Uwe Kleine-König
(?)
@ 2012-04-24 8:12 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:12 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1041bb1..ec5ba8b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -181,8 +181,8 @@ struct mxc_nand_host {
struct nand_chip nand;
struct device *dev;
- void *spare0;
- void *main_area0;
+ void __iomem *spare0;
+ void __iomem *main_area0;
void __iomem *base;
void __iomem *regs;
@@ -519,7 +519,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
}
/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +535,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
/* Wait for operation to complete */
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
if (this->options & NAND_BUSWIDTH_16) {
/* compress the ID info */
@@ -790,23 +790,23 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 i, j;
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
- u8 *s = host->spare0;
+ u8 __iomem *s = host->spare0;
u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
if (bfrom) {
for (i = 0; i < n - 1; i++)
- memcpy(d + i * j, s + i * t, j);
+ memcpy_fromio(d + i * j, s + i * t, j);
/* the last section */
- memcpy(d + i * j, s + i * t, mtd->oobsize - i * j);
+ memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
} else {
for (i = 0; i < n - 1; i++)
- memcpy(&s[i * t], &d[i * j], j);
+ memcpy_toio(&s[i * t], &d[i * j], j);
/* the last section */
- memcpy(&s[i * t], &d[i * j], mtd->oobsize - i * j);
+ memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
}
}
@@ -1070,7 +1070,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->devtype_data->send_page(mtd, NFC_OUTPUT);
- memcpy(host->data_buf, host->main_area0, mtd->writesize);
+ memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
break;
@@ -1086,7 +1086,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
break;
case NAND_CMD_PAGEPROG:
- memcpy(host->main_area0, host->data_buf, mtd->writesize);
+ memcpy_toio(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
host->devtype_data->send_page(mtd, NFC_INPUT);
host->devtype_data->send_cmd(host, command, true);
--
1.7.10
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH] mtd: mxc_nand: fix several sparse warnings about incorrect address space
@ 2012-04-24 8:12 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:12 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1041bb1..ec5ba8b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -181,8 +181,8 @@ struct mxc_nand_host {
struct nand_chip nand;
struct device *dev;
- void *spare0;
- void *main_area0;
+ void __iomem *spare0;
+ void __iomem *main_area0;
void __iomem *base;
void __iomem *regs;
@@ -519,7 +519,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
}
/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +535,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
/* Wait for operation to complete */
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
if (this->options & NAND_BUSWIDTH_16) {
/* compress the ID info */
@@ -790,23 +790,23 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 i, j;
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
- u8 *s = host->spare0;
+ u8 __iomem *s = host->spare0;
u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
if (bfrom) {
for (i = 0; i < n - 1; i++)
- memcpy(d + i * j, s + i * t, j);
+ memcpy_fromio(d + i * j, s + i * t, j);
/* the last section */
- memcpy(d + i * j, s + i * t, mtd->oobsize - i * j);
+ memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
} else {
for (i = 0; i < n - 1; i++)
- memcpy(&s[i * t], &d[i * j], j);
+ memcpy_toio(&s[i * t], &d[i * j], j);
/* the last section */
- memcpy(&s[i * t], &d[i * j], mtd->oobsize - i * j);
+ memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
}
}
@@ -1070,7 +1070,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->devtype_data->send_page(mtd, NFC_OUTPUT);
- memcpy(host->data_buf, host->main_area0, mtd->writesize);
+ memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
break;
@@ -1086,7 +1086,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
break;
case NAND_CMD_PAGEPROG:
- memcpy(host->main_area0, host->data_buf, mtd->writesize);
+ memcpy_toio(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
host->devtype_data->send_page(mtd, NFC_INPUT);
host->devtype_data->send_cmd(host, command, true);
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH] mtd: mxc_nand: fix several sparse warnings about incorrect address space
@ 2012-04-24 8:12 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-24 8:12 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1041bb1..ec5ba8b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -181,8 +181,8 @@ struct mxc_nand_host {
struct nand_chip nand;
struct device *dev;
- void *spare0;
- void *main_area0;
+ void __iomem *spare0;
+ void __iomem *main_area0;
void __iomem *base;
void __iomem *regs;
@@ -519,7 +519,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
}
/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +535,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
/* Wait for operation to complete */
wait_op_done(host, true);
- memcpy(host->data_buf, host->main_area0, 16);
+ memcpy_fromio(host->data_buf, host->main_area0, 16);
if (this->options & NAND_BUSWIDTH_16) {
/* compress the ID info */
@@ -790,23 +790,23 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 i, j;
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
- u8 *s = host->spare0;
+ u8 __iomem *s = host->spare0;
u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
if (bfrom) {
for (i = 0; i < n - 1; i++)
- memcpy(d + i * j, s + i * t, j);
+ memcpy_fromio(d + i * j, s + i * t, j);
/* the last section */
- memcpy(d + i * j, s + i * t, mtd->oobsize - i * j);
+ memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
} else {
for (i = 0; i < n - 1; i++)
- memcpy(&s[i * t], &d[i * j], j);
+ memcpy_toio(&s[i * t], &d[i * j], j);
/* the last section */
- memcpy(&s[i * t], &d[i * j], mtd->oobsize - i * j);
+ memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
}
}
@@ -1070,7 +1070,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->devtype_data->send_page(mtd, NFC_OUTPUT);
- memcpy(host->data_buf, host->main_area0, mtd->writesize);
+ memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true);
break;
@@ -1086,7 +1086,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
break;
case NAND_CMD_PAGEPROG:
- memcpy(host->main_area0, host->data_buf, mtd->writesize);
+ memcpy_toio(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false);
host->devtype_data->send_page(mtd, NFC_INPUT);
host->devtype_data->send_cmd(host, command, true);
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 05/10] mtd: mxc_nand: put ecc layout into devtype structs
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
This commit makes problems on v1 and v2 regarding 4k pages more obvious.
As I don't have a 4k flash handy I just keep the status quo.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c9cdec2..1389d40 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 {
@@ -1114,6 +1115,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: 25, 35 */
@@ -1127,6 +1131,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: 51, 53 */
@@ -1140,6 +1147,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)
@@ -1150,7 +1160,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 +
@@ -1212,8 +1221,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()) {
@@ -1221,8 +1228,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;
@@ -1239,13 +1244,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;
@@ -1305,9 +1308,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)) {
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 05/10] mtd: mxc_nand: put ecc layout into devtype structs
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
This commit makes problems on v1 and v2 regarding 4k pages more obvious.
As I don't have a 4k flash handy I just keep the status quo.
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c9cdec2..1389d40 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 {
@@ -1114,6 +1115,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: 25, 35 */
@@ -1127,6 +1131,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: 51, 53 */
@@ -1140,6 +1147,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)
@@ -1150,7 +1160,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 +
@@ -1212,8 +1221,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()) {
@@ -1221,8 +1228,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;
@@ -1239,13 +1244,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;
@@ -1305,9 +1308,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)) {
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 05/10] mtd: mxc_nand: put ecc layout into devtype structs
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
This commit makes problems on v1 and v2 regarding 4k pages more obvious.
As I don't have a 4k flash handy I just keep the status quo.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c9cdec2..1389d40 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 {
@@ -1114,6 +1115,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: 25, 35 */
@@ -1127,6 +1131,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: 51, 53 */
@@ -1140,6 +1147,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)
@@ -1150,7 +1160,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 +
@@ -1212,8 +1221,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()) {
@@ -1221,8 +1228,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;
@@ -1239,13 +1244,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;
@@ -1305,9 +1308,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)) {
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 06/10] mtd: mxc_nand: split chip_select function and put it into devtype struct
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1389d40..be17b7a 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -153,6 +153,7 @@ struct mxc_nand_devtype_data {
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;
+ void (*select_chip)(struct mtd_info *mtd, int chip);
};
struct mxc_nand_host {
@@ -722,7 +723,7 @@ static int mxc_nand_verify_buf(struct mtd_info *mtd,
/* This function is used by upper layer for select and
* deselect of the NAND chip */
-static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
+static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
{
struct nand_chip *nand_chip = mtd->priv;
struct mxc_nand_host *host = nand_chip->priv;
@@ -741,11 +742,30 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
clk_enable(host->clk);
host->clk_act = 1;
}
+}
+
+static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
+{
+ struct nand_chip *nand_chip = mtd->priv;
+ struct mxc_nand_host *host = nand_chip->priv;
+
+ if (chip == -1) {
+ /* Disable the NFC clock */
+ if (host->clk_act) {
+ clk_disable(host->clk);
+ host->clk_act = 0;
+ }
+ return;
+ }
- if (nfc_is_v21()) {
- host->active_cs = chip;
- writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
+ if (!host->clk_act) {
+ /* Enable the NFC clock */
+ clk_enable(host->clk);
+ host->clk_act = 1;
}
+
+ host->active_cs = chip;
+ writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
}
/*
@@ -1118,6 +1138,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_512 = &nandv1_hw_eccoob_smallpage,
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
/* v21: 25, 35 */
@@ -1134,6 +1155,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
+ .select_chip = mxc_nand_select_chip_v2,
};
/* v3: 51, 53 */
@@ -1150,6 +1172,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1184,7 +1207,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->priv = host;
this->dev_ready = mxc_nand_dev_ready;
this->cmdfunc = mxc_nand_command;
- this->select_chip = mxc_nand_select_chip;
this->read_byte = mxc_nand_read_byte;
this->read_word = mxc_nand_read_word;
this->write_buf = mxc_nand_write_buf;
@@ -1247,6 +1269,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
} else
BUG();
+ this->select_chip = host->devtype_data->select_chip;
this->ecc.size = 512;
this->ecc.layout = host->devtype_data->ecclayout_512;
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 06/10] mtd: mxc_nand: split chip_select function and put it into devtype struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1389d40..be17b7a 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -153,6 +153,7 @@ struct mxc_nand_devtype_data {
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;
+ void (*select_chip)(struct mtd_info *mtd, int chip);
};
struct mxc_nand_host {
@@ -722,7 +723,7 @@ static int mxc_nand_verify_buf(struct mtd_info *mtd,
/* This function is used by upper layer for select and
* deselect of the NAND chip */
-static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
+static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
{
struct nand_chip *nand_chip = mtd->priv;
struct mxc_nand_host *host = nand_chip->priv;
@@ -741,11 +742,30 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
clk_enable(host->clk);
host->clk_act = 1;
}
+}
+
+static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
+{
+ struct nand_chip *nand_chip = mtd->priv;
+ struct mxc_nand_host *host = nand_chip->priv;
+
+ if (chip == -1) {
+ /* Disable the NFC clock */
+ if (host->clk_act) {
+ clk_disable(host->clk);
+ host->clk_act = 0;
+ }
+ return;
+ }
- if (nfc_is_v21()) {
- host->active_cs = chip;
- writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
+ if (!host->clk_act) {
+ /* Enable the NFC clock */
+ clk_enable(host->clk);
+ host->clk_act = 1;
}
+
+ host->active_cs = chip;
+ writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
}
/*
@@ -1118,6 +1138,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_512 = &nandv1_hw_eccoob_smallpage,
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
/* v21: 25, 35 */
@@ -1134,6 +1155,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
+ .select_chip = mxc_nand_select_chip_v2,
};
/* v3: 51, 53 */
@@ -1150,6 +1172,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1184,7 +1207,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->priv = host;
this->dev_ready = mxc_nand_dev_ready;
this->cmdfunc = mxc_nand_command;
- this->select_chip = mxc_nand_select_chip;
this->read_byte = mxc_nand_read_byte;
this->read_word = mxc_nand_read_word;
this->write_buf = mxc_nand_write_buf;
@@ -1247,6 +1269,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
} else
BUG();
+ this->select_chip = host->devtype_data->select_chip;
this->ecc.size = 512;
this->ecc.layout = host->devtype_data->ecclayout_512;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 06/10] mtd: mxc_nand: split chip_select function and put it into devtype struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 1389d40..be17b7a 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -153,6 +153,7 @@ struct mxc_nand_devtype_data {
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;
+ void (*select_chip)(struct mtd_info *mtd, int chip);
};
struct mxc_nand_host {
@@ -722,7 +723,7 @@ static int mxc_nand_verify_buf(struct mtd_info *mtd,
/* This function is used by upper layer for select and
* deselect of the NAND chip */
-static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
+static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
{
struct nand_chip *nand_chip = mtd->priv;
struct mxc_nand_host *host = nand_chip->priv;
@@ -741,11 +742,30 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
clk_enable(host->clk);
host->clk_act = 1;
}
+}
+
+static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
+{
+ struct nand_chip *nand_chip = mtd->priv;
+ struct mxc_nand_host *host = nand_chip->priv;
+
+ if (chip == -1) {
+ /* Disable the NFC clock */
+ if (host->clk_act) {
+ clk_disable(host->clk);
+ host->clk_act = 0;
+ }
+ return;
+ }
- if (nfc_is_v21()) {
- host->active_cs = chip;
- writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
+ if (!host->clk_act) {
+ /* Enable the NFC clock */
+ clk_enable(host->clk);
+ host->clk_act = 1;
}
+
+ host->active_cs = chip;
+ writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
}
/*
@@ -1118,6 +1138,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_512 = &nandv1_hw_eccoob_smallpage,
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
/* v21: 25, 35 */
@@ -1134,6 +1155,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
+ .select_chip = mxc_nand_select_chip_v2,
};
/* v3: 51, 53 */
@@ -1150,6 +1172,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_512 = &nandv2_hw_eccoob_smallpage,
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
+ .select_chip = mxc_nand_select_chip_v1_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1184,7 +1207,6 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->priv = host;
this->dev_ready = mxc_nand_dev_ready;
this->cmdfunc = mxc_nand_command;
- this->select_chip = mxc_nand_select_chip;
this->read_byte = mxc_nand_read_byte;
this->read_word = mxc_nand_read_word;
this->write_buf = mxc_nand_write_buf;
@@ -1247,6 +1269,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
} else
BUG();
+ this->select_chip = host->devtype_data->select_chip;
this->ecc.size = 512;
this->ecc.layout = host->devtype_data->ecclayout_512;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 07/10] mtd: mxc_nand: put callback for data correction into devtype struct
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
This gets rid of one more nfc_is_vX().
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index be17b7a..ac4b2e9 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -154,6 +154,8 @@ struct mxc_nand_devtype_data {
u32 (*get_ecc_status)(struct mxc_nand_host *);
struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k;
void (*select_chip)(struct mtd_info *mtd, int chip);
+ int (*correct_data)(struct mtd_info *mtd, u_char *dat,
+ u_char *read_ecc, u_char *calc_ecc);
};
struct mxc_nand_host {
@@ -1139,6 +1141,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
};
/* v21: 25, 35 */
@@ -1156,6 +1159,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
/* v3: 51, 53 */
@@ -1173,6 +1177,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1276,10 +1281,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
- if (nfc_is_v1())
- this->ecc.correct = mxc_nand_correct_data_v1;
- else
- this->ecc.correct = mxc_nand_correct_data_v2_v3;
+ this->ecc.correct = host->devtype_data->correct_data;
this->ecc.mode = NAND_ECC_HW;
} else {
this->ecc.mode = NAND_ECC_SOFT;
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 07/10] mtd: mxc_nand: put callback for data correction into devtype struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
This gets rid of one more nfc_is_vX().
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index be17b7a..ac4b2e9 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -154,6 +154,8 @@ struct mxc_nand_devtype_data {
u32 (*get_ecc_status)(struct mxc_nand_host *);
struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k;
void (*select_chip)(struct mtd_info *mtd, int chip);
+ int (*correct_data)(struct mtd_info *mtd, u_char *dat,
+ u_char *read_ecc, u_char *calc_ecc);
};
struct mxc_nand_host {
@@ -1139,6 +1141,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
};
/* v21: 25, 35 */
@@ -1156,6 +1159,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
/* v3: 51, 53 */
@@ -1173,6 +1177,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1276,10 +1281,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
- if (nfc_is_v1())
- this->ecc.correct = mxc_nand_correct_data_v1;
- else
- this->ecc.correct = mxc_nand_correct_data_v2_v3;
+ this->ecc.correct = host->devtype_data->correct_data;
this->ecc.mode = NAND_ECC_HW;
} else {
this->ecc.mode = NAND_ECC_SOFT;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 07/10] mtd: mxc_nand: put callback for data correction into devtype struct
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
This gets rid of one more nfc_is_vX().
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index be17b7a..ac4b2e9 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -154,6 +154,8 @@ struct mxc_nand_devtype_data {
u32 (*get_ecc_status)(struct mxc_nand_host *);
struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k;
void (*select_chip)(struct mtd_info *mtd, int chip);
+ int (*correct_data)(struct mtd_info *mtd, u_char *dat,
+ u_char *read_ecc, u_char *calc_ecc);
};
struct mxc_nand_host {
@@ -1139,6 +1141,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_2k = &nandv1_hw_eccoob_largepage,
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
};
/* v21: 25, 35 */
@@ -1156,6 +1159,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
/* v3: 51, 53 */
@@ -1173,6 +1177,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_2k = &nandv2_hw_eccoob_largepage,
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v2_v3,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1276,10 +1281,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
- if (nfc_is_v1())
- this->ecc.correct = mxc_nand_correct_data_v1;
- else
- this->ecc.correct = mxc_nand_correct_data_v2_v3;
+ this->ecc.correct = host->devtype_data->correct_data;
this->ecc.mode = NAND_ECC_HW;
} else {
this->ecc.mode = NAND_ECC_SOFT;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 08/10] mtd: mxc_nand: put several more fields into devtype_data
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 128 +++++++++++++++++++++++++++++++------------
1 file changed, 93 insertions(+), 35 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index ac4b2e9..81ffb9b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -156,6 +156,22 @@ struct mxc_nand_devtype_data {
void (*select_chip)(struct mtd_info *mtd, int chip);
int (*correct_data)(struct mtd_info *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
+ int needs_ip;
+
+ size_t regs_offset;
+ size_t spare0_offset;
+ size_t axi_offset;
+
+ int spare_len;
+ int eccbytes;
+ int eccsize;
};
struct mxc_nand_host {
@@ -181,16 +197,8 @@ struct mxc_nand_host {
uint8_t *data_buf;
unsigned int buf_start;
- int spare_len;
const struct mxc_nand_devtype_data *devtype_data;
-
- /*
- * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
- * (CONFIG1:INT_MSK is set). To handle this the driver uses
- * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
- */
- int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -284,7 +292,7 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
@@ -320,7 +328,7 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
static void irq_control(struct mxc_nand_host *host, int activate)
{
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
if (activate)
enable_irq(host->irq);
else
@@ -406,7 +414,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
+ if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -781,7 +789,7 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
u8 *s = host->spare0;
- u16 t = host->spare_len;
+ u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
@@ -881,7 +889,7 @@ static void preset_v1(struct mtd_info *mtd)
if (nand_chip->ecc.mode == NAND_ECC_HW)
config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
host->eccsize = 1;
@@ -911,7 +919,7 @@ static void preset_v2(struct mtd_info *mtd)
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (mtd->writesize) {
@@ -1126,7 +1134,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1: 21, 27, 31 */
+/* v1 + irqpending_quirk: 21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1142,6 +1150,39 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 1,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
+};
+
+/* v1 + !irqpending_quirk: 27, 31 */
+static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
+ .preset = preset_v1,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .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 */
+ .select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .axi_offset = 0,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
};
/* v21: 25, 35 */
@@ -1160,6 +1201,14 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0x1e00,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0,
+ .spare_len = 64,
+ .eccbytes = 9,
+ .eccsize = 0,
};
/* v3: 51, 53 */
@@ -1178,6 +1227,14 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 1,
+ .regs_offset = 0,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0x1e00,
+ .spare_len = 64,
+ .eccbytes = 0,
+ .eccsize = 0,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1242,22 +1299,31 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
if (nfc_is_v1()) {
- host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
- host->irqpending_quirk = 1;
- host->regs = host->base + 0xe00;
- host->spare0 = host->base + 0x800;
- host->spare_len = 16;
- this->ecc.bytes = 3;
- host->eccsize = 1;
+ 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;
- host->regs = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- this->ecc.bytes = 9;
} else if (nfc_is_v3_2()) {
host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ if (host->devtype_data->regs_offset)
+ host->regs = host->base + host->devtype_data->regs_offset;
+ host->spare0 = host->base + host->devtype_data->spare0_offset;
+ if (host->devtype_data->axi_offset)
+ host->regs_axi = host->base + host->devtype_data->axi_offset;
+
+ this->ecc.bytes = host->devtype_data->eccbytes;
+ host->eccsize = host->devtype_data->eccsize;
+
+ this->select_chip = host->devtype_data->select_chip;
+ this->ecc.size = 512;
+ this->ecc.layout = host->devtype_data->ecclayout_512;
+
+ if (host->devtype_data->needs_ip) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1268,15 +1334,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
err = -ENOMEM;
goto eirq;
}
- host->regs_axi = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- } else
- BUG();
-
- this->select_chip = host->devtype_data->select_chip;
- this->ecc.size = 512;
- this->ecc.layout = host->devtype_data->ecclayout_512;
+ }
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 08/10] mtd: mxc_nand: put several more fields into devtype_data
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 128 +++++++++++++++++++++++++++++++------------
1 file changed, 93 insertions(+), 35 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index ac4b2e9..81ffb9b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -156,6 +156,22 @@ struct mxc_nand_devtype_data {
void (*select_chip)(struct mtd_info *mtd, int chip);
int (*correct_data)(struct mtd_info *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
+ int needs_ip;
+
+ size_t regs_offset;
+ size_t spare0_offset;
+ size_t axi_offset;
+
+ int spare_len;
+ int eccbytes;
+ int eccsize;
};
struct mxc_nand_host {
@@ -181,16 +197,8 @@ struct mxc_nand_host {
uint8_t *data_buf;
unsigned int buf_start;
- int spare_len;
const struct mxc_nand_devtype_data *devtype_data;
-
- /*
- * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
- * (CONFIG1:INT_MSK is set). To handle this the driver uses
- * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
- */
- int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -284,7 +292,7 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
@@ -320,7 +328,7 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
static void irq_control(struct mxc_nand_host *host, int activate)
{
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
if (activate)
enable_irq(host->irq);
else
@@ -406,7 +414,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
+ if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -781,7 +789,7 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
u8 *s = host->spare0;
- u16 t = host->spare_len;
+ u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
@@ -881,7 +889,7 @@ static void preset_v1(struct mtd_info *mtd)
if (nand_chip->ecc.mode == NAND_ECC_HW)
config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
host->eccsize = 1;
@@ -911,7 +919,7 @@ static void preset_v2(struct mtd_info *mtd)
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (mtd->writesize) {
@@ -1126,7 +1134,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1: 21, 27, 31 */
+/* v1 + irqpending_quirk: 21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1142,6 +1150,39 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 1,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
+};
+
+/* v1 + !irqpending_quirk: 27, 31 */
+static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
+ .preset = preset_v1,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .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 */
+ .select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .axi_offset = 0,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
};
/* v21: 25, 35 */
@@ -1160,6 +1201,14 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0x1e00,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0,
+ .spare_len = 64,
+ .eccbytes = 9,
+ .eccsize = 0,
};
/* v3: 51, 53 */
@@ -1178,6 +1227,14 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 1,
+ .regs_offset = 0,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0x1e00,
+ .spare_len = 64,
+ .eccbytes = 0,
+ .eccsize = 0,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1242,22 +1299,31 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
if (nfc_is_v1()) {
- host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
- host->irqpending_quirk = 1;
- host->regs = host->base + 0xe00;
- host->spare0 = host->base + 0x800;
- host->spare_len = 16;
- this->ecc.bytes = 3;
- host->eccsize = 1;
+ 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;
- host->regs = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- this->ecc.bytes = 9;
} else if (nfc_is_v3_2()) {
host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ if (host->devtype_data->regs_offset)
+ host->regs = host->base + host->devtype_data->regs_offset;
+ host->spare0 = host->base + host->devtype_data->spare0_offset;
+ if (host->devtype_data->axi_offset)
+ host->regs_axi = host->base + host->devtype_data->axi_offset;
+
+ this->ecc.bytes = host->devtype_data->eccbytes;
+ host->eccsize = host->devtype_data->eccsize;
+
+ this->select_chip = host->devtype_data->select_chip;
+ this->ecc.size = 512;
+ this->ecc.layout = host->devtype_data->ecclayout_512;
+
+ if (host->devtype_data->needs_ip) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1268,15 +1334,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
err = -ENOMEM;
goto eirq;
}
- host->regs_axi = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- } else
- BUG();
-
- this->select_chip = host->devtype_data->select_chip;
- this->ecc.size = 512;
- this->ecc.layout = host->devtype_data->ecclayout_512;
+ }
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 08/10] mtd: mxc_nand: put several more fields into devtype_data
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/nand/mxc_nand.c | 128 +++++++++++++++++++++++++++++++------------
1 file changed, 93 insertions(+), 35 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index ac4b2e9..81ffb9b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -156,6 +156,22 @@ struct mxc_nand_devtype_data {
void (*select_chip)(struct mtd_info *mtd, int chip);
int (*correct_data)(struct mtd_info *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc);
+
+ /*
+ * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
+ * (CONFIG1:INT_MSK is set). To handle this the driver uses
+ * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
+ */
+ int irqpending_quirk;
+ int needs_ip;
+
+ size_t regs_offset;
+ size_t spare0_offset;
+ size_t axi_offset;
+
+ int spare_len;
+ int eccbytes;
+ int eccsize;
};
struct mxc_nand_host {
@@ -181,16 +197,8 @@ struct mxc_nand_host {
uint8_t *data_buf;
unsigned int buf_start;
- int spare_len;
const struct mxc_nand_devtype_data *devtype_data;
-
- /*
- * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
- * (CONFIG1:INT_MSK is set). To handle this the driver uses
- * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
- */
- int irqpending_quirk;
};
/* OOB placement block for use with hardware ecc generation */
@@ -284,7 +292,7 @@ static int check_int_v1_v2(struct mxc_nand_host *host)
if (!(tmp & NFC_V1_V2_CONFIG2_INT))
return 0;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
return 1;
@@ -320,7 +328,7 @@ static void irq_control_v3(struct mxc_nand_host *host, int activate)
static void irq_control(struct mxc_nand_host *host, int activate)
{
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
if (activate)
enable_irq(host->irq);
else
@@ -406,7 +414,7 @@ static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
writew(cmd, NFC_V1_V2_FLASH_CMD);
writew(NFC_CMD, NFC_V1_V2_CONFIG2);
- if (host->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
+ if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
int max_retries = 100;
/* Reset completion is indicated by NFC_CONFIG2 */
/* being set to 0 */
@@ -781,7 +789,7 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
u16 n = mtd->writesize >> 9;
u8 *d = host->data_buf + mtd->writesize;
u8 *s = host->spare0;
- u16 t = host->spare_len;
+ u16 t = host->devtype_data->spare_len;
j = (mtd->oobsize / n >> 1) << 1;
@@ -881,7 +889,7 @@ static void preset_v1(struct mtd_info *mtd)
if (nand_chip->ecc.mode == NAND_ECC_HW)
config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
host->eccsize = 1;
@@ -911,7 +919,7 @@ static void preset_v2(struct mtd_info *mtd)
config1 |= NFC_V2_CONFIG1_FP_INT;
- if (!host->irqpending_quirk)
+ if (!host->devtype_data->irqpending_quirk)
config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
if (mtd->writesize) {
@@ -1126,7 +1134,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
.pattern = mirror_pattern,
};
-/* v1: 21, 27, 31 */
+/* v1 + irqpending_quirk: 21 */
static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.preset = preset_v1,
.send_cmd = send_cmd_v1_v2,
@@ -1142,6 +1150,39 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
.ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 1,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
+};
+
+/* v1 + !irqpending_quirk: 27, 31 */
+static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
+ .preset = preset_v1,
+ .send_cmd = send_cmd_v1_v2,
+ .send_addr = send_addr_v1_v2,
+ .send_page = send_page_v1,
+ .send_read_id = send_read_id_v1_v2,
+ .get_dev_status = get_dev_status_v1_v2,
+ .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 */
+ .select_chip = mxc_nand_select_chip_v1_v3,
+ .correct_data = mxc_nand_correct_data_v1,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0xe00,
+ .spare0_offset = 0x800,
+ .axi_offset = 0,
+ .spare_len = 16,
+ .eccbytes = 3,
+ .eccsize = 1,
};
/* v21: 25, 35 */
@@ -1160,6 +1201,14 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_4k,
.select_chip = mxc_nand_select_chip_v2,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 0,
+ .regs_offset = 0x1e00,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0,
+ .spare_len = 64,
+ .eccbytes = 9,
+ .eccsize = 0,
};
/* v3: 51, 53 */
@@ -1178,6 +1227,14 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
.select_chip = mxc_nand_select_chip_v1_v3,
.correct_data = mxc_nand_correct_data_v2_v3,
+ .irqpending_quirk = 0,
+ .needs_ip = 1,
+ .regs_offset = 0,
+ .spare0_offset = 0x1000,
+ .axi_offset = 0x1e00,
+ .spare_len = 64,
+ .eccbytes = 0,
+ .eccsize = 0,
};
static int __init mxcnd_probe(struct platform_device *pdev)
@@ -1242,22 +1299,31 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
if (nfc_is_v1()) {
- host->devtype_data = &imx21_nand_devtype_data;
if (cpu_is_mx21())
- host->irqpending_quirk = 1;
- host->regs = host->base + 0xe00;
- host->spare0 = host->base + 0x800;
- host->spare_len = 16;
- this->ecc.bytes = 3;
- host->eccsize = 1;
+ 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;
- host->regs = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- this->ecc.bytes = 9;
} else if (nfc_is_v3_2()) {
host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ if (host->devtype_data->regs_offset)
+ host->regs = host->base + host->devtype_data->regs_offset;
+ host->spare0 = host->base + host->devtype_data->spare0_offset;
+ if (host->devtype_data->axi_offset)
+ host->regs_axi = host->base + host->devtype_data->axi_offset;
+
+ this->ecc.bytes = host->devtype_data->eccbytes;
+ host->eccsize = host->devtype_data->eccsize;
+
+ this->select_chip = host->devtype_data->select_chip;
+ this->ecc.size = 512;
+ this->ecc.layout = host->devtype_data->ecclayout_512;
+
+ if (host->devtype_data->needs_ip) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
err = -ENODEV;
@@ -1268,15 +1334,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
err = -ENOMEM;
goto eirq;
}
- host->regs_axi = host->base + 0x1e00;
- host->spare0 = host->base + 0x1000;
- host->spare_len = 64;
- } else
- BUG();
-
- this->select_chip = host->devtype_data->select_chip;
- this->ecc.size = 512;
- this->ecc.layout = host->devtype_data->ecclayout_512;
+ }
if (pdata->hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 09/10] mtd: mxc_nand: implement device tree probing
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
This is tested on i.MX27.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Documentation/devicetree/bindings/mtd/mxc-nand.txt | 19 ++++
drivers/mtd/nand/mxc_nand.c | 116 ++++++++++++++++----
2 files changed, 115 insertions(+), 20 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mtd/mxc-nand.txt
diff --git a/Documentation/devicetree/bindings/mtd/mxc-nand.txt b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
new file mode 100644
index 0000000..b5833d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
@@ -0,0 +1,19 @@
+* Freescale's mxc_nand
+
+Required properties:
+- compatible: "fsl,imxXX-nand"
+- reg: address range of the nfc block
+- interrupts: irq to be used
+- nand-bus-width: see nand.txt
+- nand-ecc-mode: see nand.txt
+- nand-on-flash-bbt: see nand.txt
+
+Example:
+
+ nand@d8000000 {
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ nand-bus-width = <8>;
+ nand-ecc-mode = "hw";
+ };
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 81ffb9b..2e4b953 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -32,6 +32,8 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/completion.h>
+#include <linux/of_device.h>
+#include <linux/of_mtd.h>
#include <asm/mach/flash.h>
#include <mach/mxc_nand.h>
@@ -199,6 +201,7 @@ struct mxc_nand_host {
unsigned int buf_start;
const struct mxc_nand_devtype_data *devtype_data;
+ struct mxc_nand_platform_data pdata;
};
/* OOB placement block for use with hardware ecc generation */
@@ -268,7 +271,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
}
};
-static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
static int check_int_v3(struct mxc_nand_host *host)
{
@@ -1237,11 +1240,85 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.eccsize = 0,
};
+#ifdef CONFIG_OF_MTD
+static const struct of_device_id mxcnd_dt_ids[] = {
+ {
+ .compatible = "fsl,imx21-nand",
+ .data = &imx21_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx27-nand",
+ .data = &imx27_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx25-nand",
+ .data = &imx25_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx51-nand",
+ .data = &imx51_nand_devtype_data,
+ },
+ { /* sentinel */ }
+};
+
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ struct device_node *np = host->dev->of_node;
+ struct mxc_nand_platform_data *pdata = &host->pdata;
+ const struct of_device_id *of_id =
+ of_match_device(mxcnd_dt_ids, host->dev);
+ int buswidth;
+
+ if (!np)
+ return 1;
+
+ if (of_get_nand_ecc_mode(np) >= 0)
+ pdata->hw_ecc = 1;
+
+ pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
+
+ buswidth = of_get_nand_bus_width(np);
+ if (buswidth < 0)
+ return buswidth;
+
+ pdata->width = buswidth / 8;
+
+ host->devtype_data = of_id->data;
+
+ return 0;
+}
+#else
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ return 1;
+}
+#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_2()) {
+ host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ return 0;
+}
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
struct mtd_info *mtd;
- struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
struct mxc_nand_host *host;
struct resource *res;
int err = 0;
@@ -1298,17 +1375,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- 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_2()) {
- host->devtype_data = &imx51_nand_devtype_data;
- } else
- BUG();
+ err = mxcnd_probe_dt(host);
+ if (err > 0)
+ err = mxcnd_probe_pdata(host);
+ if (err < 0)
+ goto eirq;
if (host->devtype_data->regs_offset)
host->regs = host->base + host->devtype_data->regs_offset;
@@ -1336,7 +1407,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
}
- if (pdata->hw_ecc) {
+ if (host->pdata.hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
this->ecc.correct = host->devtype_data->correct_data;
@@ -1345,11 +1416,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->ecc.mode = NAND_ECC_SOFT;
}
- /* NAND bus width determines access funtions used by upper layer */
- if (pdata->width == 2)
+ /* NAND bus width determines access functions used by upper layer */
+ if (host->pdata.width == 2)
this->options |= NAND_BUSWIDTH_16;
- if (pdata->flash_bbt) {
+ if (host->pdata.flash_bbt) {
this->bbt_td = &bbt_main_descr;
this->bbt_md = &bbt_mirror_descr;
/* update flash based bbt */
@@ -1376,7 +1447,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
* cleared on i.MX21. Otherwise we can't read the interrupt status bit
* on this machine.
*/
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
disable_irq_nosync(host->irq);
host->devtype_data->irq_control(host, 1);
}
@@ -1409,8 +1480,12 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Register the partitions */
- mtd_device_parse_register(mtd, part_probes, NULL, pdata->parts,
- pdata->nr_parts);
+ mtd_device_parse_register(mtd, part_probes,
+ &(struct mtd_part_parser_data){
+ .of_node = pdev->dev.of_node,
+ },
+ host->pdata.parts,
+ host->pdata.nr_parts);
platform_set_drvdata(pdev, host);
@@ -1452,6 +1527,7 @@ static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mxcnd_dt_ids),
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 09/10] mtd: mxc_nand: implement device tree probing
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
This is tested on i.MX27.
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
Documentation/devicetree/bindings/mtd/mxc-nand.txt | 19 ++++
drivers/mtd/nand/mxc_nand.c | 116 ++++++++++++++++----
2 files changed, 115 insertions(+), 20 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mtd/mxc-nand.txt
diff --git a/Documentation/devicetree/bindings/mtd/mxc-nand.txt b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
new file mode 100644
index 0000000..b5833d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
@@ -0,0 +1,19 @@
+* Freescale's mxc_nand
+
+Required properties:
+- compatible: "fsl,imxXX-nand"
+- reg: address range of the nfc block
+- interrupts: irq to be used
+- nand-bus-width: see nand.txt
+- nand-ecc-mode: see nand.txt
+- nand-on-flash-bbt: see nand.txt
+
+Example:
+
+ nand at d8000000 {
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ nand-bus-width = <8>;
+ nand-ecc-mode = "hw";
+ };
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 81ffb9b..2e4b953 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -32,6 +32,8 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/completion.h>
+#include <linux/of_device.h>
+#include <linux/of_mtd.h>
#include <asm/mach/flash.h>
#include <mach/mxc_nand.h>
@@ -199,6 +201,7 @@ struct mxc_nand_host {
unsigned int buf_start;
const struct mxc_nand_devtype_data *devtype_data;
+ struct mxc_nand_platform_data pdata;
};
/* OOB placement block for use with hardware ecc generation */
@@ -268,7 +271,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
}
};
-static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
static int check_int_v3(struct mxc_nand_host *host)
{
@@ -1237,11 +1240,85 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.eccsize = 0,
};
+#ifdef CONFIG_OF_MTD
+static const struct of_device_id mxcnd_dt_ids[] = {
+ {
+ .compatible = "fsl,imx21-nand",
+ .data = &imx21_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx27-nand",
+ .data = &imx27_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx25-nand",
+ .data = &imx25_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx51-nand",
+ .data = &imx51_nand_devtype_data,
+ },
+ { /* sentinel */ }
+};
+
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ struct device_node *np = host->dev->of_node;
+ struct mxc_nand_platform_data *pdata = &host->pdata;
+ const struct of_device_id *of_id =
+ of_match_device(mxcnd_dt_ids, host->dev);
+ int buswidth;
+
+ if (!np)
+ return 1;
+
+ if (of_get_nand_ecc_mode(np) >= 0)
+ pdata->hw_ecc = 1;
+
+ pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
+
+ buswidth = of_get_nand_bus_width(np);
+ if (buswidth < 0)
+ return buswidth;
+
+ pdata->width = buswidth / 8;
+
+ host->devtype_data = of_id->data;
+
+ return 0;
+}
+#else
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ return 1;
+}
+#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_2()) {
+ host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ return 0;
+}
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
struct mtd_info *mtd;
- struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
struct mxc_nand_host *host;
struct resource *res;
int err = 0;
@@ -1298,17 +1375,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- 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_2()) {
- host->devtype_data = &imx51_nand_devtype_data;
- } else
- BUG();
+ err = mxcnd_probe_dt(host);
+ if (err > 0)
+ err = mxcnd_probe_pdata(host);
+ if (err < 0)
+ goto eirq;
if (host->devtype_data->regs_offset)
host->regs = host->base + host->devtype_data->regs_offset;
@@ -1336,7 +1407,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
}
- if (pdata->hw_ecc) {
+ if (host->pdata.hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
this->ecc.correct = host->devtype_data->correct_data;
@@ -1345,11 +1416,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->ecc.mode = NAND_ECC_SOFT;
}
- /* NAND bus width determines access funtions used by upper layer */
- if (pdata->width == 2)
+ /* NAND bus width determines access functions used by upper layer */
+ if (host->pdata.width == 2)
this->options |= NAND_BUSWIDTH_16;
- if (pdata->flash_bbt) {
+ if (host->pdata.flash_bbt) {
this->bbt_td = &bbt_main_descr;
this->bbt_md = &bbt_mirror_descr;
/* update flash based bbt */
@@ -1376,7 +1447,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
* cleared on i.MX21. Otherwise we can't read the interrupt status bit
* on this machine.
*/
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
disable_irq_nosync(host->irq);
host->devtype_data->irq_control(host, 1);
}
@@ -1409,8 +1480,12 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Register the partitions */
- mtd_device_parse_register(mtd, part_probes, NULL, pdata->parts,
- pdata->nr_parts);
+ mtd_device_parse_register(mtd, part_probes,
+ &(struct mtd_part_parser_data){
+ .of_node = pdev->dev.of_node,
+ },
+ host->pdata.parts,
+ host->pdata.nr_parts);
platform_set_drvdata(pdev, host);
@@ -1452,6 +1527,7 @@ static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mxcnd_dt_ids),
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 09/10] mtd: mxc_nand: implement device tree probing
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
This is tested on i.MX27.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Documentation/devicetree/bindings/mtd/mxc-nand.txt | 19 ++++
drivers/mtd/nand/mxc_nand.c | 116 ++++++++++++++++----
2 files changed, 115 insertions(+), 20 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mtd/mxc-nand.txt
diff --git a/Documentation/devicetree/bindings/mtd/mxc-nand.txt b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
new file mode 100644
index 0000000..b5833d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/mxc-nand.txt
@@ -0,0 +1,19 @@
+* Freescale's mxc_nand
+
+Required properties:
+- compatible: "fsl,imxXX-nand"
+- reg: address range of the nfc block
+- interrupts: irq to be used
+- nand-bus-width: see nand.txt
+- nand-ecc-mode: see nand.txt
+- nand-on-flash-bbt: see nand.txt
+
+Example:
+
+ nand@d8000000 {
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ nand-bus-width = <8>;
+ nand-ecc-mode = "hw";
+ };
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 81ffb9b..2e4b953 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -32,6 +32,8 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/completion.h>
+#include <linux/of_device.h>
+#include <linux/of_mtd.h>
#include <asm/mach/flash.h>
#include <mach/mxc_nand.h>
@@ -199,6 +201,7 @@ struct mxc_nand_host {
unsigned int buf_start;
const struct mxc_nand_devtype_data *devtype_data;
+ struct mxc_nand_platform_data pdata;
};
/* OOB placement block for use with hardware ecc generation */
@@ -268,7 +271,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
}
};
-static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
static int check_int_v3(struct mxc_nand_host *host)
{
@@ -1237,11 +1240,85 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
.eccsize = 0,
};
+#ifdef CONFIG_OF_MTD
+static const struct of_device_id mxcnd_dt_ids[] = {
+ {
+ .compatible = "fsl,imx21-nand",
+ .data = &imx21_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx27-nand",
+ .data = &imx27_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx25-nand",
+ .data = &imx25_nand_devtype_data,
+ }, {
+ .compatible = "fsl,imx51-nand",
+ .data = &imx51_nand_devtype_data,
+ },
+ { /* sentinel */ }
+};
+
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ struct device_node *np = host->dev->of_node;
+ struct mxc_nand_platform_data *pdata = &host->pdata;
+ const struct of_device_id *of_id =
+ of_match_device(mxcnd_dt_ids, host->dev);
+ int buswidth;
+
+ if (!np)
+ return 1;
+
+ if (of_get_nand_ecc_mode(np) >= 0)
+ pdata->hw_ecc = 1;
+
+ pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
+
+ buswidth = of_get_nand_bus_width(np);
+ if (buswidth < 0)
+ return buswidth;
+
+ pdata->width = buswidth / 8;
+
+ host->devtype_data = of_id->data;
+
+ return 0;
+}
+#else
+static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
+{
+ return 1;
+}
+#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_2()) {
+ host->devtype_data = &imx51_nand_devtype_data;
+ } else
+ BUG();
+
+ return 0;
+}
+
static int __init mxcnd_probe(struct platform_device *pdev)
{
struct nand_chip *this;
struct mtd_info *mtd;
- struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
struct mxc_nand_host *host;
struct resource *res;
int err = 0;
@@ -1298,17 +1375,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
host->main_area0 = host->base;
- 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_2()) {
- host->devtype_data = &imx51_nand_devtype_data;
- } else
- BUG();
+ err = mxcnd_probe_dt(host);
+ if (err > 0)
+ err = mxcnd_probe_pdata(host);
+ if (err < 0)
+ goto eirq;
if (host->devtype_data->regs_offset)
host->regs = host->base + host->devtype_data->regs_offset;
@@ -1336,7 +1407,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
}
- if (pdata->hw_ecc) {
+ if (host->pdata.hw_ecc) {
this->ecc.calculate = mxc_nand_calculate_ecc;
this->ecc.hwctl = mxc_nand_enable_hwecc;
this->ecc.correct = host->devtype_data->correct_data;
@@ -1345,11 +1416,11 @@ static int __init mxcnd_probe(struct platform_device *pdev)
this->ecc.mode = NAND_ECC_SOFT;
}
- /* NAND bus width determines access funtions used by upper layer */
- if (pdata->width == 2)
+ /* NAND bus width determines access functions used by upper layer */
+ if (host->pdata.width == 2)
this->options |= NAND_BUSWIDTH_16;
- if (pdata->flash_bbt) {
+ if (host->pdata.flash_bbt) {
this->bbt_td = &bbt_main_descr;
this->bbt_md = &bbt_mirror_descr;
/* update flash based bbt */
@@ -1376,7 +1447,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
* cleared on i.MX21. Otherwise we can't read the interrupt status bit
* on this machine.
*/
- if (host->irqpending_quirk) {
+ if (host->devtype_data->irqpending_quirk) {
disable_irq_nosync(host->irq);
host->devtype_data->irq_control(host, 1);
}
@@ -1409,8 +1480,12 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Register the partitions */
- mtd_device_parse_register(mtd, part_probes, NULL, pdata->parts,
- pdata->nr_parts);
+ mtd_device_parse_register(mtd, part_probes,
+ &(struct mtd_part_parser_data){
+ .of_node = pdev->dev.of_node,
+ },
+ host->pdata.parts,
+ host->pdata.nr_parts);
platform_set_drvdata(pdev, host);
@@ -1452,6 +1527,7 @@ static struct platform_driver mxcnd_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mxcnd_dt_ids),
},
.remove = __devexit_p(mxcnd_remove),
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 10/10] ARM: imx: add mxc_nand to imx27 device tree
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-23 9:23 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boot/dts/imx27.dtsi | 9 +++++++++
arch/arm/mach-imx/imx27-dt.c | 1 +
2 files changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index bc5e7d5..5a41b8a 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -213,5 +213,14 @@
status = "disabled";
};
};
+ nand@d8000000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ status = "disabled";
+ };
};
};
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index 861ceb8..9853319 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -29,6 +29,7 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI2_BASE_ADDR, "imx27-cspi.1", NULL),
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI3_BASE_ADDR, "imx27-cspi.2", NULL),
OF_DEV_AUXDATA("fsl,imx27-wdt", MX27_WDOG_BASE_ADDR, "imx2-wdt.0", NULL),
+ OF_DEV_AUXDATA("fsl,imx27-nand", MX27_NFC_BASE_ADDR, "mxc_nand.0", NULL),
{ /* sentinel */ }
};
--
1.7.10
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 10/10] ARM: imx: add mxc_nand to imx27 device tree
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
arch/arm/boot/dts/imx27.dtsi | 9 +++++++++
arch/arm/mach-imx/imx27-dt.c | 1 +
2 files changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index bc5e7d5..5a41b8a 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -213,5 +213,14 @@
status = "disabled";
};
};
+ nand at d8000000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ status = "disabled";
+ };
};
};
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index 861ceb8..9853319 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -29,6 +29,7 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI2_BASE_ADDR, "imx27-cspi.1", NULL),
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI3_BASE_ADDR, "imx27-cspi.2", NULL),
OF_DEV_AUXDATA("fsl,imx27-wdt", MX27_WDOG_BASE_ADDR, "imx2-wdt.0", NULL),
+ OF_DEV_AUXDATA("fsl,imx27-nand", MX27_NFC_BASE_ADDR, "mxc_nand.0", NULL),
{ /* sentinel */ }
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH 10/10] ARM: imx: add mxc_nand to imx27 device tree
@ 2012-04-23 9:23 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-23 9:23 UTC (permalink / raw)
To: linux-mtd; +Cc: devicetree-discuss, linux-arm-kernel, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
arch/arm/boot/dts/imx27.dtsi | 9 +++++++++
arch/arm/mach-imx/imx27-dt.c | 1 +
2 files changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index bc5e7d5..5a41b8a 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -213,5 +213,14 @@
status = "disabled";
};
};
+ nand@d8000000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ compatible = "fsl,imx27-nand";
+ reg = <0xd8000000 0x1000>;
+ interrupts = <29>;
+ status = "disabled";
+ };
};
};
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index 861ceb8..9853319 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -29,6 +29,7 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI2_BASE_ADDR, "imx27-cspi.1", NULL),
OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI3_BASE_ADDR, "imx27-cspi.2", NULL),
OF_DEV_AUXDATA("fsl,imx27-wdt", MX27_WDOG_BASE_ADDR, "imx2-wdt.0", NULL),
+ OF_DEV_AUXDATA("fsl,imx27-nand", MX27_NFC_BASE_ADDR, "mxc_nand.0", NULL),
{ /* sentinel */ }
};
--
1.7.10
^ permalink raw reply related [flat|nested] 51+ messages in thread
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
2012-04-23 9:22 ` Uwe Kleine-König
(?)
@ 2012-04-28 12:20 ` Artem Bityutskiy
-1 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-28 12:20 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
[-- Attachment #1.1: Type: text/plain, Size: 1543 bytes --]
On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> Hello,
>
> this series aims to be able to probe mxc_nand devices via device tree.
> Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> the case that the device is not probed via device tree.
>
> I split this conversion in several patches to allow easier review. IMHO
> it makes sense to keep this splitting for an eventual bisection.
>
> This is tested on an i.MX27 based machine and works fine including
> passing of partition data.
Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
one checkpatch.pl warning:
WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#69: FILE: drivers/mtd/nand/mxc_nand.c:274:
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
Also there are still several sparse warnings, e.g.
+drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
And you added few gcc warnings, e.g.:
+drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
Would you take a look and _possibly_ (if makes sense, I did not verify)
send incremental fixes?
--
Best Regards,
Artem Bityutskiy
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-28 12:20 ` Artem Bityutskiy
0 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-28 12:20 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-K?nig wrote:
> Hello,
>
> this series aims to be able to probe mxc_nand devices via device tree.
> Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> the case that the device is not probed via device tree.
>
> I split this conversion in several patches to allow easier review. IMHO
> it makes sense to keep this splitting for an eventual bisection.
>
> This is tested on an i.MX27 based machine and works fine including
> passing of partition data.
Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
one checkpatch.pl warning:
WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#69: FILE: drivers/mtd/nand/mxc_nand.c:274:
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
Also there are still several sparse warnings, e.g.
+drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
And you added few gcc warnings, e.g.:
+drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
Would you take a look and _possibly_ (if makes sense, I did not verify)
send incremental fixes?
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120428/4f7f8a3e/attachment.sig>
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-28 12:20 ` Artem Bityutskiy
0 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-28 12:20 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss, linux-mtd, kernel, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]
On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> Hello,
>
> this series aims to be able to probe mxc_nand devices via device tree.
> Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> the case that the device is not probed via device tree.
>
> I split this conversion in several patches to allow easier review. IMHO
> it makes sense to keep this splitting for an eventual bisection.
>
> This is tested on an i.MX27 based machine and works fine including
> passing of partition data.
Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
one checkpatch.pl warning:
WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#69: FILE: drivers/mtd/nand/mxc_nand.c:274:
+static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
Also there are still several sparse warnings, e.g.
+drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
+drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
And you added few gcc warnings, e.g.:
+drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
Would you take a look and _possibly_ (if makes sense, I did not verify)
send incremental fixes?
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
2012-04-28 12:20 ` Artem Bityutskiy
(?)
@ 2012-04-29 9:27 ` Uwe Kleine-König
-1 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-29 9:27 UTC (permalink / raw)
To: Artem Bityutskiy
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Hello Artem,
On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> > Hello,
> >
> > this series aims to be able to probe mxc_nand devices via device tree.
> > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > the case that the device is not probed via device tree.
> >
> > I split this conversion in several patches to allow easier review. IMHO
> > it makes sense to keep this splitting for an eventual bisection.
> >
> > This is tested on an i.MX27 based machine and works fine including
> > passing of partition data.
>
> Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> one checkpatch.pl warning:
>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
I noticed that, too. This is not new though and as
mtd_device_parse_register takes a const char **types applying
checkpatch's advice would yield another warning. But probably fixing
both would work. I wouldn't address this as part of this series.
> Also there are still several sparse warnings, e.g.
>
> +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
>
> And you added few gcc warnings, e.g.:
>
> +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
This is the same problem, i.e. casting away several consts. Hmm, and for
me neither gcc nor sparse provide that warning but I wonder why. At some
point I saw this warning, so I sent a patch:
http://mid.gmane.org/1335171381-24869-1-git-send-email-u.kleine-koenig@pengutronix.de
(I developed my series on top of that and rebased on linus/master for
posting.) Sparse only tells me:
include/asm-generic/bitops/ffs.h:19:23: warning: right shift by bigger than source value
(using gcc 4.3.2 and sparse (from Debian) 0.4.3+20110419-1)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-29 9:27 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-29 9:27 UTC (permalink / raw)
To: linux-arm-kernel
Hello Artem,
On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-K?nig wrote:
> > Hello,
> >
> > this series aims to be able to probe mxc_nand devices via device tree.
> > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > the case that the device is not probed via device tree.
> >
> > I split this conversion in several patches to allow easier review. IMHO
> > it makes sense to keep this splitting for an eventual bisection.
> >
> > This is tested on an i.MX27 based machine and works fine including
> > passing of partition data.
>
> Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> one checkpatch.pl warning:
>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
I noticed that, too. This is not new though and as
mtd_device_parse_register takes a const char **types applying
checkpatch's advice would yield another warning. But probably fixing
both would work. I wouldn't address this as part of this series.
> Also there are still several sparse warnings, e.g.
>
> +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
>
> And you added few gcc warnings, e.g.:
>
> +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
This is the same problem, i.e. casting away several consts. Hmm, and for
me neither gcc nor sparse provide that warning but I wonder why. At some
point I saw this warning, so I sent a patch:
http://mid.gmane.org/1335171381-24869-1-git-send-email-u.kleine-koenig at pengutronix.de
(I developed my series on top of that and rebased on linus/master for
posting.) Sparse only tells me:
include/asm-generic/bitops/ffs.h:19:23: warning: right shift by bigger than source value
(using gcc 4.3.2 and sparse (from Debian) 0.4.3+20110419-1)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-29 9:27 ` Uwe Kleine-König
0 siblings, 0 replies; 51+ messages in thread
From: Uwe Kleine-König @ 2012-04-29 9:27 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: devicetree-discuss, linux-mtd, kernel, linux-arm-kernel
Hello Artem,
On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> > Hello,
> >
> > this series aims to be able to probe mxc_nand devices via device tree.
> > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > the case that the device is not probed via device tree.
> >
> > I split this conversion in several patches to allow easier review. IMHO
> > it makes sense to keep this splitting for an eventual bisection.
> >
> > This is tested on an i.MX27 based machine and works fine including
> > passing of partition data.
>
> Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> one checkpatch.pl warning:
>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
I noticed that, too. This is not new though and as
mtd_device_parse_register takes a const char **types applying
checkpatch's advice would yield another warning. But probably fixing
both would work. I wouldn't address this as part of this series.
> Also there are still several sparse warnings, e.g.
>
> +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
>
> And you added few gcc warnings, e.g.:
>
> +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
This is the same problem, i.e. casting away several consts. Hmm, and for
me neither gcc nor sparse provide that warning but I wonder why. At some
point I saw this warning, so I sent a patch:
http://mid.gmane.org/1335171381-24869-1-git-send-email-u.kleine-koenig@pengutronix.de
(I developed my series on top of that and rebased on linus/master for
posting.) Sparse only tells me:
include/asm-generic/bitops/ffs.h:19:23: warning: right shift by bigger than source value
(using gcc 4.3.2 and sparse (from Debian) 0.4.3+20110419-1)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 51+ messages in thread
[parent not found: <20120429092701.GS20039-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
2012-04-29 9:27 ` Uwe Kleine-König
(?)
@ 2012-04-29 11:10 ` Artem Bityutskiy
-1 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-29 11:10 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
[-- Attachment #1.1: Type: text/plain, Size: 2407 bytes --]
On Sun, 2012-04-29 at 11:27 +0200, Uwe Kleine-König wrote:
> Hello Artem,
>
> On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> > On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> > > Hello,
> > >
> > > this series aims to be able to probe mxc_nand devices via device tree.
> > > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > > the case that the device is not probed via device tree.
> > >
> > > I split this conversion in several patches to allow easier review. IMHO
> > > it makes sense to keep this splitting for an eventual bisection.
> > >
> > > This is tested on an i.MX27 based machine and works fine including
> > > passing of partition data.
> >
> > Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> > one checkpatch.pl warning:
> >
> > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> > #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> > +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
> I noticed that, too. This is not new though and as
> mtd_device_parse_register takes a const char **types applying
> checkpatch's advice would yield another warning. But probably fixing
> both would work. I wouldn't address this as part of this series.
>
> > Also there are still several sparse warnings, e.g.
> >
> > +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
> >
> > And you added few gcc warnings, e.g.:
> >
> > +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
> This is the same problem, i.e. casting away several consts. Hmm, and for
> me neither gcc nor sparse provide that warning but I wonder why. At some
> point I saw this warning, so I sent a patch:
Try to compile with gcc 4.6 - you can download it from here:
ftp://ftp.kernel.org/pub/tools/crosstool/files/bin/
I do not know whether it produces good binaries or not, but for
compile-testing it is much better than ancient gcc 4.3.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-29 11:10 ` Artem Bityutskiy
0 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-29 11:10 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, 2012-04-29 at 11:27 +0200, Uwe Kleine-K?nig wrote:
> Hello Artem,
>
> On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> > On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-K?nig wrote:
> > > Hello,
> > >
> > > this series aims to be able to probe mxc_nand devices via device tree.
> > > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > > the case that the device is not probed via device tree.
> > >
> > > I split this conversion in several patches to allow easier review. IMHO
> > > it makes sense to keep this splitting for an eventual bisection.
> > >
> > > This is tested on an i.MX27 based machine and works fine including
> > > passing of partition data.
> >
> > Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> > one checkpatch.pl warning:
> >
> > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> > #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> > +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
> I noticed that, too. This is not new though and as
> mtd_device_parse_register takes a const char **types applying
> checkpatch's advice would yield another warning. But probably fixing
> both would work. I wouldn't address this as part of this series.
>
> > Also there are still several sparse warnings, e.g.
> >
> > +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
> >
> > And you added few gcc warnings, e.g.:
> >
> > +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
> This is the same problem, i.e. casting away several consts. Hmm, and for
> me neither gcc nor sparse provide that warning but I wonder why. At some
> point I saw this warning, so I sent a patch:
Try to compile with gcc 4.6 - you can download it from here:
ftp://ftp.kernel.org/pub/tools/crosstool/files/bin/
I do not know whether it produces good binaries or not, but for
compile-testing it is much better than ancient gcc 4.3.
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120429/8c14338f/attachment.sig>
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH 00/10] allow mxc_nand to be probed via device tree
@ 2012-04-29 11:10 ` Artem Bityutskiy
0 siblings, 0 replies; 51+ messages in thread
From: Artem Bityutskiy @ 2012-04-29 11:10 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-discuss, linux-mtd, kernel, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 2407 bytes --]
On Sun, 2012-04-29 at 11:27 +0200, Uwe Kleine-König wrote:
> Hello Artem,
>
> On Sat, Apr 28, 2012 at 03:20:54PM +0300, Artem Bityutskiy wrote:
> > On Mon, 2012-04-23 at 11:22 +0200, Uwe Kleine-König wrote:
> > > Hello,
> > >
> > > this series aims to be able to probe mxc_nand devices via device tree.
> > > Most of its patches reorganize the driver to only use cpu_is_mxYZ for
> > > the case that the device is not probed via device tree.
> > >
> > > I split this conversion in several patches to allow easier review. IMHO
> > > it makes sense to keep this splitting for an eventual bisection.
> > >
> > > This is tested on an i.MX27 based machine and works fine including
> > > passing of partition data.
> >
> > Applied all 11 patches from your git tree to l2-mtd.git. Note, you have
> > one checkpatch.pl warning:
> >
> > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> > #69: FILE: drivers/mtd/nand/mxc_nand.c:274:
> > +static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
> I noticed that, too. This is not new though and as
> mtd_device_parse_register takes a const char **types applying
> checkpatch's advice would yield another warning. But probably fixing
> both would work. I wouldn't address this as part of this series.
>
> > Also there are still several sparse warnings, e.g.
> >
> > +drivers/mtd/nand/mxc_nand.c:1249:26: warning: incorrect type in initializer (different modifiers) [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: expected void *data [sparse]
> > +drivers/mtd/nand/mxc_nand.c:1249:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
> >
> > And you added few gcc warnings, e.g.:
> >
> > +drivers/mtd/nand/mxc_nand.c:1252:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
> This is the same problem, i.e. casting away several consts. Hmm, and for
> me neither gcc nor sparse provide that warning but I wonder why. At some
> point I saw this warning, so I sent a patch:
Try to compile with gcc 4.6 - you can download it from here:
ftp://ftp.kernel.org/pub/tools/crosstool/files/bin/
I do not know whether it produces good binaries or not, but for
compile-testing it is much better than ancient gcc 4.3.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 51+ messages in thread