gpio/omap: conslidate enable/disable of GPIO IRQs, remove ifdefs
[deliverable/linux.git] / arch / arm / mach-omap1 / gpio16xx.c
1 /*
2 * OMAP16xx specific gpio init
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19 #include <linux/gpio.h>
20
21 #define OMAP1610_GPIO1_BASE 0xfffbe400
22 #define OMAP1610_GPIO2_BASE 0xfffbec00
23 #define OMAP1610_GPIO3_BASE 0xfffbb400
24 #define OMAP1610_GPIO4_BASE 0xfffbbc00
25 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
26
27 /* mpu gpio */
28 static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
29 {
30 .start = OMAP1_MPUIO_VBASE,
31 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
32 .flags = IORESOURCE_MEM,
33 },
34 {
35 .start = INT_MPUIO,
36 .flags = IORESOURCE_IRQ,
37 },
38 };
39
40 static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
41 .direction = OMAP_MPUIO_IO_CNTL,
42 .datain = OMAP_MPUIO_INPUT_LATCH,
43 .dataout = OMAP_MPUIO_OUTPUT,
44 .irqstatus = OMAP_MPUIO_GPIO_INT,
45 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
46 .irqenable_inv = true,
47 };
48
49 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
50 .virtual_irq_start = IH_MPUIO_BASE,
51 .bank_type = METHOD_MPUIO,
52 .bank_width = 16,
53 .bank_stride = 1,
54 .regs = &omap16xx_mpuio_regs,
55 };
56
57 static struct __initdata platform_device omap16xx_mpu_gpio = {
58 .name = "omap_gpio",
59 .id = 0,
60 .dev = {
61 .platform_data = &omap16xx_mpu_gpio_config,
62 },
63 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
64 .resource = omap16xx_mpu_gpio_resources,
65 };
66
67 /* gpio1 */
68 static struct __initdata resource omap16xx_gpio1_resources[] = {
69 {
70 .start = OMAP1610_GPIO1_BASE,
71 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
72 .flags = IORESOURCE_MEM,
73 },
74 {
75 .start = INT_GPIO_BANK1,
76 .flags = IORESOURCE_IRQ,
77 },
78 };
79
80 static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
81 .direction = OMAP1610_GPIO_DIRECTION,
82 .set_dataout = OMAP1610_GPIO_SET_DATAOUT,
83 .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
84 .datain = OMAP1610_GPIO_DATAIN,
85 .dataout = OMAP1610_GPIO_DATAOUT,
86 .irqstatus = OMAP1610_GPIO_IRQSTATUS1,
87 .irqenable = OMAP1610_GPIO_IRQENABLE1,
88 .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1,
89 .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1,
90 };
91
92 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
93 .virtual_irq_start = IH_GPIO_BASE,
94 .bank_type = METHOD_GPIO_1610,
95 .bank_width = 16,
96 .regs = &omap16xx_gpio_regs,
97 };
98
99 static struct __initdata platform_device omap16xx_gpio1 = {
100 .name = "omap_gpio",
101 .id = 1,
102 .dev = {
103 .platform_data = &omap16xx_gpio1_config,
104 },
105 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
106 .resource = omap16xx_gpio1_resources,
107 };
108
109 /* gpio2 */
110 static struct __initdata resource omap16xx_gpio2_resources[] = {
111 {
112 .start = OMAP1610_GPIO2_BASE,
113 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
114 .flags = IORESOURCE_MEM,
115 },
116 {
117 .start = INT_1610_GPIO_BANK2,
118 .flags = IORESOURCE_IRQ,
119 },
120 };
121
122 static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
123 .virtual_irq_start = IH_GPIO_BASE + 16,
124 .bank_type = METHOD_GPIO_1610,
125 .bank_width = 16,
126 .regs = &omap16xx_gpio_regs,
127 };
128
129 static struct __initdata platform_device omap16xx_gpio2 = {
130 .name = "omap_gpio",
131 .id = 2,
132 .dev = {
133 .platform_data = &omap16xx_gpio2_config,
134 },
135 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
136 .resource = omap16xx_gpio2_resources,
137 };
138
139 /* gpio3 */
140 static struct __initdata resource omap16xx_gpio3_resources[] = {
141 {
142 .start = OMAP1610_GPIO3_BASE,
143 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
144 .flags = IORESOURCE_MEM,
145 },
146 {
147 .start = INT_1610_GPIO_BANK3,
148 .flags = IORESOURCE_IRQ,
149 },
150 };
151
152 static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
153 .virtual_irq_start = IH_GPIO_BASE + 32,
154 .bank_type = METHOD_GPIO_1610,
155 .bank_width = 16,
156 .regs = &omap16xx_gpio_regs,
157 };
158
159 static struct __initdata platform_device omap16xx_gpio3 = {
160 .name = "omap_gpio",
161 .id = 3,
162 .dev = {
163 .platform_data = &omap16xx_gpio3_config,
164 },
165 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
166 .resource = omap16xx_gpio3_resources,
167 };
168
169 /* gpio4 */
170 static struct __initdata resource omap16xx_gpio4_resources[] = {
171 {
172 .start = OMAP1610_GPIO4_BASE,
173 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
174 .flags = IORESOURCE_MEM,
175 },
176 {
177 .start = INT_1610_GPIO_BANK4,
178 .flags = IORESOURCE_IRQ,
179 },
180 };
181
182 static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
183 .virtual_irq_start = IH_GPIO_BASE + 48,
184 .bank_type = METHOD_GPIO_1610,
185 .bank_width = 16,
186 .regs = &omap16xx_gpio_regs,
187 };
188
189 static struct __initdata platform_device omap16xx_gpio4 = {
190 .name = "omap_gpio",
191 .id = 4,
192 .dev = {
193 .platform_data = &omap16xx_gpio4_config,
194 },
195 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
196 .resource = omap16xx_gpio4_resources,
197 };
198
199 static struct __initdata platform_device * omap16xx_gpio_dev[] = {
200 &omap16xx_mpu_gpio,
201 &omap16xx_gpio1,
202 &omap16xx_gpio2,
203 &omap16xx_gpio3,
204 &omap16xx_gpio4,
205 };
206
207 /*
208 * omap16xx_gpio_init needs to be done before
209 * machine_init functions access gpio APIs.
210 * Hence omap16xx_gpio_init is a postcore_initcall.
211 */
212 static int __init omap16xx_gpio_init(void)
213 {
214 int i;
215
216 if (!cpu_is_omap16xx())
217 return -EINVAL;
218
219 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
220 platform_device_register(omap16xx_gpio_dev[i]);
221
222 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
223
224 return 0;
225 }
226 postcore_initcall(omap16xx_gpio_init);
This page took 0.070684 seconds and 5 git commands to generate.