blob: 0e5f68de23bfb4484b578dee72979559e959ba0e [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
Tony Lindgren873e6982012-10-31 09:54:56 -070022#include <mach/irqs.h>
23
Tony Lindgrene99b32e2015-05-21 14:50:23 -070024#include "soc.h"
25
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080026#define OMAP7XX_GPIO1_BASE 0xfffbc000
27#define OMAP7XX_GPIO2_BASE 0xfffbc800
28#define OMAP7XX_GPIO3_BASE 0xfffbd000
29#define OMAP7XX_GPIO4_BASE 0xfffbd800
30#define OMAP7XX_GPIO5_BASE 0xfffbe000
31#define OMAP7XX_GPIO6_BASE 0xfffbe800
32#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
33
34/* mpu gpio */
Tony Lindgrenffd076e2013-10-18 08:54:16 -070035static struct resource omap7xx_mpu_gpio_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080036 {
37 .start = OMAP1_MPUIO_VBASE,
38 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
39 .flags = IORESOURCE_MEM,
40 },
41 {
42 .start = INT_7XX_MPUIO,
43 .flags = IORESOURCE_IRQ,
44 },
45};
46
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070047static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070048 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070049 .direction = OMAP_MPUIO_IO_CNTL / 2,
50 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
51 .dataout = OMAP_MPUIO_OUTPUT / 2,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070052 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070053 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
54 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053055 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070056};
57
Tony Lindgrenffd076e2013-10-18 08:54:16 -070058static struct omap_gpio_platform_data omap7xx_mpu_gpio_config = {
Charulatha Vd0d665a2011-08-31 00:02:21 +053059 .is_mpuio = true,
Charulatha Vec9af5d2011-05-25 12:44:28 +053060 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080061 .bank_stride = 2,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070062 .regs = &omap7xx_mpuio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080063};
64
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -070065static struct platform_device omap7xx_mpu_gpio = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080066 .name = "omap_gpio",
67 .id = 0,
68 .dev = {
69 .platform_data = &omap7xx_mpu_gpio_config,
70 },
71 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
72 .resource = omap7xx_mpu_gpio_resources,
73};
74
75/* gpio1 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -070076static struct resource omap7xx_gpio1_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -080077 {
78 .start = OMAP7XX_GPIO1_BASE,
79 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
80 .flags = IORESOURCE_MEM,
81 },
82 {
83 .start = INT_7XX_GPIO_BANK1,
84 .flags = IORESOURCE_IRQ,
85 },
86};
87
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070088static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
Kevin Hilmane5ff4442011-04-22 14:37:16 -070089 .revision = USHRT_MAX,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070090 .direction = OMAP7XX_GPIO_DIR_CONTROL,
91 .datain = OMAP7XX_GPIO_DATA_INPUT,
92 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
Kevin Hilmaneef4bec2011-04-21 09:17:35 -070093 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
Kevin Hilman28f3b5a2011-04-21 09:53:06 -070094 .irqenable = OMAP7XX_GPIO_INT_MASK,
95 .irqenable_inv = true,
Tarun Kanti DebBarma5e571f32011-09-13 15:02:14 +053096 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070097};
98
Tony Lindgrenffd076e2013-10-18 08:54:16 -070099static struct omap_gpio_platform_data omap7xx_gpio1_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800100 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700101 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800102};
103
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700104static struct platform_device omap7xx_gpio1 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800105 .name = "omap_gpio",
106 .id = 1,
107 .dev = {
108 .platform_data = &omap7xx_gpio1_config,
109 },
110 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
111 .resource = omap7xx_gpio1_resources,
112};
113
114/* gpio2 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700115static struct resource omap7xx_gpio2_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800116 {
117 .start = OMAP7XX_GPIO2_BASE,
118 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
119 .flags = IORESOURCE_MEM,
120 },
121 {
122 .start = INT_7XX_GPIO_BANK2,
123 .flags = IORESOURCE_IRQ,
124 },
125};
126
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700127static struct omap_gpio_platform_data omap7xx_gpio2_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800128 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700129 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800130};
131
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700132static struct platform_device omap7xx_gpio2 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800133 .name = "omap_gpio",
134 .id = 2,
135 .dev = {
136 .platform_data = &omap7xx_gpio2_config,
137 },
138 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
139 .resource = omap7xx_gpio2_resources,
140};
141
142/* gpio3 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700143static struct resource omap7xx_gpio3_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800144 {
145 .start = OMAP7XX_GPIO3_BASE,
146 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
147 .flags = IORESOURCE_MEM,
148 },
149 {
150 .start = INT_7XX_GPIO_BANK3,
151 .flags = IORESOURCE_IRQ,
152 },
153};
154
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700155static struct omap_gpio_platform_data omap7xx_gpio3_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800156 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700157 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800158};
159
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700160static struct platform_device omap7xx_gpio3 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800161 .name = "omap_gpio",
162 .id = 3,
163 .dev = {
164 .platform_data = &omap7xx_gpio3_config,
165 },
166 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
167 .resource = omap7xx_gpio3_resources,
168};
169
170/* gpio4 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700171static struct resource omap7xx_gpio4_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800172 {
173 .start = OMAP7XX_GPIO4_BASE,
174 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
175 .flags = IORESOURCE_MEM,
176 },
177 {
178 .start = INT_7XX_GPIO_BANK4,
179 .flags = IORESOURCE_IRQ,
180 },
181};
182
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700183static struct omap_gpio_platform_data omap7xx_gpio4_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800184 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700185 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800186};
187
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700188static struct platform_device omap7xx_gpio4 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800189 .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 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700199static struct resource omap7xx_gpio5_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800200 {
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
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700211static struct omap_gpio_platform_data omap7xx_gpio5_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800212 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700213 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800214};
215
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700216static struct platform_device omap7xx_gpio5 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800217 .name = "omap_gpio",
218 .id = 5,
219 .dev = {
220 .platform_data = &omap7xx_gpio5_config,
221 },
222 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
223 .resource = omap7xx_gpio5_resources,
224};
225
226/* gpio6 */
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700227static struct resource omap7xx_gpio6_resources[] = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800228 {
229 .start = OMAP7XX_GPIO6_BASE,
230 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
231 .flags = IORESOURCE_MEM,
232 },
233 {
234 .start = INT_7XX_GPIO_BANK6,
235 .flags = IORESOURCE_IRQ,
236 },
237};
238
Tony Lindgrenffd076e2013-10-18 08:54:16 -0700239static struct omap_gpio_platform_data omap7xx_gpio6_config = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800240 .bank_width = 32,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700241 .regs = &omap7xx_gpio_regs,
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800242};
243
Janusz Krzysztofik07ad6ab2011-07-04 03:56:15 -0700244static struct platform_device omap7xx_gpio6 = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800245 .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
Bartlomiej Zolnierkiewiczf8e7ba62013-09-30 15:05:25 +0200254static struct platform_device *omap7xx_gpio_dev[] __initdata = {
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800255 &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
Varadarajan, Charulatha9d523422010-12-07 16:26:56 -0800279 return 0;
280}
281postcore_initcall(omap7xx_gpio_init);