To support DT booting of da850 EVM, davinci gpio driver converted to platform
driver. Also when here, start using gpiolib API for gpio get/set functionalities.
Hence removing gpio inline functionalities. However usage of gpiolib API will
cause an additional software latencies.
In this patch series
- Cleaned gpio Davinci driver code with proper commenting style.
- Create platform driver for GPIO Davinci in da8xx and dmxxx platforms and
removed gpio related member updation in davinci_soc_info structure.
- Remove soc_info reference in the gpio davinci driver and start uses
gpiolib interface.
- gpio-tnetv107x driver also modified to use gpiolib API interface.
This series has been tested on da850 EVM for gpio interrupt generation.
This patch series is based on Linux 3.10-rc4 and is availabel at [1].
1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4
KV Sujith (2):
gpio: davinci: move to platform device
ARM: davinci: da8xx: creation of gpio platform device
Philip Avinash (5):
gpio: davinci: coding style correction
ARM: davinci: creation of gpio platform device for dmxxx platforms
ARM: davinci: da8xx: gpio device creation
ARM: davinci: dmxxx: gpio device creation
ARM: davinci: Start using gpiolib API inplace of inline functions
arch/arm/Kconfig | 1 -
arch/arm/mach-davinci/board-da830-evm.c | 19 ++-
arch/arm/mach-davinci/board-da850-evm.c | 11 ++
arch/arm/mach-davinci/board-dm355-evm.c | 27 ++++
arch/arm/mach-davinci/board-dm355-leopard.c | 1 +
arch/arm/mach-davinci/board-dm365-evm.c | 28 ++++
arch/arm/mach-davinci/board-dm644x-evm.c | 26 ++++
arch/arm/mach-davinci/board-dm646x-evm.c | 27 ++++
arch/arm/mach-davinci/board-neuros-osd2.c | 1 +
arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +
arch/arm/mach-davinci/da830.c | 5 -
arch/arm/mach-davinci/da850.c | 5 -
arch/arm/mach-davinci/devices-da8xx.c | 26 ++++
arch/arm/mach-davinci/devices.c | 13 ++
arch/arm/mach-davinci/dm355.c | 5 -
arch/arm/mach-davinci/dm365.c | 6 -
arch/arm/mach-davinci/dm644x.c | 5 -
arch/arm/mach-davinci/dm646x.c | 5 -
arch/arm/mach-davinci/include/mach/common.h | 4 +
arch/arm/mach-davinci/include/mach/da8xx.h | 1 +
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 91 -------------
arch/arm/mach-davinci/include/mach/gpio.h | 88 -------------
arch/arm/mach-davinci/tnetv107x.c | 2 +-
drivers/gpio/gpio-davinci.c | 144 ++++++++++++++-------
drivers/gpio/gpio-tnetv107x.c | 1 +
include/linux/platform_data/gpio-davinci.h | 59 +++++++++
26 files changed, 341 insertions(+), 262 deletions(-)
delete mode 100644 arch/arm/mach-davinci/include/mach/gpio-davinci.h
delete mode 100644 arch/arm/mach-davinci/include/mach/gpio.h
create mode 100644 include/linux/platform_data/gpio-davinci.h
--
1.7.9.5
Make some minor coding style fixes. Use proper multi-line
commenting style, arrange include files alphabetically use
macros for bit definitions.
Signed-off-by: Philip Avinash <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
Changes since v1:
- Remove variable name replacement
- Add line break after BINTEN macro definition
drivers/gpio/gpio-davinci.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 17df6db..e8d189c 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -9,12 +9,12 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
-#include <linux/gpio.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
+
#include <linux/clk.h>
-#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gpio.h>
#include <linux/io.h>
+#include <linux/kernel.h>
#include <asm/mach/irq.h>
@@ -31,6 +31,8 @@ struct davinci_gpio_regs {
u32 intstat;
};
+#define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */
+
#define chip2controller(chip) \
container_of(chip, struct davinci_gpio_controller, chip)
@@ -304,7 +306,8 @@ static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
- /* NOTE: we assume for now that only irqs in the first gpio_chip
+ /*
+ * NOTE: we assume for now that only irqs in the first gpio_chip
* can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
*/
if (offset < soc_info->gpio_unbanked)
@@ -368,7 +371,8 @@ static int __init davinci_gpio_irq_setup(void)
}
clk_prepare_enable(clk);
- /* Arrange gpio_to_irq() support, handling either direct IRQs or
+ /*
+ * Arrange gpio_to_irq() support, handling either direct IRQs or
* banked IRQs. Having GPIOs in the first GPIO bank use direct
* IRQs, while the others use banked IRQs, would need some setup
* tweaks to recognize hardware which can do that.
@@ -450,10 +454,11 @@ static int __init davinci_gpio_irq_setup(void)
}
done:
- /* BINTEN -- per-bank interrupt enable. genirq would also let these
+ /*
+ * BINTEN -- per-bank interrupt enable. genirq would also let these
* bits be set/cleared dynamically.
*/
- __raw_writel(binten, gpio_base + 0x08);
+ __raw_writel(binten, gpio_base + BINTEN);
printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0));
--
1.7.9.5
From: KV Sujith <[email protected]>
Modify GPIO Davinci driver to be compliant to standard platform drivers.
The driver did not have platform driver structure or a probe. Instead,
had a davinci_gpio_setup() function which is called in the pure_init
sequence. The function also had dependency on davinci_soc_info structure
of the corresponding platform. For Device Tree(DT) implementation, we
need to get rid of the dependency on the davinci_soc_info structure.
Hence as a first stage of DT conversion, we implement a probe. Future
commits shall modify the probe to read platform related data from DT.
- Add platform_driver structure and driver register function for davinci
GPIO driver. The driver registration is made to happen in
postcore_initcall. This is required since machine init functions like
da850_lcd_hw_init() make use of GPIO.
- Convert the davinci_gpio_setup() to davinci_gpio_probe().
- Remove access of members in soc_info structure. Instead, relevant data
are taken from davinci_gpio_platform_data structure pointed by
pdev->dev.platform_data.
- Change clk_get() to devm_clk_get() as devm_clk_get() is a device
managed function and makes error handling simpler.
- Change pr_err to dev_err for ngpio error reporting.
- Arrange include files in alphabetical order
- Add struct davinci_gpio_platform_data davinci for gpio module.
Signed-off-by: KV Sujith <[email protected]>
[[email protected]: Move global definition for "struct
davinci_gpio_controller" variable to local in probe and set it as driver
data.]
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
Changes since v1:
- Merge header file to drivermodification patch
- Return error value updated.
- line break alignment fixing.
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 2 +
drivers/gpio/gpio-davinci.c | 123 ++++++++++++++-------
include/linux/platform_data/gpio-davinci.h | 25 +++++
3 files changed, 112 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
index 1fdd1fd..b325a1d 100644
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
@@ -60,6 +60,8 @@ struct davinci_gpio_controller {
void __iomem *set_data;
void __iomem *clr_data;
void __iomem *in_data;
+ int gpio_unbanked;
+ unsigned gpio_irq;
};
/* The __gpio_to_controller() and __gpio_mask() functions inline to constants
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index e8d189c..475a5ece 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -11,12 +11,17 @@
*/
#include <linux/clk.h>
+#include <linux/device.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/io.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
#include <linux/kernel.h>
-
-#include <asm/mach/irq.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/gpio-davinci.h>
struct davinci_gpio_regs {
u32 dir;
@@ -36,10 +41,9 @@ struct davinci_gpio_regs {
#define chip2controller(chip) \
container_of(chip, struct davinci_gpio_controller, chip)
-static struct davinci_gpio_controller chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)];
static void __iomem *gpio_base;
-static struct davinci_gpio_regs __iomem __init *gpio2regs(unsigned gpio)
+static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
{
void __iomem *ptr;
@@ -67,7 +71,7 @@ static inline struct davinci_gpio_regs __iomem *irq2regs(int irq)
return g;
}
-static int __init davinci_gpio_irq_setup(void);
+static int davinci_gpio_irq_setup(struct platform_device *pdev);
/*--------------------------------------------------------------------------*/
@@ -133,33 +137,53 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
__raw_writel((1 << offset), value ? &g->set_data : &g->clr_data);
}
-static int __init davinci_gpio_setup(void)
+static int davinci_gpio_probe(struct platform_device *pdev)
{
int i, base;
unsigned ngpio;
- struct davinci_soc_info *soc_info = &davinci_soc_info;
- struct davinci_gpio_regs *regs;
-
- if (soc_info->gpio_type != GPIO_TYPE_DAVINCI)
- return 0;
+ struct davinci_gpio_controller *chips;
+ struct davinci_gpio_platform_data *pdata;
+ struct davinci_gpio_regs __iomem *regs;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+
+ pdata = dev->platform_data;
+ if (!pdata) {
+ dev_err(dev, "No platform data found\n");
+ return -EINVAL;
+ }
/*
* The gpio banks conceptually expose a segmented bitmap,
* and "ngpio" is one more than the largest zero-based
* bit index that's valid.
*/
- ngpio = soc_info->gpio_num;
+ ngpio = pdata->ngpio;
if (ngpio == 0) {
- pr_err("GPIO setup: how many GPIOs?\n");
+ dev_err(dev, "How many GPIOs?\n");
return -EINVAL;
}
if (WARN_ON(DAVINCI_N_GPIO < ngpio))
ngpio = DAVINCI_N_GPIO;
- gpio_base = ioremap(soc_info->gpio_base, SZ_4K);
- if (WARN_ON(!gpio_base))
+ chips = devm_kzalloc(dev,
+ ngpio * sizeof(struct davinci_gpio_controller),
+ GFP_KERNEL);
+ if (!chips) {
+ dev_err(dev, "Memory allocation failed\n");
return -ENOMEM;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (unlikely(!res)) {
+ dev_err(dev, "Invalid memory resource\n");
+ return -EBUSY;
+ }
+
+ gpio_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(gpio_base))
+ return PTR_ERR(gpio_base);
for (i = 0, base = 0; base < ngpio; i++, base += 32) {
chips[i].chip.label = "DaVinci";
@@ -185,13 +209,10 @@ static int __init davinci_gpio_setup(void)
gpiochip_add(&chips[i].chip);
}
- soc_info->gpio_ctlrs = chips;
- soc_info->gpio_ctlrs_num = DIV_ROUND_UP(ngpio, 32);
-
- davinci_gpio_irq_setup();
+ platform_set_drvdata(pdev, chips);
+ davinci_gpio_irq_setup(pdev);
return 0;
}
-pure_initcall(davinci_gpio_setup);
/*--------------------------------------------------------------------------*/
/*
@@ -304,14 +325,14 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
{
- struct davinci_soc_info *soc_info = &davinci_soc_info;
+ struct davinci_gpio_controller *d = chip2controller(chip);
/*
* NOTE: we assume for now that only irqs in the first gpio_chip
* can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
*/
- if (offset < soc_info->gpio_unbanked)
- return soc_info->gpio_irq + offset;
+ if (offset < d->irq_base)
+ return d->gpio_irq + offset;
else
return -ENODEV;
}
@@ -320,12 +341,11 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
{
struct davinci_gpio_controller *d;
struct davinci_gpio_regs __iomem *g;
- struct davinci_soc_info *soc_info = &davinci_soc_info;
u32 mask;
d = (struct davinci_gpio_controller *)data->handler_data;
g = (struct davinci_gpio_regs __iomem *)d->regs;
- mask = __gpio_mask(data->irq - soc_info->gpio_irq);
+ mask = __gpio_mask(data->irq - d->gpio_irq);
if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
return -EINVAL;
@@ -346,24 +366,33 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
* (dm6446) can be set appropriately for GPIOV33 pins.
*/
-static int __init davinci_gpio_irq_setup(void)
+static int davinci_gpio_irq_setup(struct platform_device *pdev)
{
unsigned gpio, irq, bank;
struct clk *clk;
u32 binten = 0;
unsigned ngpio, bank_irq;
- struct davinci_soc_info *soc_info = &davinci_soc_info;
- struct davinci_gpio_regs __iomem *g;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
+ struct davinci_gpio_platform_data *pdata = dev->platform_data;
+ struct davinci_gpio_regs __iomem *g;
- ngpio = soc_info->gpio_num;
+ ngpio = pdata->ngpio;
+ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ if (unlikely(!res)) {
+ dev_err(dev, "Invalid IRQ resource\n");
+ return -EBUSY;
+ }
- bank_irq = soc_info->gpio_irq;
- if (bank_irq == 0) {
- printk(KERN_ERR "Don't know first GPIO bank IRQ.\n");
- return -EINVAL;
+ bank_irq = res->start;
+
+ if (unlikely(!bank_irq)) {
+ dev_err(dev, "Invalid IRQ resource\n");
+ return -ENODEV;
}
- clk = clk_get(NULL, "gpio");
+ clk = devm_clk_get(dev, "gpio");
if (IS_ERR(clk)) {
printk(KERN_ERR "Error %ld getting gpio clock?\n",
PTR_ERR(clk));
@@ -379,9 +408,9 @@ static int __init davinci_gpio_irq_setup(void)
*/
for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) {
chips[bank].chip.to_irq = gpio_to_irq_banked;
- chips[bank].irq_base = soc_info->gpio_unbanked
+ chips[bank].irq_base = pdata->gpio_unbanked
? -EINVAL
- : (soc_info->intc_irq_num + gpio);
+ : (pdata->intc_irq_num + gpio);
}
/*
@@ -389,7 +418,7 @@ static int __init davinci_gpio_irq_setup(void)
* controller only handling trigger modes. We currently assume no
* IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs.
*/
- if (soc_info->gpio_unbanked) {
+ if (pdata->gpio_unbanked) {
static struct irq_chip_type gpio_unbanked;
/* pass "bank 0" GPIO IRQs to AINTC */
@@ -409,7 +438,7 @@ static int __init davinci_gpio_irq_setup(void)
__raw_writel(~0, &g->set_rising);
/* set the direct IRQs up to use that irqchip */
- for (gpio = 0; gpio < soc_info->gpio_unbanked; gpio++, irq++) {
+ for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) {
irq_set_chip(irq, &gpio_unbanked.chip);
irq_set_handler_data(irq, &chips[gpio / 32]);
irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH);
@@ -464,3 +493,21 @@ done:
return 0;
}
+
+static struct platform_driver davinci_gpio_driver = {
+ .probe = davinci_gpio_probe,
+ .driver = {
+ .name = "davinci_gpio",
+ .owner = THIS_MODULE,
+ },
+};
+
+/**
+ * GPIO driver registration needs to be done before machine_init functions
+ * access GPIO. Hence davinci_gpio_drv_reg() is a postcore_initcall.
+ */
+static int __init davinci_gpio_drv_reg(void)
+{
+ return platform_driver_register(&davinci_gpio_driver);
+}
+postcore_initcall(davinci_gpio_drv_reg);
diff --git a/include/linux/platform_data/gpio-davinci.h b/include/linux/platform_data/gpio-davinci.h
new file mode 100644
index 0000000..2fcc125
--- /dev/null
+++ b/include/linux/platform_data/gpio-davinci.h
@@ -0,0 +1,25 @@
+/*
+ * DaVinci GPIO Platform Related Defines
+ *
+ * Copyright (C) 2013 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 as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __DAVINCI_GPIO_PLATFORM_H
+#define __DAVINCI_GPIO_PLATFORM_H
+
+struct davinci_gpio_platform_data {
+ u32 ngpio;
+ u32 gpio_unbanked;
+ u32 intc_irq_num;
+};
+
+#endif
--
1.7.9.5
From: KV Sujith <[email protected]>
gpio controller resource information being associated with
davinci_soc_info structure and not created any device. Hence davinci
gpio didn't fall under proper device model. This patch creates gpio
davinci as a platform device for da8xx platforms.
- Add Memory and IRQ resources for da8xx
- Register GPIO platform driver for da8xx.
- Add da8xx_register_gpio API to create platform device for da8xx
platforms.
Signed-off-by: KV Sujith <[email protected]>
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
arch/arm/mach-davinci/devices-da8xx.c | 26 ++++++++++++++++++++++++++
arch/arm/mach-davinci/include/mach/da8xx.h | 1 +
2 files changed, 27 insertions(+)
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index bf57252..892ad86 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -640,6 +640,32 @@ int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)
return platform_device_register(&da8xx_lcdc_device);
}
+static struct resource da8xx_gpio_resources[] = {
+ { /* registers */
+ .start = DA8XX_GPIO_BASE,
+ .end = DA8XX_GPIO_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* interrupt */
+ .start = IRQ_DA8XX_GPIO0,
+ .end = IRQ_DA8XX_GPIO8,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device da8xx_gpio_device = {
+ .name = "davinci_gpio",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(da8xx_gpio_resources),
+ .resource = da8xx_gpio_resources,
+};
+
+int __init da8xx_register_gpio(void *pdata)
+{
+ da8xx_gpio_device.dev.platform_data = pdata;
+ return platform_device_register(&da8xx_gpio_device);
+}
+
static struct resource da8xx_mmcsd0_resources[] = {
{ /* registers */
.start = DA8XX_MMCSD0_BASE,
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 2e1c9ea..aa66690 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -96,6 +96,7 @@ int da8xx_register_mmcsd0(struct davinci_mmc_config *config);
int da850_register_mmcsd1(struct davinci_mmc_config *config);
void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata);
int da8xx_register_rtc(void);
+int da8xx_register_gpio(void *pdata);
int da850_register_cpufreq(char *async_clk);
int da8xx_register_cpuidle(void);
void __iomem * __init da8xx_get_mem_ctlr(void);
--
1.7.9.5
gpio controller resource information being associated with
davinci_soc_info structure and not created any device. Hence davinci
gpio didn't fall under proper device model. This patch creates gpio
davinci as a platform device for dmxxx platforms.
Also add daivinci_register_gpio API to create platform device for dmxxx
platforms.
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
arch/arm/mach-davinci/devices.c | 13 +++++++++++++
arch/arm/mach-davinci/include/mach/common.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index a7068a3..b4f345b 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -313,6 +313,19 @@ static void davinci_init_wdt(void)
platform_device_register(&davinci_wdt_device);
}
+static struct platform_device davinci_gpio_device = {
+ .name = "davinci_gpio",
+ .id = -1,
+};
+
+int davinci_gpio_register(struct resource *res, int size, void *pdata)
+{
+ davinci_gpio_device.resource = res;
+ davinci_gpio_device.num_resources = size;
+ davinci_gpio_device.dev.platform_data = pdata;
+ return platform_device_register(&davinci_gpio_device);
+}
+
/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index b124b77..bd389ba 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -14,6 +14,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
+#include <linux/ioport.h>
extern void davinci_timer_init(void);
@@ -83,6 +84,7 @@ extern void davinci_common_init(struct davinci_soc_info *soc_info);
extern void davinci_init_ide(void);
void davinci_restart(char mode, const char *cmd);
void davinci_init_late(void);
+int davinci_gpio_register(struct resource *res, int size, void *pdata);
#ifdef CONFIG_DAVINCI_RESET_CLOCKS
int davinci_clk_disable_unused(void);
--
1.7.9.5
Create davinci gpio device and remove references in davinci_soc_info
structure. Also rearrange header file inclusion in group basis.
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 19 +++++++++++++++----
arch/arm/mach-davinci/board-da850-evm.c | 11 +++++++++++
arch/arm/mach-davinci/board-omapl138-hawk.c | 2 ++
arch/arm/mach-davinci/da830.c | 4 ----
arch/arm/mach-davinci/da850.c | 4 ----
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 1332de8..4e8bcc1 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -22,17 +22,19 @@
#include <linux/mtd/partitions.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/spi-davinci.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <mach/cp_intc.h>
#include <mach/mux.h>
-#include <linux/platform_data/mtd-davinci.h>
+#include <mach/common.h>
#include <mach/da8xx.h>
-#include <linux/platform_data/usb-davinci.h>
-#include <linux/platform_data/mtd-davinci-aemif.h>
-#include <linux/platform_data/spi-davinci.h>
#define DA830_EVM_PHY_ID ""
/*
@@ -590,11 +592,20 @@ static struct spi_board_info da830evm_spi_info[] = {
},
};
+static struct davinci_gpio_platform_data da830_gpio_platform_data = {
+ .ngpio = 128,
+ .intc_irq_num = DA830_N_CP_INTC_IRQ,
+};
+
static __init void da830_evm_init(void)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
int ret;
+ ret = da8xx_register_gpio(&da830_gpio_platform_data);
+ if (ret)
+ pr_warn("da830_evm_init: GPIO init failed: %d\n", ret);
+
ret = da830_register_edma(da830_edma_rsv);
if (ret)
pr_warning("da830_evm_init: edma registration failed: %d\n",
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 8a24b6c..d5dd010 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -28,6 +28,7 @@
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/platform_device.h>
+#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/spi-davinci.h>
@@ -42,6 +43,7 @@
#include <mach/da8xx.h>
#include <mach/mux.h>
#include <mach/sram.h>
+#include <mach/common.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -1138,6 +1140,11 @@ static struct edma_rsv_info *da850_edma_rsv[2] = {
&da850_edma_cc1_rsv,
};
+static struct davinci_gpio_platform_data da850_gpio_platform_data = {
+ .ngpio = 144,
+ .intc_irq_num = DA850_N_CP_INTC_IRQ,
+};
+
#ifdef CONFIG_CPU_FREQ
static __init int da850_evm_init_cpufreq(void)
{
@@ -1444,6 +1451,10 @@ static __init void da850_evm_init(void)
{
int ret;
+ ret = da8xx_register_gpio(&da850_gpio_platform_data);
+ if (ret)
+ pr_warn("da850_evm_init: GPIO init failed: %d\n", ret);
+
ret = pmic_tps65070_init();
if (ret)
pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret);
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index b8c20de..1f44a1b 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -13,6 +13,7 @@
#include <linux/init.h>
#include <linux/console.h>
#include <linux/gpio.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -20,6 +21,7 @@
#include <mach/cp_intc.h>
#include <mach/da8xx.h>
#include <mach/mux.h>
+#include <mach/common.h>
#define HAWKBOARD_PHY_ID "davinci_mdio-0:07"
#define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index abbaf02..e7b79ee 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1195,10 +1195,6 @@ static struct davinci_soc_info davinci_soc_info_da830 = {
.intc_irq_prios = da830_default_priorities,
.intc_irq_num = DA830_N_CP_INTC_IRQ,
.timer_info = &da830_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DA8XX_GPIO_BASE,
- .gpio_num = 128,
- .gpio_irq = IRQ_DA8XX_GPIO0,
.serial_dev = &da8xx_serial_device,
.emac_pdata = &da8xx_emac_pdata,
};
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 93bcf06..de8753d 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1298,10 +1298,6 @@ static struct davinci_soc_info davinci_soc_info_da850 = {
.intc_irq_prios = da850_default_priorities,
.intc_irq_num = DA850_N_CP_INTC_IRQ,
.timer_info = &da850_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DA8XX_GPIO_BASE,
- .gpio_num = 144,
- .gpio_irq = IRQ_DA8XX_GPIO0,
.serial_dev = &da8xx_serial_device,
.emac_pdata = &da8xx_emac_pdata,
.sram_dma = DA8XX_SHARED_RAM_BASE,
--
1.7.9.5
Create davinci gpio device and remove gpio references in
davinci_soc_info structure for dmxxx platforms. Also add Memory and IRQ
resources for GPIO platform device.
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
Changes since v1:
- Add commit message
arch/arm/mach-davinci/board-dm355-evm.c | 27 ++++++++++++++++++++++++++
arch/arm/mach-davinci/board-dm355-leopard.c | 1 +
arch/arm/mach-davinci/board-dm365-evm.c | 28 +++++++++++++++++++++++++++
arch/arm/mach-davinci/board-dm644x-evm.c | 26 +++++++++++++++++++++++++
arch/arm/mach-davinci/board-dm646x-evm.c | 27 ++++++++++++++++++++++++++
arch/arm/mach-davinci/board-neuros-osd2.c | 1 +
arch/arm/mach-davinci/dm355.c | 4 ----
arch/arm/mach-davinci/dm365.c | 5 -----
arch/arm/mach-davinci/dm644x.c | 4 ----
arch/arm/mach-davinci/dm646x.c | 4 ----
arch/arm/mach-davinci/include/mach/common.h | 2 ++
11 files changed, 112 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index c2a0a67..05e6e86 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -28,9 +28,11 @@
#include <linux/platform_data/i2c-davinci.h>
#include <mach/serial.h>
+#include <mach/common.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/gpio-davinci.h>
#include "davinci.h"
@@ -376,9 +378,34 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = {
},
};
+static struct resource dm355_gpio_resources[] = {
+ { /* registers */
+ .start = DAVINCI_GPIO_BASE,
+ .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* interrupt */
+ .start = IRQ_DM355_GPIOBNK0,
+ .end = IRQ_DM355_GPIOBNK6,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct davinci_gpio_platform_data dm355_gpio_platform_data = {
+ .ngpio = 104,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+};
+
static __init void dm355_evm_init(void)
{
struct clk *aemif;
+ int ret;
+
+ ret = davinci_gpio_register(dm355_gpio_resources,
+ sizeof(dm355_gpio_resources),
+ &dm355_gpio_platform_data);
+ if (ret)
+ pr_warn("dm355_evm_init: GPIO init failed: %d\n", ret);
gpio_request(1, "dm9000");
gpio_direction_input(1);
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index dff4ddc..34a2b64 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -25,6 +25,7 @@
#include <linux/platform_data/i2c-davinci.h>
#include <mach/serial.h>
+#include <mach/common.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/usb-davinci.h>
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index fd38c8d..60f7b84 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -39,6 +39,7 @@
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <media/ths7303.h>
#include <media/tvp514x.h>
@@ -746,8 +747,35 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = {
},
};
+static struct resource dm365_gpio_resources[] = {
+ { /* registers */
+ .start = DAVINCI_GPIO_BASE,
+ .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* interrupt */
+ .start = IRQ_DM365_GPIO0,
+ .end = IRQ_DM365_GPIO7,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct davinci_gpio_platform_data dm365_gpio_platform_data = {
+ .ngpio = 104,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+ .gpio_unbanked = 8,
+};
+
static __init void dm365_evm_init(void)
{
+ int ret;
+
+ ret = davinci_gpio_register(dm365_gpio_resources,
+ sizeof(dm365_gpio_resources),
+ &dm365_gpio_platform_data);
+ if (ret)
+ pr_warn("dm365_evm_init: GPIO init failed: %d\n", ret);
+
evm_init_i2c();
davinci_serial_init(&uart_config);
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index a33686a..57a7ed8 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -39,6 +39,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/gpio-davinci.h>
#include "davinci.h"
@@ -755,11 +756,36 @@ static int davinci_phy_fixup(struct phy_device *phydev)
#define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)
+static struct resource dm644_gpio_resources[] = {
+ { /* registers */
+ .start = DAVINCI_GPIO_BASE,
+ .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* interrupt */
+ .start = IRQ_GPIOBNK0,
+ .end = IRQ_GPIOBNK4,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct davinci_gpio_platform_data dm644_gpio_platform_data = {
+ .ngpio = 71,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+};
+
static __init void davinci_evm_init(void)
{
+ int ret;
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;
+ ret = davinci_gpio_register(dm644_gpio_resources,
+ sizeof(dm644_gpio_resources),
+ &dm644_gpio_platform_data);
+ if (ret)
+ pr_warn("davinci_evm_init: GPIO init failed: %d\n", ret);
+
aemif_clk = clk_get(NULL, "aemif");
clk_prepare_enable(aemif_clk);
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index fbb8e5a..f624d70 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -39,11 +39,13 @@
#include <mach/common.h>
#include <mach/serial.h>
+#include <mach/irqs.h>
#include <linux/platform_data/i2c-davinci.h>
#include <linux/platform_data/mtd-davinci.h>
#include <mach/clock.h>
#include <mach/cdce949.h>
#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/gpio-davinci.h>
#include "davinci.h"
#include "clock.h"
@@ -787,10 +789,35 @@ static struct edma_rsv_info dm646x_edma_rsv[] = {
},
};
+static struct resource dm646_gpio_resources[] = {
+ { /* registers */
+ .start = DAVINCI_GPIO_BASE,
+ .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ { /* interrupt */
+ .start = IRQ_DM646X_GPIOBNK0,
+ .end = IRQ_DM646X_GPIOBNK2,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct davinci_gpio_platform_data dm646_gpio_platform_data = {
+ .ngpio = 43,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+};
+
static __init void evm_init(void)
{
+ int ret;
struct davinci_soc_info *soc_info = &davinci_soc_info;
+ ret = davinci_gpio_register(dm646_gpio_resources,
+ sizeof(dm646_gpio_resources),
+ &dm646_gpio_platform_data);
+ if (ret)
+ pr_warn("evm_init: GPIO init failed: %d\n", ret);
+
evm_init_i2c();
davinci_serial_init(&uart_config);
dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 2bc112a..c2b96ec 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -37,6 +37,7 @@
#include <linux/platform_data/mtd-davinci.h>
#include <linux/platform_data/mmc-davinci.h>
#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/gpio-davinci.h>
#include "davinci.h"
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index a11034a..f7a18ff 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -977,10 +977,6 @@ static struct davinci_soc_info davinci_soc_info_dm355 = {
.intc_irq_prios = dm355_default_priorities,
.intc_irq_num = DAVINCI_N_AINTC_IRQ,
.timer_info = &dm355_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DAVINCI_GPIO_BASE,
- .gpio_num = 104,
- .gpio_irq = IRQ_DM355_GPIOBNK0,
.serial_dev = &dm355_serial_device,
.sram_dma = 0x00010000,
.sram_len = SZ_32K,
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 40fa4fe..2c80a6b 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -1088,11 +1088,6 @@ static struct davinci_soc_info davinci_soc_info_dm365 = {
.intc_irq_prios = dm365_default_priorities,
.intc_irq_num = DAVINCI_N_AINTC_IRQ,
.timer_info = &dm365_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DAVINCI_GPIO_BASE,
- .gpio_num = 104,
- .gpio_irq = IRQ_DM365_GPIO0,
- .gpio_unbanked = 8, /* really 16 ... skip muxed GPIOs */
.serial_dev = &dm365_serial_device,
.emac_pdata = &dm365_emac_pdata,
.sram_dma = 0x00010000,
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 4d37d3e..9e23e64 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -868,10 +868,6 @@ static struct davinci_soc_info davinci_soc_info_dm644x = {
.intc_irq_prios = dm644x_default_priorities,
.intc_irq_num = DAVINCI_N_AINTC_IRQ,
.timer_info = &dm644x_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DAVINCI_GPIO_BASE,
- .gpio_num = 71,
- .gpio_irq = IRQ_GPIOBNK0,
.serial_dev = &dm644x_serial_device,
.emac_pdata = &dm644x_emac_pdata,
.sram_dma = 0x00008000,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index ac7b431..1058e7c 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -845,10 +845,6 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {
.intc_irq_prios = dm646x_default_priorities,
.intc_irq_num = DAVINCI_N_AINTC_IRQ,
.timer_info = &dm646x_timer_info,
- .gpio_type = GPIO_TYPE_DAVINCI,
- .gpio_base = DAVINCI_GPIO_BASE,
- .gpio_num = 43, /* Only 33 usable */
- .gpio_irq = IRQ_DM646X_GPIOBNK0,
.serial_dev = &dm646x_serial_device,
.emac_pdata = &dm646x_emac_pdata,
.sram_dma = 0x10010000,
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index bd389ba..f9d81fb 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -38,6 +38,8 @@ struct davinci_timer_info {
struct davinci_gpio_controller;
+#define DAVINCI_GPIO_BASE 0x01C67000
+
/*
* SoC info passed into common davinci modules.
*
--
1.7.9.5
Remove NEED_MACH_GPIO_H config select option for ARCH_DAVINCI to start
use gpiolib interface for davinci platforms. However with this software
latencies for gpio_get/set APIs will affect. Latency has increased by 18
microsecond with gpiolib API as compared with inline API's.
Software latency is calculated on da850 EVM for gpio_get_value API by
taking the printk timing for API execution with interrupts disabled.
Experiment has done for inline and gpiolib API interface.
inline gpio API with interrupt disabled
[ 29.734337] before gpio_get
[ 29.736847] after gpio_get
Time difference 0.00251
gpio library with interrupt disabled
[ 272.876763] before gpio_get
[ 272.879291] after gpio_get
Time difference 0.002528
Latency increased by (0.002528 - 0.00251) = 18 microsecond.
Also being here
- Moved following definitions from mach folder to include directory
struct davinci_gpio_controller
Macro GPIO(x)
inline function __gpio_mask
- Removed GPIO_TYPE_DAVINCI enum definition as GPIO Davinci is converted
to Linux device driver model.
- With removal of select option of NEED_MACH_GPIO_H for ARCH_DAVINCI,
gpio-tnetv107x also start using gpiolib interface. Hence removes
related header files
arch/arm/mach-davinci/include/mach/gpio-davinci.h
arch/arm/mach-davinci/include/mach/gpio.h
and include linux/platform_data/gpio-davinci.h header file to support
gpio-davinci platform definitions.
Signed-off-by: Philip Avinash <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
Changes since v1:
- Remove inline GPIO API support for tnetv107x platforms
- Remove gpio header files in mach directory.
- Remove include of gpio header files from mach directory.
- Moved enum davinci_gpio_type to include folder
- Replace __ASM_ARCH_DAVINCI_GPIO_H with __DAVINCI_GPIO_PLATFORM_H
arch/arm/Kconfig | 1 -
arch/arm/mach-davinci/da830.c | 1 -
arch/arm/mach-davinci/da850.c | 1 -
arch/arm/mach-davinci/dm355.c | 1 -
arch/arm/mach-davinci/dm365.c | 1 -
arch/arm/mach-davinci/dm644x.c | 1 -
arch/arm/mach-davinci/dm646x.c | 1 -
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 93 ---------------------
arch/arm/mach-davinci/include/mach/gpio.h | 88 -------------------
arch/arm/mach-davinci/tnetv107x.c | 2 +-
drivers/gpio/gpio-tnetv107x.c | 1 +
include/linux/platform_data/gpio-davinci.h | 34 ++++++++
12 files changed, 36 insertions(+), 189 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 49d993c..4d099fe 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -839,7 +839,6 @@ config ARCH_DAVINCI
select GENERIC_CLOCKEVENTS
select GENERIC_IRQ_CHIP
select HAVE_IDE
- select NEED_MACH_GPIO_H
select USE_OF
select ZONE_DMA
help
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index e7b79ee..0f2cb28 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -20,7 +20,6 @@
#include <mach/common.h>
#include <mach/time.h>
#include <mach/da8xx.h>
-#include <mach/gpio-davinci.h>
#include "clock.h"
#include "mux.h"
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index de8753d..cf62641 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -28,7 +28,6 @@
#include <mach/da8xx.h>
#include <mach/cpufreq.h>
#include <mach/pm.h>
-#include <mach/gpio-davinci.h>
#include "clock.h"
#include "mux.h"
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index f7a18ff..9564202 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -27,7 +27,6 @@
#include <mach/serial.h>
#include <mach/common.h>
#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
#include "davinci.h"
#include "clock.h"
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 2c80a6b..8c8c0de 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -31,7 +31,6 @@
#include <mach/common.h>
#include <linux/platform_data/keyscan-davinci.h>
#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
#include "davinci.h"
#include "clock.h"
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 9e23e64..75146b5 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -23,7 +23,6 @@
#include <mach/time.h>
#include <mach/serial.h>
#include <mach/common.h>
-#include <mach/gpio-davinci.h>
#include "davinci.h"
#include "clock.h"
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 1058e7c..d15a36c 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -24,7 +24,6 @@
#include <mach/time.h>
#include <mach/serial.h>
#include <mach/common.h>
-#include <mach/gpio-davinci.h>
#include "davinci.h"
#include "clock.h"
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
deleted file mode 100644
index b325a1d..0000000
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * TI DaVinci GPIO Support
- *
- * Copyright (c) 2006 David Brownell
- * Copyright (c) 2007, MontaVista Software, Inc. <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __DAVINCI_DAVINCI_GPIO_H
-#define __DAVINCI_DAVINCI_GPIO_H
-
-#include <linux/io.h>
-#include <linux/spinlock.h>
-
-#include <asm-generic/gpio.h>
-
-#include <mach/irqs.h>
-#include <mach/common.h>
-
-#define DAVINCI_GPIO_BASE 0x01C67000
-
-enum davinci_gpio_type {
- GPIO_TYPE_DAVINCI = 0,
- GPIO_TYPE_TNETV107X,
-};
-
-/*
- * basic gpio routines
- *
- * board-specific init should be done by arch/.../.../board-XXX.c (maybe
- * initializing banks together) rather than boot loaders; kexec() won't
- * go through boot loaders.
- *
- * the gpio clock will be turned on when gpios are used, and you may also
- * need to pay attention to PINMUX registers to be sure those pins are
- * used as gpios, not with other peripherals.
- *
- * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation,
- * and maybe for later updates, code may write GPIO(N). These may be
- * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip
- * may not support all the GPIOs in that range.
- *
- * GPIOs can also be on external chips, numbered after the ones built-in
- * to the DaVinci chip. For now, they won't be usable as IRQ sources.
- */
-#define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
-
-/* Convert GPIO signal to GPIO pin number */
-#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
-
-struct davinci_gpio_controller {
- struct gpio_chip chip;
- int irq_base;
- spinlock_t lock;
- void __iomem *regs;
- void __iomem *set_data;
- void __iomem *clr_data;
- void __iomem *in_data;
- int gpio_unbanked;
- unsigned gpio_irq;
-};
-
-/* The __gpio_to_controller() and __gpio_mask() functions inline to constants
- * with constant parameters; or in outlined code they execute at runtime.
- *
- * You'd access the controller directly when reading or writing more than
- * one gpio value at a time, and to support wired logic where the value
- * being driven by the cpu need not match the value read back.
- *
- * These are NOT part of the cross-platform GPIO interface
- */
-static inline struct davinci_gpio_controller *
-__gpio_to_controller(unsigned gpio)
-{
- struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs;
- int index = gpio / 32;
-
- if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num)
- return NULL;
-
- return ctlrs + index;
-}
-
-static inline u32 __gpio_mask(unsigned gpio)
-{
- return 1 << (gpio % 32);
-}
-
-#endif /* __DAVINCI_DAVINCI_GPIO_H */
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h
deleted file mode 100644
index 960e9de..0000000
--- a/arch/arm/mach-davinci/include/mach/gpio.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * TI DaVinci GPIO Support
- *
- * Copyright (c) 2006 David Brownell
- * Copyright (c) 2007, MontaVista Software, Inc. <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __DAVINCI_GPIO_H
-#define __DAVINCI_GPIO_H
-
-#include <asm-generic/gpio.h>
-
-#define __ARM_GPIOLIB_COMPLEX
-
-/* The inline versions use the static inlines in the driver header */
-#include "gpio-davinci.h"
-
-/*
- * The get/set/clear functions will inline when called with constant
- * parameters referencing built-in GPIOs, for low-overhead bitbanging.
- *
- * gpio_set_value() will inline only on traditional Davinci style controllers
- * with distinct set/clear registers.
- *
- * Otherwise, calls with variable parameters or referencing external
- * GPIOs (e.g. on GPIO expander chips) use outlined functions.
- */
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- if (__builtin_constant_p(value) && gpio < davinci_soc_info.gpio_num) {
- struct davinci_gpio_controller *ctlr;
- u32 mask;
-
- ctlr = __gpio_to_controller(gpio);
-
- if (ctlr->set_data != ctlr->clr_data) {
- mask = __gpio_mask(gpio);
- if (value)
- __raw_writel(mask, ctlr->set_data);
- else
- __raw_writel(mask, ctlr->clr_data);
- return;
- }
- }
-
- __gpio_set_value(gpio, value);
-}
-
-/* Returns zero or nonzero; works for gpios configured as inputs OR
- * as outputs, at least for built-in GPIOs.
- *
- * NOTE: for built-in GPIOs, changes in reported values are synchronized
- * to the GPIO clock. This is easily seen after calling gpio_set_value()
- * and then immediately gpio_get_value(), where the gpio_get_value() will
- * return the old value until the GPIO clock ticks and the new value gets
- * latched.
- */
-static inline int gpio_get_value(unsigned gpio)
-{
- struct davinci_gpio_controller *ctlr;
-
- if (!__builtin_constant_p(gpio) || gpio >= davinci_soc_info.gpio_num)
- return __gpio_get_value(gpio);
-
- ctlr = __gpio_to_controller(gpio);
- return __gpio_mask(gpio) & __raw_readl(ctlr->in_data);
-}
-
-static inline int gpio_cansleep(unsigned gpio)
-{
- if (__builtin_constant_p(gpio) && gpio < davinci_soc_info.gpio_num)
- return 0;
- else
- return __gpio_cansleep(gpio);
-}
-
-static inline int irq_to_gpio(unsigned irq)
-{
- /* don't support the reverse mapping */
- return -ENOSYS;
-}
-
-#endif /* __DAVINCI_GPIO_H */
diff --git a/arch/arm/mach-davinci/tnetv107x.c b/arch/arm/mach-davinci/tnetv107x.c
index 3b2a70d..28418ba 100644
--- a/arch/arm/mach-davinci/tnetv107x.c
+++ b/arch/arm/mach-davinci/tnetv107x.c
@@ -19,6 +19,7 @@
#include <linux/io.h>
#include <linux/err.h>
#include <linux/platform_device.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <asm/mach/map.h>
@@ -30,7 +31,6 @@
#include <mach/irqs.h>
#include <mach/hardware.h>
#include <mach/tnetv107x.h>
-#include <mach/gpio-davinci.h>
#include "clock.h"
#include "mux.h"
diff --git a/drivers/gpio/gpio-tnetv107x.c b/drivers/gpio/gpio-tnetv107x.c
index c7ed335..8aaf129 100644
--- a/drivers/gpio/gpio-tnetv107x.c
+++ b/drivers/gpio/gpio-tnetv107x.c
@@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/gpio.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <mach/common.h>
#include <mach/tnetv107x.h>
diff --git a/include/linux/platform_data/gpio-davinci.h b/include/linux/platform_data/gpio-davinci.h
index 2fcc125..0df700d 100644
--- a/include/linux/platform_data/gpio-davinci.h
+++ b/include/linux/platform_data/gpio-davinci.h
@@ -16,10 +16,44 @@
#ifndef __DAVINCI_GPIO_PLATFORM_H
#define __DAVINCI_GPIO_PLATFORM_H
+#include <linux/io.h>
+#include <linux/spinlock.h>
+
+#include <asm-generic/gpio.h>
+
+enum davinci_gpio_type {
+ GPIO_TYPE_TNETV107X = 0,
+};
+
struct davinci_gpio_platform_data {
u32 ngpio;
u32 gpio_unbanked;
u32 intc_irq_num;
};
+
+struct davinci_gpio_controller {
+ struct gpio_chip chip;
+ int irq_base;
+ spinlock_t lock;
+ void __iomem *regs;
+ void __iomem *set_data;
+ void __iomem *clr_data;
+ void __iomem *in_data;
+ int gpio_unbanked;
+ unsigned gpio_irq;
+};
+
+/*
+ * basic gpio routines
+ */
+#define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
+
+/* Convert GPIO signal to GPIO pin number */
+#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
+
+static inline u32 __gpio_mask(unsigned gpio)
+{
+ return 1 << (gpio % 32);
+}
#endif
--
1.7.9.5
Sender mail id got corrupted. I will send another.
Thanks
Avinash
On Fri, Jun 14, 2013 at 15:04:34, [email protected] wrote:
> From: Philip Avinash <[email protected]>
>
> To support DT booting of da850 EVM, davinci gpio driver converted to platform
> driver. Also when here, start using gpiolib API for gpio get/set functionalities.
> Hence removing gpio inline functionalities. However usage of gpiolib API will
> cause an additional software latencies.
>
> In this patch series
> - Cleaned gpio Davinci driver code with proper commenting style.
> - Create platform driver for GPIO Davinci in da8xx and dmxxx platforms and
> removed gpio related member updation in davinci_soc_info structure.
> - Remove soc_info reference in the gpio davinci driver and start uses
> gpiolib interface.
> - gpio-tnetv107x driver also modified to use gpiolib API interface.
>
> This series has been tested on da850 EVM for gpio interrupt generation.
> This patch series is based on Linux 3.10-rc4 and is availabel at [1].
>
> 1. https://github.com/avinashphilip/am335x_linux/tree/linux_davinci_v3.10_soc_gpio_v310-rc4
>
> KV Sujith (2):
> gpio: davinci: move to platform device
> ARM: davinci: da8xx: creation of gpio platform device
>
> Philip Avinash (5):
> gpio: davinci: coding style correction
> ARM: davinci: creation of gpio platform device for dmxxx platforms
> ARM: davinci: da8xx: gpio device creation
> ARM: davinci: dmxxx: gpio device creation
> ARM: davinci: Start using gpiolib API inplace of inline functions
>
> arch/arm/Kconfig | 1 -
> arch/arm/mach-davinci/board-da830-evm.c | 19 ++-
> arch/arm/mach-davinci/board-da850-evm.c | 11 ++
> arch/arm/mach-davinci/board-dm355-evm.c | 27 ++++
> arch/arm/mach-davinci/board-dm355-leopard.c | 1 +
> arch/arm/mach-davinci/board-dm365-evm.c | 28 ++++
> arch/arm/mach-davinci/board-dm644x-evm.c | 26 ++++
> arch/arm/mach-davinci/board-dm646x-evm.c | 27 ++++
> arch/arm/mach-davinci/board-neuros-osd2.c | 1 +
> arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +
> arch/arm/mach-davinci/da830.c | 5 -
> arch/arm/mach-davinci/da850.c | 5 -
> arch/arm/mach-davinci/devices-da8xx.c | 26 ++++
> arch/arm/mach-davinci/devices.c | 13 ++
> arch/arm/mach-davinci/dm355.c | 5 -
> arch/arm/mach-davinci/dm365.c | 6 -
> arch/arm/mach-davinci/dm644x.c | 5 -
> arch/arm/mach-davinci/dm646x.c | 5 -
> arch/arm/mach-davinci/include/mach/common.h | 4 +
> arch/arm/mach-davinci/include/mach/da8xx.h | 1 +
> arch/arm/mach-davinci/include/mach/gpio-davinci.h | 91 -------------
> arch/arm/mach-davinci/include/mach/gpio.h | 88 -------------
> arch/arm/mach-davinci/tnetv107x.c | 2 +-
> drivers/gpio/gpio-davinci.c | 144 ++++++++++++++-------
> drivers/gpio/gpio-tnetv107x.c | 1 +
> include/linux/platform_data/gpio-davinci.h | 59 +++++++++
> 26 files changed, 341 insertions(+), 262 deletions(-)
> delete mode 100644 arch/arm/mach-davinci/include/mach/gpio-davinci.h
> delete mode 100644 arch/arm/mach-davinci/include/mach/gpio.h
> create mode 100644 include/linux/platform_data/gpio-davinci.h
>
> --
> 1.7.9.5
>
>
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> Make some minor coding style fixes. Use proper multi-line
> commenting style, arrange include files alphabetically use
> macros for bit definitions.
Its a register offset, not bit definition.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> Changes since v1:
> - Remove variable name replacement
> - Add line break after BINTEN macro definition
>
> drivers/gpio/gpio-davinci.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 17df6db..e8d189c 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -9,12 +9,12 @@
> * the Free Software Foundation; either version 2 of the License, or
> * (at your option) any later version.
> */
> -#include <linux/gpio.h>
> -#include <linux/errno.h>
> -#include <linux/kernel.h>
> +
This is unnecessary empty line. I made these fixes locally and added
this to my v3.11/gpio branch.
Thanks,
Sekhar
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> From: KV Sujith <[email protected]>
>
> Modify GPIO Davinci driver to be compliant to standard platform drivers.
> The driver did not have platform driver structure or a probe. Instead,
> had a davinci_gpio_setup() function which is called in the pure_init
> sequence. The function also had dependency on davinci_soc_info structure
> of the corresponding platform. For Device Tree(DT) implementation, we
> need to get rid of the dependency on the davinci_soc_info structure.
> Hence as a first stage of DT conversion, we implement a probe. Future
> commits shall modify the probe to read platform related data from DT.
>
> - Add platform_driver structure and driver register function for davinci
> GPIO driver. The driver registration is made to happen in
> postcore_initcall. This is required since machine init functions like
> da850_lcd_hw_init() make use of GPIO.
> - Convert the davinci_gpio_setup() to davinci_gpio_probe().
> - Remove access of members in soc_info structure. Instead, relevant data
> are taken from davinci_gpio_platform_data structure pointed by
> pdev->dev.platform_data.
> - Change clk_get() to devm_clk_get() as devm_clk_get() is a device
> managed function and makes error handling simpler.
> - Change pr_err to dev_err for ngpio error reporting.
s/ngpio/gpio
> - Arrange include files in alphabetical order
Doesn't happen in this patch.
> - Add struct davinci_gpio_platform_data davinci for gpio module.
>
> Signed-off-by: KV Sujith <[email protected]>
> [[email protected]: Move global definition for "struct
> davinci_gpio_controller" variable to local in probe and set it as driver
> data.]
> Signed-off-by: Philip Avinash <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
> index 1fdd1fd..b325a1d 100644
> --- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
> +++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
> @@ -60,6 +60,8 @@ struct davinci_gpio_controller {
> void __iomem *set_data;
> void __iomem *clr_data;
> void __iomem *in_data;
> + int gpio_unbanked;
You don't really use this member in this patch. You should add it in the
patch you need it in.
I fixed these issues locally and pushed this patch to my v3.11/gpio branch.
Thanks,
Sekhar
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> From: KV Sujith <[email protected]>
>
> gpio controller resource information being associated with
> davinci_soc_info structure and not created any device. Hence davinci
> gpio didn't fall under proper device model. This patch creates gpio
> davinci as a platform device for da8xx platforms.
I didn't really find the description coherent. I simplified it to:
ARM: davinci: da8xx: support gpio platform device
DaVinci GPIO driver now uses platform device model.
Convert DA8XX SoC code to use the new model.
- Add Memory and IRQ resources for da8xx
- Add da8xx_register_gpio API to create platform device for da8xx
platforms.
Signed-off-by: KV Sujith <[email protected]>
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
[[email protected]: simplify commit message]
Signed-off-by: Sekhar Nori <[email protected]>
Before applying the patch.
Thanks,
Sekhar
On Fri, Jun 14, 2013 at 11:35 AM, Philip Avinash <[email protected]> wrote:
> Remove NEED_MACH_GPIO_H config select option for ARCH_DAVINCI to start
> use gpiolib interface for davinci platforms. However with this software
> latencies for gpio_get/set APIs will affect. Latency has increased by 18
> microsecond with gpiolib API as compared with inline API's.
>
> Software latency is calculated on da850 EVM for gpio_get_value API by
> taking the printk timing for API execution with interrupts disabled.
> Experiment has done for inline and gpiolib API interface.
>
> inline gpio API with interrupt disabled
> [ 29.734337] before gpio_get
> [ 29.736847] after gpio_get
>
> Time difference 0.00251
>
> gpio library with interrupt disabled
> [ 272.876763] before gpio_get
> [ 272.879291] after gpio_get
>
> Time difference 0.002528
> Latency increased by (0.002528 - 0.00251) = 18 microsecond.
>
> Also being here
> - Moved following definitions from mach folder to include directory
> struct davinci_gpio_controller
> Macro GPIO(x)
> inline function __gpio_mask
> - Removed GPIO_TYPE_DAVINCI enum definition as GPIO Davinci is converted
> to Linux device driver model.
> - With removal of select option of NEED_MACH_GPIO_H for ARCH_DAVINCI,
> gpio-tnetv107x also start using gpiolib interface. Hence removes
> related header files
> arch/arm/mach-davinci/include/mach/gpio-davinci.h
> arch/arm/mach-davinci/include/mach/gpio.h
>
> and include linux/platform_data/gpio-davinci.h header file to support
> gpio-davinci platform definitions.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> Changes since v1:
> - Remove inline GPIO API support for tnetv107x platforms
> - Remove gpio header files in mach directory.
> - Remove include of gpio header files from mach directory.
> - Moved enum davinci_gpio_type to include folder
> - Replace __ASM_ARCH_DAVINCI_GPIO_H with __DAVINCI_GPIO_PLATFORM_H
Acked-by: Linus Walleij <[email protected]>
on this as well, and this whole 7-patch series.
For sure things look better after this series than before it,
even if there may be details I think need to be adressed later.
Yours,
Linus Walleij
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> gpio controller resource information being associated with
> davinci_soc_info structure and not created any device. Hence davinci
> gpio didn't fall under proper device model. This patch creates gpio
> davinci as a platform device for dmxxx platforms.
> Also add daivinci_register_gpio API to create platform device for dmxxx
> platforms.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> arch/arm/mach-davinci/devices.c | 13 +++++++++++++
> arch/arm/mach-davinci/include/mach/common.h | 2 ++
> 2 files changed, 15 insertions(+)
>
> diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
> index a7068a3..b4f345b 100644
> --- a/arch/arm/mach-davinci/devices.c
> +++ b/arch/arm/mach-davinci/devices.c
> @@ -313,6 +313,19 @@ static void davinci_init_wdt(void)
> platform_device_register(&davinci_wdt_device);
> }
>
> +static struct platform_device davinci_gpio_device = {
> + .name = "davinci_gpio",
> + .id = -1,
> +};
> +
> +int davinci_gpio_register(struct resource *res, int size, void *pdata)
> +{
> + davinci_gpio_device.resource = res;
> + davinci_gpio_device.num_resources = size;
> + davinci_gpio_device.dev.platform_data = pdata;
> + return platform_device_register(&davinci_gpio_device);
> +}
> +
> /*-------------------------------------------------------------------------*/
>
> /*-------------------------------------------------------------------------*/
> diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
> index b124b77..bd389ba 100644
> --- a/arch/arm/mach-davinci/include/mach/common.h
> +++ b/arch/arm/mach-davinci/include/mach/common.h
> @@ -14,6 +14,7 @@
>
> #include <linux/compiler.h>
> #include <linux/types.h>
> +#include <linux/ioport.h>
>
> extern void davinci_timer_init(void);
>
> @@ -83,6 +84,7 @@ extern void davinci_common_init(struct davinci_soc_info *soc_info);
> extern void davinci_init_ide(void);
> void davinci_restart(char mode, const char *cmd);
> void davinci_init_late(void);
> +int davinci_gpio_register(struct resource *res, int size, void *pdata);
This declaration should not be inserted into this globally visible header.
There is a local davinci.h for the same purpose.
I did the fix for you. Here is the updated patch I am committing.
I fixed the description in a manner similar to 3/7.
Thanks,
Sekhar
>From 505ac35b131a90c721bf82bd1236da7a4f46ba12 Mon Sep 17 00:00:00 2001
From: Philip Avinash <[email protected]>
Date: Fri, 14 Jun 2013 15:05:29 +0530
Subject: [PATCH 1/1] ARM: davinci: devices.c: support gpio platform device
DaVinci GPIO driver now uses platform device model.
Add a GPIO platform register API to convert the
traditional DaVinci SoCs to use the new model.
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
[[email protected]: move function declaration to local header,
simplify commit message]
Signed-off-by: Sekhar Nori <[email protected]>
---
arch/arm/mach-davinci/davinci.h | 2 ++
arch/arm/mach-davinci/devices.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
index 1ab3df4..5c0f0c1 100644
--- a/arch/arm/mach-davinci/davinci.h
+++ b/arch/arm/mach-davinci/davinci.h
@@ -53,6 +53,8 @@ extern void __iomem *davinci_sysmod_base;
#define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x))
void davinci_map_sysmod(void);
+int davinci_gpio_register(struct resource *res, int size, void *pdata);
+
/* DM355 base addresses */
#define DM355_ASYNC_EMIF_CONTROL_BASE 0x01e10000
#define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index a7068a3..b4f345b 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -313,6 +313,19 @@ static void davinci_init_wdt(void)
platform_device_register(&davinci_wdt_device);
}
+static struct platform_device davinci_gpio_device = {
+ .name = "davinci_gpio",
+ .id = -1,
+};
+
+int davinci_gpio_register(struct resource *res, int size, void *pdata)
+{
+ davinci_gpio_device.resource = res;
+ davinci_gpio_device.num_resources = size;
+ davinci_gpio_device.dev.platform_data = pdata;
+ return platform_device_register(&davinci_gpio_device);
+}
+
/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> Create davinci gpio device and remove references in davinci_soc_info
> structure. Also rearrange header file inclusion in group basis.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> arch/arm/mach-davinci/board-da830-evm.c | 19 +++++++++++++++----
> arch/arm/mach-davinci/board-da850-evm.c | 11 +++++++++++
> arch/arm/mach-davinci/board-omapl138-hawk.c | 2 ++
> arch/arm/mach-davinci/da830.c | 4 ----
> arch/arm/mach-davinci/da850.c | 4 ----
> 5 files changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
> index 1332de8..4e8bcc1 100644
> --- a/arch/arm/mach-davinci/board-da830-evm.c
> +++ b/arch/arm/mach-davinci/board-da830-evm.c
> @@ -22,17 +22,19 @@
> #include <linux/mtd/partitions.h>
> #include <linux/spi/spi.h>
> #include <linux/spi/flash.h>
> +#include <linux/platform_data/mtd-davinci.h>
> +#include <linux/platform_data/gpio-davinci.h>
> +#include <linux/platform_data/usb-davinci.h>
> +#include <linux/platform_data/mtd-davinci-aemif.h>
> +#include <linux/platform_data/spi-davinci.h>
While doing this, its better to keep the header files you are adding in
sorted order.
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
>
> #include <mach/cp_intc.h>
> #include <mach/mux.h>
> -#include <linux/platform_data/mtd-davinci.h>
> +#include <mach/common.h>
You dont need to include this file here.
> #include <mach/da8xx.h>
> -#include <linux/platform_data/usb-davinci.h>
> -#include <linux/platform_data/mtd-davinci-aemif.h>
> -#include <linux/platform_data/spi-davinci.h>
>
> #define DA830_EVM_PHY_ID ""
> /*
> @@ -590,11 +592,20 @@ static struct spi_board_info da830evm_spi_info[] = {
> },
> };
>
> +static struct davinci_gpio_platform_data da830_gpio_platform_data = {
> + .ngpio = 128,
> + .intc_irq_num = DA830_N_CP_INTC_IRQ,
> +};
> +
> static __init void da830_evm_init(void)
> {
> struct davinci_soc_info *soc_info = &davinci_soc_info;
> int ret;
>
> + ret = da8xx_register_gpio(&da830_gpio_platform_data);
> + if (ret)
> + pr_warn("da830_evm_init: GPIO init failed: %d\n", ret);
> +
> ret = da830_register_edma(da830_edma_rsv);
> if (ret)
> pr_warning("da830_evm_init: edma registration failed: %d\n",
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
> index 8a24b6c..d5dd010 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -28,6 +28,7 @@
> #include <linux/mtd/partitions.h>
> #include <linux/mtd/physmap.h>
> #include <linux/platform_device.h>
> +#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/spi-davinci.h>
> @@ -42,6 +43,7 @@
> #include <mach/da8xx.h>
> #include <mach/mux.h>
> #include <mach/sram.h>
> +#include <mach/common.h>
No need of this file, as before.
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
> @@ -1138,6 +1140,11 @@ static struct edma_rsv_info *da850_edma_rsv[2] = {
> &da850_edma_cc1_rsv,
> };
>
> +static struct davinci_gpio_platform_data da850_gpio_platform_data = {
> + .ngpio = 144,
> + .intc_irq_num = DA850_N_CP_INTC_IRQ,
> +};
> +
> #ifdef CONFIG_CPU_FREQ
> static __init int da850_evm_init_cpufreq(void)
> {
> @@ -1444,6 +1451,10 @@ static __init void da850_evm_init(void)
> {
> int ret;
>
> + ret = da8xx_register_gpio(&da850_gpio_platform_data);
> + if (ret)
> + pr_warn("da850_evm_init: GPIO init failed: %d\n", ret);
> +
> ret = pmic_tps65070_init();
> if (ret)
> pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret);
> diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
> index b8c20de..1f44a1b 100644
> --- a/arch/arm/mach-davinci/board-omapl138-hawk.c
> +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
> @@ -13,6 +13,7 @@
> #include <linux/init.h>
> #include <linux/console.h>
> #include <linux/gpio.h>
> +#include <linux/platform_data/gpio-davinci.h>
>
> #include <asm/mach-types.h>
> #include <asm/mach/arch.h>
> @@ -20,6 +21,7 @@
> #include <mach/cp_intc.h>
> #include <mach/da8xx.h>
> #include <mach/mux.h>
> +#include <mach/common.h>
No need of this again.
>
> #define HAWKBOARD_PHY_ID "davinci_mdio-0:07"
> #define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)
You don't actually register GPIO for hawkboard?
> diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
> index abbaf02..e7b79ee 100644
> --- a/arch/arm/mach-davinci/da830.c
> +++ b/arch/arm/mach-davinci/da830.c
> @@ -1195,10 +1195,6 @@ static struct davinci_soc_info davinci_soc_info_da830 = {
> .intc_irq_prios = da830_default_priorities,
> .intc_irq_num = DA830_N_CP_INTC_IRQ,
> .timer_info = &da830_timer_info,
> - .gpio_type = GPIO_TYPE_DAVINCI,
> - .gpio_base = DA8XX_GPIO_BASE,
> - .gpio_num = 128,
> - .gpio_irq = IRQ_DA8XX_GPIO0,
> .serial_dev = &da8xx_serial_device,
> .emac_pdata = &da8xx_emac_pdata,
> };
> diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
> index 93bcf06..de8753d 100644
> --- a/arch/arm/mach-davinci/da850.c
> +++ b/arch/arm/mach-davinci/da850.c
> @@ -1298,10 +1298,6 @@ static struct davinci_soc_info davinci_soc_info_da850 = {
> .intc_irq_prios = da850_default_priorities,
> .intc_irq_num = DA850_N_CP_INTC_IRQ,
> .timer_info = &da850_timer_info,
> - .gpio_type = GPIO_TYPE_DAVINCI,
> - .gpio_base = DA8XX_GPIO_BASE,
> - .gpio_num = 144,
> - .gpio_irq = IRQ_DA8XX_GPIO0,
> .serial_dev = &da8xx_serial_device,
> .emac_pdata = &da8xx_emac_pdata,
> .sram_dma = DA8XX_SHARED_RAM_BASE,
This the SoC changes can be done in 3/7 itself. I have done that in my
v3.11/gpio branch. Can you fix the issues I pointed out and reply to
this mail with an updated 5/7?
Thanks,
Sekhar
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> Create davinci gpio device and remove gpio references in
> davinci_soc_info structure for dmxxx platforms. Also add Memory and IRQ
> resources for GPIO platform device.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> ---
> Changes since v1:
> - Add commit message
>
> arch/arm/mach-davinci/board-dm355-evm.c | 27 ++++++++++++++++++++++++++
> arch/arm/mach-davinci/board-dm355-leopard.c | 1 +
> arch/arm/mach-davinci/board-dm365-evm.c | 28 +++++++++++++++++++++++++++
> arch/arm/mach-davinci/board-dm644x-evm.c | 26 +++++++++++++++++++++++++
> arch/arm/mach-davinci/board-dm646x-evm.c | 27 ++++++++++++++++++++++++++
> arch/arm/mach-davinci/board-neuros-osd2.c | 1 +
> arch/arm/mach-davinci/dm355.c | 4 ----
> arch/arm/mach-davinci/dm365.c | 5 -----
> arch/arm/mach-davinci/dm644x.c | 4 ----
> arch/arm/mach-davinci/dm646x.c | 4 ----
> arch/arm/mach-davinci/include/mach/common.h | 2 ++
> 11 files changed, 112 insertions(+), 17 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
> index c2a0a67..05e6e86 100644
> --- a/arch/arm/mach-davinci/board-dm355-evm.c
> +++ b/arch/arm/mach-davinci/board-dm355-evm.c
> @@ -28,9 +28,11 @@
>
> #include <linux/platform_data/i2c-davinci.h>
> #include <mach/serial.h>
> +#include <mach/common.h>
> #include <linux/platform_data/mtd-davinci.h>
> #include <linux/platform_data/mmc-davinci.h>
> #include <linux/platform_data/usb-davinci.h>
> +#include <linux/platform_data/gpio-davinci.h>
>
> #include "davinci.h"
>
> @@ -376,9 +378,34 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = {
> },
> };
>
> +static struct resource dm355_gpio_resources[] = {
> + { /* registers */
> + .start = DAVINCI_GPIO_BASE,
> + .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
> + .flags = IORESOURCE_MEM,
> + },
> + { /* interrupt */
> + .start = IRQ_DM355_GPIOBNK0,
> + .end = IRQ_DM355_GPIOBNK6,
> + .flags = IORESOURCE_IRQ,
> + },
> +};
Don't add these resource in board files. Granted we are not going to add
more board files, but that does not mean we add soc specific data into
board files. You need to move this into the respective SoC files.
Thanks,
Sekhar
On 6/20/2013 2:10 PM, Sekhar Nori wrote:
> On 6/14/2013 3:05 PM, Philip Avinash wrote:
>> Create davinci gpio device and remove references in davinci_soc_info
>> structure. Also rearrange header file inclusion in group basis.
>>
>> Signed-off-by: Philip Avinash <[email protected]>
>> Acked-by: Linus Walleij <[email protected]>
>> Signed-off-by: Sekhar Nori <[email protected]>
>> ---
>> arch/arm/mach-davinci/board-da830-evm.c | 19 +++++++++++++++----
>> arch/arm/mach-davinci/board-da850-evm.c | 11 +++++++++++
>> arch/arm/mach-davinci/board-omapl138-hawk.c | 2 ++
>> arch/arm/mach-davinci/da830.c | 4 ----
>> arch/arm/mach-davinci/da850.c | 4 ----
>> 5 files changed, 28 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
>> index 1332de8..4e8bcc1 100644
>> --- a/arch/arm/mach-davinci/board-da830-evm.c
>> +++ b/arch/arm/mach-davinci/board-da830-evm.c
>> @@ -22,17 +22,19 @@
>> #include <linux/mtd/partitions.h>
>> #include <linux/spi/spi.h>
>> #include <linux/spi/flash.h>
>> +#include <linux/platform_data/mtd-davinci.h>
>> +#include <linux/platform_data/gpio-davinci.h>
>> +#include <linux/platform_data/usb-davinci.h>
>> +#include <linux/platform_data/mtd-davinci-aemif.h>
>> +#include <linux/platform_data/spi-davinci.h>
>
> While doing this, its better to keep the header files you are adding in
> sorted order.
>
>>
>> #include <asm/mach-types.h>
>> #include <asm/mach/arch.h>
>>
>> #include <mach/cp_intc.h>
>> #include <mach/mux.h>
>> -#include <linux/platform_data/mtd-davinci.h>
>> +#include <mach/common.h>
>
> You dont need to include this file here.
>
>> #include <mach/da8xx.h>
>> -#include <linux/platform_data/usb-davinci.h>
>> -#include <linux/platform_data/mtd-davinci-aemif.h>
>> -#include <linux/platform_data/spi-davinci.h>
>>
>> #define DA830_EVM_PHY_ID ""
>> /*
>> @@ -590,11 +592,20 @@ static struct spi_board_info da830evm_spi_info[] = {
>> },
>> };
>>
>> +static struct davinci_gpio_platform_data da830_gpio_platform_data = {
>> + .ngpio = 128,
>> + .intc_irq_num = DA830_N_CP_INTC_IRQ,
>> +};
>> +
>> static __init void da830_evm_init(void)
>> {
>> struct davinci_soc_info *soc_info = &davinci_soc_info;
>> int ret;
>>
>> + ret = da8xx_register_gpio(&da830_gpio_platform_data);
>> + if (ret)
>> + pr_warn("da830_evm_init: GPIO init failed: %d\n", ret);
>> +
>> ret = da830_register_edma(da830_edma_rsv);
>> if (ret)
>> pr_warning("da830_evm_init: edma registration failed: %d\n",
>> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
>> index 8a24b6c..d5dd010 100644
>> --- a/arch/arm/mach-davinci/board-da850-evm.c
>> +++ b/arch/arm/mach-davinci/board-da850-evm.c
>> @@ -28,6 +28,7 @@
>> #include <linux/mtd/partitions.h>
>> #include <linux/mtd/physmap.h>
>> #include <linux/platform_device.h>
>> +#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/spi-davinci.h>
>> @@ -42,6 +43,7 @@
>> #include <mach/da8xx.h>
>> #include <mach/mux.h>
>> #include <mach/sram.h>
>> +#include <mach/common.h>
>
> No need of this file, as before.
>
>>
>> #include <asm/mach-types.h>
>> #include <asm/mach/arch.h>
>> @@ -1138,6 +1140,11 @@ static struct edma_rsv_info *da850_edma_rsv[2] = {
>> &da850_edma_cc1_rsv,
>> };
>>
>> +static struct davinci_gpio_platform_data da850_gpio_platform_data = {
>> + .ngpio = 144,
>> + .intc_irq_num = DA850_N_CP_INTC_IRQ,
>> +};
I did not notice this before, but this is a wrong place for this. This
should be in SoC file since it does not change with each board. And this
explains why you left hawk board broken - you would end up replicating
this there.
You need to fix patches 3-6 and repost again. I have some fixes what I
made while reviewing and committed to my v3.11/gpio branch. You can to
take that branch as starting point and complete the fixes.
Thanks,
Sekhar
On 6/14/2013 3:05 PM, Philip Avinash wrote:
> Remove NEED_MACH_GPIO_H config select option for ARCH_DAVINCI to start
> use gpiolib interface for davinci platforms. However with this software
> latencies for gpio_get/set APIs will affect. Latency has increased by 18
> microsecond with gpiolib API as compared with inline API's.
>
> Software latency is calculated on da850 EVM for gpio_get_value API by
> taking the printk timing for API execution with interrupts disabled.
> Experiment has done for inline and gpiolib API interface.
>
> inline gpio API with interrupt disabled
> [ 29.734337] before gpio_get
> [ 29.736847] after gpio_get
>
> Time difference 0.00251
>
> gpio library with interrupt disabled
> [ 272.876763] before gpio_get
> [ 272.879291] after gpio_get
>
> Time difference 0.002528
> Latency increased by (0.002528 - 0.00251) = 18 microsecond.
>
> Also being here
> - Moved following definitions from mach folder to include directory
> struct davinci_gpio_controller
> Macro GPIO(x)
> inline function __gpio_mask
> - Removed GPIO_TYPE_DAVINCI enum definition as GPIO Davinci is converted
> to Linux device driver model.
This is bit out-of-place here. Why not do it along with removal of its
last usage in <soc>.c files?
Rest of the patch looks good to me.
Thanks,
Sekhar