2013-08-18 05:19:29

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 0/7] Convert GPIO Davinci to platform driver

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.11-rc2 and is availabel at [1].

[1] http://git.linuxtv.org/mhadli/v4l-dvb-davinci_devices.git/shortlog/refs/heads/davinci_gpio

Changes for v3:
1: Moved the resources to Soc file.
2: Sorted the header file inclusions alphabetically.
3: included Ack from Linus.

KV Sujith (2):
gpio: davinci: move to platform device
ARM: davinci: da8xx: support gpio platform device

Philip Avinash (5):
gpio: davinci: coding style correction
ARM: davinci: devices.c: support gpio platform device
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 | 28 ++--
arch/arm/mach-davinci/board-da850-evm.c | 16 ++-
arch/arm/mach-davinci/board-dm355-evm.c | 33 +++--
arch/arm/mach-davinci/board-dm355-leopard.c | 30 +++--
arch/arm/mach-davinci/board-dm365-evm.c | 30 +++--
arch/arm/mach-davinci/board-dm644x-evm.c | 40 +++---
arch/arm/mach-davinci/board-dm646x-evm.c | 37 +++---
arch/arm/mach-davinci/board-neuros-osd2.c | 18 ++-
arch/arm/mach-davinci/board-omapl138-hawk.c | 10 +-
arch/arm/mach-davinci/da830.c | 26 ++--
arch/arm/mach-davinci/da850.c | 30 +++--
arch/arm/mach-davinci/davinci.h | 19 ++-
arch/arm/mach-davinci/devices-da8xx.c | 26 ++++
arch/arm/mach-davinci/devices.c | 13 ++
arch/arm/mach-davinci/dm355.c | 53 +++++---
arch/arm/mach-davinci/dm365.c | 57 +++++---
arch/arm/mach-davinci/dm644x.c | 46 +++++--
arch/arm/mach-davinci/dm646x.c | 46 +++++--
arch/arm/mach-davinci/include/mach/common.h | 2 +
arch/arm/mach-davinci/include/mach/da8xx.h | 23 ++--
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 | 14 +-
drivers/gpio/gpio-davinci.c | 143 ++++++++++++++-------
drivers/gpio/gpio-tnetv107x.c | 5 +-
include/linux/platform_data/gpio-davinci.h | 59 +++++++++
27 files changed, 558 insertions(+), 426 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


2013-08-18 05:19:46

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 1/7] gpio: davinci: coding style correction

From: Philip Avinash <[email protected]>

Make some minor coding style fixes. Use proper multi-line
commenting style, arrange include files alphabetically and
use a macro for register offset.

Signed-off-by: Philip Avinash <[email protected]>
[[email protected]: dropped changes which were considered
churn - line break fixes and variable name changes]
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/gpio/gpio-davinci.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 17df6db..af7ea0b 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -9,12 +9,11 @@
* 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 +30,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 +305,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 +370,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 +453,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

2013-08-18 05:20:11

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 2/7] gpio: davinci: move to platform device

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 gpio error reporting.
- 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]>
[[email protected]: dropped unused structure member, rebased on new clean-up
patch and fixes error messages]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 1 +
drivers/gpio/gpio-davinci.c | 123 ++++++++++++++-------
include/linux/platform_data/gpio-davinci.h | 25 +++++
3 files changed, 111 insertions(+), 38 deletions(-)
create mode 100644 include/linux/platform_data/gpio-davinci.h

diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
index 1fdd1fd..551ba43 100644
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
@@ -60,6 +60,7 @@ struct davinci_gpio_controller {
void __iomem *set_data;
void __iomem *clr_data;
void __iomem *in_data;
+ 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 af7ea0b..268ba80 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -10,12 +10,17 @@
* (at your option) any later version.
*/
#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;
@@ -35,10 +40,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;

@@ -66,7 +70,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);

/*--------------------------------------------------------------------------*/

@@ -132,33 +136,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";
@@ -184,13 +208,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);

/*--------------------------------------------------------------------------*/
/*
@@ -303,14 +324,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;
}
@@ -319,12 +340,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;
@@ -345,24 +365,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));
@@ -378,9 +407,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);
}

/*
@@ -388,7 +417,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 */
@@ -408,7 +437,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);
@@ -463,3 +492,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

2013-08-18 05:20:32

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 3/7] ARM: davinci: da8xx: support gpio platform device

From: KV Sujith <[email protected]>

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.
- Removed unused GPIO initialization in davinci_soc_info structure

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]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
arch/arm/mach-davinci/da830.c | 4 ----
arch/arm/mach-davinci/da850.c | 4 ----
arch/arm/mach-davinci/devices-da8xx.c | 26 ++++++++++++++++++++++++++
arch/arm/mach-davinci/include/mach/da8xx.h | 1 +
4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index d6c746e..9ef1b67 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1196,10 +1196,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,
.emac_pdata = &da8xx_emac_pdata,
};

diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index f56e5fb..887af90 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,
.emac_pdata = &da8xx_emac_pdata,
.sram_dma = DA8XX_SHARED_RAM_BASE,
.sram_len = SZ_128K,
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index a408b30..242fbd4 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -665,6 +665,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 aae5307..a96da92 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -97,6 +97,7 @@ int da8xx_register_mmcsd0(struct davinci_mmc_config *config);
int da850_register_mmcsd1(struct davinci_mmc_config *config);
void 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 *da8xx_get_mem_ctlr(void);
--
1.7.9.5

2013-08-18 05:20:53

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 4/7] ARM: davinci: devices.c: support gpio platform device

From: Philip Avinash <[email protected]>

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]>
Signed-off-by: Lad, Prabhakar <[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 2ab5d57..6dfc038 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 111573c..b0fac4e 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -318,6 +318,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);
+}
+
/*-------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------*/
--
1.7.9.5

2013-08-18 05:21:11

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 5/7] ARM: davinci: da8xx: gpio device creation

From: Philip Avinash <[email protected]>

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]>
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 28 ++++++++++++++++-----------
arch/arm/mach-davinci/board-da850-evm.c | 16 ++++++++++-----
arch/arm/mach-davinci/board-omapl138-hawk.c | 10 ++++++++--
arch/arm/mach-davinci/da830.c | 21 +++++++++++++++-----
arch/arm/mach-davinci/da850.c | 27 ++++++++++++++++++--------
arch/arm/mach-davinci/include/mach/da8xx.h | 22 +++++++++++----------
6 files changed, 83 insertions(+), 41 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index c4bdc0a..54a8690 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -9,30 +9,32 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
#include <linux/console.h>
-#include <linux/interrupt.h>
#include <linux/gpio.h>
-#include <linux/platform_device.h>
#include <linux/i2c.h>
-#include <linux/i2c/pcf857x.h>
#include <linux/i2c/at24.h>
+#include <linux/i2c/pcf857x.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
-#include <linux/spi/spi.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>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
-#include <mach/mux.h>
-#include <linux/platform_data/mtd-davinci.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>
+#include <mach/mux.h>

