Skip to contentSkip to conversation

plat-pxa: break out GPIO driver specifics

PATCH New Linus Walleij 3 participants 4 messages Sep 27, 2011 – Oct 1, 2011

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 plat-pxa: break out GPIO driver specifics

From: Linus Walleij <[email protected]>

The <mach/gpio.h> file is included from upper directories and deal with generic GPIO and gpiolib stuff. Break out the platform and driver specific defines and functions into its own header file.

Cc Eric Miao <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mach-mmp/aspenite.c               |    1 +
 arch/arm/mach-mmp/brownstone.c             |    1 -
 arch/arm/mach-mmp/gplugd.c                 |    2 +-
 arch/arm/mach-mmp/include/mach/gpio-pxa.h  |   30 ++++++
 arch/arm/mach-mmp/include/mach/gpio.h      |   23 -----
 arch/arm/mach-mmp/jasper.c                 |    1 -
 arch/arm/mach-mmp/mmp2.c                   |    2 +-
 arch/arm/mach-mmp/pxa168.c                 |    2 +-
 arch/arm/mach-mmp/pxa910.c                 |    2 +-
 arch/arm/mach-mmp/tavorevb.c               |    1 +
 arch/arm/mach-pxa/cm-x255.c                |    1 -
 arch/arm/mach-pxa/include/mach/gpio-pxa.h  |  133 ++++++++++++++++++++++++++++
 arch/arm/mach-pxa/include/mach/gpio.h      |  110 +----------------------
 arch/arm/mach-pxa/include/mach/littleton.h |    2 +-
 arch/arm/mach-pxa/irq.c                    |    2 +-
 arch/arm/mach-pxa/mfp-pxa2xx.c             |    1 +
 arch/arm/mach-pxa/pxa25x.c                 |    1 +
 arch/arm/mach-pxa/pxa27x.c                 |    1 +
 arch/arm/mach-pxa/pxa3xx.c                 |    2 +-
 arch/arm/mach-pxa/pxa95x.c                 |    2 +-
 arch/arm/mach-pxa/saarb.c                  |    1 +
 arch/arm/plat-pxa/include/plat/gpio-pxa.h  |   44 +++++++++
 arch/arm/plat-pxa/include/plat/gpio.h      |   40 +--------
 drivers/gpio/gpio-pxa.c                    |    2 +
 24 files changed, 227 insertions(+), 180 deletions(-)
 create mode 100644 arch/arm/mach-mmp/include/mach/gpio-pxa.h
 create mode 100644 arch/arm/mach-pxa/include/mach/gpio-pxa.h
 create mode 100644 arch/arm/plat-pxa/include/plat/gpio-pxa.h
arch/arm/mach-mmp/aspenite.c +1 -0
index 2b3b0c6..7a60bbb 100644
@@ -17,6 +17,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/nand.h>
 #include <linux/interrupt.h>
+#include <linux/gpio.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
arch/arm/mach-mmp/brownstone.c +0 -1
index c79162a..e411252 100644
@@ -14,7 +14,6 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
-#include <linux/gpio.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/max8649.h>
 #include <linux/regulator/fixed.h>
arch/arm/mach-mmp/gplugd.c +1 -1
index 98e25d9..32776f3 100644
@@ -9,11 +9,11 @@
  */
 
 #include <linux/init.h>
+#include <linux/gpio.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 
-#include <mach/gpio.h>
 #include <mach/pxa168.h>
 #include <mach/mfp-pxa168.h>
 
arch/arm/mach-mmp/include/mach/gpio-pxa.h new file +30 -0
new file mode 100644
index 0000000..c017a98
@@ -0,0 +1,30 @@
+#ifndef __ASM_MACH_GPIO_PXA_H
+#define __ASM_MACH_GPIO_PXA_H
+
+#include <mach/addr-map.h>
+#include <mach/irqs.h>
+
+#define GPIO_REGS_VIRT	(APB_VIRT_BASE + 0x19000)
+
+#define BANK_OFF(n)	(((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
+#define GPIO_REG(x)	(*((volatile u32 *)(GPIO_REGS_VIRT + (x))))
+
+#define NR_BUILTIN_GPIO		IRQ_GPIO_NUM
+
+#define gpio_to_bank(gpio)	((gpio) >> 5)
+
+/* NOTE: these macros are defined here to make optimization of
+ * gpio_{get,set}_value() to work when 'gpio' is a constant.
+ * Usage of these macros otherwise is no longer recommended,
+ * use generic GPIO API whenever possible.
+ */
+#define GPIO_bit(gpio)	(1 << ((gpio) & 0x1f))
+
+#define GPLR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x00)
+#define GPDR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x0c)
+#define GPSR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x18)
+#define GPCR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x24)
+
+#include <plat/gpio-pxa.h>
+
+#endif /* __ASM_MACH_GPIO_PXA_H */
arch/arm/mach-mmp/include/mach/gpio.h +0 -23
index 7bfb827..68126235 100644
@@ -1,36 +1,13 @@
 #ifndef __ASM_MACH_GPIO_H
 #define __ASM_MACH_GPIO_H
 
