gpio/omap: consolidate IRQ status handling, remove #ifdefs
[deliverable/linux.git] / arch / arm / mach-omap1 / gpio16xx.c
CommitLineData
87fe6229
VC
1/*
2 * OMAP16xx specific gpio init
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
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.
12 *
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.
17 */
18
19#include <linux/gpio.h>
20
21#define OMAP1610_GPIO1_BASE 0xfffbe400
22#define OMAP1610_GPIO2_BASE 0xfffbec00
23#define OMAP1610_GPIO3_BASE 0xfffbb400
24#define OMAP1610_GPIO4_BASE 0xfffbbc00
25#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
26
27/* mpu gpio */
28static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
29 {
30 .start = OMAP1_MPUIO_VBASE,
31 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
32 .flags = IORESOURCE_MEM,
33 },
34 {
35 .start = INT_MPUIO,
36 .flags = IORESOURCE_IRQ,
37 },
38};
39
fa87931a
KH
40static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
41 .direction = OMAP_MPUIO_IO_CNTL,
42 .datain = OMAP_MPUIO_INPUT_LATCH,
43 .dataout = OMAP_MPUIO_OUTPUT,
eef4bec7 44 .irqstatus = OMAP_MPUIO_GPIO_INT,
fa87931a
KH
45};
46
87fe6229
VC
47static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
48 .virtual_irq_start = IH_MPUIO_BASE,
49 .bank_type = METHOD_MPUIO,
50 .bank_width = 16,
5de62b86 51 .bank_stride = 1,
fa87931a 52 .regs = &omap16xx_mpuio_regs,
87fe6229
VC
53};
54
55static struct __initdata platform_device omap16xx_mpu_gpio = {
56 .name = "omap_gpio",
57 .id = 0,
58 .dev = {
59 .platform_data = &omap16xx_mpu_gpio_config,
60 },
61 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
62 .resource = omap16xx_mpu_gpio_resources,
63};
64
65/* gpio1 */
66static struct __initdata resource omap16xx_gpio1_resources[] = {
67 {
68 .start = OMAP1610_GPIO1_BASE,
69 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
70 .flags = IORESOURCE_MEM,
71 },
72 {
73 .start = INT_GPIO_BANK1,
74 .flags = IORESOURCE_IRQ,
75 },
76};
77
fa87931a
KH
78static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
79 .direction = OMAP1610_GPIO_DIRECTION,
80 .set_dataout = OMAP1610_GPIO_SET_DATAOUT,
81 .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
82 .datain = OMAP1610_GPIO_DATAIN,
83 .dataout = OMAP1610_GPIO_DATAOUT,
eef4bec7 84 .irqstatus = OMAP1610_GPIO_IRQSTATUS1,
fa87931a
KH
85};
86
87fe6229
VC
87static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
88 .virtual_irq_start = IH_GPIO_BASE,
89 .bank_type = METHOD_GPIO_1610,
90 .bank_width = 16,
fa87931a 91 .regs = &omap16xx_gpio_regs,
87fe6229
VC
92};
93
94static struct __initdata platform_device omap16xx_gpio1 = {
95 .name = "omap_gpio",
96 .id = 1,
97 .dev = {
98 .platform_data = &omap16xx_gpio1_config,
99 },
100 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
101 .resource = omap16xx_gpio1_resources,
102};
103
104/* gpio2 */
105static struct __initdata resource omap16xx_gpio2_resources[] = {
106 {
107 .start = OMAP1610_GPIO2_BASE,
108 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
109 .flags = IORESOURCE_MEM,
110 },
111 {
112 .start = INT_1610_GPIO_BANK2,
113 .flags = IORESOURCE_IRQ,
114 },
115};
116
117static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
118 .virtual_irq_start = IH_GPIO_BASE + 16,
119 .bank_type = METHOD_GPIO_1610,
120 .bank_width = 16,
fa87931a 121 .regs = &omap16xx_gpio_regs,
87fe6229
VC
122};
123
124static struct __initdata platform_device omap16xx_gpio2 = {
125 .name = "omap_gpio",
126 .id = 2,
127 .dev = {
128 .platform_data = &omap16xx_gpio2_config,
129 },
130 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
131 .resource = omap16xx_gpio2_resources,
132};
133
134/* gpio3 */
135static struct __initdata resource omap16xx_gpio3_resources[] = {
136 {
137 .start = OMAP1610_GPIO3_BASE,
138 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
139 .flags = IORESOURCE_MEM,
140 },
141 {
142 .start = INT_1610_GPIO_BANK3,
143 .flags = IORESOURCE_IRQ,
144 },
145};
146
147static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
148 .virtual_irq_start = IH_GPIO_BASE + 32,
149 .bank_type = METHOD_GPIO_1610,
150 .bank_width = 16,
fa87931a 151 .regs = &omap16xx_gpio_regs,
87fe6229
VC
152};
153
154static struct __initdata platform_device omap16xx_gpio3 = {
155 .name = "omap_gpio",
156 .id = 3,
157 .dev = {
158 .platform_data = &omap16xx_gpio3_config,
159 },
160 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
161 .resource = omap16xx_gpio3_resources,
162};
163
164/* gpio4 */
165static struct __initdata resource omap16xx_gpio4_resources[] = {
166 {
167 .start = OMAP1610_GPIO4_BASE,
168 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .start = INT_1610_GPIO_BANK4,
173 .flags = IORESOURCE_IRQ,
174 },
175};
176
177static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
178 .virtual_irq_start = IH_GPIO_BASE + 48,
179 .bank_type = METHOD_GPIO_1610,
180 .bank_width = 16,
fa87931a 181 .regs = &omap16xx_gpio_regs,
87fe6229
VC
182};
183
184static struct __initdata platform_device omap16xx_gpio4 = {
185 .name = "omap_gpio",
186 .id = 4,
187 .dev = {
188 .platform_data = &omap16xx_gpio4_config,
189 },
190 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
191 .resource = omap16xx_gpio4_resources,
192};
193
194static struct __initdata platform_device * omap16xx_gpio_dev[] = {
195 &omap16xx_mpu_gpio,
196 &omap16xx_gpio1,
197 &omap16xx_gpio2,
198 &omap16xx_gpio3,
199 &omap16xx_gpio4,
200};
201
202/*
203 * omap16xx_gpio_init needs to be done before
204 * machine_init functions access gpio APIs.
205 * Hence omap16xx_gpio_init is a postcore_initcall.
206 */
207static int __init omap16xx_gpio_init(void)
208{
209 int i;
210
211 if (!cpu_is_omap16xx())
212 return -EINVAL;
213
214 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
215 platform_device_register(omap16xx_gpio_dev[i]);
216
217 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
218
219 return 0;
220}
221postcore_initcall(omap16xx_gpio_init);
This page took 0.070589 seconds and 5 git commands to generate.