#define DA830_EVM_PHY_ID ""
/*
@@ -591,6 +593,10 @@ static __init void da830_evm_init(void)
struct davinci_soc_info *soc_info = &davinci_soc_info;
int ret;

+ ret = da830_register_gpio();
+ 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 9afd687..8b0a673 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -15,29 +15,31 @@
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/i2c/pca953x.h>
+#include <linux/init.h>
#include <linux/input.h>
#include <linux/input/tps6507x-ts.h>
+#include <linux/kernel.h>
#include <linux/mfd/tps6507x.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#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>
#include <linux/platform_data/uio_pruss.h>
+#include <linux/platform_device.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/tps6507x.h>
-#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
#include <linux/wl12xx.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
#include <mach/da8xx.h>
#include <mach/mux.h>
@@ -47,8 +49,8 @@
#include <asm/mach/arch.h>
#include <asm/system_info.h>

-#include <media/tvp514x.h>
#include <media/adv7343.h>
+#include <media/tvp514x.h>

#define DA850_EVM_PHY_ID "davinci_mdio-0:00"
#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
@@ -1439,6 +1441,10 @@ static __init void da850_evm_init(void)
{
int ret;

+ ret = da850_register_gpio();
+ 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 ab98c75..0e0b998 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -9,14 +9,16 @@
* version 2. This program is licensed "as is" without any warranty of
* any kind, whether express or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
#include <linux/console.h>
#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_data/gpio-davinci.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
#include <mach/da8xx.h>
#include <mach/mux.h>
@@ -290,6 +292,10 @@ static __init void omapl138_hawk_init(void)
{
int ret;

+ ret = da850_register_gpio();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
davinci_serial_init(da8xx_serial_device);

omapl138_hawk_config_emac();
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 9ef1b67..da498ee 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -8,19 +8,20 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
#include <linux/gpio.h>
#include <linux/init.h>
-#include <linux/clk.h>
+#include <linux/platform_data/gpio-davinci.h>

#include <asm/mach/map.h>

-#include <mach/psc.h>
-#include <mach/irqs.h>
-#include <mach/cputype.h>
#include <mach/common.h>
-#include <mach/time.h>
+#include <mach/cputype.h>
#include <mach/da8xx.h>
#include <mach/gpio-davinci.h>
+#include <mach/irqs.h>
+#include <mach/psc.h>
+#include <mach/time.h>

#include "clock.h"
#include "mux.h"
@@ -1151,6 +1152,16 @@ static struct davinci_id da830_ids[] = {
},
};

+static struct davinci_gpio_platform_data da830_gpio_platform_data = {
+ .ngpio = 128,
+ .intc_irq_num = DA830_N_CP_INTC_IRQ,
+};
+
+int __init da830_register_gpio()
+{
+ return da8xx_register_gpio(&da830_gpio_platform_data);
+}
+
static struct davinci_timer_instance da830_timer_instance[2] = {
{
.base = DA8XX_TIMER64P0_BASE,
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 887af90..c6608c4 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -11,24 +11,25 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
+#include <linux/cpufreq.h>
#include <linux/gpio.h>
#include <linux/init.h>
-#include <linux/clk.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <linux/platform_device.h>
-#include <linux/cpufreq.h>
#include <linux/regulator/consumer.h>

#include <asm/mach/map.h>

-#include <mach/psc.h>
-#include <mach/irqs.h>
-#include <mach/cputype.h>
#include <mach/common.h>
-#include <mach/time.h>
-#include <mach/da8xx.h>
#include <mach/cpufreq.h>
-#include <mach/pm.h>
+#include <mach/cputype.h>
+#include <mach/da8xx.h>
#include <mach/gpio-davinci.h>
+#include <mach/irqs.h>
+#include <mach/pm.h>
+#include <mach/psc.h>
+#include <mach/time.h>

#include "clock.h"
#include "mux.h"
@@ -1281,6 +1282,16 @@ int __init da850_register_vpif_capture(struct vpif_capture_config
return platform_device_register(&da850_vpif_capture_dev);
}

+static struct davinci_gpio_platform_data da850_gpio_platform_data = {
+ .ngpio = 144,
+ .intc_irq_num = DA850_N_CP_INTC_IRQ,
+};
+
+int __init da850_register_gpio()
+{
+ return da8xx_register_gpio(&da850_gpio_platform_data);
+}
+
static struct davinci_soc_info davinci_soc_info_da850 = {
.io_desc = da850_io_desc,
.io_desc_num = ARRAY_SIZE(da850_io_desc),
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index a96da92..8642150 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -11,26 +11,26 @@
#ifndef __ASM_ARCH_DAVINCI_DA8XX_H
#define __ASM_ARCH_DAVINCI_DA8XX_H

-#include <video/da8xx-fb.h>
-
-#include <linux/platform_device.h>
#include <linux/davinci_emac.h>
-#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
-#include <linux/reboot.h>
-#include <linux/videodev2.h>
-
-#include <mach/serial.h>
-#include <mach/pm.h>
#include <linux/platform_data/edma.h>
#include <linux/platform_data/i2c-davinci.h>
#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>
#include <linux/platform_data/spi-davinci.h>
#include <linux/platform_data/uio_pruss.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/spi/spi.h>
+#include <linux/videodev2.h>
+
+#include <mach/pm.h>
+#include <mach/serial.h>

#include <media/davinci/vpif_types.h>

+#include <video/da8xx-fb.h>
+
extern void __iomem *da8xx_syscfg0_base;
extern void __iomem *da8xx_syscfg1_base;

@@ -111,6 +111,8 @@ int da850_register_vpif_capture
void da8xx_restart(enum reboot_mode mode, const char *cmd);
void da8xx_rproc_reserve_cma(void);
int da8xx_register_rproc(void);
+int da850_register_gpio(void);
+int da830_register_gpio(void);

extern struct platform_device da8xx_serial_device[];
extern struct emac_platform_data da8xx_emac_pdata;
--
1.7.9.5

2013-08-18 05:21:31

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 6/7] ARM: davinci: dmxxx: gpio device creation

From: Philip Avinash <[email protected]>

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. Also rearrange header file inclusion
in group basis.

Signed-off-by: Philip Avinash <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
arch/arm/mach-davinci/board-dm355-evm.c | 33 +++++++-----
arch/arm/mach-davinci/board-dm355-leopard.c | 30 ++++++-----
arch/arm/mach-davinci/board-dm365-evm.c | 30 ++++++-----
arch/arm/mach-davinci/board-dm644x-evm.c | 40 ++++++++------
arch/arm/mach-davinci/board-dm646x-evm.c | 37 +++++++------
arch/arm/mach-davinci/board-neuros-osd2.c | 18 ++++---
arch/arm/mach-davinci/davinci.h | 17 +++---
arch/arm/mach-davinci/dm355.c | 54 +++++++++++++------
arch/arm/mach-davinci/dm365.c | 58 ++++++++++++++-------
arch/arm/mach-davinci/dm644x.c | 47 ++++++++++++-----
arch/arm/mach-davinci/dm646x.c | 47 ++++++++++++-----
arch/arm/mach-davinci/include/mach/common.h | 2 +
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 2 -
13 files changed, 272 insertions(+), 143 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 42b23a3..4712fb4 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -8,29 +8,31 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
-#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/clk.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/videodev2.h>
+
#include <media/tvp514x.h>
-#include <linux/spi/spi.h>
-#include <linux/spi/eeprom.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/common.h>
#include <mach/serial.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>

#include "davinci.h"

@@ -375,6 +377,11 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = {
static __init void dm355_evm_init(void)
{
struct clk *aemif;
+ int ret;
+
+ ret = dm355_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, 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 d9eb1c9..fbaeea8 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -7,27 +7,28 @@
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
-#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/clk.h>
-#include <linux/spi/spi.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/common.h>
#include <mach/serial.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>

#include "davinci.h"

@@ -233,6 +234,11 @@ static struct spi_board_info dm355_leopard_spi_info[] __initconst = {
static __init void dm355_leopard_init(void)
{
struct clk *aemif;
+ int ret;
+
+ ret = dm355_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);

gpio_request(9, "dm9000");
gpio_direction_input(9);
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 000e2ab..9c1dd31 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -12,33 +12,33 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
#include <linux/i2c.h>
-#include <linux/io.h>
-#include <linux/clk.h>
#include <linux/i2c/at24.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
#include <linux/slab.h>
-#include <linux/mtd/nand.h>
-#include <linux/input.h>
-#include <linux/spi/spi.h>
#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/v4l2-dv-timings.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <mach/mux.h>
#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/mux.h>
#include <mach/serial.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/keyscan-davinci.h>

#include <media/ths7303.h>
#include <media/tvp514x.h>
@@ -743,6 +743,12 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = {

static __init void dm365_evm_init(void)
{
+ int ret;
+
+ ret = dm365_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
evm_init_i2c();
davinci_serial_init(dm365_serial_device);

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 462812b..d0894d8 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -8,37 +8,42 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
-#include <linux/platform_device.h>
+#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
-#include <linux/i2c/pcf857x.h>
#include <linux/i2c/at24.h>
+#include <linux/i2c/pcf857x.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/phy.h>
-#include <linux/clk.h>
-#include <linux/videodev2.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/slab.h>
+#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/v4l2-dv-timings.h>
-#include <linux/export.h>
-
-#include <media/tvp514x.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
-#include <mach/serial.h>
#include <mach/mux.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/mtd-davinci-aemif.h>
+#include <mach/serial.h>
+
+#include <media/tvp514x.h>

#include "davinci.h"

@@ -753,9 +758,14 @@ static int davinci_phy_fixup(struct phy_device *phydev)

static __init void davinci_evm_init(void)
{
+ int ret;
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm644x_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, 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 734cc02..e5e4cf0 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -16,37 +16,37 @@
* Included Files
**************************************************************************/

