2018-06-25 15:34:23

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 0/9] ARM: davinci: deduplicate aemif support

From: Bartosz Golaszewski <[email protected]>

This series moves all aemif/nand users to using the ti-aemif platform
driver located in drivers/memory instead of the older API located in
mach-davinci.

The first patch adds a necessary clock lookup and the last patch
removes the duplicate aemif code.

Bartosz Golaszewski (9):
clk: davinci: psc-dm365: use two lookup entries for the aemif clock
ARM: davinci: omapl138-hawk: add aemif & nand support
ARM: davinci: da850-evm: use aemif platform driver in legacy mode
ARM: davinci: dm365-evm: use the ti-aemif soc driver
ARM: davinci: dm644x-evm: use aemif platform driver
ARM: davinci: da830-evm: use aemif platform driver
ARM: davinci: dm646x-evm: use aemif platform driver
ARM: davinci: mityomapl138: use aemif platform driver
ARM: davinci: kill davinci_aemif_setup()

arch/arm/mach-davinci/Makefile | 2 +-
arch/arm/mach-davinci/aemif.c | 218 ------------------
arch/arm/mach-davinci/board-da830-evm.c | 56 ++++-
arch/arm/mach-davinci/board-da850-evm.c | 93 ++++----
arch/arm/mach-davinci/board-dm365-evm.c | 59 +++--
arch/arm/mach-davinci/board-dm644x-evm.c | 55 +++--
arch/arm/mach-davinci/board-dm646x-evm.c | 52 ++++-
arch/arm/mach-davinci/board-mityomapl138.c | 55 +++--
arch/arm/mach-davinci/board-omapl138-hawk.c | 132 +++++++++++
drivers/clk/davinci/psc-dm365.c | 3 +-
.../linux/platform_data/mtd-davinci-aemif.h | 1 -
11 files changed, 400 insertions(+), 326 deletions(-)
delete mode 100644 arch/arm/mach-davinci/aemif.c

--
2.17.1



2018-06-25 15:31:14

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 7/9] ARM: davinci: dm646x-evm: use aemif platform driver

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in dm646x-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-dm646x-evm.c | 52 +++++++++++++++++++-----
1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 867ab2fa6cfd..99297e0612ba 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -24,6 +24,7 @@
#include <linux/i2c.h>
#include <linux/platform_data/at24.h>
#include <linux/platform_data/pcf857x.h>
+#include <linux/platform_data/ti-aemif.h>

#include <media/i2c/tvp514x.h>
#include <media/i2c/adv7343.h>
@@ -106,16 +107,47 @@ static struct resource davinci_nand_resources[] = {
},
};

-static struct platform_device davinci_nand_device = {
- .name = "davinci_nand",
- .id = 0,
+static struct platform_device davinci_aemif_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(davinci_nand_resources),
+ .resource = davinci_nand_resources,
+ .dev = {
+ .platform_data = &davinci_nand_data,
+ },
+ },
+};
+
+static struct resource davinci_aemif_resources[] = {
+ {
+ .start = DM646X_ASYNC_EMIF_CONTROL_BASE,
+ .end = DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};

- .num_resources = ARRAY_SIZE(davinci_nand_resources),
- .resource = davinci_nand_resources,
+static struct aemif_abus_data davinci_aemif_abus_data[] = {
+ {
+ .cs = 1,
+ },
+};

- .dev = {
- .platform_data = &davinci_nand_data,
+static struct aemif_platform_data davinci_aemif_pdata = {
+ .abus_data = davinci_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(davinci_aemif_abus_data),
+ .sub_devices = davinci_aemif_devices,
+ .num_sub_devices = ARRAY_SIZE(davinci_aemif_devices),
+};
+
+static struct platform_device davinci_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &davinci_aemif_pdata,
},
+ .resource = davinci_aemif_resources,
+ .num_resources = ARRAY_SIZE(davinci_aemif_resources),
+ .id = -1,
};

#define HAS_ATA (IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
@@ -793,10 +825,8 @@ static __init void evm_init(void)
if (machine_is_davinci_dm6467tevm())
davinci_nand_data.timing = &dm6467tevm_nandflash_timing;

- platform_device_register(&davinci_nand_device);
-
- if (davinci_aemif_setup(&davinci_nand_device))
- pr_warn("%s: Cannot configure AEMIF.\n", __func__);
+ if (platform_device_register(&davinci_aemif_device))
+ pr_warn("%s: Cannot register AEMIF device.\n", __func__);

dm646x_init_edma(dm646x_edma_rsv);

--
2.17.1


2018-06-25 15:31:29

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 5/9] ARM: davinci: dm644x-evm: use aemif platform driver

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in dm644x-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-dm644x-evm.c | 55 ++++++++++++++++++------
1 file changed, 42 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 738e443ab15f..e3556708c71b 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -42,6 +42,7 @@
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/usb-davinci.h>
#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>

#include "davinci.h"

@@ -174,14 +175,47 @@ static struct resource davinci_evm_nandflash_resource[] = {
},
};

-static struct platform_device davinci_evm_nandflash_device = {
- .name = "davinci_nand",
- .id = 0,
- .dev = {
- .platform_data = &davinci_evm_nandflash_data,
+static struct resource davinci_evm_aemif_resource[] = {
+ {
+ .start = DM644X_ASYNC_EMIF_CONTROL_BASE,
+ .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
},
- .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
- .resource = davinci_evm_nandflash_resource,
+};
+
+static struct aemif_abus_data davinci_evm_aemif_abus_data[] = {
+ {
+ .cs = 1,
+ },
+};
+
+static struct platform_device davinci_evm_nandflash_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 0,
+ .dev = {
+ .platform_data = &davinci_evm_nandflash_data,
+ },
+ .num_resources = ARRAY_SIZE(davinci_evm_nandflash_resource),
+ .resource = davinci_evm_nandflash_resource,
+ },
+};
+
+static struct aemif_platform_data davinci_evm_aemif_pdata = {
+ .abus_data = davinci_evm_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(davinci_evm_aemif_abus_data),
+ .sub_devices = davinci_evm_nandflash_devices,
+ .num_sub_devices = ARRAY_SIZE(davinci_evm_nandflash_devices),
+};
+
+static struct platform_device davinci_evm_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &davinci_evm_aemif_pdata,
+ },
+ .resource = davinci_evm_aemif_resource,
+ .num_resources = ARRAY_SIZE(davinci_evm_aemif_resource),
+ .id = -1,
};