-#include <mach/addr-map.h>
-#include <mach/irqs.h>
 #include <asm-generic/gpio.h>
 
-#define GPIO_REGS_VIRT	(APB_VIRT_BASE + 0x19000)
-
-#define BANK_OFF(n)	(((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
-#define GPIO_REG(x)	(*((volatile u32 *)(GPIO_REGS_VIRT + (x))))
-
-#define NR_BUILTIN_GPIO		IRQ_GPIO_NUM
-
-#define gpio_to_bank(gpio)	((gpio) >> 5)
 #define gpio_to_irq(gpio)	(IRQ_GPIO_START + (gpio))
 #define irq_to_gpio(irq)	((irq) - IRQ_GPIO_START)
 
-
 #define __gpio_is_inverted(gpio)	(0)
 #define __gpio_is_occupied(gpio)	(0)
 
-/* NOTE: these macros are defined here to make optimization of
- * gpio_{get,set}_value() to work when 'gpio' is a constant.
- * Usage of these macros otherwise is no longer recommended,
- * use generic GPIO API whenever possible.
- */
-#define GPIO_bit(gpio)	(1 << ((gpio) & 0x1f))
-
-#define GPLR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x00)
-#define GPDR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x0c)
-#define GPSR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x18)
-#define GPCR(x)		GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x24)
-
 #include <plat/gpio.h>
 #endif /* __ASM_MACH_GPIO_H */
arch/arm/mach-mmp/jasper.c +0 -1
index 5d6421d..8bfac66 100644
@@ -14,7 +14,6 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
-#include <linux/gpio.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/max8649.h>
 #include <linux/mfd/max8925.h>
arch/arm/mach-mmp/mmp2.c +1 -1
index 1935834..65d8689e 100644
@@ -9,7 +9,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -25,6 +24,7 @@
 #include <mach/irqs.h>
 #include <mach/dma.h>
 #include <mach/mfp.h>
+#include <mach/gpio-pxa.h>
 #include <mach/devices.h>
 #include <mach/mmp2.h>
 
arch/arm/mach-mmp/pxa168.c +1 -1
index e6f6789..76ca15c 100644
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -21,6 +20,7 @@
 #include <mach/regs-apbc.h>
 #include <mach/regs-apmu.h>
 #include <mach/irqs.h>
+#include <mach/gpio-pxa.h>
 #include <mach/dma.h>
 #include <mach/devices.h>
 #include <mach/mfp.h>
arch/arm/mach-mmp/pxa910.c +1 -1
index c70b4dd..4ebbfbb 100644
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -20,6 +19,7 @@
 #include <mach/regs-apmu.h>
 #include <mach/cputype.h>
 #include <mach/irqs.h>
+#include <mach/gpio-pxa.h>
 #include <mach/dma.h>
 #include <mach/mfp.h>
 #include <mach/devices.h>
arch/arm/mach-mmp/tavorevb.c +1 -0
index 143e52e..eb5be87 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/smc91x.h>
+#include <linux/gpio.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
arch/arm/mach-pxa/cm-x255.c +0 -1
index 93f59f8..be75147 100644
@@ -11,7 +11,6 @@
 
 #include <linux/platform_device.h>
 #include <linux/irq.h>
-#include <linux/gpio.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/nand-gpio.h>
arch/arm/mach-pxa/include/mach/gpio-pxa.h new file +133 -0

133 lines not on this page · raw message

arch/arm/mach-pxa/include/mach/gpio.h +2 -108

123 lines not on this page · raw message

arch/arm/mach-pxa/include/mach/littleton.h +1 -1
index 1c585a7..b6238cb 100644
@@ -1,7 +1,7 @@
 #ifndef __ASM_ARCH_LITTLETON_H
 #define __ASM_ARCH_LITTLETON_H
 
-#include <asm/gpio.h>
+#include <mach/gpio-pxa.h>
 
 #define LITTLETON_ETH_PHYS	0x30000000
 
arch/arm/mach-pxa/irq.c +1 -1
index dafb4bf..d493a23 100644
@@ -11,7 +11,6 @@
  *  it under the terms of the GNU General Public License version 2 as
  *  published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -21,6 +20,7 @@
 
 #include <mach/hardware.h>
 #include <mach/irqs.h>
