1 --- a/arch/arm/mach-ixp4xx/common.c
2 +++ b/arch/arm/mach-ixp4xx/common.c
4 #include <asm/pgtable.h>
9 #include <asm/mach/map.h>
10 #include <asm/mach/irq.h>
11 @@ -374,12 +375,39 @@ static struct platform_device *ixp46x_de
12 unsigned long ixp4xx_exp_bus_size;
13 EXPORT_SYMBOL(ixp4xx_exp_bus_size);
15 +static int ixp4xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
17 + gpio_line_config(gpio, IXP4XX_GPIO_IN);
20 +EXPORT_SYMBOL(ixp4xx_gpio_direction_input);
22 +static int ixp4xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
24 + gpio_line_set(gpio, level);
25 + gpio_line_config(gpio, IXP4XX_GPIO_OUT);
28 +EXPORT_SYMBOL(ixp4xx_gpio_direction_output);
30 +static struct gpio_chip ixp4xx_gpio_chip = {
31 + .label = "IXP4XX_GPIO_CHIP",
32 + .direction_input = ixp4xx_gpio_direction_input,
33 + .direction_output = ixp4xx_gpio_direction_output,
34 + .get = gpio_get_value,
35 + .set = gpio_set_value,
40 void __init ixp4xx_sys_init(void)
42 ixp4xx_exp_bus_size = SZ_16M;
44 platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices));
46 + gpiochip_add(&ixp4xx_gpio_chip);
48 if (cpu_is_ixp46x()) {
51 --- a/arch/arm/Kconfig
52 +++ b/arch/arm/Kconfig
53 @@ -384,6 +384,7 @@ config ARCH_IXP4XX
56 select GENERIC_CLOCKEVENTS
57 + select ARCH_REQUIRE_GPIOLIB
59 Support for Intel's IXP4XX (XScale) family of processors.
61 --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h
62 +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h
65 #include <linux/kernel.h>
66 #include <mach/hardware.h>
67 +#include <asm-generic/gpio.h> /* cansleep wrappers */
69 -static inline int gpio_request(unsigned gpio, const char *label)
74 -static inline void gpio_free(unsigned gpio)
81 -static inline int gpio_direction_input(unsigned gpio)
83 - gpio_line_config(gpio, IXP4XX_GPIO_IN);
87 -static inline int gpio_direction_output(unsigned gpio, int level)
89 - gpio_line_set(gpio, level);
90 - gpio_line_config(gpio, IXP4XX_GPIO_OUT);
93 +#define NR_BUILTIN_GPIO 16
95 static inline int gpio_get_value(unsigned gpio)
99 - gpio_line_get(gpio, &value);
102 + if (gpio < NR_BUILTIN_GPIO)
105 + gpio_line_get(gpio, &value);
109 + return __gpio_get_value(gpio);
112 static inline void gpio_set_value(unsigned gpio, int value)
114 - gpio_line_set(gpio, value);
115 + if (gpio < NR_BUILTIN_GPIO)
116 + gpio_line_set(gpio, value);
118 + __gpio_set_value(gpio, value);
121 -#include <asm-generic/gpio.h> /* cansleep wrappers */
122 +#define gpio_cansleep __gpio_cansleep
124 extern int gpio_to_irq(int gpio);
125 extern int irq_to_gpio(int gpio);