blob: 12bcd9f2864a483dfebe46a051a33694c9d664a4 [file] [log] [blame]
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -08001/*
2 * OMAP7xx 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 OMAP7XX_GPIO1_BASE 0xfffbc000
22#define OMAP7XX_GPIO2_BASE 0xfffbc800
23#define OMAP7XX_GPIO3_BASE 0xfffbd000
24#define OMAP7XX_GPIO4_BASE 0xfffbd800
25#define OMAP7XX_GPIO5_BASE 0xfffbe000
26#define OMAP7XX_GPIO6_BASE 0xfffbe800
27#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
28
29/* mpu gpio */
30static struct __initdata resource omap7xx_mpu_gpio_resources[] = {
31 {
32 .start = OMAP1_MPUIO_VBASE,
33 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
34 .flags = IORESOURCE_MEM,
35 },
36 {
37 .start = INT_7XX_MPUIO,
38 .flags = IORESOURCE_IRQ,
39 },
40};
41
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070042static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
43 .direction = OMAP_MPUIO_IO_CNTL / 2,
44 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
45 .dataout = OMAP_MPUIO_OUTPUT / 2,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070046 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070047 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
48 .irqenable_inv = true,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070049};
50
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080051static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
52 .virtual_irq_start = IH_MPUIO_BASE,
53 .bank_type = METHOD_MPUIO,
54 .bank_width = 32,
Tony Lindgren5de62b82010-12-07 16:26:58 -080055 .bank_stride = 2,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070056 .regs = &omap7xx_mpuio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080057};
58
59static struct __initdata platform_device omap7xx_mpu_gpio = {
60 .name = "omap_gpio",
61 .id = 0,
62 .dev = {
63 .platform_data = &omap7xx_mpu_gpio_config,
64 },
65 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
66 .resource = omap7xx_mpu_gpio_resources,
67};
68
69/* gpio1 */
70static struct __initdata resource omap7xx_gpio1_resources[] = {
71 {
72 .start = OMAP7XX_GPIO1_BASE,
73 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
74 .flags = IORESOURCE_MEM,
75 },
76 {
77 .start = INT_7XX_GPIO_BANK1,
78 .flags = IORESOURCE_IRQ,
79 },
80};
81
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070082static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
83 .direction = OMAP7XX_GPIO_DIR_CONTROL,
84 .datain = OMAP7XX_GPIO_DATA_INPUT,
85 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070086 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070087 .irqenable = OMAP7XX_GPIO_INT_MASK,
88 .irqenable_inv = true,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070089};
90
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080091static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
92 .virtual_irq_start = IH_GPIO_BASE,
93 .bank_type = METHOD_GPIO_7XX,
94 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070095 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080096};
97
98static struct __initdata platform_device omap7xx_gpio1 = {
99 .name = "omap_gpio",
100 .id = 1,
101 .dev = {
102 .platform_data = &omap7xx_gpio1_config,
103 },
104 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
105 .resource = omap7xx_gpio1_resources,
106};
107
108/* gpio2 */
109static struct __initdata resource omap7xx_gpio2_resources[] = {
110 {
111 .start = OMAP7XX_GPIO2_BASE,
112 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
113 .flags = IORESOURCE_MEM,
114 },
115 {
116 .start = INT_7XX_GPIO_BANK2,
117 .flags = IORESOURCE_IRQ,
118 },
119};
120
121static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
122 .virtual_irq_start = IH_GPIO_BASE + 32,
123 .bank_type = METHOD_GPIO_7XX,
124 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700125 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800126};
127
128static struct __initdata platform_device omap7xx_gpio2 = {
129 .name = "omap_gpio",
130 .id = 2,
131 .dev = {
132 .platform_data = &omap7xx_gpio2_config,
133 },
134 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
135 .resource = omap7xx_gpio2_resources,
136};
137
138/* gpio3 */
139static struct __initdata resource omap7xx_gpio3_resources[] = {
140 {
141 .start = OMAP7XX_GPIO3_BASE,
142 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
143 .flags = IORESOURCE_MEM,
144 },
145 {
146 .start = INT_7XX_GPIO_BANK3,
147 .flags = IORESOURCE_IRQ,
148 },
149};
150
151static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
152 .virtual_irq_start = IH_GPIO_BASE + 64,
153 .bank_type = METHOD_GPIO_7XX,
154 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700155 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800156};
157
158static struct __initdata platform_device omap7xx_gpio3 = {
159 .name = "omap_gpio",
160 .id = 3,
161 .dev = {
162 .platform_data = &omap7xx_gpio3_config,
163 },
164 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
165 .resource = omap7xx_gpio3_resources,
166};
167
168/* gpio4 */
169static struct __initdata resource omap7xx_gpio4_resources[] = {
170 {
171 .start = OMAP7XX_GPIO4_BASE,
172 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
173 .flags = IORESOURCE_MEM,
174 },
175 {
176 .start = INT_7XX_GPIO_BANK4,
177 .flags = IORESOURCE_IRQ,
178 },
179};
180
181static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
182 .virtual_irq_start = IH_GPIO_BASE + 96,
183 .bank_type = METHOD_GPIO_7XX,
184 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700185 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800186};
187
188static struct __initdata platform_device omap7xx_gpio4 = {
189 .name = "omap_gpio",
190 .id = 4,
191 .dev = {
192 .platform_data = &omap7xx_gpio4_config,
193 },
194 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
195 .resource = omap7xx_gpio4_resources,
196};
197
198/* gpio5 */
199static struct __initdata resource omap7xx_gpio5_resources[] = {
200 {
201 .start = OMAP7XX_GPIO5_BASE,
202 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
203 .flags = IORESOURCE_MEM,
204 },
205 {
206 .start = INT_7XX_GPIO_BANK5,
207 .flags = IORESOURCE_IRQ,
208 },
209};
210
211static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
212 .virtual_irq_start = IH_GPIO_BASE + 128,
213 .bank_type = METHOD_GPIO_7XX,
214 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700215 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800216};
217
218static struct __initdata platform_device omap7xx_gpio5 = {
219 .name = "omap_gpio",
220 .id = 5,
221 .dev = {
222 .platform_data = &omap7xx_gpio5_config,
223 },
224 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
225 .resource = omap7xx_gpio5_resources,
226};
227
228/* gpio6 */
229static struct __initdata resource omap7xx_gpio6_resources[] = {
230 {
231 .start = OMAP7XX_GPIO6_BASE,
232 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
233 .flags = IORESOURCE_MEM,
234 },
235 {
236 .start = INT_7XX_GPIO_BANK6,
237 .flags = IORESOURCE_IRQ,
238 },
239};
240
241static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
242 .virtual_irq_start = IH_GPIO_BASE + 160,
243 .bank_type = METHOD_GPIO_7XX,
244 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700245 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800246};
247
248static struct __initdata platform_device omap7xx_gpio6 = {
249 .name = "omap_gpio",
250 .id = 6,
251 .dev = {
252 .platform_data = &omap7xx_gpio6_config,
253 },
254 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
255 .resource = omap7xx_gpio6_resources,
256};
257
258static struct __initdata platform_device * omap7xx_gpio_dev[] = {
259 &omap7xx_mpu_gpio,
260 &omap7xx_gpio1,
261 &omap7xx_gpio2,
262 &omap7xx_gpio3,
263 &omap7xx_gpio4,
264 &omap7xx_gpio5,
265 &omap7xx_gpio6,
266};
267
268/*
269 * omap7xx_gpio_init needs to be done before
270 * machine_init functions access gpio APIs.
271 * Hence omap7xx_gpio_init is a postcore_initcall.
272 */
273static int __init omap7xx_gpio_init(void)
274{
275 int i;
276
277 if (!cpu_is_omap7xx())
278 return -EINVAL;
279
280 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
281 platform_device_register(omap7xx_gpio_dev[i]);
282
283 gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
284
285 return 0;
286}
287postcore_initcall(omap7xx_gpio_init);