diff options
author | Jongpill Lee <boyko.lee@samsung.com> | 2010-10-14 02:52:16 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2010-10-25 03:06:33 -0400 |
commit | d2e7eca36dde5ee8979362bed5b27e47b37e94a0 (patch) | |
tree | b9e550b22c6d4bb17ea19e007055b8e3190a64b8 /arch/arm | |
parent | 37ea63b14bec667957ca3cfaa899c6e103fdb854 (diff) |
ARM: S5PV310: Add support GPIOlib
This patch adds GPIOlib support for S5PV310 and S5PC210.
Signed-off-by: Jongpill Lee <boyko.lee@samsung.com>
Signed-off-by: Sangbeom Kim <sbkim73@samsung.com>
[kgene.kim@samsung.com: Fix NR_IRQS]
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-s5pv310/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/gpiolib.c | 304 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/irqs.h | 13 |
3 files changed, 314 insertions, 5 deletions
diff --git a/arch/arm/mach-s5pv310/Makefile b/arch/arm/mach-s5pv310/Makefile index 425cdd6f9660..ac3b4c125558 100644 --- a/arch/arm/mach-s5pv310/Makefile +++ b/arch/arm/mach-s5pv310/Makefile | |||
@@ -13,7 +13,7 @@ obj- := | |||
13 | # Core support for S5PV310 system | 13 | # Core support for S5PV310 system |
14 | 14 | ||
15 | obj-$(CONFIG_CPU_S5PV310) += cpu.o init.o clock.o irq-combiner.o | 15 | obj-$(CONFIG_CPU_S5PV310) += cpu.o init.o clock.o irq-combiner.o |
16 | obj-$(CONFIG_CPU_S5PV310) += setup-i2c0.o time.o | 16 | obj-$(CONFIG_CPU_S5PV310) += setup-i2c0.o time.o gpiolib.o |
17 | 17 | ||
18 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o | 18 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o |
19 | obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o | 19 | obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o |
diff --git a/arch/arm/mach-s5pv310/gpiolib.c b/arch/arm/mach-s5pv310/gpiolib.c new file mode 100644 index 000000000000..55217b8923ec --- /dev/null +++ b/arch/arm/mach-s5pv310/gpiolib.c | |||
@@ -0,0 +1,304 @@ | |||
1 | /* linux/arch/arm/mach-s5pv310/gpiolib.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * S5PV310 - GPIOlib support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/irq.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/gpio.h> | ||
17 | |||
18 | #include <mach/map.h> | ||
19 | |||
20 | #include <plat/gpio-core.h> | ||
21 | #include <plat/gpio-cfg.h> | ||
22 | #include <plat/gpio-cfg-helpers.h> | ||
23 | |||
24 | static struct s3c_gpio_cfg gpio_cfg = { | ||
25 | .set_config = s3c_gpio_setcfg_s3c64xx_4bit, | ||
26 | .set_pull = s3c_gpio_setpull_updown, | ||
27 | .get_pull = s3c_gpio_getpull_updown, | ||
28 | }; | ||
29 | |||
30 | static struct s3c_gpio_cfg gpio_cfg_noint = { | ||
31 | .set_config = s3c_gpio_setcfg_s3c64xx_4bit, | ||
32 | .set_pull = s3c_gpio_setpull_updown, | ||
33 | .get_pull = s3c_gpio_getpull_updown, | ||
34 | }; | ||
35 | |||
36 | /* | ||
37 | * Following are the gpio banks in v310. | ||
38 | * | ||
39 | * The 'config' member when left to NULL, is initialized to the default | ||
40 | * structure gpio_cfg in the init function below. | ||
41 | * | ||
42 | * The 'base' member is also initialized in the init function below. | ||
43 | * Note: The initialization of 'base' member of s3c_gpio_chip structure | ||
44 | * uses the above macro and depends on the banks being listed in order here. | ||
45 | */ | ||
46 | static struct s3c_gpio_chip s5pv310_gpio_part1_4bit[] = { | ||
47 | { | ||
48 | .chip = { | ||
49 | .base = S5PV310_GPA0(0), | ||
50 | .ngpio = S5PV310_GPIO_A0_NR, | ||
51 | .label = "GPA0", | ||
52 | }, | ||
53 | }, { | ||
54 | .chip = { | ||
55 | .base = S5PV310_GPA1(0), | ||
56 | .ngpio = S5PV310_GPIO_A1_NR, | ||
57 | .label = "GPA1", | ||
58 | }, | ||
59 | }, { | ||
60 | .chip = { | ||
61 | .base = S5PV310_GPB(0), | ||
62 | .ngpio = S5PV310_GPIO_B_NR, | ||
63 | .label = "GPB", | ||
64 | }, | ||
65 | }, { | ||
66 | .chip = { | ||
67 | .base = S5PV310_GPC0(0), | ||
68 | .ngpio = S5PV310_GPIO_C0_NR, | ||
69 | .label = "GPC0", | ||
70 | }, | ||
71 | }, { | ||
72 | .chip = { | ||
73 | .base = S5PV310_GPC1(0), | ||
74 | .ngpio = S5PV310_GPIO_C1_NR, | ||
75 | .label = "GPC1", | ||
76 | }, | ||
77 | }, { | ||
78 | .chip = { | ||
79 | .base = S5PV310_GPD0(0), | ||
80 | .ngpio = S5PV310_GPIO_D0_NR, | ||
81 | .label = "GPD0", | ||
82 | }, | ||
83 | }, { | ||
84 | .chip = { | ||
85 | .base = S5PV310_GPD1(0), | ||
86 | .ngpio = S5PV310_GPIO_D1_NR, | ||
87 | .label = "GPD1", | ||
88 | }, | ||
89 | }, { | ||
90 | .chip = { | ||
91 | .base = S5PV310_GPE0(0), | ||
92 | .ngpio = S5PV310_GPIO_E0_NR, | ||
93 | .label = "GPE0", | ||
94 | }, | ||
95 | }, { | ||
96 | .chip = { | ||
97 | .base = S5PV310_GPE1(0), | ||
98 | .ngpio = S5PV310_GPIO_E1_NR, | ||
99 | .label = "GPE1", | ||
100 | }, | ||
101 | }, { | ||
102 | .chip = { | ||
103 | .base = S5PV310_GPE2(0), | ||
104 | .ngpio = S5PV310_GPIO_E2_NR, | ||
105 | .label = "GPE2", | ||
106 | }, | ||
107 | }, { | ||
108 | .chip = { | ||
109 | .base = S5PV310_GPE3(0), | ||
110 | .ngpio = S5PV310_GPIO_E3_NR, | ||
111 | .label = "GPE3", | ||
112 | }, | ||
113 | }, { | ||
114 | .chip = { | ||
115 | .base = S5PV310_GPE4(0), | ||
116 | .ngpio = S5PV310_GPIO_E4_NR, | ||
117 | .label = "GPE4", | ||
118 | }, | ||
119 | }, { | ||
120 | .chip = { | ||
121 | .base = S5PV310_GPF0(0), | ||
122 | .ngpio = S5PV310_GPIO_F0_NR, | ||
123 | .label = "GPF0", | ||
124 | }, | ||
125 | }, { | ||
126 | .chip = { | ||
127 | .base = S5PV310_GPF1(0), | ||
128 | .ngpio = S5PV310_GPIO_F1_NR, | ||
129 | .label = "GPF1", | ||
130 | }, | ||
131 | }, { | ||
132 | .chip = { | ||
133 | .base = S5PV310_GPF2(0), | ||
134 | .ngpio = S5PV310_GPIO_F2_NR, | ||
135 | .label = "GPF2", | ||
136 | }, | ||
137 | }, { | ||
138 | .chip = { | ||
139 | .base = S5PV310_GPF3(0), | ||
140 | .ngpio = S5PV310_GPIO_F3_NR, | ||
141 | .label = "GPF3", | ||
142 | }, | ||
143 | }, | ||
144 | }; | ||
145 | |||
146 | static struct s3c_gpio_chip s5pv310_gpio_part2_4bit[] = { | ||
147 | { | ||
148 | .chip = { | ||
149 | .base = S5PV310_GPJ0(0), | ||
150 | .ngpio = S5PV310_GPIO_J0_NR, | ||
151 | .label = "GPJ0", | ||
152 | }, | ||
153 | }, { | ||
154 | .chip = { | ||
155 | .base = S5PV310_GPJ1(0), | ||
156 | .ngpio = S5PV310_GPIO_J1_NR, | ||
157 | .label = "GPJ1", | ||
158 | }, | ||
159 | }, { | ||
160 | .chip = { | ||
161 | .base = S5PV310_GPK0(0), | ||
162 | .ngpio = S5PV310_GPIO_K0_NR, | ||
163 | .label = "GPK0", | ||
164 | }, | ||
165 | }, { | ||
166 | .chip = { | ||
167 | .base = S5PV310_GPK1(0), | ||
168 | .ngpio = S5PV310_GPIO_K1_NR, | ||
169 | .label = "GPK1", | ||
170 | }, | ||
171 | }, { | ||
172 | .chip = { | ||
173 | .base = S5PV310_GPK2(0), | ||
174 | .ngpio = S5PV310_GPIO_K2_NR, | ||
175 | .label = "GPK2", | ||
176 | }, | ||
177 | }, { | ||
178 | .chip = { | ||
179 | .base = S5PV310_GPK3(0), | ||
180 | .ngpio = S5PV310_GPIO_K3_NR, | ||
181 | .label = "GPK3", | ||
182 | }, | ||
183 | }, { | ||
184 | .chip = { | ||
185 | .base = S5PV310_GPL0(0), | ||
186 | .ngpio = S5PV310_GPIO_L0_NR, | ||
187 | .label = "GPL0", | ||
188 | }, | ||
189 | }, { | ||
190 | .chip = { | ||
191 | .base = S5PV310_GPL1(0), | ||
192 | .ngpio = S5PV310_GPIO_L1_NR, | ||
193 | .label = "GPL1", | ||
194 | }, | ||
195 | }, { | ||
196 | .chip = { | ||
197 | .base = S5PV310_GPL2(0), | ||
198 | .ngpio = S5PV310_GPIO_L2_NR, | ||
199 | .label = "GPL2", | ||
200 | }, | ||
201 | }, { | ||
202 | .base = (S5P_VA_GPIO2 + 0xC00), | ||
203 | .config = &gpio_cfg_noint, | ||
204 | .irq_base = IRQ_EINT(0), | ||
205 | .chip = { | ||
206 | .base = S5PV310_GPX0(0), | ||
207 | .ngpio = S5PV310_GPIO_X0_NR, | ||
208 | .label = "GPX0", | ||
209 | .to_irq = samsung_gpiolib_to_irq, | ||
210 | }, | ||
211 | }, { | ||
212 | .base = (S5P_VA_GPIO2 + 0xC20), | ||
213 | .config = &gpio_cfg_noint, | ||
214 | .irq_base = IRQ_EINT(8), | ||
215 | .chip = { | ||
216 | .base = S5PV310_GPX1(0), | ||
217 | .ngpio = S5PV310_GPIO_X1_NR, | ||
218 | .label = "GPX1", | ||
219 | .to_irq = samsung_gpiolib_to_irq, | ||
220 | }, | ||
221 | }, { | ||
222 | .base = (S5P_VA_GPIO2 + 0xC40), | ||
223 | .config = &gpio_cfg_noint, | ||
224 | .irq_base = IRQ_EINT(16), | ||
225 | .chip = { | ||
226 | .base = S5PV310_GPX2(0), | ||
227 | .ngpio = S5PV310_GPIO_X2_NR, | ||
228 | .label = "GPX2", | ||
229 | .to_irq = samsung_gpiolib_to_irq, | ||
230 | }, | ||
231 | }, { | ||
232 | .base = (S5P_VA_GPIO2 + 0xC60), | ||
233 | .config = &gpio_cfg_noint, | ||
234 | .irq_base = IRQ_EINT(24), | ||
235 | .chip = { | ||
236 | .base = S5PV310_GPX3(0), | ||
237 | .ngpio = S5PV310_GPIO_X3_NR, | ||
238 | .label = "GPX3", | ||
239 | .to_irq = samsung_gpiolib_to_irq, | ||
240 | }, | ||
241 | }, | ||
242 | }; | ||
243 | |||
244 | static struct s3c_gpio_chip s5pv310_gpio_part3_4bit[] = { | ||
245 | { | ||
246 | .chip = { | ||
247 | .base = S5PV310_GPZ(0), | ||
248 | .ngpio = S5PV310_GPIO_Z_NR, | ||
249 | .label = "GPZ", | ||
250 | }, | ||
251 | }, | ||
252 | }; | ||
253 | |||
254 | static __init int s5pv310_gpiolib_init(void) | ||
255 | { | ||
256 | struct s3c_gpio_chip *chip; | ||
257 | int i; | ||
258 | int nr_chips; | ||
259 | |||
260 | /* GPIO part 1 */ | ||
261 | |||
262 | chip = s5pv310_gpio_part1_4bit; | ||
263 | nr_chips = ARRAY_SIZE(s5pv310_gpio_part1_4bit); | ||
264 | |||
265 | for (i = 0; i < nr_chips; i++, chip++) { | ||
266 | if (chip->config == NULL) | ||
267 | chip->config = &gpio_cfg; | ||
268 | if (chip->base == NULL) | ||
269 | chip->base = S5P_VA_GPIO1 + (i) * 0x20; | ||
270 | } | ||
271 | |||
272 | samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part1_4bit, nr_chips); | ||
273 | |||
274 | /* GPIO part 2 */ | ||
275 | |||
276 | chip = s5pv310_gpio_part2_4bit; | ||
277 | nr_chips = ARRAY_SIZE(s5pv310_gpio_part2_4bit); | ||
278 | |||
279 | for (i = 0; i < nr_chips; i++, chip++) { | ||
280 | if (chip->config == NULL) | ||
281 | chip->config = &gpio_cfg; | ||
282 | if (chip->base == NULL) | ||
283 | chip->base = S5P_VA_GPIO2 + (i) * 0x20; | ||
284 | } | ||
285 | |||
286 | samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part2_4bit, nr_chips); | ||
287 | |||
288 | /* GPIO part 3 */ | ||
289 | |||
290 | chip = s5pv310_gpio_part3_4bit; | ||
291 | nr_chips = ARRAY_SIZE(s5pv310_gpio_part3_4bit); | ||
292 | |||
293 | for (i = 0; i < nr_chips; i++, chip++) { | ||
294 | if (chip->config == NULL) | ||
295 | chip->config = &gpio_cfg; | ||
296 | if (chip->base == NULL) | ||
297 | chip->base = S5P_VA_GPIO3 + (i) * 0x20; | ||
298 | } | ||
299 | |||
300 | samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part3_4bit, nr_chips); | ||
301 | |||
302 | return 0; | ||
303 | } | ||
304 | core_initcall(s5pv310_gpiolib_init); | ||
diff --git a/arch/arm/mach-s5pv310/include/mach/irqs.h b/arch/arm/mach-s5pv310/include/mach/irqs.h index f301af7127f7..fa7a8a3f463f 100644 --- a/arch/arm/mach-s5pv310/include/mach/irqs.h +++ b/arch/arm/mach-s5pv310/include/mach/irqs.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | 3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
4 | * http://www.samsung.com/ | 4 | * http://www.samsung.com/ |
5 | * | 5 | * |
6 | * S5PV210 - IRQ definitions | 6 | * S5PV310 - IRQ definitions |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as | 9 | * it under the terms of the GNU General Public License version 2 as |
@@ -85,10 +85,15 @@ | |||
85 | 85 | ||
86 | #define IRQ_ONENAND_AUDI COMBINER_IRQ(34, 0) | 86 | #define IRQ_ONENAND_AUDI COMBINER_IRQ(34, 0) |
87 | 87 | ||
88 | /* Set the default NR_IRQS */ | 88 | #define MAX_COMBINER_NR 40 |
89 | 89 | ||
90 | #define NR_IRQS COMBINER_IRQ(MAX_COMBINER_NR, 0) | 90 | #define S5P_IRQ_EINT_BASE COMBINER_IRQ(MAX_COMBINER_NR, 0) |
91 | 91 | ||
92 | #define MAX_COMBINER_NR 40 | 92 | #define S5P_EINT_BASE1 (S5P_IRQ_EINT_BASE + 0) |
93 | #define S5P_EINT_BASE2 (S5P_IRQ_EINT_BASE + 16) | ||
94 | |||
95 | /* Set the default NR_IRQS */ | ||
96 | |||
97 | #define NR_IRQS (S5P_IRQ_EINT_BASE + 32) | ||
93 | 98 | ||
94 | #endif /* __ASM_ARCH_IRQS_H */ | 99 | #endif /* __ASM_ARCH_IRQS_H */ |