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 __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
43 .virtual_irq_start = IH_MPUIO_BASE,
44 .bank_type = METHOD_MPUIO,
48 static struct __initdata platform_device omap7xx_mpu_gpio = {
52 .platform_data = &omap7xx_mpu_gpio_config,
54 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
55 .resource = omap7xx_mpu_gpio_resources,
59 static struct __initdata resource omap7xx_gpio1_resources[] = {
61 .start = OMAP7XX_GPIO1_BASE,
62 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
63 .flags = IORESOURCE_MEM,
66 .start = INT_7XX_GPIO_BANK1,
67 .flags = IORESOURCE_IRQ,
71 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
72 .virtual_irq_start = IH_GPIO_BASE,
73 .bank_type = METHOD_GPIO_7XX,
77 static struct __initdata platform_device omap7xx_gpio1 = {
81 .platform_data = &omap7xx_gpio1_config,
83 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
84 .resource = omap7xx_gpio1_resources,
88 static struct __initdata resource omap7xx_gpio2_resources[] = {
90 .start = OMAP7XX_GPIO2_BASE,
91 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
92 .flags = IORESOURCE_MEM,
95 .start = INT_7XX_GPIO_BANK2,
96 .flags = IORESOURCE_IRQ,
100 static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
101 .virtual_irq_start = IH_GPIO_BASE + 32,
102 .bank_type = METHOD_GPIO_7XX,
106 static struct __initdata platform_device omap7xx_gpio2 = {
110 .platform_data = &omap7xx_gpio2_config,
112 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
113 .resource = omap7xx_gpio2_resources,
117 static struct __initdata resource omap7xx_gpio3_resources[] = {
119 .start = OMAP7XX_GPIO3_BASE,
120 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
121 .flags = IORESOURCE_MEM,
124 .start = INT_7XX_GPIO_BANK3,
125 .flags = IORESOURCE_IRQ,
129 static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
130 .virtual_irq_start = IH_GPIO_BASE + 64,
131 .bank_type = METHOD_GPIO_7XX,
135 static struct __initdata platform_device omap7xx_gpio3 = {
139 .platform_data = &omap7xx_gpio3_config,
141 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
142 .resource = omap7xx_gpio3_resources,
146 static struct __initdata resource omap7xx_gpio4_resources[] = {
148 .start = OMAP7XX_GPIO4_BASE,
149 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
150 .flags = IORESOURCE_MEM,
153 .start = INT_7XX_GPIO_BANK4,
154 .flags = IORESOURCE_IRQ,
158 static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
159 .virtual_irq_start = IH_GPIO_BASE + 96,
160 .bank_type = METHOD_GPIO_7XX,
164 static struct __initdata platform_device omap7xx_gpio4 = {
168 .platform_data = &omap7xx_gpio4_config,
170 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
171 .resource = omap7xx_gpio4_resources,
175 static struct __initdata resource omap7xx_gpio5_resources[] = {
177 .start = OMAP7XX_GPIO5_BASE,
178 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
179 .flags = IORESOURCE_MEM,
182 .start = INT_7XX_GPIO_BANK5,
183 .flags = IORESOURCE_IRQ,
187 static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
188 .virtual_irq_start = IH_GPIO_BASE + 128,
189 .bank_type = METHOD_GPIO_7XX,
193 static struct __initdata platform_device omap7xx_gpio5 = {
197 .platform_data = &omap7xx_gpio5_config,
199 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
200 .resource = omap7xx_gpio5_resources,
204 static struct __initdata resource omap7xx_gpio6_resources[] = {
206 .start = OMAP7XX_GPIO6_BASE,
207 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
208 .flags = IORESOURCE_MEM,
211 .start = INT_7XX_GPIO_BANK6,
212 .flags = IORESOURCE_IRQ,
216 static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
217 .virtual_irq_start = IH_GPIO_BASE + 160,
218 .bank_type = METHOD_GPIO_7XX,
222 static struct __initdata platform_device omap7xx_gpio6 = {
226 .platform_data = &omap7xx_gpio6_config,
228 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
229 .resource = omap7xx_gpio6_resources,
232 static struct __initdata platform_device * omap7xx_gpio_dev[] = {
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.
247 static int __init omap7xx_gpio_init(void)
251 if (!cpu_is_omap7xx())
254 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
255 platform_device_register(omap7xx_gpio_dev[i]);
257 gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
261 postcore_initcall(omap7xx_gpio_init);