static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
@@ -795,12 +829,7 @@ static __init void davinci_evm_init(void)

/* only one device will be jumpered and detected */
if (HAS_NAND) {
- platform_device_register(&davinci_evm_nandflash_device);
-
- if (davinci_aemif_setup(&davinci_evm_nandflash_device))
- pr_warn("%s: Cannot configure AEMIF\n",
- __func__);
-
+ platform_device_register(&davinci_evm_aemif_device);
#ifdef CONFIG_I2C
evm_leds[7].default_trigger = "nand-disk";
#endif
--
2.17.1


2018-06-25 15:32:17

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in da830-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index b2470141dba3..666db3cee08a 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -28,6 +28,7 @@
#include <linux/platform_data/mtd-davinci-aemif.h>
#include <linux/platform_data/spi-davinci.h>
#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
#include <linux/regulator/machine.h>

#include <asm/mach-types.h>
@@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] = {
},
};

-static struct platform_device da830_evm_nand_device = {
- .name = "davinci_nand",
- .id = 1,
- .dev = {
- .platform_data = &da830_evm_nand_pdata,
+static struct platform_device da830_evm_aemif_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 1,
+ .dev = {
+ .platform_data = &da830_evm_nand_pdata,
+ },
+ .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
+ .resource = da830_evm_nand_resources,
+ },
+};
+
+static struct resource da830_evm_aemif_resource[] = {
+ {
+ .start = DA8XX_AEMIF_CTL_BASE,
+ .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct aemif_abus_data da830_evm_aemif_abus_data[] = {
+ {
+ .cs = 3,
},
- .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
- .resource = da830_evm_nand_resources,
+};
+
+static struct aemif_platform_data da830_evm_aemif_pdata = {
+ .abus_data = da830_evm_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(da830_evm_aemif_abus_data),
+ .sub_devices = da830_evm_aemif_devices,
+ .num_sub_devices = ARRAY_SIZE(da830_evm_aemif_devices),
+ .cs_offset = 2,
+};
+
+static struct platform_device da830_evm_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &da830_evm_aemif_pdata,
+ },
+ .resource = da830_evm_aemif_resource,
+ .num_resources = ARRAY_SIZE(da830_evm_aemif_resource),
+ .id = -1,
};

