2 * OMAP7xx specific gpio init
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Charulatha V <charu@ti.com>
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.
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.
19 #include <linux/gpio.h>
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
30 static struct __initdata resource omap7xx_mpu_gpio_resources
[] = {
32 .start
= OMAP1_MPUIO_VBASE
,
33 .end
= OMAP1_MPUIO_VBASE
+ SZ_2K
- 1,
34 .flags
= IORESOURCE_MEM
,
37 .start
= INT_7XX_MPUIO
,
38 .flags
= IORESOURCE_IRQ
,
42 static struct omap_gpio_reg_offs omap7xx_mpuio_regs
= {
43 .revision
= USHRT_MAX
,
44 .direction
= OMAP_MPUIO_IO_CNTL
/ 2,
45 .datain
= OMAP_MPUIO_INPUT_LATCH
/ 2,
46 .dataout
= OMAP_MPUIO_OUTPUT
/ 2,
47 .irqstatus
= OMAP_MPUIO_GPIO_INT
/ 2,
48 .irqenable
= OMAP_MPUIO_GPIO_MASKIT
/ 2,
49 .irqenable_inv
= true,
52 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config
= {
53 .virtual_irq_start
= IH_MPUIO_BASE
,
54 .bank_type
= METHOD_MPUIO
,
57 .regs
= &omap7xx_mpuio_regs
,
60 static struct platform_device omap7xx_mpu_gpio
= {
64 .platform_data
= &omap7xx_mpu_gpio_config
,
66 .num_resources
= ARRAY_SIZE(omap7xx_mpu_gpio_resources
),
67 .resource
= omap7xx_mpu_gpio_resources
,
71 static struct __initdata resource omap7xx_gpio1_resources
[] = {
73 .start
= OMAP7XX_GPIO1_BASE
,
74 .end
= OMAP7XX_GPIO1_BASE
+ SZ_2K
- 1,
75 .flags
= IORESOURCE_MEM
,
78 .start
= INT_7XX_GPIO_BANK1
,
79 .flags
= IORESOURCE_IRQ
,
83 static struct omap_gpio_reg_offs omap7xx_gpio_regs
= {
84 .revision
= USHRT_MAX
,
85 .direction
= OMAP7XX_GPIO_DIR_CONTROL
,
86 .datain
= OMAP7XX_GPIO_DATA_INPUT
,
87 .dataout
= OMAP7XX_GPIO_DATA_OUTPUT
,
88 .irqstatus
= OMAP7XX_GPIO_INT_STATUS
,
89 .irqenable
= OMAP7XX_GPIO_INT_MASK
,
90 .irqenable_inv
= true,
93 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config
= {
94 .virtual_irq_start
= IH_GPIO_BASE
,
95 .bank_type
= METHOD_GPIO_7XX
,
97 .regs
= &omap7xx_gpio_regs
,
100 static struct platform_device omap7xx_gpio1
= {
104 .platform_data
= &omap7xx_gpio1_config
,
106 .num_resources
= ARRAY_SIZE(omap7xx_gpio1_resources
),
107 .resource
= omap7xx_gpio1_resources
,
111 static struct __initdata resource omap7xx_gpio2_resources
[] = {
113 .start
= OMAP7XX_GPIO2_BASE
,
114 .end
= OMAP7XX_GPIO2_BASE
+ SZ_2K
- 1,
115 .flags
= IORESOURCE_MEM
,
118 .start
= INT_7XX_GPIO_BANK2
,
119 .flags
= IORESOURCE_IRQ
,
123 static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config
= {
124 .virtual_irq_start
= IH_GPIO_BASE
+ 32,
125 .bank_type
= METHOD_GPIO_7XX
,
127 .regs
= &omap7xx_gpio_regs
,
130 static struct platform_device omap7xx_gpio2
= {
134 .platform_data
= &omap7xx_gpio2_config
,
136 .num_resources
= ARRAY_SIZE(omap7xx_gpio2_resources
),
137 .resource
= omap7xx_gpio2_resources
,
141 static struct __initdata resource omap7xx_gpio3_resources
[] = {
143 .start
= OMAP7XX_GPIO3_BASE
,
144 .end
= OMAP7XX_GPIO3_BASE
+ SZ_2K
- 1,
145 .flags
= IORESOURCE_MEM
,
148 .start
= INT_7XX_GPIO_BANK3
,
149 .flags
= IORESOURCE_IRQ
,
153 static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config
= {
154 .virtual_irq_start
= IH_GPIO_BASE
+ 64,
155 .bank_type
= METHOD_GPIO_7XX
,
157 .regs
= &omap7xx_gpio_regs
,
160 static struct platform_device omap7xx_gpio3
= {
164 .platform_data
= &omap7xx_gpio3_config
,
166 .num_resources
= ARRAY_SIZE(omap7xx_gpio3_resources
),
167 .resource
= omap7xx_gpio3_resources
,
171 static struct __initdata resource omap7xx_gpio4_resources
[] = {
173 .start
= OMAP7XX_GPIO4_BASE
,
174 .end
= OMAP7XX_GPIO4_BASE
+ SZ_2K
- 1,
175 .flags
= IORESOURCE_MEM
,
178 .start
= INT_7XX_GPIO_BANK4
,
179 .flags
= IORESOURCE_IRQ
,
183 static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config
= {
184 .virtual_irq_start
= IH_GPIO_BASE
+ 96,
185 .bank_type
= METHOD_GPIO_7XX
,
187 .regs
= &omap7xx_gpio_regs
,
190 static struct platform_device omap7xx_gpio4
= {
194 .platform_data
= &omap7xx_gpio4_config
,
196 .num_resources
= ARRAY_SIZE(omap7xx_gpio4_resources
),
197 .resource
= omap7xx_gpio4_resources
,
201 static struct __initdata resource omap7xx_gpio5_resources
[] = {
203 .start
= OMAP7XX_GPIO5_BASE
,
204 .end
= OMAP7XX_GPIO5_BASE
+ SZ_2K
- 1,
205 .flags
= IORESOURCE_MEM
,
208 .start
= INT_7XX_GPIO_BANK5
,
209 .flags
= IORESOURCE_IRQ
,
213 static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config
= {
214 .virtual_irq_start
= IH_GPIO_BASE
+ 128,
215 .bank_type
= METHOD_GPIO_7XX
,
217 .regs
= &omap7xx_gpio_regs
,
220 static struct platform_device omap7xx_gpio5
= {
224 .platform_data
= &omap7xx_gpio5_config
,
226 .num_resources
= ARRAY_SIZE(omap7xx_gpio5_resources
),
227 .resource
= omap7xx_gpio5_resources
,
231 static struct __initdata resource omap7xx_gpio6_resources
[] = {
233 .start
= OMAP7XX_GPIO6_BASE
,
234 .end
= OMAP7XX_GPIO6_BASE
+ SZ_2K
- 1,
235 .flags
= IORESOURCE_MEM
,
238 .start
= INT_7XX_GPIO_BANK6
,
239 .flags
= IORESOURCE_IRQ
,
243 static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config
= {
244 .virtual_irq_start
= IH_GPIO_BASE
+ 160,
245 .bank_type
= METHOD_GPIO_7XX
,
247 .regs
= &omap7xx_gpio_regs
,
250 static struct platform_device omap7xx_gpio6
= {
254 .platform_data
= &omap7xx_gpio6_config
,
256 .num_resources
= ARRAY_SIZE(omap7xx_gpio6_resources
),
257 .resource
= omap7xx_gpio6_resources
,
260 static struct __initdata platform_device
* omap7xx_gpio_dev
[] = {
271 * omap7xx_gpio_init needs to be done before
272 * machine_init functions access gpio APIs.
273 * Hence omap7xx_gpio_init is a postcore_initcall.
275 static int __init
omap7xx_gpio_init(void)
279 if (!cpu_is_omap7xx())
282 for (i
= 0; i
< ARRAY_SIZE(omap7xx_gpio_dev
); i
++)
283 platform_device_register(omap7xx_gpio_dev
[i
]);
285 gpio_bank_count
= ARRAY_SIZE(omap7xx_gpio_dev
);
289 postcore_initcall(omap7xx_gpio_init
);