diff mbox

[RESEND,v2,3/4] ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode

Message ID 20180417102917.7794-4-brgl@bgdev.pl (mailing list archive)
State New, archived
Headers show

Commit Message

Bartosz Golaszewski April 17, 2018, 10:29 a.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now have support for aemif & nand from board files. As an example
add support for nand to da850-lcdk in legacy mode.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)

Comments

Sekhar Nori April 17, 2018, 2:09 p.m. UTC | #1
On Tuesday 17 April 2018 03:59 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> We now have support for aemif & nand from board files. As an example
> add support for nand to da850-lcdk in legacy mode.

Hawkboard is a separate board of its own, although closely related to
LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy
mode". So:

ARM: davinci: omapl138-hawk: ...

> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
>  1 file changed, 132 insertions(+)
> 
> diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
> index 6c997c59a3cd..9c3de56b54e4 100644
> --- a/arch/arm/mach-davinci/board-omapl138-hawk.c
> +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
> @@ -16,6 +16,11 @@
>  #include <linux/gpio.h>
>  #include <linux/gpio/machine.h>
>  #include <linux/platform_data/gpio-davinci.h>
> +#include <linux/platform_data/ti-aemif.h>
> +#include <linux/mtd/rawnand.h>
> +#include <linux/mtd/partitions.h>
> +#include <linux/platform_data/mtd-davinci.h>
> +#include <linux/platform_data/mtd-davinci-aemif.h>
>  #include <linux/regulator/machine.h>
>  
>  #include <asm/mach-types.h>
> @@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
>  	gpiod_remove_lookup_table(&mmc_gpios_table);
>  }
>  
> +static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
> +	{
> +		.name		= "u-boot env",
> +		.offset		= 0,
> +		.size		= SZ_128K,
> +		.mask_flags	= MTD_WRITEABLE,
> +	 },
> +	{
> +		.name		= "u-boot",
> +		.offset		= MTDPART_OFS_APPEND,
> +		.size		= SZ_128K,

Can you make it 512K as it is in da850-lcdk.dts ?

> +		.mask_flags	= MTD_WRITEABLE,
> +	},
> +	{
> +		.name		= "free space",
> +		.offset		= MTDPART_OFS_APPEND,
> +		.size		= MTDPART_SIZ_FULL,
> +		.mask_flags	= 0,
> +	},
> +};

