blob: efe4dccaa4f2bd5e47b92474b9485feac8358d59 [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,
46};
47
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080048static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
49 .virtual_irq_start = IH_MPUIO_BASE,
50 .bank_type = METHOD_MPUIO,
51 .bank_width = 32,
Tony Lindgren5de62b82010-12-07 16:26:58 -080052 .bank_stride = 2,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070053 .regs = &omap7xx_mpuio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080054};
55
56static struct __initdata platform_device omap7xx_mpu_gpio = {
57 .name = "omap_gpio",
58 .id = 0,
59 .dev = {
60 .platform_data = &omap7xx_mpu_gpio_config,
61 },
62 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
63 .resource = omap7xx_mpu_gpio_resources,
64};
65
66/* gpio1 */
67static struct __initdata resource omap7xx_gpio1_resources[] = {
68 {
69 .start = OMAP7XX_GPIO1_BASE,
70 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
71 .flags = IORESOURCE_MEM,
72 },
73 {
74 .start = INT_7XX_GPIO_BANK1,
75 .flags = IORESOURCE_IRQ,
76 },
77};
78
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070079static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
80 .direction = OMAP7XX_GPIO_DIR_CONTROL,
81 .datain = OMAP7XX_GPIO_DATA_INPUT,
82 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
83};
84
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080085static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
86 .virtual_irq_start = IH_GPIO_BASE,
87 .bank_type = METHOD_GPIO_7XX,
88 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070089 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080090};
91
92static struct __initdata platform_device omap7xx_gpio1 = {
93 .name = "omap_gpio",
94 .id = 1,
95 .dev = {
96 .platform_data = &omap7xx_gpio1_config,
97 },
98 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
99 .resource = omap7xx_gpio1_resources,
100};
101
102/* gpio2 */
103static struct __initdata resource omap7xx_gpio2_resources[] = {
104 {
105 .start = OMAP7XX_GPIO2_BASE,
106 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 {
110 .start = INT_7XX_GPIO_BANK2,
111 .flags = IORESOURCE_IRQ,
112 },
113};
114
115static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
116 .virtual_irq_start = IH_GPIO_BASE + 32,
117 .bank_type = METHOD_GPIO_7XX,
118 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700119 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800120};
121
122static struct __initdata platform_device omap7xx_gpio2 = {
123 .name = "omap_gpio",
124 .id = 2,
125 .dev = {
126 .platform_data = &omap7xx_gpio2_config,
127 },
128 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
129 .resource = omap7xx_gpio2_resources,
130};
131
132/* gpio3 */
133static struct __initdata resource omap7xx_gpio3_resources[] = {
134 {
135 .start = OMAP7XX_GPIO3_BASE,
136 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
137 .flags = IORESOURCE_MEM,
138 },
139 {
140 .start = INT_7XX_GPIO_BANK3,
141 .flags = IORESOURCE_IRQ,
142 },
143};
144
145static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
146 .virtual_irq_start = IH_GPIO_BASE + 64,
147 .bank_type = METHOD_GPIO_7XX,
148 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700149 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800150};
151
152static struct __initdata platform_device omap7xx_gpio3 = {
153 .name = "omap_gpio",
154 .id = 3,
155 .dev = {
156 .platform_data = &omap7xx_gpio3_config,
157 },
158 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
159 .resource = omap7xx_gpio3_resources,
160};
161
162/* gpio4 */
163static struct __initdata resource omap7xx_gpio4_resources[] = {
164 {
165 .start = OMAP7XX_GPIO4_BASE,
166 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
167 .flags = IORESOURCE_MEM,
168 },
169 {
170 .start = INT_7XX_GPIO_BANK4,
171 .flags = IORESOURCE_IRQ,
172 },
173};
174
175static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
176 .virtual_irq_start = IH_GPIO_BASE + 96,
177 .bank_type = METHOD_GPIO_7XX,
178 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700179 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800180};
181
182static struct __initdata platform_device omap7xx_gpio4 = {
183 .name = "omap_gpio",
184 .id = 4,
185 .dev = {
186 .platform_data = &omap7xx_gpio4_config,
187 },
188 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
189 .resource = omap7xx_gpio4_resources,
190};
191
192/* gpio5 */
193static struct __initdata resource omap7xx_gpio5_resources[] = {
194 {
195 .start = OMAP7XX_GPIO5_BASE,
196 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
197 .flags = IORESOURCE_MEM,
198 },
199 {
200 .start = INT_7XX_GPIO_BANK5,
201 .flags = IORESOURCE_IRQ,
202 },
203};
204
205static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
206 .virtual_irq_start = IH_GPIO_BASE + 128,
207 .bank_type = METHOD_GPIO_7XX,
208 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700209 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800210};
211
212static struct __initdata platform_device omap7xx_gpio5 = {
213 .name = "omap_gpio",
214 .id = 5,
215 .dev = {
216 .platform_data = &omap7xx_gpio5_config,
217 },
218 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
219 .resource = omap7xx_gpio5_resources,
220};
221
222/* gpio6 */
223static struct __initdata resource omap7xx_gpio6_resources[] = {
224 {
225 .start = OMAP7XX_GPIO6_BASE,
226 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
227 .flags = IORESOURCE_MEM,
228 },
229 {
230 .start = INT_7XX_GPIO_BANK6,
231 .flags = IORESOURCE_IRQ,
232 },
233};
234
235static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
236 .virtual_irq_start = IH_GPIO_BASE + 160,
237 .bank_type = METHOD_GPIO_7XX,
238 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700239 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800240};
241
242static struct __initdata platform_device omap7xx_gpio6 = {
243 .name = "omap_gpio",
244 .id = 6,
245 .dev = {
246 .platform_data = &omap7xx_gpio6_config,
247 },
248 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
249 .resource = omap7xx_gpio6_resources,
250};
251
252static struct __initdata platform_device * omap7xx_gpio_dev[] = {
253 &omap7xx_mpu_gpio,
254 &omap7xx_gpio1,
255 &omap7xx_gpio2,
256 &omap7xx_gpio3,
257 &omap7xx_gpio4,
258 &omap7xx_gpio5,
259 &omap7xx_gpio6,
260};
261
262/*
263 * omap7xx_gpio_init needs to be done before
264 * machine_init functions access gpio APIs.
265 * Hence omap7xx_gpio_init is a postcore_initcall.
266 */
267static int __init omap7xx_gpio_init(void)
268{
269 int i;
270
271 if (!cpu_is_omap7xx())
272 return -EINVAL;
273
274 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
275 platform_device_register(omap7xx_gpio_dev[i]);
276
277 gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
278
279 return 0;
280}
281postcore_initcall(omap7xx_gpio_init);