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