/*
@@ -371,12 +406,9 @@ static inline void da830_evm_init_nand(int mux_mode)
if (ret)
pr_warn("%s: emif25 mux setup failed: %d\n", __func__, ret);

- ret = platform_device_register(&da830_evm_nand_device);
+ ret = platform_device_register(&da830_evm_aemif_device);
if (ret)
- pr_warn("%s: NAND device not registered\n", __func__);
-
- if (davinci_aemif_setup(&da830_evm_nand_device))
- pr_warn("%s: Cannot configure AEMIF\n", __func__);
+ pr_warn("%s: AEMIF device not registered\n", __func__);

gpio_direction_output(mux_mode, 1);
}
--
2.17.1


2018-06-25 15:32:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 9/9] ARM: davinci: kill davinci_aemif_setup()

From: Bartosz Golaszewski <[email protected]>

All users now register platform devices using the ti-aemif driver.
Remove the handcrafted aemif API.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/Makefile | 2 +-
arch/arm/mach-davinci/aemif.c | 218 ------------------
.../linux/platform_data/mtd-davinci-aemif.h | 1 -
3 files changed, 1 insertion(+), 220 deletions(-)
delete mode 100644 arch/arm/mach-davinci/aemif.c

diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 8725d8bea567..93d271b4d84b 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -6,7 +6,7 @@

# Common objects
obj-y := time.o serial.o usb.o \
- common.o sram.o aemif.o
+ common.o sram.o

obj-$(CONFIG_DAVINCI_MUX) += mux.o

diff --git a/arch/arm/mach-davinci/aemif.c b/arch/arm/mach-davinci/aemif.c
deleted file mode 100644
index e4ab3f3a2a1f..000000000000
--- a/arch/arm/mach-davinci/aemif.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * AEMIF support for DaVinci SoCs
- *
- * Copyright (C) 2010 Texas Instruments Incorporated. http://www.ti.com/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/clk.h>
-#include <linux/module.h>
-#include <linux/time.h>
-
-#include <linux/platform_data/mtd-davinci-aemif.h>
-#include <linux/platform_data/mtd-davinci.h>
-
-/* Timing value configuration */
-
-#define TA(x) ((x) << 2)
-#define RHOLD(x) ((x) << 4)
-#define RSTROBE(x) ((x) << 7)
-#define RSETUP(x) ((x) << 13)
-#define WHOLD(x) ((x) << 17)
-#define WSTROBE(x) ((x) << 20)
-#define WSETUP(x) ((x) << 26)
-
-#define TA_MAX 0x3
-#define RHOLD_MAX 0x7
-#define RSTROBE_MAX 0x3f
-#define RSETUP_MAX 0xf
-#define WHOLD_MAX 0x7
-#define WSTROBE_MAX 0x3f
-#define WSETUP_MAX 0xf
-
-#define TIMING_MASK (TA(TA_MAX) | \
- RHOLD(RHOLD_MAX) | \
- RSTROBE(RSTROBE_MAX) | \
- RSETUP(RSETUP_MAX) | \
- WHOLD(WHOLD_MAX) | \
- WSTROBE(WSTROBE_MAX) | \
- WSETUP(WSETUP_MAX))
-
-static inline unsigned int davinci_aemif_readl(void __iomem *base, int offset)
-{
- return readl_relaxed(base + offset);
-}
-
-static inline void davinci_aemif_writel(void __iomem *base,
- int offset, unsigned long value)
-{
- writel_relaxed(value, base + offset);
-}
-
-/*
- * aemif_calc_rate - calculate timing data.
- * @wanted: The cycle time needed in nanoseconds.
- * @clk: The input clock rate in kHz.
- * @max: The maximum divider value that can be programmed.
- *
- * On success, returns the calculated timing value minus 1 for easy
- * programming into AEMIF timing registers, else negative errno.
- */
-static int aemif_calc_rate(int wanted, unsigned long clk, int max)
-{
- int result;
-
- result = DIV_ROUND_UP((wanted * clk), NSEC_PER_MSEC) - 1;
-
- pr_debug("%s: result %d from %ld, %d\n", __func__, result, clk, wanted);
-
- /* It is generally OK to have a more relaxed timing than requested... */
- if (result < 0)
- result = 0;
-
- /* ... But configuring tighter timings is not an option. */
- else if (result > max)
- result = -EINVAL;
-
- return result;
-}
-
-/**
- * davinci_aemif_setup_timing - setup timing values for a given AEMIF interface
- * @t: timing values to be progammed
- * @base: The virtual base address of the AEMIF interface
- * @cs: chip-select to program the timing values for
- * @clkrate: the AEMIF clkrate
- *
- * This function programs the given timing values (in real clock) into the
- * AEMIF registers taking the AEMIF clock into account.
- *
- * This function does not use any locking while programming the AEMIF
- * because it is expected that there is only one user of a given
- * chip-select.
- *
- * Returns 0 on success, else negative errno.
- */
-static int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,
- void __iomem *base, unsigned cs,
- unsigned long clkrate)
-{
- unsigned set, val;
- int ta, rhold, rstrobe, rsetup, whold, wstrobe, wsetup;
- unsigned offset = A1CR_OFFSET + cs * 4;
-
- if (!t)
- return 0; /* Nothing to do */
-
- clkrate /= 1000; /* turn clock into kHz for ease of use */
-
- ta = aemif_calc_rate(t->ta, clkrate, TA_MAX);
- rhold = aemif_calc_rate(t->rhold, clkrate, RHOLD_MAX);
- rstrobe = aemif_calc_rate(t->rstrobe, clkrate, RSTROBE_MAX);
- rsetup = aemif_calc_rate(t->rsetup, clkrate, RSETUP_MAX);
- whold = aemif_calc_rate(t->whold, clkrate, WHOLD_MAX);
- wstrobe = aemif_calc_rate(t->wstrobe, clkrate, WSTROBE_MAX);
- wsetup = aemif_calc_rate(t->wsetup, clkrate, WSETUP_MAX);
-
- if (ta < 0 || rhold < 0 || rstrobe < 0 || rsetup < 0 ||
- whold < 0 || wstrobe < 0 || wsetup < 0) {
- pr_err("%s: cannot get suitable timings\n", __func__);
- return -EINVAL;
- }
-
- set = TA(ta) | RHOLD(rhold) | RSTROBE(rstrobe) | RSETUP(rsetup) |
- WHOLD(whold) | WSTROBE(wstrobe) | WSETUP(wsetup);
-
- val = __raw_readl(base + offset);
- val &= ~TIMING_MASK;
- val |= set;
- __raw_writel(val, base + offset);
-
- return 0;
-}
-
-/**
- * davinci_aemif_setup - setup AEMIF interface by davinci_nand_pdata
- * @pdev - link to platform device to setup settings for
- *
- * This function does not use any locking while programming the AEMIF
- * because it is expected that there is only one user of a given
- * chip-select.
- *
- * Returns 0 on success, else negative errno.
- */
-int davinci_aemif_setup(struct platform_device *pdev)
-{
- struct davinci_nand_pdata *pdata = dev_get_platdata(&pdev->dev);
- uint32_t val;
- unsigned long clkrate;
- struct resource *res;
- void __iomem *base;
- struct clk *clk;
- int ret = 0;
-
- clk = clk_get(&pdev->dev, "aemif");
- if (IS_ERR(clk)) {
- ret = PTR_ERR(clk);
- dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret);
- return ret;
- }
-
- ret = clk_prepare_enable(clk);
- if (ret < 0) {
- dev_dbg(&pdev->dev, "unable to enable AEMIF clock, err %d\n",
- ret);
- goto err_put;
- }
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res) {
- dev_err(&pdev->dev, "cannot get IORESOURCE_MEM\n");
- ret = -ENOMEM;
- goto err;
- }
-
- base = ioremap(res->start, resource_size(res));
- if (!base) {
- dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res);
- ret = -ENOMEM;
- goto err;
- }
-
- /*
- * Setup Async configuration register in case we did not boot
- * from NAND and so bootloader did not bother to set it up.
- */
- val = davinci_aemif_readl(base, A1CR_OFFSET + pdata->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 (pdata->options & NAND_BUSWIDTH_16)
- val |= 0x1;
-
- davinci_aemif_writel(base, A1CR_OFFSET + pdata->core_chipsel * 4, val);
-
- clkrate = clk_get_rate(clk);
-
- if (pdata->timing)
- ret = davinci_aemif_setup_timing(pdata->timing, base,
- pdata->core_chipsel, clkrate);
-
- if (ret < 0)
- dev_dbg(&pdev->dev, "NAND timing values setup fail\n");
-
- iounmap(base);
-err:
- clk_disable_unprepare(clk);
-err_put:
- clk_put(clk);
- return ret;
-}
diff --git a/include/linux/platform_data/mtd-davinci-aemif.h b/include/linux/platform_data/mtd-davinci-aemif.h
index 97948ac2bb9b..a403dd51dacc 100644
--- a/include/linux/platform_data/mtd-davinci-aemif.h
+++ b/include/linux/platform_data/mtd-davinci-aemif.h
@@ -33,5 +33,4 @@ struct davinci_aemif_timing {
u8 ta;
};

