blob: acf12b73eace0a07c5567d199c96d73e506fcb7a [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 = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070043 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070044 .direction = OMAP_MPUIO_IO_CNTL / 2,
45 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
46 .dataout = OMAP_MPUIO_OUTPUT / 2,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070047 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070048 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
49 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053050 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070051};
52
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080053static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
Charulatha Vd0d665a2011-08-31 00:02:21 +053054 .is_mpuio = true,
Charulatha Vec9af5d2011-05-25 12:44:28 +053055 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080056 .bank_stride = 2,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070057 .regs = &omap7xx_mpuio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080058};
59
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070060static struct platform_device omap7xx_mpu_gpio = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080061 .name = "omap_gpio",
62 .id = 0,
63 .dev = {
64 .platform_data = &omap7xx_mpu_gpio_config,
65 },
66 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
67 .resource = omap7xx_mpu_gpio_resources,
68};
69
70/* gpio1 */
71static struct __initdata resource omap7xx_gpio1_resources[] = {
72 {
73 .start = OMAP7XX_GPIO1_BASE,
74 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
75 .flags = IORESOURCE_MEM,
76 },
77 {
78 .start = INT_7XX_GPIO_BANK1,
79 .flags = IORESOURCE_IRQ,
80 },
81};
82
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070083static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070084 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070085 .direction = OMAP7XX_GPIO_DIR_CONTROL,
86 .datain = OMAP7XX_GPIO_DATA_INPUT,
87 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070088 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070089 .irqenable = OMAP7XX_GPIO_INT_MASK,
90 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053091 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070092};
93
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080094static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080095 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070096 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080097};
98
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070099static struct platform_device omap7xx_gpio1 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800100 .name = "omap_gpio",
101 .id = 1,
102 .dev = {
103 .platform_data = &omap7xx_gpio1_config,
104 },
105 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
106 .resource = omap7xx_gpio1_resources,
107};
108
109/* gpio2 */
110static struct __initdata resource omap7xx_gpio2_resources[] = {
111 {
112 .start = OMAP7XX_GPIO2_BASE,
113 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
114 .flags = IORESOURCE_MEM,
115 },
116 {
117 .start = INT_7XX_GPIO_BANK2,
118 .flags = IORESOURCE_IRQ,
119 },
120};
121
122static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800123 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700124 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800125};
126
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700127static struct platform_device omap7xx_gpio2 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800128 .name = "omap_gpio",
129 .id = 2,
130 .dev = {
131 .platform_data = &omap7xx_gpio2_config,
132 },
133 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
134 .resource = omap7xx_gpio2_resources,
135};
136
137/* gpio3 */
138static struct __initdata resource omap7xx_gpio3_resources[] = {
139 {
140 .start = OMAP7XX_GPIO3_BASE,
141 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
142 .flags = IORESOURCE_MEM,
143 },
144 {
145 .start = INT_7XX_GPIO_BANK3,
146 .flags = IORESOURCE_IRQ,
147 },
148};
149
150static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800151 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700152 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800153};
154
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700155static struct platform_device omap7xx_gpio3 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800156 .name = "omap_gpio",
157 .id = 3,
158 .dev = {
159 .platform_data = &omap7xx_gpio3_config,
160 },
161 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
162 .resource = omap7xx_gpio3_resources,
163};
164
165/* gpio4 */
166static struct __initdata resource omap7xx_gpio4_resources[] = {
167 {
168 .start = OMAP7XX_GPIO4_BASE,
169 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
170 .flags = IORESOURCE_MEM,
171 },
172 {
173 .start = INT_7XX_GPIO_BANK4,
174 .flags = IORESOURCE_IRQ,
175 },
176};
177
178static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800179 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700180 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800181};
182
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700183static struct platform_device omap7xx_gpio4 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800184 .name = "omap_gpio",
185 .id = 4,
186 .dev = {
187 .platform_data = &omap7xx_gpio4_config,
188 },
189 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
190 .resource = omap7xx_gpio4_resources,
191};
192
193/* gpio5 */
194static struct __initdata resource omap7xx_gpio5_resources[] = {
195 {
196 .start = OMAP7XX_GPIO5_BASE,
197 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
198 .flags = IORESOURCE_MEM,
199 },
200 {
201 .start = INT_7XX_GPIO_BANK5,
202 .flags = IORESOURCE_IRQ,
203 },
204};
205
206static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800207 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700208 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800209};
210
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700211static struct platform_device omap7xx_gpio5 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800212 .name = "omap_gpio",
213 .id = 5,
214 .dev = {
215 .platform_data = &omap7xx_gpio5_config,
216 },
217 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
218 .resource = omap7xx_gpio5_resources,
219};
220
221/* gpio6 */
222static struct __initdata resource omap7xx_gpio6_resources[] = {
223 {
224 .start = OMAP7XX_GPIO6_BASE,
225 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
226 .flags = IORESOURCE_MEM,
227 },
228 {
229 .start = INT_7XX_GPIO_BANK6,
230 .flags = IORESOURCE_IRQ,
231 },
232};
233
234static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800235 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700236 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800237};
238
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700239static struct platform_device omap7xx_gpio6 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800240 .name = "omap_gpio",
241 .id = 6,
242 .dev = {
243 .platform_data = &omap7xx_gpio6_config,
244 },
245 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
246 .resource = omap7xx_gpio6_resources,
247};
248
249static struct __initdata platform_device * omap7xx_gpio_dev[] = {
250 &omap7xx_mpu_gpio,
251 &omap7xx_gpio1,
252 &omap7xx_gpio2,
253 &omap7xx_gpio3,
254 &omap7xx_gpio4,
255 &omap7xx_gpio5,
256 &omap7xx_gpio6,
257};
258
259/*
260 * omap7xx_gpio_init needs to be done before
261 * machine_init functions access gpio APIs.
262 * Hence omap7xx_gpio_init is a postcore_initcall.
263 */
264static int __init omap7xx_gpio_init(void)
265{
266 int i;
267
268 if (!cpu_is_omap7xx())
269 return -EINVAL;
270
271 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
272 platform_device_register(omap7xx_gpio_dev[i]);
273
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800274 return 0;
275}
276postcore_initcall(omap7xx_gpio_init);