+#include <mach/gpio-pxa.h>
 
 #include "generic.h"
 
arch/arm/mach-pxa/mfp-pxa2xx.c +1 -0
index b129527..43a5f68 100644
@@ -20,6 +20,7 @@
 
 #include <mach/pxa2xx-regs.h>
 #include <mach/mfp-pxa2xx.h>
+#include <mach/gpio-pxa.h>
 
 #include "generic.h"
 
arch/arm/mach-pxa/pxa25x.c +1 -0
index 6bb3fa5..8746e10 100644
@@ -24,6 +24,7 @@
 #include <linux/suspend.h>
 #include <linux/syscore_ops.h>
 #include <linux/irq.h>
+#include <linux/gpio.h>
 
 #include <asm/mach/map.h>
 #include <asm/suspend.h>
arch/arm/mach-pxa/pxa27x.c +1 -0
index d2cdcd6..2bb5cf8 100644
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/i2c/pxa-i2c.h>
+#include <linux/gpio.h>
 
 #include <asm/mach/map.h>
 #include <mach/hardware.h>
arch/arm/mach-pxa/pxa3xx.c +1 -1
index 3ab9e84..f940a13 100644
@@ -12,7 +12,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -26,6 +25,7 @@
 #include <asm/mach/map.h>
 #include <asm/suspend.h>
 #include <mach/hardware.h>
+#include <mach/gpio-pxa.h>
 #include <mach/pxa3xx-regs.h>
 #include <mach/reset.h>
 #include <mach/ohci.h>
arch/arm/mach-pxa/pxa95x.c +1 -1
index de25ceb..51371b3 100644
@@ -9,7 +9,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -21,6 +20,7 @@
 #include <linux/syscore_ops.h>
 
 #include <mach/hardware.h>
+#include <mach/gpio-pxa.h>
 #include <mach/pxa3xx-regs.h>
 #include <mach/pxa930.h>
 #include <mach/reset.h>
arch/arm/mach-pxa/saarb.c +1 -0
index 87070a8..3c988b6f 100644
@@ -15,6 +15,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c/pxa-i2c.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/gpio.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
arch/arm/plat-pxa/include/plat/gpio-pxa.h new file +44 -0

44 lines not on this page · raw message

arch/arm/plat-pxa/include/plat/gpio.h +2 -38
index 6fc41db..258f772 100644
@@ -3,35 +3,8 @@
 
 #define __ARM_GPIOLIB_COMPLEX
 