-int davinci_aemif_setup(struct platform_device *pdev);
#endif
--
2.17.1


2018-06-25 15:32:45

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its
con_id and from the aemif driver by dev_id.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/clk/davinci/psc-dm365.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/davinci/psc-dm365.c b/drivers/clk/davinci/psc-dm365.c
index 8c73086cc676..c75424f4ea3b 100644
--- a/drivers/clk/davinci/psc-dm365.c
+++ b/drivers/clk/davinci/psc-dm365.c
@@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev, NULL, "da830-mmc.1");
LPSC_CLKDEV1(asp0_clkdev, NULL, "davinci-mcbsp");
LPSC_CLKDEV1(usb_clkdev, "usb", NULL);
LPSC_CLKDEV1(spi2_clkdev, NULL, "spi_davinci.2");
-LPSC_CLKDEV1(aemif_clkdev, "aemif", NULL);
+LPSC_CLKDEV2(aemif_clkdev, "aemif", NULL,
+ NULL, "ti-aemif");
LPSC_CLKDEV1(mmcsd0_clkdev, NULL, "da830-mmc.0");
LPSC_CLKDEV1(i2c_clkdev, NULL, "i2c_davinci.1");
LPSC_CLKDEV1(uart0_clkdev, NULL, "serial8250.0");
--
2.17.1


2018-06-25 15:33:04

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 3/9] ARM: davinci: da850-evm: use aemif platform driver in legacy mode

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in da850-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-da850-evm.c | 93 ++++++++++++++-----------
1 file changed, 51 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 442c16773f09..0ae7c47ed2b0 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -33,6 +33,7 @@
#include <linux/platform_data/gpio-davinci.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>
#include <linux/platform_data/spi-davinci.h>
#include <linux/platform_data/uio_pruss.h>
#include <linux/regulator/machine.h>
@@ -185,16 +186,6 @@ static struct resource da850_evm_norflash_resource[] = {
},
};

-static struct platform_device da850_evm_norflash_device = {
- .name = "physmap-flash",
- .id = 0,
- .dev = {
- .platform_data = &da850_evm_norflash_data,
- },
- .num_resources = 1,
- .resource = da850_evm_norflash_resource,
-};
-
/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
* (128K blocks). It may be used instead of the (default) SPI flash
* to boot, using TI's tools to install the secondary boot loader
@@ -266,37 +257,58 @@ static struct resource da850_evm_nandflash_resource[] = {
},
};

-static struct platform_device da850_evm_nandflash_device = {
- .name = "davinci_nand",
- .id = 1,
- .dev = {
- .platform_data = &da850_evm_nandflash_data,
- },
- .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
- .resource = da850_evm_nandflash_resource,
+static struct resource da850_evm_aemif_resource[] = {
+ {
+ .start = DA8XX_AEMIF_CTL_BASE,
+ .end = DA8XX_AEMIF_CTL_BASE + SZ_32K,
+ .flags = IORESOURCE_MEM,
+ }
};

-static struct platform_device *da850_evm_devices[] = {
- &da850_evm_nandflash_device,
- &da850_evm_norflash_device,
+static struct aemif_abus_data da850_evm_aemif_abus_data[] = {
+ {
+ .cs = 3,
+ }
};

-#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
-#define DA8XX_AEMIF_ASIZE_16BIT 0x1
-
-static void __init da850_evm_init_nor(void)
-{
- void __iomem *aemif_addr;
-
- aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
+static struct platform_device da850_evm_aemif_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 1,
+ .dev = {
+ .platform_data = &da850_evm_nandflash_data,
+ },
+ .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
+ .resource = da850_evm_nandflash_resource,
+ },
+ {
+ .name = "physmap-flash",
+ .id = 0,
+ .dev = {
+ .platform_data = &da850_evm_norflash_data,
+ },
+ .num_resources = 1,
+ .resource = da850_evm_norflash_resource,
+ }
+};

- /* Configure data bus width of CS2 to 16 bit */
- writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
- DA8XX_AEMIF_ASIZE_16BIT,
- aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
+static struct aemif_platform_data da850_evm_aemif_pdata = {
+ .cs_offset = 2,
+ .abus_data = da850_evm_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(da850_evm_aemif_abus_data),
+ .sub_devices = da850_evm_aemif_devices,
+ .num_sub_devices = ARRAY_SIZE(da850_evm_aemif_devices),
+};

- iounmap(aemif_addr);
-}
+static struct platform_device da850_evm_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &da850_evm_aemif_pdata,
+ },
+ .resource = da850_evm_aemif_resource,
+ .num_resources = ARRAY_SIZE(da850_evm_aemif_resource),
+ .id = -1,
+};

static const short da850_evm_nand_pins[] = {
DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
@@ -339,13 +351,10 @@ static inline void da850_evm_setup_nor_nand(void)
pr_warn("%s: NOR mux setup failed: %d\n",
__func__, ret);

- da850_evm_init_nor();
-
- platform_add_devices(da850_evm_devices,
- ARRAY_SIZE(da850_evm_devices));
-
- if (davinci_aemif_setup(&da850_evm_nandflash_device))
- pr_warn("%s: Cannot configure AEMIF.\n", __func__);
+ ret = platform_device_register(&da850_evm_aemif_device);
+ if (ret)
+ pr_warn("%s: registering aemif failed: %d\n",
+ __func__, ret);
}
}

--
2.17.1


2018-06-25 15:33:16

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 8/9] ARM: davinci: mityomapl138: use aemif platform driver

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in mityomapl138.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-mityomapl138.c | 55 ++++++++++++++++------
1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 2cce0d7d2f2a..b0fdea355d96 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -30,6 +30,7 @@
#include <mach/da8xx.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>
#include <mach/mux.h>
#include <linux/platform_data/spi-davinci.h>

