blob: 958ce9acee954c871fd67bcef67763c5a8021cce [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>
Tony Lindgren4b254082012-08-30 15:37:24 -070020#include <linux/platform_data/gpio-omap.h>
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080021
22#define OMAP7XX_GPIO1_BASE 0xfffbc000
23#define OMAP7XX_GPIO2_BASE 0xfffbc800
24#define OMAP7XX_GPIO3_BASE 0xfffbd000
25#define OMAP7XX_GPIO4_BASE 0xfffbd800
26#define OMAP7XX_GPIO5_BASE 0xfffbe000
27#define OMAP7XX_GPIO6_BASE 0xfffbe800
28#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
29
30/* mpu gpio */
31static struct __initdata resource omap7xx_mpu_gpio_resources[] = {
32 {
33 .start = OMAP1_MPUIO_VBASE,
34 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
35 .flags = IORESOURCE_MEM,
36 },
37 {
38 .start = INT_7XX_MPUIO,
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070043static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070044 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070045 .direction = OMAP_MPUIO_IO_CNTL / 2,
46 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
47 .dataout = OMAP_MPUIO_OUTPUT / 2,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070048 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070049 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
50 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053051 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070052};
53
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080054static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
Charulatha Vd0d665a2011-08-31 00:02:21 +053055 .is_mpuio = true,
Charulatha Vec9af5d2011-05-25 12:44:28 +053056 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080057 .bank_stride = 2,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070058 .regs = &omap7xx_mpuio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080059};
60
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070061static struct platform_device omap7xx_mpu_gpio = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080062 .name = "omap_gpio",
63 .id = 0,
64 .dev = {
65 .platform_data = &omap7xx_mpu_gpio_config,
66 },
67 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
68 .resource = omap7xx_mpu_gpio_resources,
69};
70
71/* gpio1 */
72static struct __initdata resource omap7xx_gpio1_resources[] = {
73 {
74 .start = OMAP7XX_GPIO1_BASE,
75 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
76 .flags = IORESOURCE_MEM,
77 },
78 {
79 .start = INT_7XX_GPIO_BANK1,
80 .flags = IORESOURCE_IRQ,
81 },
82};
83
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070084static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070085 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070086 .direction = OMAP7XX_GPIO_DIR_CONTROL,
87 .datain = OMAP7XX_GPIO_DATA_INPUT,
88 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070089 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070090 .irqenable = OMAP7XX_GPIO_INT_MASK,
91 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053092 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070093};
94
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080095static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080096 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070097 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080098};
99
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700100static struct platform_device omap7xx_gpio1 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800101 .name = "omap_gpio",
102 .id = 1,
103 .dev = {
104 .platform_data = &omap7xx_gpio1_config,
105 },
106 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
107 .resource = omap7xx_gpio1_resources,
108};
109
110/* gpio2 */
111static struct __initdata resource omap7xx_gpio2_resources[] = {
112 {
113 .start = OMAP7XX_GPIO2_BASE,
114 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
115 .flags = IORESOURCE_MEM,
116 },
117 {
118 .start = INT_7XX_GPIO_BANK2,
119 .flags = IORESOURCE_IRQ,
120 },
121};
122
123static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800124 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700125 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800126};
127
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700128static struct platform_device omap7xx_gpio2 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800129 .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 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800152 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700153 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800154};
155
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700156static struct platform_device omap7xx_gpio3 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800157 .name = "omap_gpio",
158 .id = 3,
159 .dev = {
160 .platform_data = &omap7xx_gpio3_config,
161 },
162 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
163 .resource = omap7xx_gpio3_resources,
164};
165
166/* gpio4 */
167static struct __initdata resource omap7xx_gpio4_resources[] = {
168 {
169 .start = OMAP7XX_GPIO4_BASE,
170 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
171 .flags = IORESOURCE_MEM,
172 },
173 {
174 .start = INT_7XX_GPIO_BANK4,
175 .flags = IORESOURCE_IRQ,
176 },
177};
178
179static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800180 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700181 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800182};
183
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700184static struct platform_device omap7xx_gpio4 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800185 .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 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800208 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700209 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800210};
211
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700212static struct platform_device omap7xx_gpio5 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800213 .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 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800236 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700237 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800238};
239
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700240static struct platform_device omap7xx_gpio6 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800241 .name = "omap_gpio",
242 .id = 6,
243 .dev = {
244 .platform_data = &omap7xx_gpio6_config,
245 },
246 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
247 .resource = omap7xx_gpio6_resources,
248};
249
250static struct __initdata platform_device * omap7xx_gpio_dev[] = {
251 &omap7xx_mpu_gpio,
252 &omap7xx_gpio1,
253 &omap7xx_gpio2,
254 &omap7xx_gpio3,
255 &omap7xx_gpio4,
256 &omap7xx_gpio5,
257 &omap7xx_gpio6,
258};
259
260/*
261 * omap7xx_gpio_init needs to be done before
262 * machine_init functions access gpio APIs.
263 * Hence omap7xx_gpio_init is a postcore_initcall.
264 */
265static int __init omap7xx_gpio_init(void)
266{
267 int i;
268
269 if (!cpu_is_omap7xx())
270 return -EINVAL;
271
272 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
273 platform_device_register(omap7xx_gpio_dev[i]);
274
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800275 return 0;
276}
277postcore_initcall(omap7xx_gpio_init);