-struct irq_data;
-
-/*
- * We handle the GPIOs by banks, each bank covers up to 32 GPIOs with
- * one set of registers. The register offsets are organized below:
- *
- *           GPLR    GPDR    GPSR    GPCR    GRER    GFER    GEDR
- * BANK 0 - 0x0000  0x000C  0x0018  0x0024  0x0030  0x003C  0x0048
- * BANK 1 - 0x0004  0x0010  0x001C  0x0028  0x0034  0x0040  0x004C
- * BANK 2 - 0x0008  0x0014  0x0020  0x002C  0x0038  0x0044  0x0050
- *
- * BANK 3 - 0x0100  0x010C  0x0118  0x0124  0x0130  0x013C  0x0148
- * BANK 4 - 0x0104  0x0110  0x011C  0x0128  0x0134  0x0140  0x014C
- * BANK 5 - 0x0108  0x0114  0x0120  0x012C  0x0138  0x0144  0x0150
- *
- * NOTE:
- *   BANK 3 is only available on PXA27x and later processors.
- *   BANK 4 and 5 are only available on PXA935
- */
-
-#define GPIO_BANK(n)	(GPIO_REGS_VIRT + BANK_OFF(n))
-
-#define GPLR_OFFSET	0x00
-#define GPDR_OFFSET	0x0C
-#define GPSR_OFFSET	0x18
-#define GPCR_OFFSET	0x24
-#define GRER_OFFSET	0x30
-#define GFER_OFFSET	0x3C
-#define GEDR_OFFSET	0x48
+/* The individual machine provides register offsets and NR_BUILTIN_GPIO */
+#include <mach/gpio-pxa.h>
 
 static inline int gpio_get_value(unsigned gpio)
 {
@@ -54,13 +27,4 @@ static inline void gpio_set_value(unsigned gpio, int value)
 
 #define gpio_cansleep		__gpio_cansleep
 
-/* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85).
- * Those cases currently cause holes in the GPIO number space, the
- * actual number of the last GPIO is recorded by 'pxa_last_gpio'.
- */
-extern int pxa_last_gpio;
-
-typedef int (*set_wake_t)(struct irq_data *d, unsigned int on);
-
-extern void pxa_init_gpio(int mux_irq, int start, int end, set_wake_t fn);
 #endif /* __PLAT_GPIO_H */
drivers/gpio/gpio-pxa.c +2 -0
index 5d6a86b..9052925 100644
@@ -18,6 +18,8 @@
 #include <linux/syscore_ops.h>
 #include <linux/slab.h>
 
+#include <mach/gpio-pxa.h>
+
 int pxa_last_gpio;
 
 struct pxa_gpio_chip {
Signature · 1 line
1.7.3.2
maintainer
#1 lore raw

PATCH v2 2/2 plat-pxa: break out GPIO driver specifics

Quoted 35 lines · Linus Walleij

From: Linus Walleij <[email protected]>

The <mach/gpio.h> file is included from upper directories and deal with generic GPIO and gpiolib stuff. Break out the platform and driver specific defines and functions into its own header file.

Cc Eric Miao <[email protected]>
Cc Russell King <[email protected]>

---

?arch/arm/mach-mmp/aspenite.c ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-mmp/brownstone.c ? ? ? ? ? ? | ? ?1 -
?arch/arm/mach-mmp/gplugd.c ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-mmp/include/mach/gpio-pxa.h ?| ? 30 ++++++
?arch/arm/mach-mmp/include/mach/gpio.h ? ? ?| ? 23 -----
?arch/arm/mach-mmp/jasper.c ? ? ? ? ? ? ? ? | ? ?1 -
?arch/arm/mach-mmp/mmp2.c ? ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-mmp/pxa168.c ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-mmp/pxa910.c ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-mmp/tavorevb.c ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/cm-x255.c ? ? ? ? ? ? ? ?| ? ?1 -
?arch/arm/mach-pxa/include/mach/gpio-pxa.h ?| ?133 ++++++++++++++++++++++++++++
?arch/arm/mach-pxa/include/mach/gpio.h ? ? ?| ?110 +----------------------
?arch/arm/mach-pxa/include/mach/littleton.h | ? ?2 +-
?arch/arm/mach-pxa/irq.c ? ? ? ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-pxa/mfp-pxa2xx.c ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/pxa25x.c ? ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/pxa27x.c ? ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/pxa3xx.c ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-pxa/pxa95x.c ? ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-pxa/saarb.c ? ? ? ? ? ? ? ? ?| ? ?1 +
?arch/arm/plat-pxa/include/plat/gpio-pxa.h ?| ? 44 +++++++++
?arch/arm/plat-pxa/include/plat/gpio.h ? ? ?| ? 40 +--------
?drivers/gpio/gpio-pxa.c ? ? ? ? ? ? ? ? ? ?| ? ?2 +
Quoted 5 lines

?24 files changed, 227 insertions(+), 180 deletions(-) ?create mode 100644 arch/arm/mach-mmp/include/mach/gpio-pxa.h ?create mode 100644 arch/arm/mach-pxa/include/mach/gpio-pxa.h ?create mode 100644 arch/arm/plat-pxa/include/plat/gpio-pxa.h

I think that we can move gpio out of plat-pxa directory. And gpio driver needs to be simplified by supporting both pxa and mmp.

I sent a new patch series for review.

Thanks
Haojian

#2 lore raw

PATCH v2 2/2 plat-pxa: break out GPIO driver specifics

Quoted 1 line · Haojian Zhuang

I think that we can move gpio out of plat-pxa directory.

Patch [1/2] in this series does that?

Quoted 5 lines

And gpio
driver needs to be simplified by supporting both pxa and mmp.

I sent a new patch series for review.

Sure I'll have a look...

Yours,
Linus Walleij

#3 lore raw

PATCH v2 2/2 plat-pxa: break out GPIO driver specifics

In reply to Linus Walleij
Quoted 7 lines · Linus Walleij
arch/arm/mach-mmp/gplugd.c +0 -0
index 98e25d9..32776f3 100644
@@ -9,11 +9,11 @@
  */
 

arch/arm/mach-mmp/gplugd.c line 19

Quoted 10 lines
arch/arm/mach-mmp/gplugd.c +1 -1
 #include <linux/init.h>
+#include <linux/gpio.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 
-#include <mach/gpio.h>
 #include <mach/pxa168.h>
 #include <mach/mfp-pxa168.h>
 

Mine looks like:

arch/arm/mach-mmp/gplugd.c +1 -1
index c070c24..ef738de 100644
@@ -9,11 +9,11 @@
  */
 
 #include <linux/init.h>
+#include <linux/gpio.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 
-#include <mach/gpio.h>
 #include <mach/pxa168.h>
 #include <mach/mfp-pxa168.h>
 #include <mach/mfp-gplugd.h>