aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s5pc1xx
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2010-05-18 06:38:41 -0400
committerBen Dooks <ben-linux@fluff.org>2010-05-19 05:23:11 -0400
commit7904449021de399a03ec8a32e536d031a61def5b (patch)
tree610c804c4bd185147e5507f28de5b458121ea015 /arch/arm/plat-s5pc1xx
parent252b8efeba9cd1e28ade902275b27133114d2382 (diff)
ARM: S5PC100: Move gpio support from plat-s5pc1xx to mach-s5pc100
Move gpio-lib support from plat-s5pc1xx to mach-s5pc100. Only basic gpio functionality is now supported. Gpio interrupts are disabled temporarly and will be added later. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s5pc1xx')
-rw-r--r--arch/arm/plat-s5pc1xx/Makefile3
-rw-r--r--arch/arm/plat-s5pc1xx/gpiolib.c425
-rw-r--r--arch/arm/plat-s5pc1xx/include/plat/regs-gpio.h70
3 files changed, 1 insertions, 497 deletions
diff --git a/arch/arm/plat-s5pc1xx/Makefile b/arch/arm/plat-s5pc1xx/Makefile
index 66a8f3eb7071..540fca5b4860 100644
--- a/arch/arm/plat-s5pc1xx/Makefile
+++ b/arch/arm/plat-s5pc1xx/Makefile
@@ -13,9 +13,8 @@ obj- :=
13 13
14obj-y += dev-uart.o 14obj-y += dev-uart.o
15obj-y += cpu.o 15obj-y += cpu.o
16obj-y += irq.o irq-gpio.o irq-eint.o 16obj-y += irq.o
17obj-y += clock.o 17obj-y += clock.o
18obj-y += gpiolib.o
19 18
20# CPU support 19# CPU support
21 20
diff --git a/arch/arm/plat-s5pc1xx/gpiolib.c b/arch/arm/plat-s5pc1xx/gpiolib.c
deleted file mode 100644
index 5a97a8f8e368..000000000000
--- a/arch/arm/plat-s5pc1xx/gpiolib.c
+++ /dev/null
@@ -1,425 +0,0 @@
1/*
2 * arch/arm/plat-s5pc1xx/gpiolib.c
3 *
4 * Copyright 2009 Samsung Electronics Co
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 *
7 * S5PC1XX - GPIOlib support
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
15#include <linux/irq.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18
19#include <mach/map.h>
20
21#include <plat/gpio-core.h>
22#include <plat/gpio-cfg.h>
23#include <plat/gpio-cfg-helpers.h>
24#include <plat/regs-gpio.h>
25
26/* S5PC100 GPIO bank summary:
27 *
28 * Bank GPIOs Style INT Type
29 * A0 8 4Bit GPIO_INT0
30 * A1 5 4Bit GPIO_INT1
31 * B 8 4Bit GPIO_INT2
32 * C 5 4Bit GPIO_INT3
33 * D 7 4Bit GPIO_INT4
34 * E0 8 4Bit GPIO_INT5
35 * E1 6 4Bit GPIO_INT6
36 * F0 8 4Bit GPIO_INT7
37 * F1 8 4Bit GPIO_INT8
38 * F2 8 4Bit GPIO_INT9
39 * F3 4 4Bit GPIO_INT10
40 * G0 8 4Bit GPIO_INT11
41 * G1 3 4Bit GPIO_INT12
42 * G2 7 4Bit GPIO_INT13
43 * G3 7 4Bit GPIO_INT14
44 * H0 8 4Bit WKUP_INT
45 * H1 8 4Bit WKUP_INT
46 * H2 8 4Bit WKUP_INT
47 * H3 8 4Bit WKUP_INT
48 * I 8 4Bit GPIO_INT15
49 * J0 8 4Bit GPIO_INT16
50 * J1 5 4Bit GPIO_INT17
51 * J2 8 4Bit GPIO_INT18
52 * J3 8 4Bit GPIO_INT19
53 * J4 4 4Bit GPIO_INT20
54 * K0 8 4Bit None
55 * K1 6 4Bit None
56 * K2 8 4Bit None
57 * K3 8 4Bit None
58 * L0 8 4Bit None
59 * L1 8 4Bit None
60 * L2 8 4Bit None
61 * L3 8 4Bit None
62 */
63
64static int s5pc1xx_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
65{
66 return S3C_IRQ_GPIO(chip->base + offset);
67}
68
69static int s5pc1xx_gpiolib_to_eint(struct gpio_chip *chip, unsigned int offset)
70{
71 int base;
72
73 base = chip->base - S5PC100_GPH0(0);
74 if (base == 0)
75 return IRQ_EINT(offset);
76 base = chip->base - S5PC100_GPH1(0);
77 if (base == 0)
78 return IRQ_EINT(8 + offset);
79 base = chip->base - S5PC100_GPH2(0);
80 if (base == 0)
81 return IRQ_EINT(16 + offset);
82 base = chip->base - S5PC100_GPH3(0);
83 if (base == 0)
84 return IRQ_EINT(24 + offset);
85 return -EINVAL;
86}
87
88static struct s3c_gpio_cfg gpio_cfg = {
89 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
90 .set_pull = s3c_gpio_setpull_updown,
91 .get_pull = s3c_gpio_getpull_updown,
92};
93
94static struct s3c_gpio_cfg gpio_cfg_eint = {
95 .cfg_eint = 0xf,
96 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
97 .set_pull = s3c_gpio_setpull_updown,
98 .get_pull = s3c_gpio_getpull_updown,
99};
100
101static struct s3c_gpio_cfg gpio_cfg_noint = {
102 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
103 .set_pull = s3c_gpio_setpull_updown,
104 .get_pull = s3c_gpio_getpull_updown,
105};
106
107static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
108 {
109 .base = S5PC100_GPA0_BASE,
110 .config = &gpio_cfg,
111 .chip = {
112 .base = S5PC100_GPA0(0),
113 .ngpio = S5PC100_GPIO_A0_NR,
114 .label = "GPA0",
115 },
116 }, {
117 .base = S5PC100_GPA1_BASE,
118 .config = &gpio_cfg,
119 .chip = {
120 .base = S5PC100_GPA1(0),
121 .ngpio = S5PC100_GPIO_A1_NR,
122 .label = "GPA1",
123 },
124 }, {
125 .base = S5PC100_GPB_BASE,
126 .config = &gpio_cfg,
127 .chip = {
128 .base = S5PC100_GPB(0),
129 .ngpio = S5PC100_GPIO_B_NR,
130 .label = "GPB",
131 },
132 }, {
133 .base = S5PC100_GPC_BASE,
134 .config = &gpio_cfg,
135 .chip = {
136 .base = S5PC100_GPC(0),
137 .ngpio = S5PC100_GPIO_C_NR,
138 .label = "GPC",
139 },
140 }, {
141 .base = S5PC100_GPD_BASE,
142 .config = &gpio_cfg,
143 .chip = {
144 .base = S5PC100_GPD(0),
145 .ngpio = S5PC100_GPIO_D_NR,
146 .label = "GPD",
147 },
148 }, {
149 .base = S5PC100_GPE0_BASE,
150 .config = &gpio_cfg,
151 .chip = {
152 .base = S5PC100_GPE0(0),
153 .ngpio = S5PC100_GPIO_E0_NR,
154 .label = "GPE0",
155 },
156 }, {
157 .base = S5PC100_GPE1_BASE,
158 .config = &gpio_cfg,
159 .chip = {
160 .base = S5PC100_GPE1(0),
161 .ngpio = S5PC100_GPIO_E1_NR,
162 .label = "GPE1",
163 },
164 }, {
165 .base = S5PC100_GPF0_BASE,
166 .config = &gpio_cfg,
167 .chip = {
168 .base = S5PC100_GPF0(0),
169 .ngpio = S5PC100_GPIO_F0_NR,
170 .label = "GPF0",
171 },
172 }, {
173 .base = S5PC100_GPF1_BASE,
174 .config = &gpio_cfg,
175 .chip = {
176 .base = S5PC100_GPF1(0),
177 .ngpio = S5PC100_GPIO_F1_NR,
178 .label = "GPF1",
179 },
180 }, {
181 .base = S5PC100_GPF2_BASE,
182 .config = &gpio_cfg,
183 .chip = {
184 .base = S5PC100_GPF2(0),
185 .ngpio = S5PC100_GPIO_F2_NR,
186 .label = "GPF2",
187 },
188 }, {
189 .base = S5PC100_GPF3_BASE,
190 .config = &gpio_cfg,
191 .chip = {
192 .base = S5PC100_GPF3(0),
193 .ngpio = S5PC100_GPIO_F3_NR,
194 .label = "GPF3",
195 },
196 }, {
197 .base = S5PC100_GPG0_BASE,
198 .config = &gpio_cfg,
199 .chip = {
200 .base = S5PC100_GPG0(0),
201 .ngpio = S5PC100_GPIO_G0_NR,
202 .label = "GPG0",
203 },
204 }, {
205 .base = S5PC100_GPG1_BASE,
206 .config = &gpio_cfg,
207 .chip = {
208 .base = S5PC100_GPG1(0),
209 .ngpio = S5PC100_GPIO_G1_NR,
210 .label = "GPG1",
211 },
212 }, {
213 .base = S5PC100_GPG2_BASE,
214 .config = &gpio_cfg,
215 .chip = {
216 .base = S5PC100_GPG2(0),
217 .ngpio = S5PC100_GPIO_G2_NR,
218 .label = "GPG2",
219 },
220 }, {
221 .base = S5PC100_GPG3_BASE,
222 .config = &gpio_cfg,
223 .chip = {
224 .base = S5PC100_GPG3(0),
225 .ngpio = S5PC100_GPIO_G3_NR,
226 .label = "GPG3",
227 },
228 }, {
229 .base = S5PC100_GPH0_BASE,
230 .config = &gpio_cfg_eint,
231 .chip = {
232 .base = S5PC100_GPH0(0),
233 .ngpio = S5PC100_GPIO_H0_NR,
234 .label = "GPH0",
235 },
236 }, {
237 .base = S5PC100_GPH1_BASE,
238 .config = &gpio_cfg_eint,
239 .chip = {
240 .base = S5PC100_GPH1(0),
241 .ngpio = S5PC100_GPIO_H1_NR,
242 .label = "GPH1",
243 },
244 }, {
245 .base = S5PC100_GPH2_BASE,
246 .config = &gpio_cfg_eint,
247 .chip = {
248 .base = S5PC100_GPH2(0),
249 .ngpio = S5PC100_GPIO_H2_NR,
250 .label = "GPH2",
251 },
252 }, {
253 .base = S5PC100_GPH3_BASE,
254 .config = &gpio_cfg_eint,
255 .chip = {
256 .base = S5PC100_GPH3(0),
257 .ngpio = S5PC100_GPIO_H3_NR,
258 .label = "GPH3",
259 },
260 }, {
261 .base = S5PC100_GPI_BASE,
262 .config = &gpio_cfg,
263 .chip = {
264 .base = S5PC100_GPI(0),
265 .ngpio = S5PC100_GPIO_I_NR,
266 .label = "GPI",
267 },
268 }, {
269 .base = S5PC100_GPJ0_BASE,
270 .config = &gpio_cfg,
271 .chip = {
272 .base = S5PC100_GPJ0(0),
273 .ngpio = S5PC100_GPIO_J0_NR,
274 .label = "GPJ0",
275 },
276 }, {
277 .base = S5PC100_GPJ1_BASE,
278 .config = &gpio_cfg,
279 .chip = {
280 .base = S5PC100_GPJ1(0),
281 .ngpio = S5PC100_GPIO_J1_NR,
282 .label = "GPJ1",
283 },
284 }, {
285 .base = S5PC100_GPJ2_BASE,
286 .config = &gpio_cfg,
287 .chip = {
288 .base = S5PC100_GPJ2(0),
289 .ngpio = S5PC100_GPIO_J2_NR,
290 .label = "GPJ2",
291 },
292 }, {
293 .base = S5PC100_GPJ3_BASE,
294 .config = &gpio_cfg,
295 .chip = {
296 .base = S5PC100_GPJ3(0),
297 .ngpio = S5PC100_GPIO_J3_NR,
298 .label = "GPJ3",
299 },
300 }, {
301 .base = S5PC100_GPJ4_BASE,
302 .config = &gpio_cfg,
303 .chip = {
304 .base = S5PC100_GPJ4(0),
305 .ngpio = S5PC100_GPIO_J4_NR,
306 .label = "GPJ4",
307 },
308 }, {
309 .base = S5PC100_GPK0_BASE,
310 .config = &gpio_cfg_noint,
311 .chip = {
312 .base = S5PC100_GPK0(0),
313 .ngpio = S5PC100_GPIO_K0_NR,
314 .label = "GPK0",
315 },
316 }, {
317 .base = S5PC100_GPK1_BASE,
318 .config = &gpio_cfg_noint,
319 .chip = {
320 .base = S5PC100_GPK1(0),
321 .ngpio = S5PC100_GPIO_K1_NR,
322 .label = "GPK1",
323 },
324 }, {
325 .base = S5PC100_GPK2_BASE,
326 .config = &gpio_cfg_noint,
327 .chip = {
328 .base = S5PC100_GPK2(0),
329 .ngpio = S5PC100_GPIO_K2_NR,
330 .label = "GPK2",
331 },
332 }, {
333 .base = S5PC100_GPK3_BASE,
334 .config = &gpio_cfg_noint,
335 .chip = {
336 .base = S5PC100_GPK3(0),
337 .ngpio = S5PC100_GPIO_K3_NR,
338 .label = "GPK3",
339 },
340 }, {
341 .base = S5PC100_GPL0_BASE,
342 .config = &gpio_cfg_noint,
343 .chip = {
344 .base = S5PC100_GPL0(0),
345 .ngpio = S5PC100_GPIO_L0_NR,
346 .label = "GPL0",
347 },
348 }, {
349 .base = S5PC100_GPL1_BASE,
350 .config = &gpio_cfg_noint,
351 .chip = {
352 .base = S5PC100_GPL1(0),
353 .ngpio = S5PC100_GPIO_L1_NR,
354 .label = "GPL1",
355 },
356 }, {
357 .base = S5PC100_GPL2_BASE,
358 .config = &gpio_cfg_noint,
359 .chip = {
360 .base = S5PC100_GPL2(0),
361 .ngpio = S5PC100_GPIO_L2_NR,
362 .label = "GPL2",
363 },
364 }, {
365 .base = S5PC100_GPL3_BASE,
366 .config = &gpio_cfg_noint,
367 .chip = {
368 .base = S5PC100_GPL3(0),
369 .ngpio = S5PC100_GPIO_L3_NR,
370 .label = "GPL3",
371 },
372 }, {
373 .base = S5PC100_GPL4_BASE,
374 .config = &gpio_cfg_noint,
375 .chip = {
376 .base = S5PC100_GPL4(0),
377 .ngpio = S5PC100_GPIO_L4_NR,
378 .label = "GPL4",
379 },
380 },
381};
382
383/* FIXME move from irq-gpio.c */
384extern struct irq_chip s5pc1xx_gpioint;
385extern void s5pc1xx_irq_gpioint_handler(unsigned int irq, struct irq_desc *desc);
386
387static __init void s5pc100_gpiolib_link(struct s3c_gpio_chip *chip)
388{
389
390 /* Interrupt */
391 if (chip->config == &gpio_cfg) {
392 int i, irq;
393
394 chip->chip.to_irq = s5pc1xx_gpiolib_to_irq;
395
396 for (i = 0; i < chip->chip.ngpio; i++) {
397 irq = S3C_IRQ_GPIO_BASE + chip->chip.base + i;
398 set_irq_chip(irq, &s5pc1xx_gpioint);
399 set_irq_data(irq, &chip->chip);
400 set_irq_handler(irq, handle_level_irq);
401 set_irq_flags(irq, IRQF_VALID);
402 }
403 } else if (chip->config == &gpio_cfg_eint)
404 chip->chip.to_irq = s5pc1xx_gpiolib_to_eint;
405}
406
407static __init int s5pc1xx_gpiolib_init(void)
408{
409 struct s3c_gpio_chip *chip;
410 int nr_chips;
411
412 chip = s5pc100_gpio_chips;
413 nr_chips = ARRAY_SIZE(s5pc100_gpio_chips);
414
415 for (; nr_chips > 0; nr_chips--, chip++)
416 s5pc100_gpiolib_link(chip);
417
418 samsung_gpiolib_add_4bit_chips(s5pc100_gpio_chips,
419 ARRAY_SIZE(s5pc100_gpio_chips));
420 /* Interrupt */
421 set_irq_chained_handler(IRQ_GPIOINT, s5pc1xx_irq_gpioint_handler);
422
423 return 0;
424}
425core_initcall(s5pc1xx_gpiolib_init);
diff --git a/arch/arm/plat-s5pc1xx/include/plat/regs-gpio.h b/arch/arm/plat-s5pc1xx/include/plat/regs-gpio.h
deleted file mode 100644
index 43c7bc8bf784..000000000000
--- a/arch/arm/plat-s5pc1xx/include/plat/regs-gpio.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/* linux/arch/arm/plat-s5pc1xx/include/plat/regs-gpio.h
2 *
3 * Copyright 2009 Samsung Electronics Co.
4 * Byungho Min <bhmin@samsung.com>
5 *
6 * S5PC1XX - GPIO register definitions
7 */
8
9#ifndef __ASM_PLAT_S5PC1XX_REGS_GPIO_H
10#define __ASM_PLAT_S5PC1XX_REGS_GPIO_H __FILE__
11
12#include <mach/map.h>
13
14/* S5PC100 */
15#define S5PC100_GPIO_BASE S5PC1XX_VA_GPIO
16#define S5PC100_GPA0_BASE (S5PC100_GPIO_BASE + 0x0000)
17#define S5PC100_GPA1_BASE (S5PC100_GPIO_BASE + 0x0020)
18#define S5PC100_GPB_BASE (S5PC100_GPIO_BASE + 0x0040)
19#define S5PC100_GPC_BASE (S5PC100_GPIO_BASE + 0x0060)
20#define S5PC100_GPD_BASE (S5PC100_GPIO_BASE + 0x0080)
21#define S5PC100_GPE0_BASE (S5PC100_GPIO_BASE + 0x00A0)
22#define S5PC100_GPE1_BASE (S5PC100_GPIO_BASE + 0x00C0)
23#define S5PC100_GPF0_BASE (S5PC100_GPIO_BASE + 0x00E0)
24#define S5PC100_GPF1_BASE (S5PC100_GPIO_BASE + 0x0100)
25#define S5PC100_GPF2_BASE (S5PC100_GPIO_BASE + 0x0120)
26#define S5PC100_GPF3_BASE (S5PC100_GPIO_BASE + 0x0140)
27#define S5PC100_GPG0_BASE (S5PC100_GPIO_BASE + 0x0160)
28#define S5PC100_GPG1_BASE (S5PC100_GPIO_BASE + 0x0180)
29#define S5PC100_GPG2_BASE (S5PC100_GPIO_BASE + 0x01A0)
30#define S5PC100_GPG3_BASE (S5PC100_GPIO_BASE + 0x01C0)
31#define S5PC100_GPH0_BASE (S5PC100_GPIO_BASE + 0x0C00)
32#define S5PC100_GPH1_BASE (S5PC100_GPIO_BASE + 0x0C20)
33#define S5PC100_GPH2_BASE (S5PC100_GPIO_BASE + 0x0C40)
34#define S5PC100_GPH3_BASE (S5PC100_GPIO_BASE + 0x0C60)
35#define S5PC100_GPI_BASE (S5PC100_GPIO_BASE + 0x01E0)
36#define S5PC100_GPJ0_BASE (S5PC100_GPIO_BASE + 0x0200)
37#define S5PC100_GPJ1_BASE (S5PC100_GPIO_BASE + 0x0220)
38#define S5PC100_GPJ2_BASE (S5PC100_GPIO_BASE + 0x0240)
39#define S5PC100_GPJ3_BASE (S5PC100_GPIO_BASE + 0x0260)
40#define S5PC100_GPJ4_BASE (S5PC100_GPIO_BASE + 0x0280)
41#define S5PC100_GPK0_BASE (S5PC100_GPIO_BASE + 0x02A0)
42#define S5PC100_GPK1_BASE (S5PC100_GPIO_BASE + 0x02C0)
43#define S5PC100_GPK2_BASE (S5PC100_GPIO_BASE + 0x02E0)
44#define S5PC100_GPK3_BASE (S5PC100_GPIO_BASE + 0x0300)
45#define S5PC100_GPL0_BASE (S5PC100_GPIO_BASE + 0x0320)
46#define S5PC100_GPL1_BASE (S5PC100_GPIO_BASE + 0x0340)
47#define S5PC100_GPL2_BASE (S5PC100_GPIO_BASE + 0x0360)
48#define S5PC100_GPL3_BASE (S5PC100_GPIO_BASE + 0x0380)
49#define S5PC100_GPL4_BASE (S5PC100_GPIO_BASE + 0x03A0)
50#define S5PC100_EINT_BASE (S5PC100_GPIO_BASE + 0x0E00)
51
52#define S5PC100_UHOST (S5PC100_GPIO_BASE + 0x0B68)
53#define S5PC100_PDNEN (S5PC100_GPIO_BASE + 0x0F80)
54
55/* PDNEN */
56#define S5PC100_PDNEN_CFG_PDNEN (1 << 1)
57#define S5PC100_PDNEN_CFG_AUTO (0 << 1)
58#define S5PC100_PDNEN_POWERDOWN (1 << 0)
59#define S5PC100_PDNEN_NORMAL (0 << 0)
60
61/* Common part */
62/* External interrupt base is same at both s5pc100 and s5pc110 */
63#define S5PC1XX_EINT_BASE (S5PC100_EINT_BASE)
64
65#define S5PC100_GPx_INPUT(__gpio) (0x0 << ((__gpio) * 4))
66#define S5PC100_GPx_OUTPUT(__gpio) (0x1 << ((__gpio) * 4))
67#define S5PC100_GPx_CONMASK(__gpio) (0xf << ((__gpio) * 4))
68
69#endif /* __ASM_PLAT_S5PC1XX_REGS_GPIO_H */
70