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,
50 .irqctrl
= OMAP_MPUIO_GPIO_INT_EDGE
>> 1,
53 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config
= {
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,
91 .irqctrl
= OMAP7XX_GPIO_INT_CONTROL
,
94 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config
= {
96 .regs
= &omap7xx_gpio_regs
,
99 static struct platform_device omap7xx_gpio1
= {
103 .platform_data
= &omap7xx_gpio1_config
,
105 .num_resources
= ARRAY_SIZE(omap7xx_gpio1_resources
),
106 .resource
= omap7xx_gpio1_resources
,
110 static struct __initdata resource omap7xx_gpio2_resources
[] = {
112 .start
= OMAP7XX_GPIO2_BASE
,
113 .end
= OMAP7XX_GPIO2_BASE
+ SZ_2K
- 1,
114 .flags
= IORESOURCE_MEM
,
117 .start
= INT_7XX_GPIO_BANK2
,
118 .flags
= IORESOURCE_IRQ
,
122 static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config
= {
124 .regs
= &omap7xx_gpio_regs
,
127 static struct platform_device omap7xx_gpio2
= {
131 .platform_data
= &omap7xx_gpio2_config
,
133 .num_resources
= ARRAY_SIZE(omap7xx_gpio2_resources
),
134 .resource
= omap7xx_gpio2_resources
,
138 static struct __initdata resource omap7xx_gpio3_resources
[] = {
140 .start
= OMAP7XX_GPIO3_BASE
,
141 .end
= OMAP7XX_GPIO3_BASE
+ SZ_2K
- 1,
142 .flags
= IORESOURCE_MEM
,
145 .start
= INT_7XX_GPIO_BANK3
,
146 .flags
= IORESOURCE_IRQ
,
150 static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config
= {
152 .regs
= &omap7xx_gpio_regs
,
155 static struct platform_device omap7xx_gpio3
= {
159 .platform_data
= &omap7xx_gpio3_config
,
161 .num_resources
= ARRAY_SIZE(omap7xx_gpio3_resources
),
162 .resource
= omap7xx_gpio3_resources
,
166 static struct __initdata resource omap7xx_gpio4_resources
[] = {
168 .start
= OMAP7XX_GPIO4_BASE
,
169 .end
= OMAP7XX_GPIO4_BASE
+ SZ_2K
- 1,
170 .flags
= IORESOURCE_MEM
,
173 .start
= INT_7XX_GPIO_BANK4
,
174 .flags
= IORESOURCE_IRQ
,
178 static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config
= {
180 .regs
= &omap7xx_gpio_regs
,
183 static struct platform_device omap7xx_gpio4
= {
187 .platform_data
= &omap7xx_gpio4_config
,
189 .num_resources
= ARRAY_SIZE(omap7xx_gpio4_resources
),
190 .resource
= omap7xx_gpio4_resources
,
194 static struct __initdata resource omap7xx_gpio5_resources
[] = {
196 .start
= OMAP7XX_GPIO5_BASE
,
197 .end
= OMAP7XX_GPIO5_BASE
+ SZ_2K
- 1,
198 .flags
= IORESOURCE_MEM
,
201 .start
= INT_7XX_GPIO_BANK5
,
202 .flags
= IORESOURCE_IRQ
,
206 static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config
= {
208 .regs
= &omap7xx_gpio_regs
,
211 static struct platform_device omap7xx_gpio5
= {
215 .platform_data
= &omap7xx_gpio5_config
,
217 .num_resources
= ARRAY_SIZE(omap7xx_gpio5_resources
),
218 .resource
= omap7xx_gpio5_resources
,
222 static struct __initdata resource omap7xx_gpio6_resources
[] = {
224 .start
= OMAP7XX_GPIO6_BASE
,
225 .end
= OMAP7XX_GPIO6_BASE
+ SZ_2K
- 1,
226 .flags
= IORESOURCE_MEM
,
229 .start
= INT_7XX_GPIO_BANK6
,
230 .flags
= IORESOURCE_IRQ
,
234 static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config
= {
236 .regs
= &omap7xx_gpio_regs
,
239 static struct platform_device omap7xx_gpio6
= {
243 .platform_data
= &omap7xx_gpio6_config
,
245 .num_resources
= ARRAY_SIZE(omap7xx_gpio6_resources
),
246 .resource
= omap7xx_gpio6_resources
,
249 static struct __initdata platform_device
* omap7xx_gpio_dev
[] = {
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.
264 static int __init
omap7xx_gpio_init(void)
268 if (!cpu_is_omap7xx())
271 for (i
= 0; i
< ARRAY_SIZE(omap7xx_gpio_dev
); i
++)
272 platform_device_register(omap7xx_gpio_dev
[i
]);
276 postcore_initcall(omap7xx_gpio_init
);