-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/leds.h>
+#include <linux/clk.h>
+#include <linux/export.h>
#include <linux/gpio.h>
-#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/i2c/pcf857x.h>
-
-#include <media/tvp514x.h>
-#include <media/adv7343.h>
-
+#include <linux/init.h>
+#include <mach/irqs.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
-#include <linux/clk.h>
-#include <linux/export.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_device.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/cdce949.h>
+#include <mach/clock.h>
#include <mach/common.h>
#include <mach/serial.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 "davinci.h"
+#include <media/tvp514x.h>
+#include <media/adv7343.h>
+
#include "clock.h"
+#include "davinci.h"

#define NAND_BLOCK_SIZE SZ_128K

@@ -785,8 +785,13 @@ static struct edma_rsv_info dm646x_edma_rsv[] = {

static __init void evm_init(void)
{
+ int ret;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm646x_gpio_register();
+ if (ret)
+ pr_warn("evm_init: GPIO init failed: %d\n", ret);
+
evm_init_i2c();
davinci_serial_init(dm646x_serial_device);
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 8e156e0..322eabd 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -23,20 +23,21 @@
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
-#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/mtd/partitions.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
-#include <mach/serial.h>
#include <mach/mux.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>
+#include <mach/serial.h>

#include "davinci.h"

@@ -168,9 +169,14 @@ static struct davinci_mmc_config davinci_ntosd2_mmc_config = {

static __init void davinci_ntosd2_init(void)
{
+ int ret;
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm644x_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
aemif_clk = clk_get(NULL, "aemif");
clk_prepare_enable(aemif_clk);

diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
index 6dfc038..e297cb7 100644
--- a/arch/arm/mach-davinci/davinci.h
+++ b/arch/arm/mach-davinci/davinci.h
@@ -18,22 +18,23 @@
#define __DAVINCI_H

#include <linux/clk.h>
-#include <linux/videodev2.h>
#include <linux/davinci_emac.h>
-#include <linux/platform_device.h>
-#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
#include <linux/platform_data/edma.h>
#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/videodev2.h>
+
#include <mach/hardware.h>

-#include <media/davinci/vpfe_capture.h>
-#include <media/davinci/vpif_types.h>
-#include <media/davinci/vpss.h>
#include <media/davinci/vpbe_types.h>
#include <media/davinci/vpbe_venc.h>
#include <media/davinci/vpbe.h>
#include <media/davinci/vpbe_osd.h>
+#include <media/davinci/vpfe_capture.h>
+#include <media/davinci/vpif_types.h>
+#include <media/davinci/vpss.h>

#define DAVINCI_SYSTEM_MODULE_BASE 0x01c40000
#define SYSMOD_VDAC_CONFIG 0x2c
@@ -84,6 +85,7 @@ void dm355_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
void dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata);
int dm355_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm355_gpio_register(void);

/* DM365 function declarations */
void dm365_init(void);
@@ -94,11 +96,13 @@ void dm365_init_rtc(void);
void dm365_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
int dm365_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm365_gpio_register(void);

/* DM644x function declarations */
void dm644x_init(void);
void dm644x_init_asp(struct snd_platform_data *pdata);
int dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm644x_gpio_register(void);

/* DM646x function declarations */
void dm646x_init(void);
@@ -108,6 +112,7 @@ int dm646x_init_edma(struct edma_rsv_info *rsv);
void dm646x_video_init(void);
void dm646x_setup_vpif(struct vpif_display_config *,
struct vpif_capture_config *);
+int dm646x_gpio_register(void);

extern struct platform_device dm365_serial_device[];
extern struct platform_device dm355_serial_device[];
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 0f3cb48..3eb5ffe 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -8,31 +8,31 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
-
+#include <linux/init.h>
+#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/spi-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
#include <linux/spi/spi.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/psc.h>
-#include <mach/mux.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/time.h>
+#include <mach/mux.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
-#include <linux/platform_data/edma.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DM355_UART2_BASE (IO_PHYS + 0x206000)
#define DM355_OSD_BASE (IO_PHYS + 0x70200)
@@ -886,6 +886,30 @@ static struct platform_device dm355_vpbe_dev = {
},
};

+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,
+};
+
+int __init dm355_gpio_register()
+{
+ return davinci_gpio_register(dm355_gpio_resources,
+ sizeof(dm355_gpio_resources),
+ &dm355_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm355_io_desc[] = {
@@ -1005,10 +1029,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,
.sram_dma = 0x00010000,
.sram_len = SZ_32K,
};
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 278080d..9bb60f1 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -12,31 +12,32 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
-#include <linux/spi/spi.h>
+#include <linux/init.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/spi-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
+#include <linux/spi/spi.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/psc.h>
-#include <mach/mux.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/time.h>
+#include <mach/mux.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <linux/platform_data/keyscan-davinci.h>
-#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */
#define DM365_RTC_BASE 0x01c69000
@@ -698,6 +699,32 @@ void __init dm365_init_spi0(unsigned chipselect_mask,
platform_device_register(&dm365_spi0_device);
}

+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,
+};
+
+int __init dm365_gpio_register()
+{
+ return davinci_gpio_register(dm365_gpio_resources,
+ sizeof(dm365_gpio_resources),
+ &dm365_gpio_platform_data);
+}
+
static struct emac_platform_data dm365_emac_pdata = {
.ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET,
.ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET,
@@ -1105,11 +1132,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 */
.emac_pdata = &dm365_emac_pdata,
.sram_dma = 0x00010000,
.sram_len = SZ_32K,
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 4f74682..9f5f059 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -8,27 +8,28 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
+#include <linux/init.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/serial_8250.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/psc.h>
#include <mach/mux.h>
-#include <mach/time.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

/*
* Device specific clocks
@@ -771,6 +772,30 @@ static struct platform_device dm644x_vpbe_dev = {
},
};

+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,
+};
+
+int __init dm644x_gpio_register()
+{
+ return davinci_gpio_register(dm644_gpio_resources,
+ sizeof(dm644_gpio_resources),
+ &dm644_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm644x_io_desc[] = {
@@ -897,10 +922,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,
.emac_pdata = &dm644x_emac_pdata,
.sram_dma = 0x00008000,
.sram_len = SZ_16K,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 68f8d1f..02042d5 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -8,28 +8,29 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
-#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/psc.h>
#include <mach/mux.h>
-#include <mach/time.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DAVINCI_VPIF_BASE (0x01C12000)

@@ -748,6 +749,30 @@ static struct platform_device vpif_capture_dev = {
.num_resources = ARRAY_SIZE(vpif_capture_resource),
};

+static struct resource dm646x_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 dm646x_gpio_platform_data = {
+ .ngpio = 43,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+};
+
+int __init dm646x_gpio_register()
+{
+ return davinci_gpio_register(dm646x_gpio_resources,
+ sizeof(dm646x_gpio_resources),
+ &dm646x_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm646x_io_desc[] = {
@@ -874,10 +899,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,
.emac_pdata = &dm646x_emac_pdata,
.sram_dma = 0x10010000,
.sram_len = SZ_32K,
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index 0b3c169..4bb25e2 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.
*
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
index 551ba43..0d63b24 100644
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
@@ -21,8 +21,6 @@
#include <mach/irqs.h>
#include <mach/common.h>

-#define DAVINCI_GPIO_BASE 0x01C67000
-
enum davinci_gpio_type {
GPIO_TYPE_DAVINCI = 0,
GPIO_TYPE_TNETV107X,
--
1.7.9.5

2013-08-18 05:21:46

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3 7/7] ARM: davinci: Start using gpiolib API inplace of inline functions

From: Philip Avinash <[email protected]>

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]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
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 | 90 ---------------------
arch/arm/mach-davinci/include/mach/gpio.h | 88 --------------------
arch/arm/mach-davinci/tnetv107x.c | 14 ++--
drivers/gpio/gpio-tnetv107x.c | 5 +-
include/linux/platform_data/gpio-davinci.h | 34 ++++++++
12 files changed, 44 insertions(+), 194 deletions(-)
delete mode 100644 arch/arm/mach-davinci/include/mach/gpio-davinci.h
delete mode 100644 arch/arm/mach-davinci/include/mach/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ba412e0..c298bec 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -845,7 +845,6 @@ config ARCH_DAVINCI
select GENERIC_CLOCKEVENTS
select GENERIC_IRQ_CHIP
select HAVE_IDE
- select NEED_MACH_GPIO_H
select TI_PRIV_EDMA
select USE_OF
select ZONE_DMA
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index da498ee..771d0e7 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -18,7 +18,6 @@
#include <mach/common.h>
#include <mach/cputype.h>
#include <mach/da8xx.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/psc.h>
#include <mach/time.h>
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index c6608c4..94ef9bf 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -25,7 +25,6 @@
#include <mach/cpufreq.h>
#include <mach/cputype.h>
#include <mach/da8xx.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/pm.h>
#include <mach/psc.h>
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 3eb5ffe..55e79b6 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -22,7 +22,6 @@

#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/mux.h>
#include <mach/psc.h>
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 9bb60f1..d539e7a 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -27,7 +27,6 @@

#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/mux.h>
#include <mach/psc.h>
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 9f5f059..fb16a0c 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -19,7 +19,6 @@

#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/mux.h>
#include <mach/psc.h>
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 02042d5..fd48282 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -20,7 +20,6 @@

#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
#include <mach/mux.h>
#include <mach/psc.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 0d63b24..0000000
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ /dev/null
@@ -1,90 +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>
-
-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;
- 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 f4d7fbb..e2cbc40 100644
--- a/arch/arm/mach-davinci/tnetv107x.c
+++ b/arch/arm/mach-davinci/tnetv107x.c
@@ -12,26 +12,26 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
+#include <linux/clk.h>
+#include <linux/err.h>
#include <linux/gpio.h>
-#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/clk.h>
#include <linux/io.h>
-#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <linux/platform_device.h>
#include <linux/reboot.h>

#include <asm/mach/map.h>

#include <mach/common.h>
-#include <mach/time.h>
#include <mach/cputype.h>
-#include <mach/psc.h>
#include <mach/cp_intc.h>
-#include <mach/irqs.h>
#include <mach/hardware.h>
+#include <mach/irqs.h>
+#include <mach/psc.h>
+#include <mach/time.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 3fa3e28..b5689f6 100644
--- a/drivers/gpio/gpio-tnetv107x.c
+++ b/drivers/gpio/gpio-tnetv107x.c
@@ -12,9 +12,10 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/kernel.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

2013-08-23 17:54:24

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 1/7] gpio: davinci: coding style correction

Prabhakar,

On 8/18/2013 10:48 AM, Lad, Prabhakar wrote:
> From: Philip Avinash <[email protected]>
>
> Make some minor coding style fixes. Use proper multi-line
> commenting style, arrange include files alphabetically and
> use a macro for register offset.
>
> Signed-off-by: Philip Avinash <[email protected]>
> [[email protected]: dropped changes which were considered
> churn - line break fixes and variable name changes]
> Acked-by: Linus Walleij <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> Signed-off-by: Lad, Prabhakar <[email protected]>

Queuing this for v3.12 through DaVinci tree (since there are dependent
mach-davinci patches). That said, its late for v3.12 and I cannot say if
ARM SoC team will take it.

Thanks,
Sekhar

2013-08-23 18:03:27

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] gpio: davinci: move to platform device

On 8/18/2013 10:48 AM, Lad, Prabhakar 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 gpio error reporting.
> - 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]>
> [[email protected]: dropped unused structure member, rebased on new clean-up
> patch and fixes error messages]
> Signed-off-by: Sekhar Nori <[email protected]>
> Signed-off-by: Lad, Prabhakar <[email protected]>

Queuing this after editing the commit message for brevity and ...

> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (unlikely(!res)) {

... removing such unneeded unlikely() calls. This is not performance
critical path.

Updated patch attached for reference.

Thanks,
Sekhar

>From bb2857ab7a264463fb87c211ab6b077b40637e92 Mon Sep 17 00:00:00 2001
From: KV Sujith <[email protected]>
Date: Sun, 18 Aug 2013 10:48:58 +0530
Subject: [PATCH 2/7] gpio: davinci: move to platform device

Modify DaVinci GPIO driver to become a platform device
driver.

The driver does not have platform driver structure or
a probe. Instead, it has pure_initcall function for
initialization. The platform specific information is
obtained using the DaVinci specific davinci_soc_info
structure. This is a problem for Device Tree (DT)
implementation.

As a first stage of DT conversion, we implement a probe.

Additional notes:

- The driver registration happens as postcore_initcall.
This is required since machine init functions like
da850_lcd_hw_init() make use of GPIO.
- Start using devres APIs for simpler error handling.

Signed-off-by: KV Sujith <[email protected]>
[[email protected]: Move global definition of
"davinci_gpio_controller" to local]
Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
[[email protected]: drop unused structure member, rebase to new
clean-up patch and fix error messages]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 1 +
drivers/gpio/gpio-davinci.c | 123 ++++++++++++++-------
include/linux/platform_data/gpio-davinci.h | 25 +++++
3 files changed, 111 insertions(+), 38 deletions(-)
create mode 100644 include/linux/platform_data/gpio-davinci.h

diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
index 1fdd1fd..551ba43 100644
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
@@ -60,6 +60,7 @@ struct davinci_gpio_controller {
void __iomem *set_data;
void __iomem *clr_data;
void __iomem *in_data;
+ 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 af7ea0b..b537e31 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -10,12 +10,17 @@
* (at your option) any later version.
*/
#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;
@@ -35,10 +40,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;

@@ -66,7 +70,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);

/*--------------------------------------------------------------------------*/

@@ -132,33 +136,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 (!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";
@@ -184,13 +208,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);

/*--------------------------------------------------------------------------*/
/*
@@ -303,14 +324,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;
}
@@ -319,12 +340,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;
@@ -345,24 +365,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 (!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 (!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));
@@ -378,9 +407,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);
}

/*
@@ -388,7 +417,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 */
@@ -408,7 +437,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);
@@ -463,3 +492,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.10.1

2013-08-26 11:00:28

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 3/7] ARM: davinci: da8xx: support gpio platform device