> +static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
> +	{
> +		.cs	= 3,
> +	}
> +};
> +
> +static struct platform_device omapl138_hawk_aemif_devices[] = {
> +	{
> +		.name		= "davinci_nand",
> +		.id		= 1,

Is there a reason for .id to be set to 1 here? Ideally it should be -1,
I think since there is a single NAND on the board.

Note that I sent a patch dropping AEMIF clock acquisition from DaVinci
NAND driver.

> +		.dev		= {
> +			.platform_data	= &omapl138_hawk_nandflash_data,
> +		},
> +		.resource	= omapl138_hawk_nandflash_resource,
> +		.num_resources	= ARRAY_SIZE(omapl138_hawk_nandflash_resource),
> +		.id		= 0,

This should have resulted in a double init warning?

Thanks,
Sekhar
Bartosz Golaszewski April 25, 2018, 9:14 a.m. UTC | #2
2018-04-17 16:09 GMT+02:00 Sekhar Nori <nsekhar@ti.com>:
> On Tuesday 17 April 2018 03:59 PM, Bartosz Golaszewski wrote:
>> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>
>> We now have support for aemif & nand from board files. As an example
>> add support for nand to da850-lcdk in legacy mode.
>
> Hawkboard is a separate board of its own, although closely related to
> LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy
> mode". So:
>
> ARM: davinci: omapl138-hawk: ...
>
>>
>> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>> ---
>>  arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
>>  1 file changed, 132 insertions(+)
>>
>> diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
>> index 6c997c59a3cd..9c3de56b54e4 100644
>> --- a/arch/arm/mach-davinci/board-omapl138-hawk.c
>> +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
>> @@ -16,6 +16,11 @@
>>  #include <linux/gpio.h>
>>  #include <linux/gpio/machine.h>
>>  #include <linux/platform_data/gpio-davinci.h>
>> +#include <linux/platform_data/ti-aemif.h>
>> +#include <linux/mtd/rawnand.h>
>> +#include <linux/mtd/partitions.h>
>> +#include <linux/platform_data/mtd-davinci.h>
>> +#include <linux/platform_data/mtd-davinci-aemif.h>
>>  #include <linux/regulator/machine.h>
>>
>>  #include <asm/mach-types.h>
>> @@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
>>       gpiod_remove_lookup_table(&mmc_gpios_table);
>>  }
>>
>> +static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
>> +     {
>> +             .name           = "u-boot env",
>> +             .offset         = 0,
>> +             .size           = SZ_128K,
>> +             .mask_flags     = MTD_WRITEABLE,
>> +      },
>> +     {
>> +             .name           = "u-boot",
>> +             .offset         = MTDPART_OFS_APPEND,
>> +             .size           = SZ_128K,
>
> Can you make it 512K as it is in da850-lcdk.dts ?
>
>> +             .mask_flags     = MTD_WRITEABLE,
>> +     },
>> +     {
>> +             .name           = "free space",
>> +             .offset         = MTDPART_OFS_APPEND,
>> +             .size           = MTDPART_SIZ_FULL,
>> +             .mask_flags     = 0,
>> +     },
>> +};
>
>> +static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
>> +     {
>> +             .cs     = 3,
>> +     }
>> +};
>> +
>> +static struct platform_device omapl138_hawk_aemif_devices[] = {
>> +     {
>> +             .name           = "davinci_nand",
>> +             .id             = 1,
>
> Is there a reason for .id to be set to 1 here? Ideally it should be -1,
> I think since there is a single NAND on the board.
>

The davinci nand driver uses pdev->id as the chipselect number. I
guess this should be in the platform data. I'll send a patch for that.

> Note that I sent a patch dropping AEMIF clock acquisition from DaVinci
> NAND driver.
>
>> +             .dev            = {
>> +                     .platform_data  = &omapl138_hawk_nandflash_data,
>> +             },
>> +             .resource       = omapl138_hawk_nandflash_resource,
>> +             .num_resources  = ARRAY_SIZE(omapl138_hawk_nandflash_resource),
>> +             .id             = 0,
>
> This should have resulted in a double init warning?
>

It should, strange it didn't - at least for me.

Thanks,
Bart
Sekhar Nori April 25, 2018, 9:20 a.m. UTC | #3
On Wednesday 25 April 2018 02:44 PM, Bartosz Golaszewski wrote:
> 2018-04-17 16:09 GMT+02:00 Sekhar Nori <nsekhar@ti.com>:
>> On Tuesday 17 April 2018 03:59 PM, Bartosz Golaszewski wrote:
>>> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>>
>>> We now have support for aemif & nand from board files. As an example
>>> add support for nand to da850-lcdk in legacy mode.
>>
>> Hawkboard is a separate board of its own, although closely related to
>> LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy
>> mode". So:
>>
>> ARM: davinci: omapl138-hawk: ...
>>
>>>
>>> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>> ---
>>>  arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
>>>  1 file changed, 132 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
>>> index 6c997c59a3cd..9c3de56b54e4 100644
>>> --- a/arch/arm/mach-davinci/board-omapl138-hawk.c
>>> +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
>>> @@ -16,6 +16,11 @@
>>>  #include <linux/gpio.h>
>>>  #include <linux/gpio/machine.h>
>>>  #include <linux/platform_data/gpio-davinci.h>
>>> +#include <linux/platform_data/ti-aemif.h>
>>> +#include <linux/mtd/rawnand.h>
>>> +#include <linux/mtd/partitions.h>
>>> +#include <linux/platform_data/mtd-davinci.h>
>>> +#include <linux/platform_data/mtd-davinci-aemif.h>
>>>  #include <linux/regulator/machine.h>
>>>
>>>  #include <asm/mach-types.h>
>>> @@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
>>>       gpiod_remove_lookup_table(&mmc_gpios_table);
>>>  }
>>>
>>> +static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
>>> +     {
>>> +             .name           = "u-boot env",
>>> +             .offset         = 0,
>>> +             .size           = SZ_128K,
>>> +             .mask_flags     = MTD_WRITEABLE,
>>> +      },
>>> +     {
>>> +             .name           = "u-boot",
>>> +             .offset         = MTDPART_OFS_APPEND,
>>> +             .size           = SZ_128K,
>>
>> Can you make it 512K as it is in da850-lcdk.dts ?
>>
>>> +             .mask_flags     = MTD_WRITEABLE,
>>> +     },
>>> +     {
>>> +             .name           = "free space",
>>> +             .offset         = MTDPART_OFS_APPEND,
>>> +             .size           = MTDPART_SIZ_FULL,
>>> +             .mask_flags     = 0,
>>> +     },
>>> +};
>>
>>> +static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
>>> +     {
>>> +             .cs     = 3,
>>> +     }
>>> +};
>>> +
>>> +static struct platform_device omapl138_hawk_aemif_devices[] = {
>>> +     {
>>> +             .name           = "davinci_nand",
>>> +             .id             = 1,
>>
>> Is there a reason for .id to be set to 1 here? Ideally it should be -1,
>> I think since there is a single NAND on the board.
>>
> 
> The davinci nand driver uses pdev->id as the chipselect number. I
> guess this should be in the platform data. I'll send a patch for that.

I remember that now. No need to change that, I think. Just a comment
here would suffice.

Thanks,
Sekhar
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index 6c997c59a3cd..9c3de56b54e4 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -16,6 +16,11 @@ 
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -162,6 +167,129 @@  static __init void omapl138_hawk_mmc_init(void)
 	gpiod_remove_lookup_table(&mmc_gpios_table);
 }
 
+static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
+	{
+		.name		= "u-boot env",
+		.offset		= 0,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	 },
+	{
+		.name		= "u-boot",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "free space",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0,
+	},
+};
+
+static struct davinci_aemif_timing omapl138_hawk_nandflash_timing = {
+	.wsetup		= 24,
+	.wstrobe	= 21,
+	.whold		= 14,
+	.rsetup		= 19,
+	.rstrobe	= 50,
+	.rhold		= 0,
+	.ta		= 20,
+};
+
+static struct davinci_nand_pdata omapl138_hawk_nandflash_data = {
+	.parts		= omapl138_hawk_nandflash_partition,
+	.nr_parts	= ARRAY_SIZE(omapl138_hawk_nandflash_partition),
+	.ecc_mode	= NAND_ECC_HW,
+	.ecc_bits	= 4,
+	.bbt_options	= NAND_BBT_USE_FLASH,
+	.options	= NAND_BUSWIDTH_16,
+	.timing		= &omapl138_hawk_nandflash_timing,
+	.mask_chipsel	= 0,
+	.mask_ale	= 0,
+	.mask_cle	= 0,
+};
+
+static struct resource omapl138_hawk_nandflash_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CS3_BASE,
+		.end	= DA8XX_AEMIF_CS3_BASE + SZ_32M,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct resource omapl138_hawk_aemif_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K,
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
+static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
+	{
+		.cs	= 3,
+	}
+};
+
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,
+		.dev		= {
+			.platform_data	= &omapl138_hawk_nandflash_data,
+		},
+		.resource	= omapl138_hawk_nandflash_resource,
+		.num_resources	= ARRAY_SIZE(omapl138_hawk_nandflash_resource),
+		.id		= 0,
+	}
+};
+
+static struct aemif_platform_data omapl138_hawk_aemif_pdata = {
+	.cs_offset = 2,
+	.abus_data = omapl138_hawk_aemif_abus_data,
+	.num_abus_data = ARRAY_SIZE(omapl138_hawk_aemif_abus_data),
+	.sub_devices = omapl138_hawk_aemif_devices,
+	.num_sub_devices = ARRAY_SIZE(omapl138_hawk_aemif_devices),
+};
+
+static struct platform_device omapl138_hawk_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data	= &omapl138_hawk_aemif_pdata,
+	},
+	.resource	= omapl138_hawk_aemif_resource,
+	.num_resources	= ARRAY_SIZE(omapl138_hawk_aemif_resource),
+	.id		= -1,
+};
+
+static const short omapl138_hawk_nand_pins[] = {
+	DA850_EMA_WAIT_1, DA850_NEMA_OE, DA850_NEMA_WE, DA850_NEMA_CS_3,
+	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
+	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
+	DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11,
+	DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15,
+	DA850_EMA_A_1, DA850_EMA_A_2,
+	-1
+};
+
+static int omapl138_hawk_register_aemif(void)
+{
+	int ret;
+
+	ret = davinci_cfg_reg_list(omapl138_hawk_nand_pins);
+	if (ret)
+		pr_warn("%s: NAND mux setup failed: %d\n", __func__, ret);
+
+	return platform_device_register(&omapl138_hawk_aemif_device);
+}
+
 static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);
 static da8xx_ocic_handler_t hawk_usb_ocic_handler;
 
@@ -294,6 +422,10 @@  static __init void omapl138_hawk_init(void)
 
 	omapl138_hawk_usb_init();
 
+	ret = omapl138_hawk_register_aemif();
+	if (ret)
+		pr_warn("%s: aemif registration failed: %d\n", __func__, ret);
+
 	ret = da8xx_register_watchdog();
 	if (ret)
 		pr_warn("%s: watchdog registration failed: %d\n",