aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1
diff options
context:
space:
mode:
authorVaradarajan, Charulatha <charu@ti.com>2010-12-07 19:26:56 -0500
committerTony Lindgren <tony@atomide.com>2010-12-07 19:26:56 -0500
commit9d52342c27b7b43c4a7b24bac24ff7bee0b80e07 (patch)
treef433d1eb63178549edbc323a895327816010f7fd /arch/arm/mach-omap1
parent87fe6229c75a2ca1ebfa1e9e937cba2535e961a8 (diff)
OMAP7xx: GPIO: Introduce support for GPIO init
Add support for handling OMAP7xx specific gpio_init by providing platform device data and doing device registration. Signed-off-by: Charulatha V <charu@ti.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap1')
-rw-r--r--arch/arm/mach-omap1/gpio7xx.c261
1 files changed, 261 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c
new file mode 100644
index 000000000000..94bccd44181d
--- /dev/null
+++ b/arch/arm/mach-omap1/gpio7xx.c
@@ -0,0 +1,261 @@
1/*
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
42static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
43 .virtual_irq_start = IH_MPUIO_BASE,
44 .bank_type = METHOD_MPUIO,
45 .bank_width = 32,
46};
47
48static struct __initdata platform_device omap7xx_mpu_gpio = {
49 .name = "omap_gpio",
50 .id = 0,
51 .dev = {
52 .platform_data = &omap7xx_mpu_gpio_config,
53 },
54 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
55 .resource = omap7xx_mpu_gpio_resources,
56};
57
58/* gpio1 */
59static struct __initdata resource omap7xx_gpio1_resources[] = {
60 {
61 .start = OMAP7XX_GPIO1_BASE,
62 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
63 .flags = IORESOURCE_MEM,
64 },
65 {
66 .start = INT_7XX_GPIO_BANK1,
67 .flags = IORESOURCE_IRQ,
68 },
69};
70
71static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
72 .virtual_irq_start = IH_GPIO_BASE,
73 .bank_type = METHOD_GPIO_7XX,
74 .bank_width = 32,
75};
76
77static struct __initdata platform_device omap7xx_gpio1 = {
78 .name = "omap_gpio",
79 .id = 1,
80 .dev = {
81 .platform_data = &omap7xx_gpio1_config,
82 },
83 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
84 .resource = omap7xx_gpio1_resources,
85};
86
87/* gpio2 */
88static struct __initdata resource omap7xx_gpio2_resources[] = {
89 {
90 .start = OMAP7XX_GPIO2_BASE,
91 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
92 .flags = IORESOURCE_MEM,
93 },
94 {
95 .start = INT_7XX_GPIO_BANK2,
96 .flags = IORESOURCE_IRQ,
97 },
98};
99
100static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
101 .virtual_irq_start = IH_GPIO_BASE + 32,
102 .bank_type = METHOD_GPIO_7XX,
103 .bank_width = 32,
104};
105
106static struct __initdata platform_device omap7xx_gpio2 = {
107 .name = "omap_gpio",
108 .id = 2,
109 .dev = {
110 .platform_data = &omap7xx_gpio2_config,
111 },
112 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
113 .resource = omap7xx_gpio2_resources,
114};
115
116/* gpio3 */
117static struct __initdata resource omap7xx_gpio3_resources[] = {
118 {
119 .start = OMAP7XX_GPIO3_BASE,
120 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
121 .flags = IORESOURCE_MEM,
122 },
123 {
124 .start = INT_7XX_GPIO_BANK3,
125 .flags = IORESOURCE_IRQ,
126 },
127};
128
129static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
130 .virtual_irq_start = IH_GPIO_BASE + 64,
131 .bank_type = METHOD_GPIO_7XX,
132 .bank_width = 32,
133};
134
135static struct __initdata platform_device omap7xx_gpio3 = {
136 .name = "omap_gpio",
137 .id = 3,
138 .dev = {
139 .platform_data = &omap7xx_gpio3_config,
140 },
141 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
142 .resource = omap7xx_gpio3_resources,
143};
144
145/* gpio4 */
146static struct __initdata resource omap7xx_gpio4_resources[] = {
147 {
148 .start = OMAP7XX_GPIO4_BASE,
149 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
150 .flags = IORESOURCE_MEM,
151 },
152 {
153 .start = INT_7XX_GPIO_BANK4,
154 .flags = IORESOURCE_IRQ,
155 },
156};
157
158static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
159 .virtual_irq_start = IH_GPIO_BASE + 96,
160 .bank_type = METHOD_GPIO_7XX,
161 .bank_width = 32,
162};
163
164static struct __initdata platform_device omap7xx_gpio4 = {
165 .name = "omap_gpio",
166 .id = 4,
167 .dev = {
168 .platform_data = &omap7xx_gpio4_config,
169 },
170 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
171 .resource = omap7xx_gpio4_resources,
172};
173
174/* gpio5 */
175static struct __initdata resource omap7xx_gpio5_resources[] = {
176 {
177 .start = OMAP7XX_GPIO5_BASE,
178 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
179 .flags = IORESOURCE_MEM,
180 },
181 {
182 .start = INT_7XX_GPIO_BANK5,
183 .flags = IORESOURCE_IRQ,
184 },
185};
186
187static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
188 .virtual_irq_start = IH_GPIO_BASE + 128,
189 .bank_type = METHOD_GPIO_7XX,
190 .bank_width = 32,
191};
192
193static struct __initdata platform_device omap7xx_gpio5 = {
194 .name = "omap_gpio",
195 .id = 5,
196 .dev = {
197 .platform_data = &omap7xx_gpio5_config,
198 },
199 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
200 .resource = omap7xx_gpio5_resources,
201};
202
203/* gpio6 */
204static struct __initdata resource omap7xx_gpio6_resources[] = {
205 {
206 .start = OMAP7XX_GPIO6_BASE,
207 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
208 .flags = IORESOURCE_MEM,
209 },
210 {
211 .start = INT_7XX_GPIO_BANK6,
212 .flags = IORESOURCE_IRQ,
213 },
214};
215
216static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
217 .virtual_irq_start = IH_GPIO_BASE + 160,
218 .bank_type = METHOD_GPIO_7XX,
219 .bank_width = 32,
220};
221
222static struct __initdata platform_device omap7xx_gpio6 = {
223 .name = "omap_gpio",
224 .id = 6,
225 .dev = {
226 .platform_data = &omap7xx_gpio6_config,
227 },
228 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
229 .resource = omap7xx_gpio6_resources,
230};
231
232static struct __initdata platform_device * omap7xx_gpio_dev[] = {
233 &omap7xx_mpu_gpio,
234 &omap7xx_gpio1,
235 &omap7xx_gpio2,
236 &omap7xx_gpio3,
237 &omap7xx_gpio4,
238 &omap7xx_gpio5,
239 &omap7xx_gpio6,
240};
241
242/*
243 * omap7xx_gpio_init needs to be done before
244 * machine_init functions access gpio APIs.
245 * Hence omap7xx_gpio_init is a postcore_initcall.
246 */
247static int __init omap7xx_gpio_init(void)
248{
249 int i;
250
251 if (!cpu_is_omap7xx())
252 return -EINVAL;
253
254 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
255 platform_device_register(omap7xx_gpio_dev[i]);
256
257 gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
258
259 return 0;
260}
261postcore_initcall(omap7xx_gpio_init);