@@ -422,27 +423,53 @@ static struct resource mityomapl138_nandflash_resource[] = {
},
};

-static struct platform_device mityomapl138_nandflash_device = {
- .name = "davinci_nand",
- .id = 1,
- .dev = {
- .platform_data = &mityomapl138_nandflash_data,
+static struct platform_device mityomapl138_aemif_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 1,
+ .dev = {
+ .platform_data = &mityomapl138_nandflash_data,
+ },
+ .num_resources = ARRAY_SIZE(mityomapl138_nandflash_resource),
+ .resource = mityomapl138_nandflash_resource,
},
- .num_resources = ARRAY_SIZE(mityomapl138_nandflash_resource),
- .resource = mityomapl138_nandflash_resource,
};

-static struct platform_device *mityomapl138_devices[] __initdata = {
- &mityomapl138_nandflash_device,
+static struct resource mityomapl138_aemif_resources[] = {
+ {
+ .start = DA8XX_AEMIF_CTL_BASE,
+ .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct aemif_abus_data mityomapl138_aemif_abus_data[] = {
+ {
+ .cs = 1,
+ },
+};
+
+static struct aemif_platform_data mityomapl138_aemif_pdata = {
+ .abus_data = mityomapl138_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(mityomapl138_aemif_abus_data),
+ .sub_devices = mityomapl138_aemif_devices,
+ .num_sub_devices = ARRAY_SIZE(mityomapl138_aemif_devices),
+};
+
+static struct platform_device mityomapl138_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &mityomapl138_aemif_pdata,
+ },
+ .resource = mityomapl138_aemif_resources,
+ .num_resources = ARRAY_SIZE(mityomapl138_aemif_resources),
+ .id = -1,
};

static void __init mityomapl138_setup_nand(void)
{
- platform_add_devices(mityomapl138_devices,
- ARRAY_SIZE(mityomapl138_devices));
-
- if (davinci_aemif_setup(&mityomapl138_nandflash_device))
- pr_warn("%s: Cannot configure AEMIF\n", __func__);
+ if (platform_device_register(&mityomapl138_aemif_device))
+ pr_warn("%s: Cannot register AEMIF device\n", __func__);
}

static const short mityomap_mii_pins[] = {
--
2.17.1


2018-06-25 15:33:19

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 2/9] ARM: davinci: omapl138-hawk: add aemif & nand support

From: Bartosz Golaszewski <[email protected]>

We now have support for aemif & nand from board files. As an example
add support for nand to da850-hawk.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
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 466e87b24e9a..02c0f36633e9 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>
@@ -166,6 +171,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_512K,
+ .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 = {
+ .core_chipsel = 1,
+ .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),
+ }
+};
+
+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;

@@ -298,6 +426,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",
--
2.17.1


2018-06-25 15:33:57

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 4/9] ARM: davinci: dm365-evm: use the ti-aemif soc driver

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform
device instead of using the handcrafted API in dm365-evm.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
arch/arm/mach-davinci/board-dm365-evm.c | 59 +++++++++++++++++++------
1 file changed, 46 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 307e88d99dd3..12b8d7b8c6b8 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -28,6 +28,7 @@
#include <linux/spi/spi.h>
#include <linux/spi/eeprom.h>
#include <linux/v4l2-dv-timings.h>
+#include <linux/platform_data/ti-aemif.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -159,14 +160,47 @@ static struct resource davinci_nand_resources[] = {
},
};

