2 * OMAP7xx specific gpio init
4 * Copyright (C) 2010 Texas Instruments Incorporated - https://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>
25 #define OMAP7XX_GPIO1_BASE 0xfffbc000
26 #define OMAP7XX_GPIO2_BASE 0xfffbc800
27 #define OMAP7XX_GPIO3_BASE 0xfffbd000
28 #define OMAP7XX_GPIO4_BASE 0xfffbd800
29 #define OMAP7XX_GPIO5_BASE 0xfffbe000
30 #define OMAP7XX_GPIO6_BASE 0xfffbe800
31 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
34 static struct resource omap7xx_mpu_gpio_resources[] = {
36 .start = OMAP1_MPUIO_VBASE,
37 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
38 .flags = IORESOURCE_MEM,
41 .start = INT_7XX_MPUIO,
42 .flags = IORESOURCE_IRQ,
46 static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
47 .revision = USHRT_MAX,
48 .direction = OMAP_MPUIO_IO_CNTL / 2,
49 .datain = OMAP_MPUIO_INPUT_LATCH / 2,
50 .dataout = OMAP_MPUIO_OUTPUT / 2,
51 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
52 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
53 .irqenable_inv = true,
54 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
57 static struct omap_gpio_platform_data omap7xx_mpu_gpio_config = {
61 .regs = &omap7xx_mpuio_regs,
64 static struct platform_device omap7xx_mpu_gpio = {
68 .platform_data = &omap7xx_mpu_gpio_config,
70 .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources),
71 .resource = omap7xx_mpu_gpio_resources,
75 static struct resource omap7xx_gpio1_resources[] = {
77 .start = OMAP7XX_GPIO1_BASE,
78 .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1,
79 .flags = IORESOURCE_MEM,
82 .start = INT_7XX_GPIO_BANK1,
83 .flags = IORESOURCE_IRQ,
87 static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
88 .revision = USHRT_MAX,
89 .direction = OMAP7XX_GPIO_DIR_CONTROL,
90 .datain = OMAP7XX_GPIO_DATA_INPUT,
91 .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
92 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
93 .irqenable = OMAP7XX_GPIO_INT_MASK,
94 .irqenable_inv = true,
95 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
98 static struct omap_gpio_platform_data omap7xx_gpio1_config = {
100 .regs = &omap7xx_gpio_regs,
103 static struct platform_device omap7xx_gpio1 = {
107 .platform_data = &omap7xx_gpio1_config,
109 .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources),
110 .resource = omap7xx_gpio1_resources,
114 static struct resource omap7xx_gpio2_resources[] = {
116 .start = OMAP7XX_GPIO2_BASE,
117 .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1,
118 .flags = IORESOURCE_MEM,
121 .start = INT_7XX_GPIO_BANK2,
122 .flags = IORESOURCE_IRQ,
126 static struct omap_gpio_platform_data omap7xx_gpio2_config = {
128 .regs = &omap7xx_gpio_regs,
131 static struct platform_device omap7xx_gpio2 = {
135 .platform_data = &omap7xx_gpio2_config,
137 .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources),
138 .resource = omap7xx_gpio2_resources,
142 static struct resource omap7xx_gpio3_resources[] = {
144 .start = OMAP7XX_GPIO3_BASE,
145 .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1,
146 .flags = IORESOURCE_MEM,
149 .start = INT_7XX_GPIO_BANK3,
150 .flags = IORESOURCE_IRQ,
154 static struct omap_gpio_platform_data omap7xx_gpio3_config = {
156 .regs = &omap7xx_gpio_regs,
159 static struct platform_device omap7xx_gpio3 = {
163 .platform_data = &omap7xx_gpio3_config,
165 .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources),
166 .resource = omap7xx_gpio3_resources,
170 static struct resource omap7xx_gpio4_resources[] = {
172 .start = OMAP7XX_GPIO4_BASE,
173 .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1,
174 .flags = IORESOURCE_MEM,
177 .start = INT_7XX_GPIO_BANK4,
178 .flags = IORESOURCE_IRQ,
182 static struct omap_gpio_platform_data omap7xx_gpio4_config = {
184 .regs = &omap7xx_gpio_regs,
187 static struct platform_device omap7xx_gpio4 = {
191 .platform_data = &omap7xx_gpio4_config,
193 .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources),
194 .resource = omap7xx_gpio4_resources,
198 static struct resource omap7xx_gpio5_resources[] = {
200 .start = OMAP7XX_GPIO5_BASE,
201 .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1,
202 .flags = IORESOURCE_MEM,
205 .start = INT_7XX_GPIO_BANK5,
206 .flags = IORESOURCE_IRQ,
210 static struct omap_gpio_platform_data omap7xx_gpio5_config = {
212 .regs = &omap7xx_gpio_regs,
215 static struct platform_device omap7xx_gpio5 = {
219 .platform_data = &omap7xx_gpio5_config,
221 .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources),
222 .resource = omap7xx_gpio5_resources,
226 static struct resource omap7xx_gpio6_resources[] = {
228 .start = OMAP7XX_GPIO6_BASE,
229 .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1,
230 .flags = IORESOURCE_MEM,
233 .start = INT_7XX_GPIO_BANK6,
234 .flags = IORESOURCE_IRQ,
238 static struct omap_gpio_platform_data omap7xx_gpio6_config = {
240 .regs = &omap7xx_gpio_regs,
243 static struct platform_device omap7xx_gpio6 = {
247 .platform_data = &omap7xx_gpio6_config,
249 .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources),
250 .resource = omap7xx_gpio6_resources,
253 static struct platform_device *omap7xx_gpio_dev[] __initdata = {
264 * omap7xx_gpio_init needs to be done before
265 * machine_init functions access gpio APIs.
266 * Hence omap7xx_gpio_init is a postcore_initcall.
268 static int __init omap7xx_gpio_init(void)
272 if (!cpu_is_omap7xx())
275 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
276 platform_device_register(omap7xx_gpio_dev[i]);
280 postcore_initcall(omap7xx_gpio_init);