On Sunday 18 August 2013 10:48 AM, Lad, Prabhakar wrote:
> From: KV Sujith <[email protected]>
>
> 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.
> - Removed unused GPIO initialization in davinci_soc_info structure
>
> 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]>
> Signed-off-by: Lad, Prabhakar <[email protected]>

Parts of 5/7 which touch SoC specific portion can be merged into this
patch. I did that for you and here is the result.

Thanks,
Sekhar

>From 50db0a98a3076a667d85b4009eb3f029a2f51d14 Mon Sep 17 00:00:00 2001
From: KV Sujith <[email protected]>
Date: Sun, 18 Aug 2013 10:48:59 +0530
Subject: [PATCH] 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 da8xx_register_gpio() to create platform device for da8xx
platforms.

While at it, reorder include files in alphabetical order.
This will eventually help avoid duplicate include files.

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]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
arch/arm/mach-davinci/da830.c | 25 ++++++++++++++--------
arch/arm/mach-davinci/da850.c | 31 +++++++++++++++++-----------
arch/arm/mach-davinci/devices-da8xx.c | 26 +++++++++++++++++++++++
arch/arm/mach-davinci/include/mach/da8xx.h | 23 ++++++++++++---------
4 files changed, 74 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index d6c746e..73c094d 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -8,19 +8,20 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
#include <linux/gpio.h>
#include <linux/init.h>
-#include <linux/clk.h>
+#include <linux/platform_data/gpio-davinci.h>

#include <asm/mach/map.h>

-#include <mach/psc.h>
-#include <mach/irqs.h>
-#include <mach/cputype.h>
#include <mach/common.h>
-#include <mach/time.h>
+#include <mach/cputype.h>
#include <mach/da8xx.h>
#include <mach/gpio-davinci.h>
+#include <mach/irqs.h>
+#include <mach/psc.h>
+#include <mach/time.h>

