2 * S5PC100 - GPIOlib support
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * Copyright 2009 Samsung Electronics Co
8 * Kyungmin Park <kyungmin.park@samsung.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/irq.h>
18 #include <linux/gpio.h>
21 #include <mach/regs-gpio.h>
23 #include <plat/gpio-core.h>
24 #include <plat/gpio-cfg.h>
25 #include <plat/gpio-cfg-helpers.h>
27 /* S5PC100 GPIO bank summary:
29 * Bank GPIOs Style INT Type
40 * F3 4 4Bit GPIO_INT10
41 * G0 8 4Bit GPIO_INT11
42 * G1 3 4Bit GPIO_INT12
43 * G2 7 4Bit GPIO_INT13
44 * G3 7 4Bit GPIO_INT14
50 * J0 8 4Bit GPIO_INT16
51 * J1 5 4Bit GPIO_INT17
52 * J2 8 4Bit GPIO_INT18
53 * J3 8 4Bit GPIO_INT19
54 * J4 4 4Bit GPIO_INT20
65 static struct s3c_gpio_cfg gpio_cfg
= {
66 .set_config
= s3c_gpio_setcfg_s3c64xx_4bit
,
67 .set_pull
= s3c_gpio_setpull_updown
,
68 .get_pull
= s3c_gpio_getpull_updown
,
71 static struct s3c_gpio_cfg gpio_cfg_eint
= {
73 .set_config
= s3c_gpio_setcfg_s3c64xx_4bit
,
74 .set_pull
= s3c_gpio_setpull_updown
,
75 .get_pull
= s3c_gpio_getpull_updown
,
78 static struct s3c_gpio_cfg gpio_cfg_noint
= {
79 .set_config
= s3c_gpio_setcfg_s3c64xx_4bit
,
80 .set_pull
= s3c_gpio_setpull_updown
,
81 .get_pull
= s3c_gpio_getpull_updown
,
85 * GPIO bank's base address given the index of the bank in the
86 * list of all gpio banks.
88 #define S5PC100_BANK_BASE(bank_nr) (S5P_VA_GPIO + ((bank_nr) * 0x20))
91 * Following are the gpio banks in S5PC100.
93 * The 'config' member when left to NULL, is initialized to the default
94 * structure gpio_cfg in the init function below.
96 * The 'base' member is also initialized in the init function below.
97 * Note: The initialization of 'base' member of s3c_gpio_chip structure
98 * uses the above macro and depends on the banks being listed in order here.
100 static struct s3c_gpio_chip s5pc100_gpio_chips
[] = {
103 .base
= S5PC100_GPA0(0),
104 .ngpio
= S5PC100_GPIO_A0_NR
,
109 .base
= S5PC100_GPA1(0),
110 .ngpio
= S5PC100_GPIO_A1_NR
,
115 .base
= S5PC100_GPB(0),
116 .ngpio
= S5PC100_GPIO_B_NR
,
121 .base
= S5PC100_GPC(0),
122 .ngpio
= S5PC100_GPIO_C_NR
,
127 .base
= S5PC100_GPD(0),
128 .ngpio
= S5PC100_GPIO_D_NR
,
133 .base
= S5PC100_GPE0(0),
134 .ngpio
= S5PC100_GPIO_E0_NR
,
139 .base
= S5PC100_GPE1(0),
140 .ngpio
= S5PC100_GPIO_E1_NR
,
145 .base
= S5PC100_GPF0(0),
146 .ngpio
= S5PC100_GPIO_F0_NR
,
151 .base
= S5PC100_GPF1(0),
152 .ngpio
= S5PC100_GPIO_F1_NR
,
157 .base
= S5PC100_GPF2(0),
158 .ngpio
= S5PC100_GPIO_F2_NR
,
163 .base
= S5PC100_GPF3(0),
164 .ngpio
= S5PC100_GPIO_F3_NR
,
169 .base
= S5PC100_GPG0(0),
170 .ngpio
= S5PC100_GPIO_G0_NR
,
175 .base
= S5PC100_GPG1(0),
176 .ngpio
= S5PC100_GPIO_G1_NR
,
181 .base
= S5PC100_GPG2(0),
182 .ngpio
= S5PC100_GPIO_G2_NR
,
187 .base
= S5PC100_GPG3(0),
188 .ngpio
= S5PC100_GPIO_G3_NR
,
193 .base
= S5PC100_GPI(0),
194 .ngpio
= S5PC100_GPIO_I_NR
,
199 .base
= S5PC100_GPJ0(0),
200 .ngpio
= S5PC100_GPIO_J0_NR
,
205 .base
= S5PC100_GPJ1(0),
206 .ngpio
= S5PC100_GPIO_J1_NR
,
211 .base
= S5PC100_GPJ2(0),
212 .ngpio
= S5PC100_GPIO_J2_NR
,
217 .base
= S5PC100_GPJ3(0),
218 .ngpio
= S5PC100_GPIO_J3_NR
,
223 .base
= S5PC100_GPJ4(0),
224 .ngpio
= S5PC100_GPIO_J4_NR
,
228 .config
= &gpio_cfg_noint
,
230 .base
= S5PC100_GPK0(0),
231 .ngpio
= S5PC100_GPIO_K0_NR
,
235 .config
= &gpio_cfg_noint
,
237 .base
= S5PC100_GPK1(0),
238 .ngpio
= S5PC100_GPIO_K1_NR
,
242 .config
= &gpio_cfg_noint
,
244 .base
= S5PC100_GPK2(0),
245 .ngpio
= S5PC100_GPIO_K2_NR
,
249 .config
= &gpio_cfg_noint
,
251 .base
= S5PC100_GPK3(0),
252 .ngpio
= S5PC100_GPIO_K3_NR
,
256 .config
= &gpio_cfg_noint
,
258 .base
= S5PC100_GPL0(0),
259 .ngpio
= S5PC100_GPIO_L0_NR
,
263 .config
= &gpio_cfg_noint
,
265 .base
= S5PC100_GPL1(0),
266 .ngpio
= S5PC100_GPIO_L1_NR
,
270 .config
= &gpio_cfg_noint
,
272 .base
= S5PC100_GPL2(0),
273 .ngpio
= S5PC100_GPIO_L2_NR
,
277 .config
= &gpio_cfg_noint
,
279 .base
= S5PC100_GPL3(0),
280 .ngpio
= S5PC100_GPIO_L3_NR
,
284 .config
= &gpio_cfg_noint
,
286 .base
= S5PC100_GPL4(0),
287 .ngpio
= S5PC100_GPIO_L4_NR
,
291 .base
= (S5P_VA_GPIO
+ 0xC00),
292 .config
= &gpio_cfg_eint
,
293 .irq_base
= IRQ_EINT(0),
295 .base
= S5PC100_GPH0(0),
296 .ngpio
= S5PC100_GPIO_H0_NR
,
298 .to_irq
= samsung_gpiolib_to_irq
,
301 .base
= (S5P_VA_GPIO
+ 0xC20),
302 .config
= &gpio_cfg_eint
,
303 .irq_base
= IRQ_EINT(8),
305 .base
= S5PC100_GPH1(0),
306 .ngpio
= S5PC100_GPIO_H1_NR
,
308 .to_irq
= samsung_gpiolib_to_irq
,
311 .base
= (S5P_VA_GPIO
+ 0xC40),
312 .config
= &gpio_cfg_eint
,
313 .irq_base
= IRQ_EINT(16),
315 .base
= S5PC100_GPH2(0),
316 .ngpio
= S5PC100_GPIO_H2_NR
,
318 .to_irq
= samsung_gpiolib_to_irq
,
321 .base
= (S5P_VA_GPIO
+ 0xC60),
322 .config
= &gpio_cfg_eint
,
323 .irq_base
= IRQ_EINT(24),
325 .base
= S5PC100_GPH3(0),
326 .ngpio
= S5PC100_GPIO_H3_NR
,
328 .to_irq
= samsung_gpiolib_to_irq
,
333 static __init
int s5pc100_gpiolib_init(void)
335 struct s3c_gpio_chip
*chip
= s5pc100_gpio_chips
;
336 int nr_chips
= ARRAY_SIZE(s5pc100_gpio_chips
);
337 int gpioint_group
= 0;
340 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
341 if (chip
->config
== NULL
) {
342 chip
->config
= &gpio_cfg
;
343 chip
->group
= gpioint_group
++;
345 if (chip
->base
== NULL
)
346 chip
->base
= S5PC100_BANK_BASE(i
);
349 samsung_gpiolib_add_4bit_chips(s5pc100_gpio_chips
, nr_chips
);
350 s5p_register_gpioint_bank(IRQ_GPIOINT
, 0, S5P_GPIOINT_GROUP_MAXNR
);
354 core_initcall(s5pc100_gpiolib_init
);