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>
20 #include <linux/platform_data/gpio-omap.h>
22 #define OMAP7XX_GPIO1_BASE 0xfffbc000
23 #define OMAP7XX_GPIO2_BASE 0xfffbc800
24 #define OMAP7XX_GPIO3_BASE 0xfffbd000
25 #define OMAP7XX_GPIO4_BASE 0xfffbd800
26 #define OMAP7XX_GPIO5_BASE 0xfffbe000
27 #define OMAP7XX_GPIO6_BASE 0xfffbe800
28 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
31 static struct __initdata resource omap7xx_mpu_gpio_resources[] = {
33 .start = OMAP1_MPUIO_VBASE,
34 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
35 .flags = IORESOURCE_MEM,
38 .start = INT_7XX_MPUIO,
39 .flags = IORESOURCE_IRQ,
43 static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
44 .revision = USHRT_MAX,
45 .direction = OMAP_MPUIO_IO_CNTL / 2,
46 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
47 .dataout = OMAP_MPUIO_OUTPUT / 2,
48 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
49 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
50 .irqenable_inv = true,
51 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
54 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
58 .regs = &omap7xx_mpuio_regs,
61 static struct platform_device omap7xx_mpu_gpio = {
65 .platform_data = &omap7xx_mpu_gpio_config,
67 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
68 .resource = omap7xx_mpu_gpio_resources,
72 static struct __initdata resource omap7xx_gpio1_resources[] = {
74 .start = OMAP7XX_GPIO1_BASE,
75 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
76 .flags = IORESOURCE_MEM,
79 .start = INT_7XX_GPIO_BANK1,
80 .flags = IORESOURCE_IRQ,
84 static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
85 .revision = USHRT_MAX,
86 .direction = OMAP7XX_GPIO_DIR_CONTROL,
87 .datain = OMAP7XX_GPIO_DATA_INPUT,
88 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
89 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
90 .irqenable = OMAP7XX_GPIO_INT_MASK,
91 .irqenable_inv = true,
92 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
95 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
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 = {
125 .regs = &omap7xx_gpio_regs,
128 static struct platform_device omap7xx_gpio2 = {
132 .platform_data = &omap7xx_gpio2_config,
134 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
135 .resource = omap7xx_gpio2_resources,
139 static struct __initdata resource omap7xx_gpio3_resources[] = {
141 .start = OMAP7XX_GPIO3_BASE,
142 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
143 .flags = IORESOURCE_MEM,
146 .start = INT_7XX_GPIO_BANK3,
147 .flags = IORESOURCE_IRQ,
151 static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
153 .regs = &omap7xx_gpio_regs,
156 static struct platform_device omap7xx_gpio3 = {
160 .platform_data = &omap7xx_gpio3_config,
162 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
163 .resource = omap7xx_gpio3_resources,
167 static struct __initdata resource omap7xx_gpio4_resources[] = {
169 .start = OMAP7XX_GPIO4_BASE,
170 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
171 .flags = IORESOURCE_MEM,
174 .start = INT_7XX_GPIO_BANK4,
175 .flags = IORESOURCE_IRQ,
179 static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
181 .regs = &omap7xx_gpio_regs,
184 static struct platform_device omap7xx_gpio4 = {
188 .platform_data = &omap7xx_gpio4_config,
190 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
191 .resource = omap7xx_gpio4_resources,
195 static struct __initdata resource omap7xx_gpio5_resources[] = {
197 .start = OMAP7XX_GPIO5_BASE,
198 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
199 .flags = IORESOURCE_MEM,
202 .start = INT_7XX_GPIO_BANK5,
203 .flags = IORESOURCE_IRQ,
207 static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
209 .regs = &omap7xx_gpio_regs,
212 static struct platform_device omap7xx_gpio5 = {
216 .platform_data = &omap7xx_gpio5_config,
218 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
219 .resource = omap7xx_gpio5_resources,
223 static struct __initdata resource omap7xx_gpio6_resources[] = {
225 .start = OMAP7XX_GPIO6_BASE,
226 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
227 .flags = IORESOURCE_MEM,
230 .start = INT_7XX_GPIO_BANK6,
231 .flags = IORESOURCE_IRQ,
235 static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
237 .regs = &omap7xx_gpio_regs,
240 static struct platform_device omap7xx_gpio6 = {
244 .platform_data = &omap7xx_gpio6_config,
246 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
247 .resource = omap7xx_gpio6_resources,
250 static struct __initdata platform_device * omap7xx_gpio_dev[] = {
261 * omap7xx_gpio_init needs to be done before
262 * machine_init functions access gpio APIs.
263 * Hence omap7xx_gpio_init is a postcore_initcall.
265 static int __init omap7xx_gpio_init(void)
269 if (!cpu_is_omap7xx())
272 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
273 platform_device_register(omap7xx_gpio_dev[i]);
277 postcore_initcall(omap7xx_gpio_init);