#include "clock.h"
#include "mux.h"
@@ -1151,6 +1152,16 @@ static struct davinci_id da830_ids[] = {
},
};

+static struct davinci_gpio_platform_data da830_gpio_platform_data = {
+ .ngpio = 128,
+ .intc_irq_num = DA830_N_CP_INTC_IRQ,
+};
+
+int __init da830_register_gpio(void)
+{
+ return da8xx_register_gpio(&da830_gpio_platform_data);
+}
+
static struct davinci_timer_instance da830_timer_instance[2] = {
{
.base = DA8XX_TIMER64P0_BASE,
@@ -1196,10 +1207,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,
.emac_pdata = &da8xx_emac_pdata,
};

diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index f56e5fb..bcabb1e 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -11,24 +11,25 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
+#include <linux/cpufreq.h>
#include <linux/gpio.h>
#include <linux/init.h>
-#include <linux/clk.h>
+#include <linux/platform_data/gpio-davinci.h>
#include <linux/platform_device.h>
-#include <linux/cpufreq.h>
#include <linux/regulator/consumer.h>

#include <asm/mach/map.h>

-#include <mach/psc.h>
-#include <mach/irqs.h>
-#include <mach/cputype.h>
#include <mach/common.h>
-#include <mach/time.h>
-#include <mach/da8xx.h>
#include <mach/cpufreq.h>
-#include <mach/pm.h>
+#include <mach/cputype.h>
+#include <mach/da8xx.h>
#include <mach/gpio-davinci.h>
+#include <mach/irqs.h>
+#include <mach/pm.h>
+#include <mach/psc.h>
+#include <mach/time.h>

#include "clock.h"
#include "mux.h"
@@ -1281,6 +1282,16 @@ int __init da850_register_vpif_capture(struct vpif_capture_config
return platform_device_register(&da850_vpif_capture_dev);
}

+static struct davinci_gpio_platform_data da850_gpio_platform_data = {
+ .ngpio = 144,
+ .intc_irq_num = DA850_N_CP_INTC_IRQ,
+};
+
+int __init da850_register_gpio(void)
+{
+ return da8xx_register_gpio(&da850_gpio_platform_data);
+}
+
static struct davinci_soc_info davinci_soc_info_da850 = {
.io_desc = da850_io_desc,
.io_desc_num = ARRAY_SIZE(da850_io_desc),
@@ -1298,10 +1309,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,
.emac_pdata = &da8xx_emac_pdata,
.sram_dma = DA8XX_SHARED_RAM_BASE,
.sram_len = SZ_128K,
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index 2e473fe..c46eccb 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -665,6 +665,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 aae5307..8642150 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -11,26 +11,26 @@
#ifndef __ASM_ARCH_DAVINCI_DA8XX_H
#define __ASM_ARCH_DAVINCI_DA8XX_H

-#include <video/da8xx-fb.h>
-
-#include <linux/platform_device.h>
#include <linux/davinci_emac.h>
-#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
-#include <linux/reboot.h>
-#include <linux/videodev2.h>
-
-#include <mach/serial.h>
-#include <mach/pm.h>
#include <linux/platform_data/edma.h>
#include <linux/platform_data/i2c-davinci.h>
#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>
#include <linux/platform_data/spi-davinci.h>
#include <linux/platform_data/uio_pruss.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/spi/spi.h>
+#include <linux/videodev2.h>
+
+#include <mach/pm.h>
+#include <mach/serial.h>

#include <media/davinci/vpif_types.h>

+#include <video/da8xx-fb.h>
+
extern void __iomem *da8xx_syscfg0_base;
extern void __iomem *da8xx_syscfg1_base;

@@ -97,6 +97,7 @@ int da8xx_register_mmcsd0(struct davinci_mmc_config *config);
int da850_register_mmcsd1(struct davinci_mmc_config *config);
void 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 *da8xx_get_mem_ctlr(void);
@@ -110,6 +111,8 @@ int da850_register_vpif_capture
void da8xx_restart(enum reboot_mode mode, const char *cmd);
void da8xx_rproc_reserve_cma(void);
int da8xx_register_rproc(void);
+int da850_register_gpio(void);
+int da830_register_gpio(void);

extern struct platform_device da8xx_serial_device[];
extern struct emac_platform_data da8xx_emac_pdata;
--
1.7.10.1


2013-08-27 19:37:47

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 4/7] ARM: davinci: devices.c: support gpio platform device

On 8/18/2013 10:49 AM, Lad, Prabhakar wrote:
> From: Philip Avinash <[email protected]>
>
> 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]>
> Signed-off-by: Lad, Prabhakar <[email protected]>

Similar to what was done for the DA8XX part, the SoC specific parts
from 6/7 can be merged into this. This way 6/7 is just board changes.

I did that for you and here is the result.

Thanks,
Sekhar

---8<---
>From 95a5d877d8d63d9decd496f616b375f30014aad8 Mon Sep 17 00:00:00 2001
From: Philip Avinash <[email protected]>
Date: Sun, 18 Aug 2013 10:49:00 +0530
Subject: [PATCH 4/7] ARM: davinci: 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.

While at it, also sort include files in alphabetic
order as it will help later in avoiding duplicate
includes.

Signed-off-by: Philip Avinash <[email protected]>
Acked-by: Linus Walleij <[email protected]>
[[email protected]: move function declaration to local header,
simplify commit message, merge SoC specific
portions from other patches into this patch]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
---
arch/arm/mach-davinci/davinci.h | 20 ++++---
arch/arm/mach-davinci/devices.c | 13 +++++
arch/arm/mach-davinci/dm355.c | 54 +++++++++++++------
arch/arm/mach-davinci/dm365.c | 58 ++++++++++++++-------
arch/arm/mach-davinci/dm644x.c | 47 ++++++++++++-----
arch/arm/mach-davinci/dm646x.c | 47 ++++++++++++-----
arch/arm/mach-davinci/include/mach/gpio-davinci.h | 2 -
7 files changed, 172 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
index 2ab5d57..645f376 100644
--- a/arch/arm/mach-davinci/davinci.h
+++ b/arch/arm/mach-davinci/davinci.h
@@ -18,22 +18,23 @@
#define __DAVINCI_H

#include <linux/clk.h>
-#include <linux/videodev2.h>
#include <linux/davinci_emac.h>
-#include <linux/platform_device.h>
-#include <linux/spi/spi.h>
#include <linux/platform_data/davinci_asp.h>
#include <linux/platform_data/edma.h>
#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/videodev2.h>
+
#include <mach/hardware.h>

-#include <media/davinci/vpfe_capture.h>
-#include <media/davinci/vpif_types.h>
-#include <media/davinci/vpss.h>
#include <media/davinci/vpbe_types.h>
#include <media/davinci/vpbe_venc.h>
#include <media/davinci/vpbe.h>
#include <media/davinci/vpbe_osd.h>
+#include <media/davinci/vpfe_capture.h>
+#include <media/davinci/vpif_types.h>
+#include <media/davinci/vpss.h>

#define DAVINCI_SYSTEM_MODULE_BASE 0x01c40000
#define SYSMOD_VDAC_CONFIG 0x2c
@@ -53,6 +54,9 @@ extern void __iomem *davinci_sysmod_base;
#define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x))
void davinci_map_sysmod(void);

+#define DAVINCI_GPIO_BASE 0x01C67000
+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
@@ -82,6 +86,7 @@ void dm355_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
void dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata);
int dm355_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm355_gpio_register(void);

/* DM365 function declarations */
void dm365_init(void);
@@ -92,11 +97,13 @@ void dm365_init_rtc(void);
void dm365_init_spi0(unsigned chipselect_mask,
const struct spi_board_info *info, unsigned len);
int dm365_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm365_gpio_register(void);

/* DM644x function declarations */
void dm644x_init(void);
void dm644x_init_asp(struct snd_platform_data *pdata);
int dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
+int dm644x_gpio_register(void);

/* DM646x function declarations */
void dm646x_init(void);
@@ -106,6 +113,7 @@ int dm646x_init_edma(struct edma_rsv_info *rsv);
void dm646x_video_init(void);
void dm646x_setup_vpif(struct vpif_display_config *,
struct vpif_capture_config *);
+int dm646x_gpio_register(void);

