aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1/gpio16xx.c
diff options
context:
space:
mode:
authorVaradarajan, Charulatha <charu@ti.com>2010-12-07 19:26:56 -0500
committerTony Lindgren <tony@atomide.com>2010-12-07 19:26:56 -0500
commit87fe6229c75a2ca1ebfa1e9e937cba2535e961a8 (patch)
tree4d176905468337e940519ed3972dfb65ac1c7ab3 /arch/arm/mach-omap1/gpio16xx.c
parentc95d10bc49d50a9bc0f63a6eae79bb2707dabfdc (diff)
OMAP16xx: GPIO: Introduce support for GPIO init
Add support for handling OMAP16xx specific gpio_init by providing platform device data and doing device registration. Signed-off-by: Charulatha V <charu@ti.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap1/gpio16xx.c')
-rw-r--r--arch/arm/mach-omap1/gpio16xx.c199
1 files changed, 199 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
new file mode 100644
index 000000000000..8d4d0a061b56
--- /dev/null
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -0,0 +1,199 @@
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
40static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
41 .virtual_irq_start = IH_MPUIO_BASE,
42 .bank_type = METHOD_MPUIO,
43 .bank_width = 16,
44};
45
46static struct __initdata platform_device omap16xx_mpu_gpio = {
47 .name = "omap_gpio",
48 .id = 0,
49 .dev = {
50 .platform_data = &omap16xx_mpu_gpio_config,
51 },
52 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
53 .resource = omap16xx_mpu_gpio_resources,
54};
55
56/* gpio1 */
57static struct __initdata resource omap16xx_gpio1_resources[] = {
58 {
59 .start = OMAP1610_GPIO1_BASE,
60 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
61 .flags = IORESOURCE_MEM,
62 },
63 {
64 .start = INT_GPIO_BANK1,
65 .flags = IORESOURCE_IRQ,
66 },
67};
68
69static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
70 .virtual_irq_start = IH_GPIO_BASE,
71 .bank_type = METHOD_GPIO_1610,
72 .bank_width = 16,
73};
74
75static struct __initdata platform_device omap16xx_gpio1 = {
76 .name = "omap_gpio",
77 .id = 1,
78 .dev = {
79 .platform_data = &omap16xx_gpio1_config,
80 },
81 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
82 .resource = omap16xx_gpio1_resources,
83};
84
85/* gpio2 */
86static struct __initdata resource omap16xx_gpio2_resources[] = {
87 {
88 .start = OMAP1610_GPIO2_BASE,
89 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
90 .flags = IORESOURCE_MEM,
91 },
92 {
93 .start = INT_1610_GPIO_BANK2,
94 .flags = IORESOURCE_IRQ,
95 },
96};
97
98static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
99 .virtual_irq_start = IH_GPIO_BASE + 16,
100 .bank_type = METHOD_GPIO_1610,
101 .bank_width = 16,
102};
103
104static struct __initdata platform_device omap16xx_gpio2 = {
105 .name = "omap_gpio",
106 .id = 2,
107 .dev = {
108 .platform_data = &omap16xx_gpio2_config,
109 },
110 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
111 .resource = omap16xx_gpio2_resources,
112};
113
114/* gpio3 */
115static struct __initdata resource omap16xx_gpio3_resources[] = {
116 {
117 .start = OMAP1610_GPIO3_BASE,
118 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
119 .flags = IORESOURCE_MEM,
120 },
121 {
122 .start = INT_1610_GPIO_BANK3,
123 .flags = IORESOURCE_IRQ,
124 },
125};
126
127static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
128 .virtual_irq_start = IH_GPIO_BASE + 32,
129 .bank_type = METHOD_GPIO_1610,
130 .bank_width = 16,
131};
132
133static struct __initdata platform_device omap16xx_gpio3 = {
134 .name = "omap_gpio",
135 .id = 3,
136 .dev = {
137 .platform_data = &omap16xx_gpio3_config,
138 },
139 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
140 .resource = omap16xx_gpio3_resources,
141};
142
143/* gpio4 */
144static struct __initdata resource omap16xx_gpio4_resources[] = {
145 {
146 .start = OMAP1610_GPIO4_BASE,
147 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
148 .flags = IORESOURCE_MEM,
149 },
150 {
151 .start = INT_1610_GPIO_BANK4,
152 .flags = IORESOURCE_IRQ,
153 },
154};
155
156static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
157 .virtual_irq_start = IH_GPIO_BASE + 48,
158 .bank_type = METHOD_GPIO_1610,
159 .bank_width = 16,
160};
161
162static struct __initdata platform_device omap16xx_gpio4 = {
163 .name = "omap_gpio",
164 .id = 4,
165 .dev = {
166 .platform_data = &omap16xx_gpio4_config,
167 },
168 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
169 .resource = omap16xx_gpio4_resources,
170};
171
172static struct __initdata platform_device * omap16xx_gpio_dev[] = {
173 &omap16xx_mpu_gpio,
174 &omap16xx_gpio1,
175 &omap16xx_gpio2,
176 &omap16xx_gpio3,
177 &omap16xx_gpio4,
178};
179
180/*
181 * omap16xx_gpio_init needs to be done before
182 * machine_init functions access gpio APIs.
183 * Hence omap16xx_gpio_init is a postcore_initcall.
184 */
185static int __init omap16xx_gpio_init(void)
186{
187 int i;
188
189 if (!cpu_is_omap16xx())
190 return -EINVAL;
191
192 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
193 platform_device_register(omap16xx_gpio_dev[i]);
194
195 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
196
197 return 0;
198}
199postcore_initcall(omap16xx_gpio_init);