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 #include <mach/irqs.h>
26 #define OMAP7XX_GPIO1_BASE 0xfffbc000
27 #define OMAP7XX_GPIO2_BASE 0xfffbc800
28 #define OMAP7XX_GPIO3_BASE 0xfffbd000
29 #define OMAP7XX_GPIO4_BASE 0xfffbd800
30 #define OMAP7XX_GPIO5_BASE 0xfffbe000
31 #define OMAP7XX_GPIO6_BASE 0xfffbe800
32 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
35 static struct resource omap7xx_mpu_gpio_resources[] = {
37 .start = OMAP1_MPUIO_VBASE,
38 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
39 .flags = IORESOURCE_MEM,
42 .start = INT_7XX_MPUIO,
43 .flags = IORESOURCE_IRQ,
47 static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
48 .revision = USHRT_MAX,
49 .direction = OMAP_MPUIO_IO_CNTL / 2,
50 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
51 .dataout = OMAP_MPUIO_OUTPUT / 2,
52 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
53 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
54 .irqenable_inv = true,
55 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
58 static struct omap_gpio_platform_data omap7xx_mpu_gpio_config = {
62 .regs = &omap7xx_mpuio_regs,
65 static struct platform_device omap7xx_mpu_gpio = {
69 .platform_data = &omap7xx_mpu_gpio_config,
71 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
72 .resource = omap7xx_mpu_gpio_resources,
76 static struct resource omap7xx_gpio1_resources[] = {
78 .start = OMAP7XX_GPIO1_BASE,
79 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
80 .flags = IORESOURCE_MEM,
83 .start = INT_7XX_GPIO_BANK1,
84 .flags = IORESOURCE_IRQ,
88 static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
89 .revision = USHRT_MAX,
90 .direction = OMAP7XX_GPIO_DIR_CONTROL,
91 .datain = OMAP7XX_GPIO_DATA_INPUT,
92 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
93 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
94 .irqenable = OMAP7XX_GPIO_INT_MASK,
95 .irqenable_inv = true,
96 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
99 static struct omap_gpio_platform_data omap7xx_gpio1_config = {
101 .regs = &omap7xx_gpio_regs,
104 static struct platform_device omap7xx_gpio1 = {
108 .platform_data = &omap7xx_gpio1_config,
110 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
111 .resource = omap7xx_gpio1_resources,
115 static struct resource omap7xx_gpio2_resources[] = {
117 .start = OMAP7XX_GPIO2_BASE,
118 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
119 .flags = IORESOURCE_MEM,
122 .start = INT_7XX_GPIO_BANK2,
123 .flags = IORESOURCE_IRQ,
127 static struct omap_gpio_platform_data omap7xx_gpio2_config = {
129 .regs = &omap7xx_gpio_regs,
132 static struct platform_device omap7xx_gpio2 = {
136 .platform_data = &omap7xx_gpio2_config,
138 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
139 .resource = omap7xx_gpio2_resources,
143 static struct resource omap7xx_gpio3_resources[] = {
145 .start = OMAP7XX_GPIO3_BASE,
146 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
147 .flags = IORESOURCE_MEM,
150 .start = INT_7XX_GPIO_BANK3,
151 .flags = IORESOURCE_IRQ,
155 static struct omap_gpio_platform_data omap7xx_gpio3_config = {
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 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 omap_gpio_platform_data omap7xx_gpio4_config = {
185 .regs = &omap7xx_gpio_regs,
188 static struct platform_device omap7xx_gpio4 = {
192 .platform_data = &omap7xx_gpio4_config,
194 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
195 .resource = omap7xx_gpio4_resources,
199 static struct resource omap7xx_gpio5_resources[] = {
201 .start = OMAP7XX_GPIO5_BASE,
202 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
203 .flags = IORESOURCE_MEM,
206 .start = INT_7XX_GPIO_BANK5,
207 .flags = IORESOURCE_IRQ,
211 static struct omap_gpio_platform_data omap7xx_gpio5_config = {
213 .regs = &omap7xx_gpio_regs,
216 static struct platform_device omap7xx_gpio5 = {
220 .platform_data = &omap7xx_gpio5_config,
222 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
223 .resource = omap7xx_gpio5_resources,
227 static struct resource omap7xx_gpio6_resources[] = {
229 .start = OMAP7XX_GPIO6_BASE,
230 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
231 .flags = IORESOURCE_MEM,
234 .start = INT_7XX_GPIO_BANK6,
235 .flags = IORESOURCE_IRQ,
239 static struct omap_gpio_platform_data omap7xx_gpio6_config = {
241 .regs = &omap7xx_gpio_regs,
244 static struct platform_device omap7xx_gpio6 = {
248 .platform_data = &omap7xx_gpio6_config,
250 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
251 .resource = omap7xx_gpio6_resources,
254 static struct platform_device *omap7xx_gpio_dev[] __initdata = {
265 * omap7xx_gpio_init needs to be done before
266 * machine_init functions access gpio APIs.
267 * Hence omap7xx_gpio_init is a postcore_initcall.
269 static int __init omap7xx_gpio_init(void)
273 if (!cpu_is_omap7xx())
276 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
277 platform_device_register(omap7xx_gpio_dev[i]);
281 postcore_initcall(omap7xx_gpio_init);