extern struct platform_device dm365_serial_device[];
extern struct platform_device dm355_serial_device[];
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index 111573c..3996e98 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -318,6 +318,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/dm355.c b/arch/arm/mach-davinci/dm355.c
index 0f3cb48..1796213 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -8,31 +8,31 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
-
+#include <linux/init.h>
+#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/spi-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
#include <linux/spi/spi.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/psc.h>
-#include <mach/mux.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/time.h>
+#include <mach/mux.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
-#include <linux/platform_data/edma.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DM355_UART2_BASE (IO_PHYS + 0x206000)
#define DM355_OSD_BASE (IO_PHYS + 0x70200)
@@ -886,6 +886,30 @@ static struct platform_device dm355_vpbe_dev = {
},
};

+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,
+};
+
+int __init dm355_gpio_register(void)
+{
+ return davinci_gpio_register(dm355_gpio_resources,
+ sizeof(dm355_gpio_resources),
+ &dm355_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm355_io_desc[] = {
@@ -1005,10 +1029,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,
.sram_dma = 0x00010000,
.sram_len = SZ_32K,
};
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 278080d..3263d0b 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -12,31 +12,32 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
-#include <linux/spi/spi.h>
+#include <linux/init.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/spi-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
+#include <linux/spi/spi.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
-#include <mach/psc.h>
-#include <mach/mux.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/time.h>
+#include <mach/mux.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <linux/platform_data/keyscan-davinci.h>
-#include <linux/platform_data/spi-davinci.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */
#define DM365_RTC_BASE 0x01c69000
@@ -698,6 +699,32 @@ void __init dm365_init_spi0(unsigned chipselect_mask,
platform_device_register(&dm365_spi0_device);
}

+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,
+};
+
+int __init dm365_gpio_register(void)
+{
+ return davinci_gpio_register(dm365_gpio_resources,
+ sizeof(dm365_gpio_resources),
+ &dm365_gpio_platform_data);
+}
+
static struct emac_platform_data dm365_emac_pdata = {
.ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET,
.ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET,
@@ -1105,11 +1132,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 */
.emac_pdata = &dm365_emac_pdata,
.sram_dma = 0x00010000,
.sram_len = SZ_32K,
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 4f74682..71cdc35 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -8,27 +8,28 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/init.h>
#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
+#include <linux/init.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/serial_8250.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/psc.h>
#include <mach/mux.h>
-#include <mach/time.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

/*
* Device specific clocks
@@ -771,6 +772,30 @@ static struct platform_device dm644x_vpbe_dev = {
},
};

+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,
+};
+
+int __init dm644x_gpio_register(void)
+{
+ return davinci_gpio_register(dm644_gpio_resources,
+ sizeof(dm644_gpio_resources),
+ &dm644_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm644x_io_desc[] = {
@@ -897,10 +922,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,
.emac_pdata = &dm644x_emac_pdata,
.sram_dma = 0x00008000,
.sram_len = SZ_16K,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 68f8d1f..ef1abdc 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -8,28 +8,29 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
-#include <linux/clk.h>
-#include <linux/serial_8250.h>
-#include <linux/platform_device.h>
#include <linux/platform_data/edma.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>

#include <asm/mach/map.h>

+#include <mach/common.h>
#include <mach/cputype.h>
+#include <mach/gpio-davinci.h>
#include <mach/irqs.h>
-#include <mach/psc.h>
#include <mach/mux.h>
-#include <mach/time.h>
+#include <mach/psc.h>
#include <mach/serial.h>
-#include <mach/common.h>
-#include <mach/gpio-davinci.h>
+#include <mach/time.h>

-#include "davinci.h"
+#include "asp.h"
#include "clock.h"
+#include "davinci.h"
#include "mux.h"
-#include "asp.h"

#define DAVINCI_VPIF_BASE (0x01C12000)

@@ -748,6 +749,30 @@ static struct platform_device vpif_capture_dev = {
.num_resources = ARRAY_SIZE(vpif_capture_resource),
};

+static struct resource dm646x_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 dm646x_gpio_platform_data = {
+ .ngpio = 43,
+ .intc_irq_num = DAVINCI_N_AINTC_IRQ,
+};
+
+int __init dm646x_gpio_register(void)
+{
+ return davinci_gpio_register(dm646x_gpio_resources,
+ sizeof(dm646x_gpio_resources),
+ &dm646x_gpio_platform_data);
+}
/*----------------------------------------------------------------------*/

static struct map_desc dm646x_io_desc[] = {
@@ -874,10 +899,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,
.emac_pdata = &dm646x_emac_pdata,
.sram_dma = 0x10010000,
.sram_len = SZ_32K,
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
index 551ba43..0d63b24 100644
--- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
+++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h
@@ -21,8 +21,6 @@
#include <mach/irqs.h>
#include <mach/common.h>

-#define DAVINCI_GPIO_BASE 0x01C67000
-
enum davinci_gpio_type {
GPIO_TYPE_DAVINCI = 0,
GPIO_TYPE_TNETV107X,
--
1.7.10.1

2013-08-27 20:06:04

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 5/7] ARM: davinci: da8xx: gpio device creation

On 8/18/2013 10:49 AM, Lad, Prabhakar wrote:
> From: Philip Avinash <[email protected]>
>
> 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]>
> Signed-off-by: Sekhar Nori <[email protected]>
> Signed-off-by: Lad, Prabhakar <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> ---
> arch/arm/mach-davinci/board-da830-evm.c | 28 ++++++++++++++++-----------
> arch/arm/mach-davinci/board-da850-evm.c | 16 ++++++++++-----
> arch/arm/mach-davinci/board-omapl138-hawk.c | 10 ++++++++--
> arch/arm/mach-davinci/da830.c | 21 +++++++++++++++-----
> arch/arm/mach-davinci/da850.c | 27 ++++++++++++++++++--------
> arch/arm/mach-davinci/include/mach/da8xx.h | 22 +++++++++++----------
> 6 files changed, 83 insertions(+), 41 deletions(-)
>

> #define DA850_EVM_PHY_ID "davinci_mdio-0:00"
> #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
> @@ -1439,6 +1441,10 @@ static __init void da850_evm_init(void)
> {
> int ret;
>
> + ret = da850_register_gpio();
> + if (ret)
> + pr_warn("da850_evm_init: GPIO init failed: %d\n", ret);

Changed this to use __func__ for function name print to remain
consistent with rest of this function.

> +int __init da830_register_gpio()

This should be da830_register_gpio(void). Please check the patches you
submit for compilation warnings.

> +int __init da850_register_gpio()

Same problem here too.

Here is the updated patch. Now with just the board updates.

Thanks,
Sekhar

---8<---
>From daa3db9c70850578e041bb57d3ae8cc6d17ef7f3 Mon Sep 17 00:00:00 2001
From: Philip Avinash <[email protected]>
Date: Sun, 18 Aug 2013 10:49:01 +0530
Subject: [PATCH 5/7] ARM: davinci: da8xx boards: gpio device creation

Register gpio platform device on DA8XX boards.

While at it, rearrange header files to group related header
files together and sort them in alphabetic order within the
group. This will help avoid duplicate inclusions in future.

Signed-off-by: Philip Avinash <[email protected]>
[[email protected]: remove SoC specific parts from this file.
fix compile warnings]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
arch/arm/mach-davinci/board-da830-evm.c | 28 ++++++++++++++++-----------
arch/arm/mach-davinci/board-da850-evm.c | 16 ++++++++++-----
arch/arm/mach-davinci/board-omapl138-hawk.c | 10 ++++++++--
3 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index c4bdc0a..54a8690 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -9,30 +9,32 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
#include <linux/console.h>
-#include <linux/interrupt.h>
#include <linux/gpio.h>
-#include <linux/platform_device.h>
#include <linux/i2c.h>
-#include <linux/i2c/pcf857x.h>
#include <linux/i2c/at24.h>
+#include <linux/i2c/pcf857x.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
-#include <linux/spi/spi.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>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
-#include <mach/mux.h>
-#include <linux/platform_data/mtd-davinci.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>
+#include <mach/mux.h>

#define DA830_EVM_PHY_ID ""
/*
@@ -591,6 +593,10 @@ static __init void da830_evm_init(void)
struct davinci_soc_info *soc_info = &davinci_soc_info;
int ret;

+ ret = da830_register_gpio();
+ 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 9afd687..31d55a1 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -15,29 +15,31 @@
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/i2c/pca953x.h>
+#include <linux/init.h>
#include <linux/input.h>
#include <linux/input/tps6507x-ts.h>
+#include <linux/kernel.h>
#include <linux/mfd/tps6507x.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#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>
#include <linux/platform_data/uio_pruss.h>
+#include <linux/platform_device.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/tps6507x.h>
-#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
#include <linux/wl12xx.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
#include <mach/da8xx.h>
#include <mach/mux.h>
@@ -47,8 +49,8 @@
#include <asm/mach/arch.h>
#include <asm/system_info.h>

-#include <media/tvp514x.h>
#include <media/adv7343.h>
+#include <media/tvp514x.h>

#define DA850_EVM_PHY_ID "davinci_mdio-0:00"
#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
@@ -1439,6 +1441,10 @@ static __init void da850_evm_init(void)
{
int ret;

+ ret = da850_register_gpio();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, 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 ab98c75..0e0b998 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -9,14 +9,16 @@
* version 2. This program is licensed "as is" without any warranty of
* any kind, whether express or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
#include <linux/console.h>
#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_data/gpio-davinci.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/common.h>
#include <mach/cp_intc.h>
#include <mach/da8xx.h>
#include <mach/mux.h>
@@ -290,6 +292,10 @@ static __init void omapl138_hawk_init(void)
{
int ret;

+ ret = da850_register_gpio();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
davinci_serial_init(da8xx_serial_device);

omapl138_hawk_config_emac();
--
1.7.10.1

2013-08-27 20:26:12

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 6/7] ARM: davinci: dmxxx: gpio device creation

On 8/18/2013 10:49 AM, Lad, Prabhakar wrote:
> From: Philip Avinash <[email protected]>
>
> 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. Also rearrange header file inclusion
> in group basis.
>
> Signed-off-by: Philip Avinash <[email protected]>
> Signed-off-by: Sekhar Nori <[email protected]>
> Signed-off-by: Lad, Prabhakar <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> ---
> arch/arm/mach-davinci/board-dm355-evm.c | 33 +++++++-----
> arch/arm/mach-davinci/board-dm355-leopard.c | 30 ++++++-----
> arch/arm/mach-davinci/board-dm365-evm.c | 30 ++++++-----
> arch/arm/mach-davinci/board-dm644x-evm.c | 40 ++++++++------
> arch/arm/mach-davinci/board-dm646x-evm.c | 37 +++++++------
> arch/arm/mach-davinci/board-neuros-osd2.c | 18 ++++---
> arch/arm/mach-davinci/davinci.h | 17 +++---
> arch/arm/mach-davinci/dm355.c | 54 +++++++++++++------
> arch/arm/mach-davinci/dm365.c | 58 ++++++++++++++-------
> arch/arm/mach-davinci/dm644x.c | 47 ++++++++++++-----
> arch/arm/mach-davinci/dm646x.c | 47 ++++++++++++-----
> arch/arm/mach-davinci/include/mach/common.h | 2 +
> arch/arm/mach-davinci/include/mach/gpio-davinci.h | 2 -
> 13 files changed, 272 insertions(+), 143 deletions(-)
>
> +int __init dm355_gpio_register()

This line and other lines like this for other SoCs causes
compiler warning.

> --- 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

No need to place this in a globally visible header.
There is a local davinci.h just for this purpose.

So here is the updated patch with all the SoC bits
of this patch moved.

Thanks,
Sekhar

---8<---
>From a01133ae68247d762b491a56bbf9fc8d94b389c4 Mon Sep 17 00:00:00 2001
From: Philip Avinash <[email protected]>
Date: Sun, 18 Aug 2013 10:49:02 +0530
Subject: [PATCH 6/7] ARM: davinci: board: gpio device creation

Create GPIO device for existing DaVinci boards.

While at it, group related header files together and
sort in alphabetic order within the group. This will
help in future in avoiding duplicate header files.

Signed-off-by: Philip Avinash <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>
[[email protected]: remove soc bits from this patch and simplify
commit message]
Signed-off-by: Sekhar Nori <[email protected]>
---
arch/arm/mach-davinci/board-dm355-evm.c | 33 +++++++++++++---------
arch/arm/mach-davinci/board-dm355-leopard.c | 30 ++++++++++++--------
arch/arm/mach-davinci/board-dm365-evm.c | 30 ++++++++++++--------
arch/arm/mach-davinci/board-dm644x-evm.c | 40 +++++++++++++++++----------
arch/arm/mach-davinci/board-dm646x-evm.c | 37 ++++++++++++++-----------
arch/arm/mach-davinci/board-neuros-osd2.c | 18 ++++++++----
6 files changed, 114 insertions(+), 74 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 42b23a3..4712fb4 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -8,29 +8,31 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
-#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/clk.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
+#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/videodev2.h>
+
#include <media/tvp514x.h>
-#include <linux/spi/spi.h>
-#include <linux/spi/eeprom.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/common.h>
#include <mach/serial.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>

#include "davinci.h"

@@ -375,6 +377,11 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = {
static __init void dm355_evm_init(void)
{
struct clk *aemif;
+ int ret;
+
+ ret = dm355_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, 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 d9eb1c9..fbaeea8 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -7,27 +7,28 @@
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
-#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/clk.h>
-#include <linux/spi/spi.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>
#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/common.h>
#include <mach/serial.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>

#include "davinci.h"

@@ -233,6 +234,11 @@ static struct spi_board_info dm355_leopard_spi_info[] __initconst = {
static __init void dm355_leopard_init(void)
{
struct clk *aemif;
+ int ret;
+
+ ret = dm355_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);

gpio_request(9, "dm9000");
gpio_direction_input(9);
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 000e2ab..9c1dd31 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -12,33 +12,33 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/err.h>
#include <linux/i2c.h>
-#include <linux/io.h>
-#include <linux/clk.h>
#include <linux/i2c/at24.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
#include <linux/slab.h>
-#include <linux/mtd/nand.h>
-#include <linux/input.h>
-#include <linux/spi/spi.h>
#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/v4l2-dv-timings.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

-#include <mach/mux.h>
#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
+#include <mach/mux.h>
#include <mach/serial.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/keyscan-davinci.h>

#include <media/ths7303.h>
#include <media/tvp514x.h>
@@ -743,6 +743,12 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = {

static __init void dm365_evm_init(void)
{
+ int ret;
+
+ ret = dm365_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
evm_init_i2c();
davinci_serial_init(dm365_serial_device);

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 462812b..d0894d8 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -8,37 +8,42 @@
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
-#include <linux/kernel.h>
-#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
-#include <linux/platform_device.h>
+#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
-#include <linux/i2c/pcf857x.h>
#include <linux/i2c/at24.h>
+#include <linux/i2c/pcf857x.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/phy.h>
-#include <linux/clk.h>
-#include <linux/videodev2.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/keyscan-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/slab.h>
+#include <linux/spi/eeprom.h>
+#include <linux/spi/spi.h>
#include <linux/v4l2-dv-timings.h>
-#include <linux/export.h>
-
-#include <media/tvp514x.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
-#include <mach/serial.h>
#include <mach/mux.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/mtd-davinci-aemif.h>
+#include <mach/serial.h>
+
+#include <media/tvp514x.h>

#include "davinci.h"

@@ -753,9 +758,14 @@ static int davinci_phy_fixup(struct phy_device *phydev)

static __init void davinci_evm_init(void)
{
+ int ret;
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm644x_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, 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 734cc02..fe79d8d 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -16,37 +16,37 @@
* Included Files
**************************************************************************/

-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/leds.h>
+#include <linux/clk.h>
+#include <linux/export.h>
#include <linux/gpio.h>
-#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/i2c/pcf857x.h>
-
-#include <media/tvp514x.h>
-#include <media/adv7343.h>
-
+#include <linux/init.h>
+#include <mach/irqs.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
-#include <linux/clk.h>
-#include <linux/export.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_device.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+#include <mach/cdce949.h>
+#include <mach/clock.h>
#include <mach/common.h>
#include <mach/serial.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 "davinci.h"
+#include <media/tvp514x.h>
+#include <media/adv7343.h>
+
#include "clock.h"
+#include "davinci.h"

#define NAND_BLOCK_SIZE SZ_128K

@@ -785,8 +785,13 @@ static struct edma_rsv_info dm646x_edma_rsv[] = {

static __init void evm_init(void)
{
+ int ret;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm646x_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
evm_init_i2c();
davinci_serial_init(dm646x_serial_device);
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 8e156e0..322eabd 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -23,20 +23,21 @@
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
-#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/mtd/partitions.h>
+#include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/i2c-davinci.h>
+#include <linux/platform_data/mmc-davinci.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_device.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>

#include <mach/common.h>
-#include <linux/platform_data/i2c-davinci.h>
-#include <mach/serial.h>
#include <mach/mux.h>
-#include <linux/platform_data/mtd-davinci.h>
-#include <linux/platform_data/mmc-davinci.h>
-#include <linux/platform_data/usb-davinci.h>
+#include <mach/serial.h>

#include "davinci.h"

@@ -168,9 +169,14 @@ static struct davinci_mmc_config davinci_ntosd2_mmc_config = {

static __init void davinci_ntosd2_init(void)
{
+ int ret;
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;

+ ret = dm644x_gpio_register();
+ if (ret)
+ pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
+
aemif_clk = clk_get(NULL, "aemif");
clk_prepare_enable(aemif_clk);

--
1.7.10.1

2013-08-27 20:34:06

by Sekhar Nori

[permalink] [raw]
Subject: Re: [PATCH v3 7/7] ARM: davinci: Start using gpiolib API inplace of inline functions

On 8/18/2013 10:49 AM, Lad, Prabhakar wrote:
> From: Philip Avinash <[email protected]>
>
> 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

Latency was not calculated, it was measured. The patch looks good. There
were some minor adjustments like the above needed to the patch
description which I did locally. Here is the updated commit message.

Thanks,
Sekhar

>From 856b63608b6b48dd92c8b41fbbd6a2edde07738d Mon Sep 17 00:00:00 2001
From: Philip Avinash <[email protected]>
Date: Sun, 18 Aug 2013 10:49:03 +0530
Subject: [PATCH 7/7] ARM: davinci: gpio: use gpiolib API instead of inline
functions

Remove NEED_MACH_GPIO_H config select option for ARCH_DAVINCI
to start using gpiolib interface for davinci platforms. This makes
it easier to use the gpio driver on other platforms as it breaks
dependency on mach-davinci.

Latencies for gpio_get/set APIs will increase. On measurement,
latency was found to have increased by 18 microsecond with
gpiolib API as compared to inline APIs.

Measurement was done on DA850 EVM for gpio_get_value() API by
taking the printk timing across the call with interrupts disabled.

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.

While at it, remove GPIO_TYPE_DAVINCI enum definition as
gpio-davinci.c is converted to Linux device driver model.

Signed-off-by: Philip Avinash <[email protected]>
[[email protected]: minor edits to commit message]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Lad, Prabhakar <[email protected]>
Acked-by: Linus Walleij <[email protected]>




> 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]>
> Signed-off-by: Lad, Prabhakar <[email protected]>
> Acked-by: Linus Walleij <[email protected]>
> ---
> 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 | 90 ---------------------
> arch/arm/mach-davinci/include/mach/gpio.h | 88 --------------------
> arch/arm/mach-davinci/tnetv107x.c | 14 ++--
> drivers/gpio/gpio-tnetv107x.c | 5 +-
> include/linux/platform_data/gpio-davinci.h | 34 ++++++++
> 12 files changed, 44 insertions(+), 194 deletions(-)
> delete mode 100644 arch/arm/mach-davinci/include/mach/gpio-davinci.h
> delete mode 100644 arch/arm/mach-davinci/include/mach/gpio.h
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index ba412e0..c298bec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -845,7 +845,6 @@ config ARCH_DAVINCI
> select GENERIC_CLOCKEVENTS
> select GENERIC_IRQ_CHIP
> select HAVE_IDE
> - select NEED_MACH_GPIO_H
> select TI_PRIV_EDMA
> select USE_OF
> select ZONE_DMA
> diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
> index da498ee..771d0e7 100644
> --- a/arch/arm/mach-davinci/da830.c
> +++ b/arch/arm/mach-davinci/da830.c
> @@ -18,7 +18,6 @@
> #include <mach/common.h>
> #include <mach/cputype.h>
> #include <mach/da8xx.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/psc.h>
> #include <mach/time.h>
> diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
> index c6608c4..94ef9bf 100644
> --- a/arch/arm/mach-davinci/da850.c
> +++ b/arch/arm/mach-davinci/da850.c
> @@ -25,7 +25,6 @@
> #include <mach/cpufreq.h>
> #include <mach/cputype.h>
> #include <mach/da8xx.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/pm.h>
> #include <mach/psc.h>
> diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
> index 3eb5ffe..55e79b6 100644
> --- a/arch/arm/mach-davinci/dm355.c
> +++ b/arch/arm/mach-davinci/dm355.c
> @@ -22,7 +22,6 @@
>
> #include <mach/common.h>
> #include <mach/cputype.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/mux.h>
> #include <mach/psc.h>
> diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
> index 9bb60f1..d539e7a 100644
> --- a/arch/arm/mach-davinci/dm365.c
> +++ b/arch/arm/mach-davinci/dm365.c
> @@ -27,7 +27,6 @@
>
> #include <mach/common.h>
> #include <mach/cputype.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/mux.h>
> #include <mach/psc.h>
> diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
> index 9f5f059..fb16a0c 100644
> --- a/arch/arm/mach-davinci/dm644x.c
> +++ b/arch/arm/mach-davinci/dm644x.c
> @@ -19,7 +19,6 @@
>
> #include <mach/common.h>
> #include <mach/cputype.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/mux.h>
> #include <mach/psc.h>
> diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
> index 02042d5..fd48282 100644
> --- a/arch/arm/mach-davinci/dm646x.c
> +++ b/arch/arm/mach-davinci/dm646x.c
> @@ -20,7 +20,6 @@
>
> #include <mach/common.h>
> #include <mach/cputype.h>
> -#include <mach/gpio-davinci.h>
> #include <mach/irqs.h>
> #include <mach/mux.h>
> #include <mach/psc.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 0d63b24..0000000
> --- a/arch/arm/mach-davinci/include/mach/gpio-davinci.h
> +++ /dev/null
> @@ -1,90 +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>
> -
> -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;
> - 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 f4d7fbb..e2cbc40 100644
> --- a/arch/arm/mach-davinci/tnetv107x.c
> +++ b/arch/arm/mach-davinci/tnetv107x.c
> @@ -12,26 +12,26 @@
> * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> * GNU General Public License for more details.
> */
> +#include <linux/clk.h>
> +#include <linux/err.h>
> #include <linux/gpio.h>
> -#include <linux/kernel.h>
> #include <linux/init.h>
> -#include <linux/clk.h>
> #include <linux/io.h>
> -#include <linux/err.h>
> +#include <linux/kernel.h>
> +#include <linux/platform_data/gpio-davinci.h>
> #include <linux/platform_device.h>
> #include <linux/reboot.h>
>
> #include <asm/mach/map.h>
>
> #include <mach/common.h>
> -#include <mach/time.h>
> #include <mach/cputype.h>
> -#include <mach/psc.h>
> #include <mach/cp_intc.h>
> -#include <mach/irqs.h>
> #include <mach/hardware.h>
> +#include <mach/irqs.h>
> +#include <mach/psc.h>
> +#include <mach/time.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 3fa3e28..b5689f6 100644
> --- a/drivers/gpio/gpio-tnetv107x.c
> +++ b/drivers/gpio/gpio-tnetv107x.c
> @@ -12,9 +12,10 @@
> * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> * GNU General Public License for more details.
> */
> -#include <linux/kernel.h>
> -#include <linux/init.h>
> #include <linux/gpio.h>
> +#include <linux/init.h>
> +#include <linux/kernel.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
>