]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: plat-iop: instantiate GPIO from platform device
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 9 Sep 2013 14:39:51 +0000 (16:39 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 20 Sep 2013 21:04:50 +0000 (23:04 +0200)
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>
16 files changed:
arch/arm/Kconfig
arch/arm/include/asm/hardware/iop3xx-gpio.h [deleted file]
arch/arm/include/asm/hardware/iop3xx.h
arch/arm/mach-iop32x/em7210.c
arch/arm/mach-iop32x/glantank.c
arch/arm/mach-iop32x/gpio-iop32x.h [new file with mode: 0644]
arch/arm/mach-iop32x/include/mach/gpio.h [deleted file]
arch/arm/mach-iop32x/include/mach/iop32x.h
arch/arm/mach-iop32x/iq31244.c
arch/arm/mach-iop32x/iq80321.c
arch/arm/mach-iop32x/n2100.c
arch/arm/mach-iop33x/include/mach/gpio.h [deleted file]
arch/arm/mach-iop33x/include/mach/iop33x.h
arch/arm/mach-iop33x/iq80331.c
arch/arm/mach-iop33x/iq80332.c
drivers/gpio/gpio-iop.c

index fc8c0928bfafe820acebcd3e09f92af82084d601..e83529b42ac6767f67306efbf68362b050fdeab9 100644 (file)
@@ -458,7 +458,6 @@ config ARCH_IOP32X
        select ARCH_REQUIRE_GPIOLIB
        select CPU_XSCALE
        select GPIO_IOP
-       select NEED_MACH_GPIO_H
        select NEED_RET_TO_USER
        select PCI
        select PLAT_IOP
@@ -472,7 +471,6 @@ config ARCH_IOP33X
        select ARCH_REQUIRE_GPIOLIB
        select CPU_XSCALE
        select GPIO_IOP
-       select NEED_MACH_GPIO_H
        select NEED_RET_TO_USER
        select PCI
        select PLAT_IOP
diff --git a/arch/arm/include/asm/hardware/iop3xx-gpio.h b/arch/arm/include/asm/hardware/iop3xx-gpio.h
deleted file mode 100644 (file)
index e2a0970..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * arch/arm/include/asm/hardware/iop3xx-gpio.h
- *
- * IOP3xx GPIO wrappers
- *
- * Copyright (c) 2008 Arnaud Patard <arnaud.patard@rtp-net.org>
- * Based on IXP4XX gpio.h file
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#ifndef __ASM_ARM_HARDWARE_IOP3XX_GPIO_H
-#define __ASM_ARM_HARDWARE_IOP3XX_GPIO_H
-
-#include <mach/hardware.h>
-#include <asm-generic/gpio.h>
-
-#endif
-
index 6af9c2841fcb5d16ee7c23f0637458bf9310f8cd..2594a95ff19a5ea39bc9f86a14b66eafe1d2989d 100644 (file)
 /*
  * IOP3XX GPIO handling
  */
-#define GPIO_IN                        0
-#define GPIO_OUT               1
-#define GPIO_LOW               0
-#define GPIO_HIGH              1
 #define IOP3XX_GPIO_LINE(x)    (x)
 
 #ifndef __ASSEMBLY__
@@ -165,11 +161,6 @@ extern int iop3xx_get_init_atu(void);
 /* PERCR0 DOESN'T EXIST - index from 1! */
 #define IOP3XX_PERCR0          (volatile u32 *)IOP3XX_REG_ADDR(0x0710)
 
-/* General Purpose I/O  */
-#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)
-
 /* Timers  */
 #define IOP3XX_TU_TMR0         (volatile u32 *)IOP3XX_TIMER_REG(0x0000)
 #define IOP3XX_TU_TMR1         (volatile u32 *)IOP3XX_TIMER_REG(0x0004)
index 31fbb6c61b25c304adc2f0ee940ac1df38ac33f1..177cd073a83bf4e6d9de439b478ae689ef95d283 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/mach/time.h>
 #include <asm/mach-types.h>
 #include <mach/time.h>
+#include "gpio-iop32x.h"
 
 static void __init em7210_timer_init(void)
 {
@@ -183,6 +184,7 @@ void em7210_power_off(void)
 
 static void __init em7210_init_machine(void)
 {
+       register_iop32x_gpio();
        platform_device_register(&em7210_serial_device);
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
index ac304705fe68956ebae0f85bf2d5c53b2cbf9e37..547b2342d61a881a4be35d9286daf2a46d27623e 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/mach-types.h>
 #include <asm/page.h>
 #include <mach/time.h>
+#include "gpio-iop32x.h"
 
 /*
  * GLAN Tank timer tick configuration.
@@ -187,6 +188,7 @@ static void glantank_power_off(void)
 
 static void __init glantank_init_machine(void)
 {
+       register_iop32x_gpio();
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
        platform_device_register(&glantank_flash_device);
diff --git a/arch/arm/mach-iop32x/gpio-iop32x.h b/arch/arm/mach-iop32x/gpio-iop32x.h
new file mode 100644 (file)
index 0000000..b8710a6
--- /dev/null
@@ -0,0 +1,10 @@
+static struct resource iop32x_gpio_res[] = {
+       DEFINE_RES_MEM((IOP3XX_PERIPHERAL_VIRT_BASE + 0x07c4), 0x10),
+};
+
+static inline void register_iop32x_gpio(void)
+{
+       platform_device_register_simple("gpio-iop", 0,
+                                       iop32x_gpio_res,
+                                       ARRAY_SIZE(iop32x_gpio_res));
+}
diff --git a/arch/arm/mach-iop32x/include/mach/gpio.h b/arch/arm/mach-iop32x/include/mach/gpio.h
deleted file mode 100644 (file)
index 708f4ec..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __ASM_ARCH_IOP32X_GPIO_H
-#define __ASM_ARCH_IOP32X_GPIO_H
-
-#include <asm/hardware/iop3xx-gpio.h>
-
-#endif
index 941f363aca56411bb26505bb776ceb3772dbbfe9..56ec864ec313b7e88883b5a86ec13bfa2dd93523 100644 (file)
@@ -19,7 +19,6 @@
  * Peripherals that are shared between the iop32x and iop33x but
  * located at different addresses.
  */
-#define IOP3XX_GPIO_REG(reg)   (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07c4 + (reg))
 #define IOP3XX_TIMER_REG(reg)  (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07e0 + (reg))
 
 #include <asm/hardware/iop3xx.h>
index f2cd2966212da1381d677d47abb147f4b5c88879..0e1392b20d18e764f6558ae523e7f0fa0a350257 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <mach/time.h>
+#include "gpio-iop32x.h"
 
 /*
  * Until March of 2007 iq31244 platforms and ep80219 platforms shared the
@@ -283,6 +284,7 @@ void ep80219_power_off(void)
 
 static void __init iq31244_init_machine(void)
 {
+       register_iop32x_gpio();
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
        platform_device_register(&iq31244_flash_device);
index 015435de90dd6f179b808e693b209f4da1c9f021..66782ff1f46a0a477da57301baf7686dd4c900c9 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <mach/time.h>
+#include "gpio-iop32x.h"
 
 /*
  * IQ80321 timer tick configuration.
@@ -170,6 +171,7 @@ static struct platform_device iq80321_serial_device = {
 
 static void __init iq80321_init_machine(void)
 {
+       register_iop32x_gpio();
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
        platform_device_register(&iq80321_flash_device);
index bc40a97050a13ebc409b786b19fcbfe24e7ac3f1..c1cd80ecc21992b2778c20f03f04ea9c328e0a4e 100644 (file)
@@ -41,6 +41,7 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <mach/time.h>
+#include "gpio-iop32x.h"
 
 /*
  * N2100 timer tick configuration.
@@ -345,6 +346,7 @@ device_initcall(n2100_request_gpios);
 
 static void __init n2100_init_machine(void)
 {
+       register_iop32x_gpio();
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&n2100_flash_device);
        platform_device_register(&n2100_serial_device);
diff --git a/arch/arm/mach-iop33x/include/mach/gpio.h b/arch/arm/mach-iop33x/include/mach/gpio.h
deleted file mode 100644 (file)
index ddd55bb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __ASM_ARCH_IOP33X_GPIO_H
-#define __ASM_ARCH_IOP33X_GPIO_H
-
-#include <asm/hardware/iop3xx-gpio.h>
-
-#endif
index a89c0a234bffff05baee92e08eb23e6a703a0103..c951226530947e0f3f90fd2ce913bda17bed998e 100644 (file)
@@ -18,7 +18,6 @@
  * Peripherals that are shared between the iop32x and iop33x but
  * located at different addresses.
  */
-#define IOP3XX_GPIO_REG(reg)   (IOP3XX_PERIPHERAL_VIRT_BASE + 0x1780 + (reg))
 #define IOP3XX_TIMER_REG(reg)  (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07d0 + (reg))
 
 #include <asm/hardware/iop3xx.h>
index c43304a10fa72cdeac813890a68ac6e3a476ff30..25741c4c92de218805f66efa4347df4a9e325f09 100644 (file)
@@ -122,8 +122,15 @@ static struct platform_device iq80331_flash_device = {
        .resource       = &iq80331_flash_resource,
 };
 
+static struct resource iq80331_gpio_res[] = {
+       DEFINE_RES_MEM((IOP3XX_PERIPHERAL_VIRT_BASE + 0x1780), 0x10),
+};
+
 static void __init iq80331_init_machine(void)
 {
+       platform_device_register_simple("gpio-iop", 0,
+                                       iq80331_gpio_res,
+                                       ARRAY_SIZE(iq80331_gpio_res));
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
        platform_device_register(&iop33x_uart0_device);
index 8192987e78e5b7107254ffb29a6dd8856fcc8bad..a3b56e1c2ad46aa201e5dadcfb1a1c596c91920d 100644 (file)
@@ -122,8 +122,15 @@ static struct platform_device iq80332_flash_device = {
        .resource       = &iq80332_flash_resource,
 };
 
+static struct resource iq80332_gpio_res[] = {
+       DEFINE_RES_MEM((IOP3XX_PERIPHERAL_VIRT_BASE + 0x1780), 0x10),
+};
+
 static void __init iq80332_init_machine(void)
 {
+       platform_device_register_simple("gpio-iop", 0,
+                                       iq80332_gpio_res,
+                                       ARRAY_SIZE(iq80332_gpio_res));
        platform_device_register(&iop3xx_i2c0_device);
        platform_device_register(&iop3xx_i2c1_device);
        platform_device_register(&iop33x_uart0_device);
index 17cc7010cd04388540ce9eeff720dbc2bcc286fe..24a86b05dc8cb4f38f69e05d2686b2e18ae257ef 100644 (file)
 #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);