1 --- a/arch/arm/mach-cns3xxx/cns3420vb.c
2 +++ b/arch/arm/mach-cns3xxx/cns3420vb.c
3 @@ -215,7 +215,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/gic.h>
16 #include <asm/smp_twd.h>
17 #include <asm/hardware/cache-l2x0.h>
18 +#include <asm/gpio.h>
19 #include <mach/cns3xxx.h>
22 @@ -75,12 +76,96 @@ 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 #ifdef CONFIG_LOCAL_TIMERS
112 twd_base = (void __iomem *) CNS3XXX_TC11MP_TWD_BASE_VIRT;
114 iotable_init(cns3xxx_io_desc, ARRAY_SIZE(cns3xxx_io_desc));
116 + gpiochip_add(&cns3xxx_gpio_chip);
119 /* used by entry-macro.S */
120 --- a/arch/arm/mach-cns3xxx/core.h
121 +++ b/arch/arm/mach-cns3xxx/core.h
122 @@ -20,7 +20,7 @@ void __init cns3xxx_l2x0_init(void);
123 static inline void cns3xxx_l2x0_init(void) {}
124 #endif /* CONFIG_CACHE_L2X0 */
126 -void __init cns3xxx_map_io(void);
127 +void __init cns3xxx_common_init(void);
128 void __init cns3xxx_init_irq(void);
129 void cns3xxx_power_off(void);
131 --- a/arch/arm/mach-cns3xxx/laguna.c
132 +++ b/arch/arm/mach-cns3xxx/laguna.c
133 @@ -611,7 +611,7 @@ static struct map_desc laguna_io_desc[]
135 static void __init laguna_map_io(void)
138 + cns3xxx_common_init();
139 iotable_init(laguna_io_desc, ARRAY_SIZE(laguna_io_desc));
140 laguna_early_serial_setup();