diff options
Diffstat (limited to 'arch/arm/mach-omap1/gpio16xx.c')
-rw-r--r-- | arch/arm/mach-omap1/gpio16xx.c | 200 |
1 files changed, 200 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..5dd0d4c82b24 --- /dev/null +++ b/arch/arm/mach-omap1/gpio16xx.c | |||
@@ -0,0 +1,200 @@ | |||
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 */ | ||
28 | static 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 | |||
40 | static 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 | .bank_stride = 1, | ||
45 | }; | ||
46 | |||
47 | static struct __initdata platform_device omap16xx_mpu_gpio = { | ||
48 | .name = "omap_gpio", | ||
49 | .id = 0, | ||
50 | .dev = { | ||
51 | .platform_data = &omap16xx_mpu_gpio_config, | ||
52 | }, | ||
53 | .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources), | ||
54 | .resource = omap16xx_mpu_gpio_resources, | ||
55 | }; | ||
56 | |||
57 | /* gpio1 */ | ||
58 | static struct __initdata resource omap16xx_gpio1_resources[] = { | ||
59 | { | ||
60 | .start = OMAP1610_GPIO1_BASE, | ||
61 | .end = OMAP1610_GPIO1_BASE + SZ_2K - 1, | ||
62 | .flags = IORESOURCE_MEM, | ||
63 | }, | ||
64 | { | ||
65 | .start = INT_GPIO_BANK1, | ||
66 | .flags = IORESOURCE_IRQ, | ||
67 | }, | ||
68 | }; | ||
69 | |||
70 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { | ||
71 | .virtual_irq_start = IH_GPIO_BASE, | ||
72 | .bank_type = METHOD_GPIO_1610, | ||
73 | .bank_width = 16, | ||
74 | }; | ||
75 | |||
76 | static struct __initdata platform_device omap16xx_gpio1 = { | ||
77 | .name = "omap_gpio", | ||
78 | .id = 1, | ||
79 | .dev = { | ||
80 | .platform_data = &omap16xx_gpio1_config, | ||
81 | }, | ||
82 | .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources), | ||
83 | .resource = omap16xx_gpio1_resources, | ||
84 | }; | ||
85 | |||
86 | /* gpio2 */ | ||
87 | static struct __initdata resource omap16xx_gpio2_resources[] = { | ||
88 | { | ||
89 | .start = OMAP1610_GPIO2_BASE, | ||
90 | .end = OMAP1610_GPIO2_BASE + SZ_2K - 1, | ||
91 | .flags = IORESOURCE_MEM, | ||
92 | }, | ||
93 | { | ||
94 | .start = INT_1610_GPIO_BANK2, | ||
95 | .flags = IORESOURCE_IRQ, | ||
96 | }, | ||
97 | }; | ||
98 | |||
99 | static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { | ||
100 | .virtual_irq_start = IH_GPIO_BASE + 16, | ||
101 | .bank_type = METHOD_GPIO_1610, | ||
102 | .bank_width = 16, | ||
103 | }; | ||
104 | |||
105 | static struct __initdata platform_device omap16xx_gpio2 = { | ||
106 | .name = "omap_gpio", | ||
107 | .id = 2, | ||
108 | .dev = { | ||
109 | .platform_data = &omap16xx_gpio2_config, | ||
110 | }, | ||
111 | .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources), | ||
112 | .resource = omap16xx_gpio2_resources, | ||
113 | }; | ||
114 | |||
115 | /* gpio3 */ | ||
116 | static struct __initdata resource omap16xx_gpio3_resources[] = { | ||
117 | { | ||
118 | .start = OMAP1610_GPIO3_BASE, | ||
119 | .end = OMAP1610_GPIO3_BASE + SZ_2K - 1, | ||
120 | .flags = IORESOURCE_MEM, | ||
121 | }, | ||
122 | { | ||
123 | .start = INT_1610_GPIO_BANK3, | ||
124 | .flags = IORESOURCE_IRQ, | ||
125 | }, | ||
126 | }; | ||
127 | |||
128 | static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { | ||
129 | .virtual_irq_start = IH_GPIO_BASE + 32, | ||
130 | .bank_type = METHOD_GPIO_1610, | ||
131 | .bank_width = 16, | ||
132 | }; | ||
133 | |||
134 | static struct __initdata platform_device omap16xx_gpio3 = { | ||
135 | .name = "omap_gpio", | ||
136 | .id = 3, | ||
137 | .dev = { | ||
138 | .platform_data = &omap16xx_gpio3_config, | ||
139 | }, | ||
140 | .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources), | ||
141 | .resource = omap16xx_gpio3_resources, | ||
142 | }; | ||
143 | |||
144 | /* gpio4 */ | ||
145 | static struct __initdata resource omap16xx_gpio4_resources[] = { | ||
146 | { | ||
147 | .start = OMAP1610_GPIO4_BASE, | ||
148 | .end = OMAP1610_GPIO4_BASE + SZ_2K - 1, | ||
149 | .flags = IORESOURCE_MEM, | ||
150 | }, | ||
151 | { | ||
152 | .start = INT_1610_GPIO_BANK4, | ||
153 | .flags = IORESOURCE_IRQ, | ||
154 | }, | ||
155 | }; | ||
156 | |||
157 | static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { | ||
158 | .virtual_irq_start = IH_GPIO_BASE + 48, | ||
159 | .bank_type = METHOD_GPIO_1610, | ||
160 | .bank_width = 16, | ||
161 | }; | ||
162 | |||
163 | static struct __initdata platform_device omap16xx_gpio4 = { | ||
164 | .name = "omap_gpio", | ||
165 | .id = 4, | ||
166 | .dev = { | ||
167 | .platform_data = &omap16xx_gpio4_config, | ||
168 | }, | ||
169 | .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources), | ||
170 | .resource = omap16xx_gpio4_resources, | ||
171 | }; | ||
172 | |||
173 | static struct __initdata platform_device * omap16xx_gpio_dev[] = { | ||
174 | &omap16xx_mpu_gpio, | ||
175 | &omap16xx_gpio1, | ||
176 | &omap16xx_gpio2, | ||
177 | &omap16xx_gpio3, | ||
178 | &omap16xx_gpio4, | ||
179 | }; | ||
180 | |||
181 | /* | ||
182 | * omap16xx_gpio_init needs to be done before | ||
183 | * machine_init functions access gpio APIs. | ||
184 | * Hence omap16xx_gpio_init is a postcore_initcall. | ||
185 | */ | ||
186 | static int __init omap16xx_gpio_init(void) | ||
187 | { | ||
188 | int i; | ||
189 | |||
190 | if (!cpu_is_omap16xx()) | ||
191 | return -EINVAL; | ||
192 | |||
193 | for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) | ||
194 | platform_device_register(omap16xx_gpio_dev[i]); | ||
195 | |||
196 | gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev); | ||
197 | |||
198 | return 0; | ||
199 | } | ||
200 | postcore_initcall(omap16xx_gpio_init); | ||