summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-09-09 16:39:51 +0200
committerLinus Walleij <linus.walleij@linaro.org>2013-09-20 23:04:50 +0200
commit7b85b867b99044da93f83851c806d1e324d49ed5 (patch)
tree22fd6412f7d986b1d3720badd4d5fe60f3fd9a45 /drivers
parent51a97d829e32b7a1b960d3365e4c2546c9c792aa (diff)
downloadlinux-7b85b867b99044da93f83851c806d1e324d49ed5.tar.bz2
ARM: plat-iop: instantiate GPIO from platform device
This converts the IOP32x and IOP33x platforms to pass their base address offset by a resource attached to a platform device instead of using static offset macros implicitly passed through <linux/gpio.h> including <mach/gpio.h>. Delete the local <mach/gpio.h> and <asm/hardware/iop3xx-gpio.h> headers and remove the selection of NEED_MACH_GPIO_H. Pass the virtual address as a resource in the platform device at this point for bisectability, next patch will pass the physical address as is custom. Cc: Lennert Buytenhek <kernel@wantstofly.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Mikael Pettersson <mikpe@it.uu.se> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpio-iop.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c
index 17cc7010cd04..24a86b05dc8c 100644
--- a/drivers/gpio/gpio-iop.c
+++ b/drivers/gpio/gpio-iop.c
@@ -16,9 +16,23 @@
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/export.h>
+#include <linux/platform_device.h>
#define IOP3XX_N_GPIOS 8
+#define GPIO_IN 0
+#define GPIO_OUT 1
+#define GPIO_LOW 0
+#define GPIO_HIGH 1
+
+/* Memory base offset */
+static void __iomem *base;
+
+#define IOP3XX_GPIO_REG(reg) (base + (reg))
+#define IOP3XX_GPOE (volatile u32 *)IOP3XX_GPIO_REG(0x0000)
+#define IOP3XX_GPID (volatile u32 *)IOP3XX_GPIO_REG(0x0004)
+#define IOP3XX_GPOD (volatile u32 *)IOP3XX_GPIO_REG(0x0008)
+
static void gpio_line_config(int line, int direction)
{
unsigned long flags;
@@ -83,8 +97,26 @@ static struct gpio_chip iop3xx_chip = {
.ngpio = IOP3XX_N_GPIOS,
};
-static int __init iop3xx_gpio_setup(void)
+static int iop3xx_gpio_probe(struct platform_device *pdev)
{
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ base = (void *) res->start;
+
return gpiochip_add(&iop3xx_chip);
}
-arch_initcall(iop3xx_gpio_setup);
+
+static struct platform_driver iop3xx_gpio_driver = {
+ .driver = {
+ .name = "gpio-iop",
+ .owner = THIS_MODULE,
+ },
+ .probe = iop3xx_gpio_probe,
+};
+
+static int __init iop3xx_gpio_init(void)
+{
+ return platform_driver_register(&iop3xx_gpio_driver);
+}
+arch_initcall(iop3xx_gpio_init);