2 * EXYNOS4 - GPIOlib support
4 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/irq.h>
15 #include <linux/gpio.h>
19 #include <plat/gpio-core.h>
20 #include <plat/gpio-cfg.h>
21 #include <plat/gpio-cfg-helpers.h>
23 static struct s3c_gpio_cfg gpio_cfg
= {
24 .set_config
= s3c_gpio_setcfg_s3c64xx_4bit
,
25 .set_pull
= s3c_gpio_setpull_updown
,
26 .get_pull
= s3c_gpio_getpull_updown
,
29 static struct s3c_gpio_cfg gpio_cfg_noint
= {
30 .set_config
= s3c_gpio_setcfg_s3c64xx_4bit
,
31 .set_pull
= s3c_gpio_setpull_updown
,
32 .get_pull
= s3c_gpio_getpull_updown
,
36 * Following are the gpio banks in v310.
38 * The 'config' member when left to NULL, is initialized to the default
39 * structure gpio_cfg in the init function below.
41 * The 'base' member is also initialized in the init function below.
42 * Note: The initialization of 'base' member of s3c_gpio_chip structure
43 * uses the above macro and depends on the banks being listed in order here.
45 static struct s3c_gpio_chip exynos4_gpio_part1_4bit
[] = {
48 .base
= EXYNOS4_GPA0(0),
49 .ngpio
= EXYNOS4_GPIO_A0_NR
,
54 .base
= EXYNOS4_GPA1(0),
55 .ngpio
= EXYNOS4_GPIO_A1_NR
,
60 .base
= EXYNOS4_GPB(0),
61 .ngpio
= EXYNOS4_GPIO_B_NR
,
66 .base
= EXYNOS4_GPC0(0),
67 .ngpio
= EXYNOS4_GPIO_C0_NR
,
72 .base
= EXYNOS4_GPC1(0),
73 .ngpio
= EXYNOS4_GPIO_C1_NR
,
78 .base
= EXYNOS4_GPD0(0),
79 .ngpio
= EXYNOS4_GPIO_D0_NR
,
84 .base
= EXYNOS4_GPD1(0),
85 .ngpio
= EXYNOS4_GPIO_D1_NR
,
90 .base
= EXYNOS4_GPE0(0),
91 .ngpio
= EXYNOS4_GPIO_E0_NR
,
96 .base
= EXYNOS4_GPE1(0),
97 .ngpio
= EXYNOS4_GPIO_E1_NR
,
102 .base
= EXYNOS4_GPE2(0),
103 .ngpio
= EXYNOS4_GPIO_E2_NR
,
108 .base
= EXYNOS4_GPE3(0),
109 .ngpio
= EXYNOS4_GPIO_E3_NR
,
114 .base
= EXYNOS4_GPE4(0),
115 .ngpio
= EXYNOS4_GPIO_E4_NR
,
120 .base
= EXYNOS4_GPF0(0),
121 .ngpio
= EXYNOS4_GPIO_F0_NR
,
126 .base
= EXYNOS4_GPF1(0),
127 .ngpio
= EXYNOS4_GPIO_F1_NR
,
132 .base
= EXYNOS4_GPF2(0),
133 .ngpio
= EXYNOS4_GPIO_F2_NR
,
138 .base
= EXYNOS4_GPF3(0),
139 .ngpio
= EXYNOS4_GPIO_F3_NR
,
145 static struct s3c_gpio_chip exynos4_gpio_part2_4bit
[] = {
148 .base
= EXYNOS4_GPJ0(0),
149 .ngpio
= EXYNOS4_GPIO_J0_NR
,
154 .base
= EXYNOS4_GPJ1(0),
155 .ngpio
= EXYNOS4_GPIO_J1_NR
,
160 .base
= EXYNOS4_GPK0(0),
161 .ngpio
= EXYNOS4_GPIO_K0_NR
,
166 .base
= EXYNOS4_GPK1(0),
167 .ngpio
= EXYNOS4_GPIO_K1_NR
,
172 .base
= EXYNOS4_GPK2(0),
173 .ngpio
= EXYNOS4_GPIO_K2_NR
,
178 .base
= EXYNOS4_GPK3(0),
179 .ngpio
= EXYNOS4_GPIO_K3_NR
,
184 .base
= EXYNOS4_GPL0(0),
185 .ngpio
= EXYNOS4_GPIO_L0_NR
,
190 .base
= EXYNOS4_GPL1(0),
191 .ngpio
= EXYNOS4_GPIO_L1_NR
,
196 .base
= EXYNOS4_GPL2(0),
197 .ngpio
= EXYNOS4_GPIO_L2_NR
,
201 .config
= &gpio_cfg_noint
,
203 .base
= EXYNOS4_GPY0(0),
204 .ngpio
= EXYNOS4_GPIO_Y0_NR
,
208 .config
= &gpio_cfg_noint
,
210 .base
= EXYNOS4_GPY1(0),
211 .ngpio
= EXYNOS4_GPIO_Y1_NR
,
215 .config
= &gpio_cfg_noint
,
217 .base
= EXYNOS4_GPY2(0),
218 .ngpio
= EXYNOS4_GPIO_Y2_NR
,
222 .config
= &gpio_cfg_noint
,
224 .base
= EXYNOS4_GPY3(0),
225 .ngpio
= EXYNOS4_GPIO_Y3_NR
,
229 .config
= &gpio_cfg_noint
,
231 .base
= EXYNOS4_GPY4(0),
232 .ngpio
= EXYNOS4_GPIO_Y4_NR
,
236 .config
= &gpio_cfg_noint
,
238 .base
= EXYNOS4_GPY5(0),
239 .ngpio
= EXYNOS4_GPIO_Y5_NR
,
243 .config
= &gpio_cfg_noint
,
245 .base
= EXYNOS4_GPY6(0),
246 .ngpio
= EXYNOS4_GPIO_Y6_NR
,
250 .base
= (S5P_VA_GPIO2
+ 0xC00),
251 .config
= &gpio_cfg_noint
,
252 .irq_base
= IRQ_EINT(0),
254 .base
= EXYNOS4_GPX0(0),
255 .ngpio
= EXYNOS4_GPIO_X0_NR
,
257 .to_irq
= samsung_gpiolib_to_irq
,
260 .base
= (S5P_VA_GPIO2
+ 0xC20),
261 .config
= &gpio_cfg_noint
,
262 .irq_base
= IRQ_EINT(8),
264 .base
= EXYNOS4_GPX1(0),
265 .ngpio
= EXYNOS4_GPIO_X1_NR
,
267 .to_irq
= samsung_gpiolib_to_irq
,
270 .base
= (S5P_VA_GPIO2
+ 0xC40),
271 .config
= &gpio_cfg_noint
,
272 .irq_base
= IRQ_EINT(16),
274 .base
= EXYNOS4_GPX2(0),
275 .ngpio
= EXYNOS4_GPIO_X2_NR
,
277 .to_irq
= samsung_gpiolib_to_irq
,
280 .base
= (S5P_VA_GPIO2
+ 0xC60),
281 .config
= &gpio_cfg_noint
,
282 .irq_base
= IRQ_EINT(24),
284 .base
= EXYNOS4_GPX3(0),
285 .ngpio
= EXYNOS4_GPIO_X3_NR
,
287 .to_irq
= samsung_gpiolib_to_irq
,
292 static struct s3c_gpio_chip exynos4_gpio_part3_4bit
[] = {
295 .base
= EXYNOS4_GPZ(0),
296 .ngpio
= EXYNOS4_GPIO_Z_NR
,
302 static __init
int exynos4_gpiolib_init(void)
304 struct s3c_gpio_chip
*chip
;
311 chip
= exynos4_gpio_part1_4bit
;
312 nr_chips
= ARRAY_SIZE(exynos4_gpio_part1_4bit
);
314 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
315 if (chip
->config
== NULL
) {
316 chip
->config
= &gpio_cfg
;
317 /* Assign the GPIO interrupt group */
318 chip
->group
= group
++;
320 if (chip
->base
== NULL
)
321 chip
->base
= S5P_VA_GPIO1
+ (i
) * 0x20;
324 samsung_gpiolib_add_4bit_chips(exynos4_gpio_part1_4bit
, nr_chips
);
328 chip
= exynos4_gpio_part2_4bit
;
329 nr_chips
= ARRAY_SIZE(exynos4_gpio_part2_4bit
);
331 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
332 if (chip
->config
== NULL
) {
333 chip
->config
= &gpio_cfg
;
334 /* Assign the GPIO interrupt group */
335 chip
->group
= group
++;
337 if (chip
->base
== NULL
)
338 chip
->base
= S5P_VA_GPIO2
+ (i
) * 0x20;
341 samsung_gpiolib_add_4bit_chips(exynos4_gpio_part2_4bit
, nr_chips
);
345 chip
= exynos4_gpio_part3_4bit
;
346 nr_chips
= ARRAY_SIZE(exynos4_gpio_part3_4bit
);
348 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
349 if (chip
->config
== NULL
) {
350 chip
->config
= &gpio_cfg
;
351 /* Assign the GPIO interrupt group */
352 chip
->group
= group
++;
354 if (chip
->base
== NULL
)
355 chip
->base
= S5P_VA_GPIO3
+ (i
) * 0x20;
358 samsung_gpiolib_add_4bit_chips(exynos4_gpio_part3_4bit
, nr_chips
);
359 s5p_register_gpioint_bank(IRQ_GPIO_XA
, 0, IRQ_GPIO1_NR_GROUPS
);
360 s5p_register_gpioint_bank(IRQ_GPIO_XB
, IRQ_GPIO1_NR_GROUPS
, IRQ_GPIO2_NR_GROUPS
);
364 core_initcall(exynos4_gpiolib_init
);