1 --- a/arch/arm/mach-cns3xxx/cns3420vb.c
2 +++ b/arch/arm/mach-cns3xxx/cns3420vb.c
3 @@ -191,7 +191,7 @@ static struct map_desc cns3420_io_desc[]
5 static void __init cns3420_map_io(void)
8 + cns3xxx_common_init();
9 iotable_init(cns3420_io_desc, ARRAY_SIZE(cns3420_io_desc));
11 cns3420_early_serial_setup();
12 --- a/arch/arm/mach-cns3xxx/core.c
13 +++ b/arch/arm/mach-cns3xxx/core.c
15 #include <asm/hardware/cache-l2x0.h>
16 #include <asm/hardware/gic.h>
17 #include <asm/smp_twd.h>
18 +#include <asm/gpio.h>
19 #include <mach/cns3xxx.h>
22 @@ -80,7 +81,89 @@ static struct map_desc cns3xxx_io_desc[]
26 -void __init cns3xxx_map_io(void)
27 +int gpio_to_irq(int gpio)
33 + return IRQ_CNS3XXX_GPIOA;
35 + return IRQ_CNS3XXX_GPIOB;
37 +EXPORT_SYMBOL(gpio_to_irq);
39 +int irq2gpio(int irq)
41 + if (irq == IRQ_CNS3XXX_GPIOA)
43 + else if (irq == IRQ_CNS3XXX_GPIOB)
48 +EXPORT_SYMBOL(irq2gpio);
50 +static inline void gpio_line_config(u8 line, u32 direction)
55 + reg = __raw_readl(CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_DIR);
57 + __raw_writel(reg, CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_DIR);
59 + reg = __raw_readl(CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_DIR);
60 + reg |= (1 << (line - 32));
61 + __raw_writel(reg, CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_DIR);
65 + reg = __raw_readl(CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_DIR);
66 + reg &= ~(1 << line);
67 + __raw_writel(reg, CNS3XXX_GPIOA_BASE_VIRT + CNS3XXX_GPIO_DIR);
69 + reg = __raw_readl(CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_DIR);
70 + reg &= ~(1 << (line - 32));
71 + __raw_writel(reg, CNS3XXX_GPIOB_BASE_VIRT + CNS3XXX_GPIO_DIR);
76 +static int cns3xxx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
78 + gpio_line_config(gpio, CNS3XXX_GPIO_IN);
82 +static int cns3xxx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
84 + gpio_line_set(gpio, level);
85 + gpio_line_config(gpio, CNS3XXX_GPIO_OUT);
89 +static int cns3xxx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
91 + return gpio_get_value(gpio);
94 +static void cns3xxx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
96 + gpio_set_value(gpio, value);
99 +static struct gpio_chip cns3xxx_gpio_chip = {
100 + .label = "CNS3XXX_GPIO_CHIP",
101 + .direction_input = cns3xxx_gpio_direction_input,
102 + .direction_output = cns3xxx_gpio_direction_output,
103 + .get = cns3xxx_gpio_get_value,
104 + .set = cns3xxx_gpio_set_value,
109 +void __init cns3xxx_common_init(void)
111 iotable_init(cns3xxx_io_desc, ARRAY_SIZE(cns3xxx_io_desc));
112 #ifdef CONFIG_CACHE_L2X0
113 @@ -95,6 +178,7 @@ void __init cns3xxx_map_io(void)
114 #ifdef CONFIG_LOCAL_TIMERS
115 twd_base = (void __iomem *) CNS3XXX_TC11MP_TWD_BASE_VIRT;
117 + gpiochip_add(&cns3xxx_gpio_chip);
120 /* used by entry-macro.S */
121 --- a/arch/arm/mach-cns3xxx/core.h
122 +++ b/arch/arm/mach-cns3xxx/core.h
125 extern struct sys_timer cns3xxx_timer;
127 -void __init cns3xxx_map_io(void);
128 +void __init cns3xxx_common_init(void);
129 void __init cns3xxx_init_irq(void);
130 void cns3xxx_power_off(void);
132 --- a/arch/arm/mach-cns3xxx/laguna.c
133 +++ b/arch/arm/mach-cns3xxx/laguna.c
134 @@ -520,7 +520,7 @@ static struct map_desc laguna_io_desc[]
136 static void __init laguna_map_io(void)
139 + cns3xxx_common_init();
140 iotable_init(laguna_io_desc, ARRAY_SIZE(laguna_io_desc));
142 laguna_early_serial_setup();