aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c64xx
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-31 12:14:34 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-15 18:34:15 -0500
commit21b23664b9354c5449841e401efb9ad523fb898b (patch)
treeb26017929643be8be4e0a562943ef75fa96499d7 /arch/arm/plat-s3c64xx
parent89d043c3db22c37523165905708d2fa8062fda86 (diff)
[ARM] S3C: Add new GPIO configuration calls
Add new GPIO configuration calls that mesh with the new gpiolib support. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c64xx')
-rw-r--r--arch/arm/plat-s3c64xx/Kconfig3
-rw-r--r--arch/arm/plat-s3c64xx/gpiolib.c75
2 files changed, 77 insertions, 1 deletions
diff --git a/arch/arm/plat-s3c64xx/Kconfig b/arch/arm/plat-s3c64xx/Kconfig
index 3df2ec19d08a..842200abeb36 100644
--- a/arch/arm/plat-s3c64xx/Kconfig
+++ b/arch/arm/plat-s3c64xx/Kconfig
@@ -15,6 +15,9 @@ config PLAT_S3C64XX
15 select NO_IOPORT 15 select NO_IOPORT
16 select ARCH_REQUIRE_GPIOLIB 16 select ARCH_REQUIRE_GPIOLIB
17 select S3C_GPIO_TRACK 17 select S3C_GPIO_TRACK
18 select S3C_GPIO_PULL_UPDOWN
19 select S3C_GPIO_CFG_S3C24XX
20 select S3C_GPIO_CFG_S3C64XX
18 help 21 help
19 Base platform code for any Samsung S3C64XX device 22 Base platform code for any Samsung S3C64XX device
20 23
diff --git a/arch/arm/plat-s3c64xx/gpiolib.c b/arch/arm/plat-s3c64xx/gpiolib.c
index 28ba23502bce..cc62941d7b5c 100644
--- a/arch/arm/plat-s3c64xx/gpiolib.c
+++ b/arch/arm/plat-s3c64xx/gpiolib.c
@@ -18,8 +18,10 @@
18 18
19#include <mach/map.h> 19#include <mach/map.h>
20#include <mach/gpio.h> 20#include <mach/gpio.h>
21#include <mach/gpio-core.h>
21 22
22#include <plat/gpio-core.h> 23#include <plat/gpio-cfg.h>
24#include <plat/gpio-cfg-helpers.h>
23#include <plat/regs-gpio.h> 25#include <plat/regs-gpio.h>
24 26
25/* GPIO bank summary: 27/* GPIO bank summary:
@@ -52,6 +54,12 @@
52 54
53#define con_4bit_shift(__off) ((__off) * 4) 55#define con_4bit_shift(__off) ((__off) * 4)
54 56
57#if 1
58#define gpio_dbg(x...) do { } while(0)
59#else
60#define gpio_dbg(x...) printk(KERN_DEBUG ## x)
61#endif
62
55/* The s3c64xx_gpiolib_4bit routines are to control the gpio banks where 63/* The s3c64xx_gpiolib_4bit routines are to control the gpio banks where
56 * the gpio configuration register (GPxCON) has 4 bits per GPIO, as the 64 * the gpio configuration register (GPxCON) has 4 bits per GPIO, as the
57 * following example: 65 * following example:
@@ -77,6 +85,8 @@ static int s3c64xx_gpiolib_4bit_input(struct gpio_chip *chip, unsigned offset)
77 con &= ~(0xf << con_4bit_shift(offset)); 85 con &= ~(0xf << con_4bit_shift(offset));
78 __raw_writel(con, base + OFF_GPCON); 86 __raw_writel(con, base + OFF_GPCON);
79 87
88 gpio_dbg("%s: %p: CON now %08lx\n", __func__, base, con);
89
80 return 0; 90 return 0;
81} 91}
82 92
@@ -102,6 +112,8 @@ static int s3c64xx_gpiolib_4bit_output(struct gpio_chip *chip,
102 __raw_writel(con, base + OFF_GPCON); 112 __raw_writel(con, base + OFF_GPCON);
103 __raw_writel(dat, base + OFF_GPDAT); 113 __raw_writel(dat, base + OFF_GPDAT);
104 114
115 gpio_dbg("%s: %p: CON %08lx, DAT %08lx\n", __func__, base, con, dat);
116
105 return 0; 117 return 0;
106} 118}
107 119
@@ -142,6 +154,8 @@ static int s3c64xx_gpiolib_4bit2_input(struct gpio_chip *chip, unsigned offset)
142 con &= ~(0xf << con_4bit_shift(offset)); 154 con &= ~(0xf << con_4bit_shift(offset));
143 __raw_writel(con, regcon); 155 __raw_writel(con, regcon);
144 156
157 gpio_dbg("%s: %p: CON %08lx\n", __func__, base, con);
158
145 return 0; 159 return 0;
146 160
147} 161}
@@ -174,12 +188,35 @@ static int s3c64xx_gpiolib_4bit2_output(struct gpio_chip *chip,
174 __raw_writel(con, regcon); 188 __raw_writel(con, regcon);
175 __raw_writel(dat, base + OFF_GPDAT); 189 __raw_writel(dat, base + OFF_GPDAT);
176 190
191 gpio_dbg("%s: %p: CON %08lx, DAT %08lx\n", __func__, base, con, dat);
192
177 return 0; 193 return 0;
178} 194}
179 195
196static struct s3c_gpio_cfg gpio_4bit_cfg_noint = {
197 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
198 .set_pull = s3c_gpio_setpull_updown,
199 .get_pull = s3c_gpio_getpull_updown,
200};
201
202static struct s3c_gpio_cfg gpio_4bit_cfg_eint0111 = {
203 .cfg_eint = 7,
204 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
205 .set_pull = s3c_gpio_setpull_updown,
206 .get_pull = s3c_gpio_getpull_updown,
207};
208
209static struct s3c_gpio_cfg gpio_4bit_cfg_eint0011 = {
210 .cfg_eint = 3,
211 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
212 .set_pull = s3c_gpio_setpull_updown,
213 .get_pull = s3c_gpio_getpull_updown,
214};
215
180static struct s3c_gpio_chip gpio_4bit[] = { 216static struct s3c_gpio_chip gpio_4bit[] = {
181 { 217 {
182 .base = S3C64XX_GPA_BASE, 218 .base = S3C64XX_GPA_BASE,
219 .config = &gpio_4bit_cfg_eint0111,
183 .chip = { 220 .chip = {
184 .base = S3C64XX_GPA(0), 221 .base = S3C64XX_GPA(0),
185 .ngpio = S3C64XX_GPIO_A_NR, 222 .ngpio = S3C64XX_GPIO_A_NR,
@@ -187,6 +224,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
187 }, 224 },
188 }, { 225 }, {
189 .base = S3C64XX_GPB_BASE, 226 .base = S3C64XX_GPB_BASE,
227 .config = &gpio_4bit_cfg_eint0111,
190 .chip = { 228 .chip = {
191 .base = S3C64XX_GPB(0), 229 .base = S3C64XX_GPB(0),
192 .ngpio = S3C64XX_GPIO_B_NR, 230 .ngpio = S3C64XX_GPIO_B_NR,
@@ -194,6 +232,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
194 }, 232 },
195 }, { 233 }, {
196 .base = S3C64XX_GPC_BASE, 234 .base = S3C64XX_GPC_BASE,
235 .config = &gpio_4bit_cfg_eint0111,
197 .chip = { 236 .chip = {
198 .base = S3C64XX_GPC(0), 237 .base = S3C64XX_GPC(0),
199 .ngpio = S3C64XX_GPIO_C_NR, 238 .ngpio = S3C64XX_GPIO_C_NR,
@@ -201,6 +240,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
201 }, 240 },
202 }, { 241 }, {
203 .base = S3C64XX_GPD_BASE, 242 .base = S3C64XX_GPD_BASE,
243 .config = &gpio_4bit_cfg_eint0111,
204 .chip = { 244 .chip = {
205 .base = S3C64XX_GPD(0), 245 .base = S3C64XX_GPD(0),
206 .ngpio = S3C64XX_GPIO_D_NR, 246 .ngpio = S3C64XX_GPIO_D_NR,
@@ -208,6 +248,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
208 }, 248 },
209 }, { 249 }, {
210 .base = S3C64XX_GPE_BASE, 250 .base = S3C64XX_GPE_BASE,
251 .config = &gpio_4bit_cfg_noint,
211 .chip = { 252 .chip = {
212 .base = S3C64XX_GPE(0), 253 .base = S3C64XX_GPE(0),
213 .ngpio = S3C64XX_GPIO_E_NR, 254 .ngpio = S3C64XX_GPIO_E_NR,
@@ -215,6 +256,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
215 }, 256 },
216 }, { 257 }, {
217 .base = S3C64XX_GPG_BASE, 258 .base = S3C64XX_GPG_BASE,
259 .config = &gpio_4bit_cfg_eint0111,
218 .chip = { 260 .chip = {
219 .base = S3C64XX_GPG(0), 261 .base = S3C64XX_GPG(0),
220 .ngpio = S3C64XX_GPIO_G_NR, 262 .ngpio = S3C64XX_GPIO_G_NR,
@@ -222,6 +264,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
222 }, 264 },
223 }, { 265 }, {
224 .base = S3C64XX_GPM_BASE, 266 .base = S3C64XX_GPM_BASE,
267 .config = &gpio_4bit_cfg_eint0011,
225 .chip = { 268 .chip = {
226 .base = S3C64XX_GPM(0), 269 .base = S3C64XX_GPM(0),
227 .ngpio = S3C64XX_GPIO_M_NR, 270 .ngpio = S3C64XX_GPIO_M_NR,
@@ -233,6 +276,7 @@ static struct s3c_gpio_chip gpio_4bit[] = {
233static struct s3c_gpio_chip gpio_4bit2[] = { 276static struct s3c_gpio_chip gpio_4bit2[] = {
234 { 277 {
235 .base = S3C64XX_GPH_BASE + 0x4, 278 .base = S3C64XX_GPH_BASE + 0x4,
279 .config = &gpio_4bit_cfg_eint0111,
236 .chip = { 280 .chip = {
237 .base = S3C64XX_GPH(0), 281 .base = S3C64XX_GPH(0),
238 .ngpio = S3C64XX_GPIO_H_NR, 282 .ngpio = S3C64XX_GPIO_H_NR,
@@ -240,6 +284,7 @@ static struct s3c_gpio_chip gpio_4bit2[] = {
240 }, 284 },
241 }, { 285 }, {
242 .base = S3C64XX_GPK_BASE + 0x4, 286 .base = S3C64XX_GPK_BASE + 0x4,
287 .config = &gpio_4bit_cfg_noint,
243 .chip = { 288 .chip = {
244 .base = S3C64XX_GPK(0), 289 .base = S3C64XX_GPK(0),
245 .ngpio = S3C64XX_GPIO_K_NR, 290 .ngpio = S3C64XX_GPIO_K_NR,
@@ -247,6 +292,7 @@ static struct s3c_gpio_chip gpio_4bit2[] = {
247 }, 292 },
248 }, { 293 }, {
249 .base = S3C64XX_GPL_BASE + 0x4, 294 .base = S3C64XX_GPL_BASE + 0x4,
295 .config = &gpio_4bit_cfg_eint0011,
250 .chip = { 296 .chip = {
251 .base = S3C64XX_GPL(0), 297 .base = S3C64XX_GPL(0),
252 .ngpio = S3C64XX_GPIO_L_NR, 298 .ngpio = S3C64XX_GPIO_L_NR,
@@ -255,9 +301,30 @@ static struct s3c_gpio_chip gpio_4bit2[] = {
255 }, 301 },
256}; 302};
257 303
304static struct s3c_gpio_cfg gpio_2bit_cfg_noint = {
305 .set_config = s3c_gpio_setcfg_s3c24xx,
306 .set_pull = s3c_gpio_setpull_updown,
307 .get_pull = s3c_gpio_getpull_updown,
308};
309
310static struct s3c_gpio_cfg gpio_2bit_cfg_eint10 = {
311 .cfg_eint = 2,
312 .set_config = s3c_gpio_setcfg_s3c24xx,
313 .set_pull = s3c_gpio_setpull_updown,
314 .get_pull = s3c_gpio_getpull_updown,
315};
316
317static struct s3c_gpio_cfg gpio_2bit_cfg_eint11 = {
318 .cfg_eint = 3,
319 .set_config = s3c_gpio_setcfg_s3c24xx,
320 .set_pull = s3c_gpio_setpull_updown,
321 .get_pull = s3c_gpio_getpull_updown,
322};
323
258static struct s3c_gpio_chip gpio_2bit[] = { 324static struct s3c_gpio_chip gpio_2bit[] = {
259 { 325 {
260 .base = S3C64XX_GPF_BASE, 326 .base = S3C64XX_GPF_BASE,
327 .config = &gpio_2bit_cfg_eint11,
261 .chip = { 328 .chip = {
262 .base = S3C64XX_GPF(0), 329 .base = S3C64XX_GPF(0),
263 .ngpio = S3C64XX_GPIO_F_NR, 330 .ngpio = S3C64XX_GPIO_F_NR,
@@ -265,6 +332,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
265 }, 332 },
266 }, { 333 }, {
267 .base = S3C64XX_GPI_BASE, 334 .base = S3C64XX_GPI_BASE,
335 .config = &gpio_2bit_cfg_noint,
268 .chip = { 336 .chip = {
269 .base = S3C64XX_GPI(0), 337 .base = S3C64XX_GPI(0),
270 .ngpio = S3C64XX_GPIO_I_NR, 338 .ngpio = S3C64XX_GPIO_I_NR,
@@ -272,6 +340,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
272 }, 340 },
273 }, { 341 }, {
274 .base = S3C64XX_GPJ_BASE, 342 .base = S3C64XX_GPJ_BASE,
343 .config = &gpio_2bit_cfg_noint,
275 .chip = { 344 .chip = {
276 .base = S3C64XX_GPJ(0), 345 .base = S3C64XX_GPJ(0),
277 .ngpio = S3C64XX_GPIO_J_NR, 346 .ngpio = S3C64XX_GPIO_J_NR,
@@ -279,6 +348,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
279 }, 348 },
280 }, { 349 }, {
281 .base = S3C64XX_GPN_BASE, 350 .base = S3C64XX_GPN_BASE,
351 .config = &gpio_2bit_cfg_eint10,
282 .chip = { 352 .chip = {
283 .base = S3C64XX_GPN(0), 353 .base = S3C64XX_GPN(0),
284 .ngpio = S3C64XX_GPIO_N_NR, 354 .ngpio = S3C64XX_GPIO_N_NR,
@@ -286,6 +356,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
286 }, 356 },
287 }, { 357 }, {
288 .base = S3C64XX_GPO_BASE, 358 .base = S3C64XX_GPO_BASE,
359 .config = &gpio_2bit_cfg_eint11,
289 .chip = { 360 .chip = {
290 .base = S3C64XX_GPO(0), 361 .base = S3C64XX_GPO(0),
291 .ngpio = S3C64XX_GPIO_O_NR, 362 .ngpio = S3C64XX_GPIO_O_NR,
@@ -293,6 +364,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
293 }, 364 },
294 }, { 365 }, {
295 .base = S3C64XX_GPP_BASE, 366 .base = S3C64XX_GPP_BASE,
367 .config = &gpio_2bit_cfg_eint11,
296 .chip = { 368 .chip = {
297 .base = S3C64XX_GPP(0), 369 .base = S3C64XX_GPP(0),
298 .ngpio = S3C64XX_GPIO_P_NR, 370 .ngpio = S3C64XX_GPIO_P_NR,
@@ -300,6 +372,7 @@ static struct s3c_gpio_chip gpio_2bit[] = {
300 }, 372 },
301 }, { 373 }, {
302 .base = S3C64XX_GPQ_BASE, 374 .base = S3C64XX_GPQ_BASE,
375 .config = &gpio_2bit_cfg_eint11,
303 .chip = { 376 .chip = {
304 .base = S3C64XX_GPQ(0), 377 .base = S3C64XX_GPQ(0),
305 .ngpio = S3C64XX_GPIO_Q_NR, 378 .ngpio = S3C64XX_GPIO_Q_NR,