* [PATCH 1/3] mtd: nand: davinci: reuse driver for Keystone arch
2013-11-20 16:24 [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Ivan Khoronzhuk
@ 2013-11-20 16:24 ` Ivan Khoronzhuk
2013-11-23 18:15 ` Arnd Bergmann
2013-11-20 16:24 ` [PATCH 2/3] mtd: nand: davinci: don't set timings if AEMIF is used Ivan Khoronzhuk
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Ivan Khoronzhuk @ 2013-11-20 16:24 UTC (permalink / raw)
To: linux-arm-kernel
The Keystone arch has compatible nand device, so reuse it.
In case with Keystone it depends on TI_AEMIF because AEMIF
driver is responsible to set timings.
See http://www.ti.com/lit/ug/sprugz3a/sprugz3a.pdf
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com>
---
.../devicetree/bindings/mtd/davinci-nand.txt | 8 +++++---
drivers/mtd/nand/Kconfig | 6 +++---
drivers/mtd/nand/davinci_nand.c | 1 +
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/mtd/davinci-nand.txt b/Documentation/devicetree/bindings/mtd/davinci-nand.txt
index befaa5b..cfb18ab 100644
--- a/Documentation/devicetree/bindings/mtd/davinci-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/davinci-nand.txt
@@ -1,14 +1,16 @@
-Device tree bindings for Texas instruments Davinci NAND controller
+Device tree bindings for Texas instruments Davinci/Keystone NAND controller
-This file provides information, what the device node for the davinci NAND
-interface contains.
+This file provides information, what the device node for the davinci/keystone
+NAND interface contains.
Documentation:
Davinci DM646x - http://www.ti.com/lit/ug/sprueq7c/sprueq7c.pdf
+Kestone - http://www.ti.com/lit/ug/sprugz3a/sprugz3a.pdf
Required properties:
- compatible: "ti,davinci-nand"
+ "ti,keystone-nand"
- reg: Contains 2 offset/length values:
- offset and length for the access window.
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index d885298..8bf69c7 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -492,11 +492,11 @@ config MTD_NAND_SH_FLCTL
for NAND Flash using FLCTL.
config MTD_NAND_DAVINCI
- tristate "Support NAND on DaVinci SoC"
- depends on ARCH_DAVINCI
+ tristate "Support NAND on DaVinci/Keystone SoC"
+ depends on ARCH_DAVINCI || (ARCH_KEYSTONE && TI_AEMIF)
help
Enable the driver for NAND flash chips on Texas Instruments
- DaVinci processors.
+ DaVinci/Keystone processors.
config MTD_NAND_TXX9NDFMC
tristate "NAND Flash support for TXx9 SoC"
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index f7b21b8..8459720 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -523,6 +523,7 @@ static struct nand_ecclayout hwecc4_2048 __initconst = {
#if defined(CONFIG_OF)
static const struct of_device_id davinci_nand_of_match[] = {
{.compatible = "ti,davinci-nand", },
+ {.compatible = "ti,keystone-nand", },
{},
};
MODULE_DEVICE_TABLE(of, davinci_nand_of_match);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 1/3] mtd: nand: davinci: reuse driver for Keystone arch
2013-11-20 16:24 ` [PATCH 1/3] mtd: nand: davinci: reuse " Ivan Khoronzhuk
@ 2013-11-23 18:15 ` Arnd Bergmann
2013-11-25 15:57 ` ivan.khoronzhuk
0 siblings, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2013-11-23 18:15 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday 20 November 2013, Ivan Khoronzhuk wrote:
> --- a/drivers/mtd/nand/davinci_nand.c
> +++ b/drivers/mtd/nand/davinci_nand.c
> @@ -523,6 +523,7 @@ static struct nand_ecclayout hwecc4_2048 __initconst = {
> #if defined(CONFIG_OF)
> static const struct of_device_id davinci_nand_of_match[] = {
> {.compatible = "ti,davinci-nand", },
> + {.compatible = "ti,keystone-nand", },
> {},
> };
> MODULE_DEVICE_TABLE(of, davinci_nand_of_match);
Same comment as for the watchdog driver: when the devices are actually compatible,
the driver does not need to know the new string, the preferred method is to
set both strings from the .dts file.
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/3] mtd: nand: davinci: reuse driver for Keystone arch
2013-11-23 18:15 ` Arnd Bergmann
@ 2013-11-25 15:57 ` ivan.khoronzhuk
0 siblings, 0 replies; 9+ messages in thread
From: ivan.khoronzhuk @ 2013-11-25 15:57 UTC (permalink / raw)
To: linux-arm-kernel
On 11/23/2013 08:15 PM, Arnd Bergmann wrote:
> On Wednesday 20 November 2013, Ivan Khoronzhuk wrote:
>> --- a/drivers/mtd/nand/davinci_nand.c
>> +++ b/drivers/mtd/nand/davinci_nand.c
>> @@ -523,6 +523,7 @@ static struct nand_ecclayout hwecc4_2048 __initconst = {
>> #if defined(CONFIG_OF)
>> static const struct of_device_id davinci_nand_of_match[] = {
>> {.compatible = "ti,davinci-nand", },
>> + {.compatible = "ti,keystone-nand", },
>> {},
>> };
>> MODULE_DEVICE_TABLE(of, davinci_nand_of_match);
>
> Same comment as for the watchdog driver: when the devices are actually compatible,
> the driver does not need to know the new string, the preferred method is to
> set both strings from the .dts file.
>
> Arnd
>
Thanks. I'll correct it.
--
Regards,
Ivan Khoronzhuk
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] mtd: nand: davinci: don't set timings if AEMIF is used
2013-11-20 16:24 [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Ivan Khoronzhuk
2013-11-20 16:24 ` [PATCH 1/3] mtd: nand: davinci: reuse " Ivan Khoronzhuk
@ 2013-11-20 16:24 ` Ivan Khoronzhuk
2013-11-20 16:24 ` [PATCH 3/3] mtd: nand: davinci: don't request AEMIF address range Ivan Khoronzhuk
2013-11-20 20:17 ` [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Grygorii Strashko
3 siblings, 0 replies; 9+ messages in thread
From: Ivan Khoronzhuk @ 2013-11-20 16:24 UTC (permalink / raw)
To: linux-arm-kernel
The problem that the set timings code contains the call of Davinci
platform function davinci_aemif_setup_timing() which is not
accessible if kernel is built for Keystone only.
The Keysone platform is going to use TI AEMIF driver.
If TI AEMIF is used we don't need to set timings and bus width.
It is done by AEMIF driver (drivers/memory/ti-aemfi.c).
The timings code has to be removed together with Davinci aemif
platform code (aemif.c), once Davinci will be converted to DT and use
ti-aemif.c driver.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com>
---
drivers/mtd/nand/davinci_nand.c | 48 +++++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 8459720..e904364 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -605,6 +605,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
int ret;
uint32_t val;
nand_ecc_modes_t ecc_mode;
+ bool aemif = IS_ENABLED(CONFIG_TI_AEMIF);
pdata = nand_davinci_get_pdata(pdev);
if (IS_ERR(pdata))
@@ -741,25 +742,38 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
}
/*
- * Setup Async configuration register in case we did not boot from
- * NAND and so bootloader did not bother to set it up.
+ * TODO:
+ * This is temp solution to support Davinci platform and it has to be
+ * removed once Davinci will be updated to use ti-aemif.c driver.
*/
- val = davinci_nand_readl(info, A1CR_OFFSET + info->core_chipsel * 4);
-
- /* Extended Wait is not valid and Select Strobe mode is not used */
- val &= ~(ACR_ASIZE_MASK | ACR_EW_MASK | ACR_SS_MASK);
- if (info->chip.options & NAND_BUSWIDTH_16)
- val |= 0x1;
-
- davinci_nand_writel(info, A1CR_OFFSET + info->core_chipsel * 4, val);
+ if (!aemif) {
+ /*
+ * Setup Async configuration register in case we did not boot
+ * from NAND and so bootloader did not bother to set it up.
+ */
+ val = davinci_nand_readl(info, A1CR_OFFSET +
+ info->core_chipsel * 4);
- ret = 0;
- if (info->timing)
- ret = davinci_aemif_setup_timing(info->timing, info->base,
- info->core_chipsel);
- if (ret < 0) {
- dev_dbg(&pdev->dev, "NAND timing values setup fail\n");
- goto err;
+ /*
+ * Extended Wait is not valid and Select Strobe mode is not
+ * used
+ */
+ val &= ~(ACR_ASIZE_MASK | ACR_EW_MASK | ACR_SS_MASK);
+ if (info->chip.options & NAND_BUSWIDTH_16)
+ val |= 0x1;
+
+ davinci_nand_writel(info, A1CR_OFFSET +
+ info->core_chipsel * 4, val);
+
+ ret = 0;
+ if (info->timing)
+ ret = davinci_aemif_setup_timing(info->timing,
+ info->base,
+ info->core_chipsel);
+ if (ret < 0) {
+ dev_dbg(&pdev->dev, "NAND timing values setup fail\n");
+ goto err;
+ }
}
spin_lock_irq(&davinci_nand_lock);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/3] mtd: nand: davinci: don't request AEMIF address range
2013-11-20 16:24 [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Ivan Khoronzhuk
2013-11-20 16:24 ` [PATCH 1/3] mtd: nand: davinci: reuse " Ivan Khoronzhuk
2013-11-20 16:24 ` [PATCH 2/3] mtd: nand: davinci: don't set timings if AEMIF is used Ivan Khoronzhuk
@ 2013-11-20 16:24 ` Ivan Khoronzhuk
2013-11-20 20:17 ` [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Grygorii Strashko
3 siblings, 0 replies; 9+ messages in thread
From: Ivan Khoronzhuk @ 2013-11-20 16:24 UTC (permalink / raw)
To: linux-arm-kernel
The TI AEMIF driver registers are used to setup timings for each chip
select. The same registers range is used to setup NAND settings.
The AEMIF and NAND drivers not use the same registers in this range.
In case with TI AEMIF driver, the memory address range is requested
already by AEMIF, so we cannot request it twice, just ioremap.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/mtd/nand/davinci_nand.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index e904364..aa30708 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -638,9 +638,11 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);
- base = devm_ioremap_resource(&pdev->dev, res2);
- if (IS_ERR(base))
- return PTR_ERR(base);
+ base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
+ if (!base) {
+ dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
+ return -EADDRNOTAVAIL;
+ }
info->dev = &pdev->dev;
info->base = base;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 0/3] Reuse davinci-nand driver for Keystone arch
2013-11-20 16:24 [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Ivan Khoronzhuk
` (2 preceding siblings ...)
2013-11-20 16:24 ` [PATCH 3/3] mtd: nand: davinci: don't request AEMIF address range Ivan Khoronzhuk
@ 2013-11-20 20:17 ` Grygorii Strashko
2013-11-20 20:33 ` Santosh Shilimkar
3 siblings, 1 reply; 9+ messages in thread
From: Grygorii Strashko @ 2013-11-20 20:17 UTC (permalink / raw)
To: linux-arm-kernel
On 11/20/2013 06:24 PM, Ivan Khoronzhuk wrote:
> This series contains updates of Davinci nand driver, in order to be
> reused for Keystone platform.
>
> Depends on:
> - Davinci nand driver fixes and updates:
> https://lkml.org/lkml/2013/11/20/271
^^^^ I suggest to merge this series with above one as it
should not break anything.
>
> - Introduce AEMIF driver for Davinci/Keystone archs:
> http://lkml.org/lkml/2013/11/11/352
>
> V1:
> https://lkml.org/lkml/2013/11/11/352
>
> Ivan Khoronzhuk (3):
> mtd: nand: davinci: reuse driver for Keystone arch
> mtd: nand: davinci: don't set timings if AEMIF is used
> mtd: nand: davinci: don't request AEMIF address range
For patches:
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
>
> .../devicetree/bindings/mtd/davinci-nand.txt | 8 +--
> drivers/mtd/nand/Kconfig | 6 +--
> drivers/mtd/nand/davinci_nand.c | 57 +++++++++++++-------
> 3 files changed, 45 insertions(+), 26 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 0/3] Reuse davinci-nand driver for Keystone arch
2013-11-20 20:17 ` [PATCH 0/3] Reuse davinci-nand driver for Keystone arch Grygorii Strashko
@ 2013-11-20 20:33 ` Santosh Shilimkar
2013-11-20 20:38 ` ivan.khoronzhuk
0 siblings, 1 reply; 9+ messages in thread
From: Santosh Shilimkar @ 2013-11-20 20:33 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday 20 November 2013 03:17 PM, Grygorii Strashko wrote:
> On 11/20/2013 06:24 PM, Ivan Khoronzhuk wrote:
>> This series contains updates of Davinci nand driver, in order to be
>> reused for Keystone platform.
>>
>> Depends on:
>> - Davinci nand driver fixes and updates:
>> https://lkml.org/lkml/2013/11/20/271
>
> ^^^^ I suggest to merge this series with above one as it
> should not break anything.
>
I agree. That way the mtd patch series can go
together nicely.
Regards,
Santosh
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/3] Reuse davinci-nand driver for Keystone arch
2013-11-20 20:33 ` Santosh Shilimkar
@ 2013-11-20 20:38 ` ivan.khoronzhuk
0 siblings, 0 replies; 9+ messages in thread
From: ivan.khoronzhuk @ 2013-11-20 20:38 UTC (permalink / raw)
To: linux-arm-kernel
On 11/20/2013 10:33 PM, Santosh Shilimkar wrote:
> On Wednesday 20 November 2013 03:17 PM, Grygorii Strashko wrote:
>> On 11/20/2013 06:24 PM, Ivan Khoronzhuk wrote:
>>> This series contains updates of Davinci nand driver, in order to be
>>> reused for Keystone platform.
>>>
>>> Depends on:
>>> - Davinci nand driver fixes and updates:
>>> https://lkml.org/lkml/2013/11/20/271
>>
>> ^^^^ I suggest to merge this series with above one as it
>> should not break anything.
>>
> I agree. That way the mtd patch series can go
> together nicely.
>
> Regards,
> Santosh
>
Ok, I will combine them
--
Regards,
Ivan Khoronzhuk
^ permalink raw reply [flat|nested] 9+ messages in thread