-static struct platform_device davinci_nand_device = {
- .name = "davinci_nand",
- .id = 0,
- .num_resources = ARRAY_SIZE(davinci_nand_resources),
- .resource = davinci_nand_resources,
- .dev = {
- .platform_data = &davinci_nand_data,
+static struct platform_device davinci_aemif_devices[] = {
+ {
+ .name = "davinci_nand",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(davinci_nand_resources),
+ .resource = davinci_nand_resources,
+ .dev = {
+ .platform_data = &davinci_nand_data,
+ },
+ }
+};
+
+static struct resource davinci_aemif_resources[] = {
+ {
+ .start = DM365_ASYNC_EMIF_CONTROL_BASE,
+ .end = DM365_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct aemif_abus_data da850_evm_aemif_abus_data[] = {
+ {
+ .cs = 1,
+ },
+};
+
+static struct aemif_platform_data davinci_aemif_pdata = {
+ .abus_data = da850_evm_aemif_abus_data,
+ .num_abus_data = ARRAY_SIZE(da850_evm_aemif_abus_data),
+ .sub_devices = davinci_aemif_devices,
+ .num_sub_devices = ARRAY_SIZE(davinci_aemif_devices),
+};
+
+static struct platform_device davinci_aemif_device = {
+ .name = "ti-aemif",
+ .dev = {
+ .platform_data = &davinci_aemif_pdata,
},
+ .resource = davinci_aemif_resources,
+ .num_resources = ARRAY_SIZE(davinci_aemif_resources),
+ .id = -1,
};

static struct at24_platform_data eeprom_info = {
@@ -537,10 +571,6 @@ static void __init evm_init_i2c(void)
i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
}

-static struct platform_device *dm365_evm_nand_devices[] __initdata = {
- &davinci_nand_device,
-};
-
static inline int have_leds(void)
{
#ifdef CONFIG_LEDS_CLASS
@@ -628,6 +658,7 @@ static void __init evm_init_cpld(void)
u8 mux, resets;
const char *label;
struct clk *aemif_clk;
+ int rc;

/* Make sure we can configure the CPLD through CS1. Then
* leave it on for later access to MMC and LED registers.
@@ -660,8 +691,10 @@ static void __init evm_init_cpld(void)
/* external keypad mux */
mux |= BIT(7);

- platform_add_devices(dm365_evm_nand_devices,
- ARRAY_SIZE(dm365_evm_nand_devices));
+ rc = platform_device_register(&davinci_aemif_device);
+ if (rc)
+ pr_warn("%s(): error registering the aemif device: %d\n",
+ __func__, rc);
} else {
/* no OneNAND support yet */
}
--
2.17.1


2018-06-25 15:56:03

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> We want to be able to get the clock both from the board file by its
> con_id and from the aemif driver by dev_id.

What about the other SoCs? Don't they need this change as well?

>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> drivers/clk/davinci/psc-dm365.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/davinci/psc-dm365.c b/drivers/clk/davinci/psc-dm365.c
> index 8c73086cc676..c75424f4ea3b 100644
> --- a/drivers/clk/davinci/psc-dm365.c
> +++ b/drivers/clk/davinci/psc-dm365.c
> @@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev, NULL, "da830-mmc.1");
> LPSC_CLKDEV1(asp0_clkdev, NULL, "davinci-mcbsp");
> LPSC_CLKDEV1(usb_clkdev, "usb", NULL);
> LPSC_CLKDEV1(spi2_clkdev, NULL, "spi_davinci.2");
> -LPSC_CLKDEV1(aemif_clkdev, "aemif", NULL);
> +LPSC_CLKDEV2(aemif_clkdev, "aemif", NULL,
> + NULL, "ti-aemif");
> LPSC_CLKDEV1(mmcsd0_clkdev, NULL, "da830-mmc.0");
> LPSC_CLKDEV1(i2c_clkdev, NULL, "i2c_davinci.1");
> LPSC_CLKDEV1(uart0_clkdev, NULL, "serial8250.0");
>


2018-06-25 16:01:17

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 3/9] ARM: davinci: da850-evm: use aemif platform driver in legacy mode

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> We now support board files in the aemif driver. Register a platform
> device instead of using the handcrafted API in da850-evm.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---

> - iounmap(aemif_addr);
> -}
> +static struct platform_device da850_evm_aemif_device = {
> + .name = "ti-aemif",
> + .dev = {
> + .platform_data = &da850_evm_aemif_pdata,
> + },
> + .resource = da850_evm_aemif_resource,
> + .num_resources = ARRAY_SIZE(da850_evm_aemif_resource),
> + .id = -1,
> +};
>

Not essential, but it is nice to have the id right after name
since they are closely related (as you did in several other
instances in this same patch). For a second, I thought you
forgot id = -1 here before I saw it.

2018-06-25 16:03:39

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:
> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>
>> From: Bartosz Golaszewski <[email protected]>
>>
>> We want to be able to get the clock both from the board file by its
>> con_id and from the aemif driver by dev_id.
>
>
> What about the other SoCs? Don't they need this change as well?
>

So I double checked and turns out I missed one other board that's
affected by this series and calls clk_get() from machine code:
dm644x-evm.

I'll fix it in v2.

Thanks,
Bart

>
>>
>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>> ---
>> drivers/clk/davinci/psc-dm365.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/davinci/psc-dm365.c
>> b/drivers/clk/davinci/psc-dm365.c
>> index 8c73086cc676..c75424f4ea3b 100644
>> --- a/drivers/clk/davinci/psc-dm365.c
>> +++ b/drivers/clk/davinci/psc-dm365.c
>> @@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev, NULL,
>> "da830-mmc.1");
>> LPSC_CLKDEV1(asp0_clkdev, NULL, "davinci-mcbsp");
>> LPSC_CLKDEV1(usb_clkdev, "usb", NULL);
>> LPSC_CLKDEV1(spi2_clkdev, NULL, "spi_davinci.2");
>> -LPSC_CLKDEV1(aemif_clkdev, "aemif", NULL);
>> +LPSC_CLKDEV2(aemif_clkdev, "aemif", NULL,
>> + NULL, "ti-aemif");
>> LPSC_CLKDEV1(mmcsd0_clkdev, NULL, "da830-mmc.0");
>> LPSC_CLKDEV1(i2c_clkdev, NULL, "i2c_davinci.1");
>> LPSC_CLKDEV1(uart0_clkdev, NULL, "serial8250.0");
>>
>

2018-06-25 16:05:59

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 3/9] ARM: davinci: da850-evm: use aemif platform driver in legacy mode

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> We now support board files in the aemif driver. Register a platform
> device instead of using the handcrafted API in da850-evm.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> arch/arm/mach-davinci/board-da850-evm.c | 93 ++++++++++++++-----------
> 1 file changed, 51 insertions(+), 42 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
> index 442c16773f09..0ae7c47ed2b0 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -33,6 +33,7 @@
> #include <linux/platform_data/gpio-davinci.h>
> #include <linux/platform_data/mtd-davinci.h>
> #include <linux/platform_data/mtd-davinci-aemif.h>
> +#include <linux/platform_data/ti-aemif.h>

alphabetical order would be after spi-davinci.h

> #include <linux/platform_data/spi-davinci.h>
> #include <linux/platform_data/uio_pruss.h>
> #include <linux/regulator/machine.h>


> @@ -266,37 +257,58 @@ static struct resource da850_evm_nandflash_resource[] = {
> },
> };
>
> -static struct platform_device da850_evm_nandflash_device = {
> - .name = "davinci_nand",
> - .id = 1,
> - .dev = {
> - .platform_data = &da850_evm_nandflash_data,
> - },
> - .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
> - .resource = da850_evm_nandflash_resource,
> +static struct resource da850_evm_aemif_resource[] = {
> + {
> + .start = DA8XX_AEMIF_CTL_BASE,
> + .end = DA8XX_AEMIF_CTL_BASE + SZ_32K,
> + .flags = IORESOURCE_MEM,
> + }
> };
>
> -static struct platform_device *da850_evm_devices[] = {
> - &da850_evm_nandflash_device,
> - &da850_evm_norflash_device,
> +static struct aemif_abus_data da850_evm_aemif_abus_data[] = {
> + {
> + .cs = 3,
> + }
> };
>
> -#define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
> -#define DA8XX_AEMIF_ASIZE_16BIT 0x1
> -
> -static void __init da850_evm_init_nor(void)
> -{
> - void __iomem *aemif_addr;
> -
> - aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
> +static struct platform_device da850_evm_aemif_devices[] = {
> + {
> + .name = "davinci_nand",
> + .id = 1,

The existing clock lookup is for "davinci_nand.0". Might need to
change id here.

> + .dev = {
> + .platform_data = &da850_evm_nandflash_data,
> + },
> + .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
> + .resource = da850_evm_nandflash_resource,
> + },
> + {
> + .name = "physmap-flash",
> + .id = 0,
> + .dev = {
> + .platform_data = &da850_evm_norflash_data,
> + },
> + .num_resources = 1,
> + .resource = da850_evm_norflash_resource,
> + }
> +};
>
> - /* Configure data bus width of CS2 to 16 bit */
> - writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
> - DA8XX_AEMIF_ASIZE_16BIT,
> - aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
> +static struct aemif_platform_data da850_evm_aemif_pdata = {
> + .cs_offset = 2,
> + .abus_data = da850_evm_aemif_abus_data,
> + .num_abus_data = ARRAY_SIZE(da850_evm_aemif_abus_data),
> + .sub_devices = da850_evm_aemif_devices,
> + .num_sub_devices = ARRAY_SIZE(da850_evm_aemif_devices),
> +};
>
> - iounmap(aemif_addr);
> -}
> +static struct platform_device da850_evm_aemif_device = {
> + .name = "ti-aemif",
> + .dev = {
> + .platform_data = &da850_evm_aemif_pdata,
> + },
> + .resource = da850_evm_aemif_resource,
> + .num_resources = ARRAY_SIZE(da850_evm_aemif_resource),
> + .id = -1,
> +};
>
> static const short da850_evm_nand_pins[] = {
> DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,

2018-06-25 16:07:47

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

On 06/25/2018 11:01 AM, Bartosz Golaszewski wrote:
> 2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:
>> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>>
>>> From: Bartosz Golaszewski <[email protected]>
>>>
>>> We want to be able to get the clock both from the board file by its
>>> con_id and from the aemif driver by dev_id.
>>
>>
>> What about the other SoCs? Don't they need this change as well?
>>
>
> So I double checked and turns out I missed one other board that's
> affected by this series and calls clk_get() from machine code:
> dm644x-evm.
>
> I'll fix it in v2.

The ti-aemif platform driver also does clk_get(). Don't you need
lookups to make that work as well? For example, DA830 doesn't have
a clock lookup for aemif at all.


2018-06-25 16:10:46

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 2/9] ARM: davinci: omapl138-hawk: add aemif & nand support

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> We now have support for aemif & nand from board files. As an example
> add support for nand to da850-hawk.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---

> +static struct platform_device omapl138_hawk_aemif_devices[] = {
> + {
> + .name = "davinci_nand",
> + .id = 1,

same comment as on da850-evm...

this might need id = 0 now.

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

2018-06-25 16:11:54

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

2018-06-25 18:06 GMT+02:00 David Lechner <[email protected]>:
> On 06/25/2018 11:01 AM, Bartosz Golaszewski wrote:
>>
>> 2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:
>>>
>>> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>>>
>>>>
>>>> From: Bartosz Golaszewski <[email protected]>
>>>>
>>>> We want to be able to get the clock both from the board file by its
>>>> con_id and from the aemif driver by dev_id.
>>>
>>>
>>>
>>> What about the other SoCs? Don't they need this change as well?
>>>
>>
>> So I double checked and turns out I missed one other board that's
>> affected by this series and calls clk_get() from machine code:
>> dm644x-evm.
>>
>> I'll fix it in v2.
>
>
> The ti-aemif platform driver also does clk_get(). Don't you need
> lookups to make that work as well? For example, DA830 doesn't have
> a clock lookup for aemif at all.
>

Right, I'll check that too.

Thanks,
Bart

2018-06-25 16:22:34

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> We now support board files in the aemif driver. Register a platform
> device instead of using the handcrafted API in da830-evm.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
> 1 file changed, 44 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
> index b2470141dba3..666db3cee08a 100644
> --- a/arch/arm/mach-davinci/board-da830-evm.c
> +++ b/arch/arm/mach-davinci/board-da830-evm.c
> @@ -28,6 +28,7 @@
> #include <linux/platform_data/mtd-davinci-aemif.h>
> #include <linux/platform_data/spi-davinci.h>
> #include <linux/platform_data/usb-davinci.h>
> +#include <linux/platform_data/ti-aemif.h>
> #include <linux/regulator/machine.h>
>
> #include <asm/mach-types.h>
> @@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] = {
> },
> };
>
> -static struct platform_device da830_evm_nand_device = {
> - .name = "davinci_nand",
> - .id = 1,
> - .dev = {
> - .platform_data = &da830_evm_nand_pdata,
> +static struct platform_device da830_evm_aemif_devices[] = {
> + {
> + .name = "davinci_nand",
> + .id = 1,

Actually, now that I've thought about it some more. It probably
makes more sense to make all of the "davinci_nand" devices in this
series use id = -1 since there is only one per board. It looks like
da850 is the only one that has a lookup for "davinic_nand.0" already.

I think that we are going to have to add clock lookups for the
"davinci_nand" devices as well. Although the driver doesn't do
clk_get() explicitly, I think some function it calls does get a
clock. I remember that we had to add a clock-ranges property to
device tree to get the davinci_nand driver working, which is why
I think we are going to need a clock lookup for these devices
as well.

> + .dev = {
> + .platform_data = &da830_evm_nand_pdata,
> + },
> + .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
> + .resource = da830_evm_nand_resources,
> + },
> +};
> +

2018-06-25 16:24:29

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 9/9] ARM: davinci: kill davinci_aemif_setup()

On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> All users now register platform devices using the ti-aemif driver.
> Remove the handcrafted aemif API.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---

I found the subject line to be a bit misleading since this patch
removes an entire file, not just the one function mentioned.



2018-06-25 16:25:26

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

2018-06-25 18:20 GMT+02:00 David Lechner <[email protected]>:
> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>
>> From: Bartosz Golaszewski <[email protected]>
>>
>> We now support board files in the aemif driver. Register a platform
>> device instead of using the handcrafted API in da830-evm.
>>
>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>> ---
>> arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
>> 1 file changed, 44 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/arm/mach-davinci/board-da830-evm.c
>> b/arch/arm/mach-davinci/board-da830-evm.c
>> index b2470141dba3..666db3cee08a 100644
>> --- a/arch/arm/mach-davinci/board-da830-evm.c
>> +++ b/arch/arm/mach-davinci/board-da830-evm.c
>> @@ -28,6 +28,7 @@
>> #include <linux/platform_data/mtd-davinci-aemif.h>
>> #include <linux/platform_data/spi-davinci.h>
>> #include <linux/platform_data/usb-davinci.h>
>> +#include <linux/platform_data/ti-aemif.h>
>> #include <linux/regulator/machine.h>
>> #include <asm/mach-types.h>
>> @@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] =
>> {
>> },
>> };
>> -static struct platform_device da830_evm_nand_device = {
>> - .name = "davinci_nand",
>> - .id = 1,
>> - .dev = {
>> - .platform_data = &da830_evm_nand_pdata,
>> +static struct platform_device da830_evm_aemif_devices[] = {
>> + {
>> + .name = "davinci_nand",
>> + .id = 1,
>
>
> Actually, now that I've thought about it some more. It probably
> makes more sense to make all of the "davinci_nand" devices in this
> series use id = -1 since there is only one per board. It looks like
> da850 is the only one that has a lookup for "davinic_nand.0" already.
>
> I think that we are going to have to add clock lookups for the
> "davinci_nand" devices as well. Although the driver doesn't do
> clk_get() explicitly, I think some function it calls does get a
> clock. I remember that we had to add a clock-ranges property to
> device tree to get the davinci_nand driver working, which is why
> I think we are going to need a clock lookup for these devices
> as well.
>

Seems like ever since commit a8e3923ab571 ("mtd: rawnand: davinci:
don't acquire and enable clock") we no longer need to worry about the
clock entries for nand.

Thanks,
Bart

2018-06-25 16:30:29

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

On 06/25/2018 11:23 AM, Bartosz Golaszewski wrote:
> 2018-06-25 18:20 GMT+02:00 David Lechner <[email protected]>:
>> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>>
>>> From: Bartosz Golaszewski <[email protected]>
>>>
>>> We now support board files in the aemif driver. Register a platform
>>> device instead of using the handcrafted API in da830-evm.
>>>
>>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>>> ---
>>> arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
>>> 1 file changed, 44 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-davinci/board-da830-evm.c
>>> b/arch/arm/mach-davinci/board-da830-evm.c
>>> index b2470141dba3..666db3cee08a 100644
>>> --- a/arch/arm/mach-davinci/board-da830-evm.c
>>> +++ b/arch/arm/mach-davinci/board-da830-evm.c
>>> @@ -28,6 +28,7 @@
>>> #include <linux/platform_data/mtd-davinci-aemif.h>
>>> #include <linux/platform_data/spi-davinci.h>
>>> #include <linux/platform_data/usb-davinci.h>
>>> +#include <linux/platform_data/ti-aemif.h>
>>> #include <linux/regulator/machine.h>
>>> #include <asm/mach-types.h>
>>> @@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] =
>>> {
>>> },
>>> };
>>> -static struct platform_device da830_evm_nand_device = {
>>> - .name = "davinci_nand",
>>> - .id = 1,
>>> - .dev = {
>>> - .platform_data = &da830_evm_nand_pdata,
>>> +static struct platform_device da830_evm_aemif_devices[] = {
>>> + {
>>> + .name = "davinci_nand",
>>> + .id = 1,
>>
>>
>> Actually, now that I've thought about it some more. It probably
>> makes more sense to make all of the "davinci_nand" devices in this
>> series use id = -1 since there is only one per board. It looks like
>> da850 is the only one that has a lookup for "davinic_nand.0" already.
>>
>> I think that we are going to have to add clock lookups for the
>> "davinci_nand" devices as well. Although the driver doesn't do
>> clk_get() explicitly, I think some function it calls does get a
>> clock. I remember that we had to add a clock-ranges property to
>> device tree to get the davinci_nand driver working, which is why
>> I think we are going to need a clock lookup for these devices
>> as well.
>>
>
> Seems like ever since commit a8e3923ab571 ("mtd: rawnand: davinci:
> don't acquire and enable clock") we no longer need to worry about the
> clock entries for nand.
>
> Thanks,
> Bart
>

Sounds good. If you end up touching the da850 clock lookups, you can
probably drop the "davinci_nand.0" entry there.


2018-06-26 08:29:27

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

2018-06-25 18:06 GMT+02:00 David Lechner <[email protected]>:
> On 06/25/2018 11:01 AM, Bartosz Golaszewski wrote:
>>
>> 2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:
>>>
>>> On 06/25/2018 10:29 AM, Bartosz Golaszewski wrote:
>>>>
>>>>
>>>> From: Bartosz Golaszewski <[email protected]>
>>>>
>>>> We want to be able to get the clock both from the board file by its
>>>> con_id and from the aemif driver by dev_id.
>>>
>>>
>>>
>>> What about the other SoCs? Don't they need this change as well?
>>>
>>
>> So I double checked and turns out I missed one other board that's
>> affected by this series and calls clk_get() from machine code:
>> dm644x-evm.
>>
>> I'll fix it in v2.
>
>
> The ti-aemif platform driver also does clk_get(). Don't you need
> lookups to make that work as well? For example, DA830 doesn't have
> a clock lookup for aemif at all.
>

This seems like a bug: in arch/arm/mach-davinci/aemif.c in current
mainline we do call clk_get() for 'aemif' and it's called indirectly
from board-da830-evm.c via davinci_aemif_setup().

I'll address this too in v2.

Bart