2 * Copyright (c) 2009-2011 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com/
5 * Copyright 2008 Openmoko, Inc.
6 * Copyright 2008 Simtec Electronics
7 * Ben Dooks <ben@simtec.co.uk>
8 * http://armlinux.simtec.co.uk/
10 * SAMSUNG - GPIOlib support
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/kernel.h>
18 #include <linux/irq.h>
20 #include <linux/gpio.h>
21 #include <linux/init.h>
22 #include <linux/spinlock.h>
23 #include <linux/module.h>
24 #include <linux/interrupt.h>
25 #include <linux/sysdev.h>
26 #include <linux/ioport.h>
30 #include <mach/hardware.h>
32 #include <mach/regs-clock.h>
33 #include <mach/regs-gpio.h>
36 #include <plat/gpio-core.h>
37 #include <plat/gpio-cfg.h>
38 #include <plat/gpio-cfg-helpers.h>
39 #include <plat/gpio-fns.h>
43 #define gpio_dbg(x...) do { } while (0)
45 #define gpio_dbg(x...) printk(KERN_DEBUG x)
48 int samsung_gpio_setpull_updown(struct samsung_gpio_chip
*chip
,
49 unsigned int off
, samsung_gpio_pull_t pull
)
51 void __iomem
*reg
= chip
->base
+ 0x08;
55 pup
= __raw_readl(reg
);
58 __raw_writel(pup
, reg
);
63 samsung_gpio_pull_t
samsung_gpio_getpull_updown(struct samsung_gpio_chip
*chip
,
66 void __iomem
*reg
= chip
->base
+ 0x08;
68 u32 pup
= __raw_readl(reg
);
73 return (__force samsung_gpio_pull_t
)pup
;
76 int s3c2443_gpio_setpull(struct samsung_gpio_chip
*chip
,
77 unsigned int off
, samsung_gpio_pull_t pull
)
80 case S3C_GPIO_PULL_NONE
:
83 case S3C_GPIO_PULL_UP
:
86 case S3C_GPIO_PULL_DOWN
:
90 return samsung_gpio_setpull_updown(chip
, off
, pull
);
93 samsung_gpio_pull_t
s3c2443_gpio_getpull(struct samsung_gpio_chip
*chip
,
96 samsung_gpio_pull_t pull
;
98 pull
= samsung_gpio_getpull_updown(chip
, off
);
102 pull
= S3C_GPIO_PULL_UP
;
106 pull
= S3C_GPIO_PULL_NONE
;
109 pull
= S3C_GPIO_PULL_DOWN
;
116 static int s3c24xx_gpio_setpull_1(struct samsung_gpio_chip
*chip
,
117 unsigned int off
, samsung_gpio_pull_t pull
,
118 samsung_gpio_pull_t updown
)
120 void __iomem
*reg
= chip
->base
+ 0x08;
121 u32 pup
= __raw_readl(reg
);
125 else if (pull
== S3C_GPIO_PULL_NONE
)
130 __raw_writel(pup
, reg
);
134 static samsung_gpio_pull_t
s3c24xx_gpio_getpull_1(struct samsung_gpio_chip
*chip
,
136 samsung_gpio_pull_t updown
)
138 void __iomem
*reg
= chip
->base
+ 0x08;
139 u32 pup
= __raw_readl(reg
);
142 return pup
? S3C_GPIO_PULL_NONE
: updown
;
145 samsung_gpio_pull_t
s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip
*chip
,
148 return s3c24xx_gpio_getpull_1(chip
, off
, S3C_GPIO_PULL_UP
);
151 int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip
*chip
,
152 unsigned int off
, samsung_gpio_pull_t pull
)
154 return s3c24xx_gpio_setpull_1(chip
, off
, pull
, S3C_GPIO_PULL_UP
);
157 samsung_gpio_pull_t
s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip
*chip
,
160 return s3c24xx_gpio_getpull_1(chip
, off
, S3C_GPIO_PULL_DOWN
);
163 int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip
*chip
,
164 unsigned int off
, samsung_gpio_pull_t pull
)
166 return s3c24xx_gpio_setpull_1(chip
, off
, pull
, S3C_GPIO_PULL_DOWN
);
169 static int exynos4_gpio_setpull(struct samsung_gpio_chip
*chip
,
170 unsigned int off
, samsung_gpio_pull_t pull
)
172 if (pull
== S3C_GPIO_PULL_UP
)
175 return samsung_gpio_setpull_updown(chip
, off
, pull
);
178 static samsung_gpio_pull_t
exynos4_gpio_getpull(struct samsung_gpio_chip
*chip
,
181 samsung_gpio_pull_t pull
;
183 pull
= samsung_gpio_getpull_updown(chip
, off
);
186 pull
= S3C_GPIO_PULL_UP
;
192 * samsung_gpio_setcfg_2bit - Samsung 2bit style GPIO configuration.
193 * @chip: The gpio chip that is being configured.
194 * @off: The offset for the GPIO being configured.
195 * @cfg: The configuration value to set.
197 * This helper deal with the GPIO cases where the control register
198 * has two bits of configuration per gpio, which have the following
202 * 1x = special function
205 static int samsung_gpio_setcfg_2bit(struct samsung_gpio_chip
*chip
,
206 unsigned int off
, unsigned int cfg
)
208 void __iomem
*reg
= chip
->base
;
209 unsigned int shift
= off
* 2;
212 if (samsung_gpio_is_cfg_special(cfg
)) {
220 con
= __raw_readl(reg
);
221 con
&= ~(0x3 << shift
);
223 __raw_writel(con
, reg
);
229 * samsung_gpio_getcfg_2bit - Samsung 2bit style GPIO configuration read.
230 * @chip: The gpio chip that is being configured.
231 * @off: The offset for the GPIO being configured.
233 * The reverse of samsung_gpio_setcfg_2bit(). Will return a value whicg
234 * could be directly passed back to samsung_gpio_setcfg_2bit(), from the
235 * S3C_GPIO_SPECIAL() macro.
238 static unsigned int samsung_gpio_getcfg_2bit(struct samsung_gpio_chip
*chip
,
243 con
= __raw_readl(chip
->base
);
247 /* this conversion works for IN and OUT as well as special mode */
248 return S3C_GPIO_SPECIAL(con
);
252 * samsung_gpio_setcfg_4bit - Samsung 4bit single register GPIO config.
253 * @chip: The gpio chip that is being configured.
254 * @off: The offset for the GPIO being configured.
255 * @cfg: The configuration value to set.
257 * This helper deal with the GPIO cases where the control register has 4 bits
258 * of control per GPIO, generally in the form of:
261 * others = Special functions (dependent on bank)
263 * Note, since the code to deal with the case where there are two control
264 * registers instead of one, we do not have a separate set of functions for
268 static int samsung_gpio_setcfg_4bit(struct samsung_gpio_chip
*chip
,
269 unsigned int off
, unsigned int cfg
)
271 void __iomem
*reg
= chip
->base
;
272 unsigned int shift
= (off
& 7) * 4;
275 if (off
< 8 && chip
->chip
.ngpio
> 8)
278 if (samsung_gpio_is_cfg_special(cfg
)) {
283 con
= __raw_readl(reg
);
284 con
&= ~(0xf << shift
);
286 __raw_writel(con
, reg
);
292 * samsung_gpio_getcfg_4bit - Samsung 4bit single register GPIO config read.
293 * @chip: The gpio chip that is being configured.
294 * @off: The offset for the GPIO being configured.
296 * The reverse of samsung_gpio_setcfg_4bit(), turning a gpio configuration
297 * register setting into a value the software can use, such as could be passed
298 * to samsung_gpio_setcfg_4bit().
300 * @sa samsung_gpio_getcfg_2bit
303 static unsigned samsung_gpio_getcfg_4bit(struct samsung_gpio_chip
*chip
,
306 void __iomem
*reg
= chip
->base
;
307 unsigned int shift
= (off
& 7) * 4;
310 if (off
< 8 && chip
->chip
.ngpio
> 8)
313 con
= __raw_readl(reg
);
317 /* this conversion works for IN and OUT as well as special mode */
318 return S3C_GPIO_SPECIAL(con
);
321 #ifdef CONFIG_PLAT_S3C24XX
323 * s3c24xx_gpio_setcfg_abank - S3C24XX style GPIO configuration (Bank A)
324 * @chip: The gpio chip that is being configured.
325 * @off: The offset for the GPIO being configured.
326 * @cfg: The configuration value to set.
328 * This helper deal with the GPIO cases where the control register
329 * has one bit of configuration for the gpio, where setting the bit
330 * means the pin is in special function mode and unset means output.
333 static int s3c24xx_gpio_setcfg_abank(struct samsung_gpio_chip
*chip
,
334 unsigned int off
, unsigned int cfg
)
336 void __iomem
*reg
= chip
->base
;
337 unsigned int shift
= off
;
340 if (samsung_gpio_is_cfg_special(cfg
)) {
343 /* Map output to 0, and SFN2 to 1 */
351 con
= __raw_readl(reg
);
352 con
&= ~(0x1 << shift
);
354 __raw_writel(con
, reg
);
360 * s3c24xx_gpio_getcfg_abank - S3C24XX style GPIO configuration read (Bank A)
361 * @chip: The gpio chip that is being configured.
362 * @off: The offset for the GPIO being configured.
364 * The reverse of s3c24xx_gpio_setcfg_abank() turning an GPIO into a usable
365 * GPIO configuration value.
367 * @sa samsung_gpio_getcfg_2bit
368 * @sa samsung_gpio_getcfg_4bit
371 static unsigned s3c24xx_gpio_getcfg_abank(struct samsung_gpio_chip
*chip
,
376 con
= __raw_readl(chip
->base
);
381 return S3C_GPIO_SFN(con
);
385 #if defined(CONFIG_CPU_S5P6440) || defined(CONFIG_CPU_S5P6450)
386 static int s5p64x0_gpio_setcfg_rbank(struct samsung_gpio_chip
*chip
,
387 unsigned int off
, unsigned int cfg
)
389 void __iomem
*reg
= chip
->base
;
400 shift
= (off
& 7) * 4;
404 shift
= ((off
+ 1) & 7) * 4;
407 shift
= ((off
+ 1) & 7) * 4;
411 if (samsung_gpio_is_cfg_special(cfg
)) {
416 con
= __raw_readl(reg
);
417 con
&= ~(0xf << shift
);
419 __raw_writel(con
, reg
);
425 static void __init
samsung_gpiolib_set_cfg(struct samsung_gpio_cfg
*chipcfg
,
428 for (; nr_chips
> 0; nr_chips
--, chipcfg
++) {
429 if (!chipcfg
->set_config
)
430 chipcfg
->set_config
= samsung_gpio_setcfg_4bit
;
431 if (!chipcfg
->get_config
)
432 chipcfg
->get_config
= samsung_gpio_getcfg_4bit
;
433 if (!chipcfg
->set_pull
)
434 chipcfg
->set_pull
= samsung_gpio_setpull_updown
;
435 if (!chipcfg
->get_pull
)
436 chipcfg
->get_pull
= samsung_gpio_getpull_updown
;
440 struct samsung_gpio_cfg s3c24xx_gpiocfg_default
= {
441 .set_config
= samsung_gpio_setcfg_2bit
,
442 .get_config
= samsung_gpio_getcfg_2bit
,
445 #ifdef CONFIG_PLAT_S3C24XX
446 static struct samsung_gpio_cfg s3c24xx_gpiocfg_banka
= {
447 .set_config
= s3c24xx_gpio_setcfg_abank
,
448 .get_config
= s3c24xx_gpio_getcfg_abank
,
452 static struct samsung_gpio_cfg exynos4_gpio_cfg
= {
453 .set_pull
= exynos4_gpio_setpull
,
454 .get_pull
= exynos4_gpio_getpull
,
455 .set_config
= samsung_gpio_setcfg_4bit
,
456 .get_config
= samsung_gpio_getcfg_4bit
,
459 #if defined(CONFIG_CPU_S5P6440) || defined(CONFIG_CPU_S5P6450)
460 static struct samsung_gpio_cfg s5p64x0_gpio_cfg_rbank
= {
462 .set_config
= s5p64x0_gpio_setcfg_rbank
,
463 .get_config
= samsung_gpio_getcfg_4bit
,
464 .set_pull
= samsung_gpio_setpull_updown
,
465 .get_pull
= samsung_gpio_getpull_updown
,
469 static struct samsung_gpio_cfg samsung_gpio_cfgs
[] = {
480 .set_config
= samsung_gpio_setcfg_2bit
,
481 .get_config
= samsung_gpio_getcfg_2bit
,
484 .set_config
= samsung_gpio_setcfg_2bit
,
485 .get_config
= samsung_gpio_getcfg_2bit
,
488 .set_config
= samsung_gpio_setcfg_2bit
,
489 .get_config
= samsung_gpio_getcfg_2bit
,
491 .set_config
= samsung_gpio_setcfg_2bit
,
492 .get_config
= samsung_gpio_getcfg_2bit
,
494 .set_pull
= exynos4_gpio_setpull
,
495 .get_pull
= exynos4_gpio_getpull
,
498 .set_pull
= exynos4_gpio_setpull
,
499 .get_pull
= exynos4_gpio_getpull
,
504 * Default routines for controlling GPIO, based on the original S3C24XX
505 * GPIO functions which deal with the case where each gpio bank of the
506 * chip is as following:
508 * base + 0x00: Control register, 2 bits per gpio
509 * gpio n: 2 bits starting at (2*n)
510 * 00 = input, 01 = output, others mean special-function
511 * base + 0x04: Data register, 1 bit per gpio
515 static int samsung_gpiolib_2bit_input(struct gpio_chip
*chip
, unsigned offset
)
517 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
518 void __iomem
*base
= ourchip
->base
;
522 samsung_gpio_lock(ourchip
, flags
);
524 con
= __raw_readl(base
+ 0x00);
525 con
&= ~(3 << (offset
* 2));
527 __raw_writel(con
, base
+ 0x00);
529 samsung_gpio_unlock(ourchip
, flags
);
533 static int samsung_gpiolib_2bit_output(struct gpio_chip
*chip
,
534 unsigned offset
, int value
)
536 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
537 void __iomem
*base
= ourchip
->base
;
542 samsung_gpio_lock(ourchip
, flags
);
544 dat
= __raw_readl(base
+ 0x04);
545 dat
&= ~(1 << offset
);
548 __raw_writel(dat
, base
+ 0x04);
550 con
= __raw_readl(base
+ 0x00);
551 con
&= ~(3 << (offset
* 2));
552 con
|= 1 << (offset
* 2);
554 __raw_writel(con
, base
+ 0x00);
555 __raw_writel(dat
, base
+ 0x04);
557 samsung_gpio_unlock(ourchip
, flags
);
562 * The samsung_gpiolib_4bit routines are to control the gpio banks where
563 * the gpio configuration register (GPxCON) has 4 bits per GPIO, as the
566 * base + 0x00: Control register, 4 bits per gpio
567 * gpio n: 4 bits starting at (4*n)
568 * 0000 = input, 0001 = output, others mean special-function
569 * base + 0x04: Data register, 1 bit per gpio
572 * Note, since the data register is one bit per gpio and is at base + 0x4
573 * we can use samsung_gpiolib_get and samsung_gpiolib_set to change the
574 * state of the output.
577 static int samsung_gpiolib_4bit_input(struct gpio_chip
*chip
,
580 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
581 void __iomem
*base
= ourchip
->base
;
584 con
= __raw_readl(base
+ GPIOCON_OFF
);
585 con
&= ~(0xf << con_4bit_shift(offset
));
586 __raw_writel(con
, base
+ GPIOCON_OFF
);
588 gpio_dbg("%s: %p: CON now %08lx\n", __func__
, base
, con
);
593 static int samsung_gpiolib_4bit_output(struct gpio_chip
*chip
,
594 unsigned int offset
, int value
)
596 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
597 void __iomem
*base
= ourchip
->base
;
601 con
= __raw_readl(base
+ GPIOCON_OFF
);
602 con
&= ~(0xf << con_4bit_shift(offset
));
603 con
|= 0x1 << con_4bit_shift(offset
);
605 dat
= __raw_readl(base
+ GPIODAT_OFF
);
610 dat
&= ~(1 << offset
);
612 __raw_writel(dat
, base
+ GPIODAT_OFF
);
613 __raw_writel(con
, base
+ GPIOCON_OFF
);
614 __raw_writel(dat
, base
+ GPIODAT_OFF
);
616 gpio_dbg("%s: %p: CON %08lx, DAT %08lx\n", __func__
, base
, con
, dat
);
622 * The next set of routines are for the case where the GPIO configuration
623 * registers are 4 bits per GPIO but there is more than one register (the
624 * bank has more than 8 GPIOs.
626 * This case is the similar to the 4 bit case, but the registers are as
629 * base + 0x00: Control register, 4 bits per gpio (lower 8 GPIOs)
630 * gpio n: 4 bits starting at (4*n)
631 * 0000 = input, 0001 = output, others mean special-function
632 * base + 0x04: Control register, 4 bits per gpio (up to 8 additions GPIOs)
633 * gpio n: 4 bits starting at (4*n)
634 * 0000 = input, 0001 = output, others mean special-function
635 * base + 0x08: Data register, 1 bit per gpio
638 * To allow us to use the samsung_gpiolib_get and samsung_gpiolib_set
639 * routines we store the 'base + 0x4' address so that these routines see
640 * the data register at ourchip->base + 0x04.
643 static int samsung_gpiolib_4bit2_input(struct gpio_chip
*chip
,
646 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
647 void __iomem
*base
= ourchip
->base
;
648 void __iomem
*regcon
= base
;
656 con
= __raw_readl(regcon
);
657 con
&= ~(0xf << con_4bit_shift(offset
));
658 __raw_writel(con
, regcon
);
660 gpio_dbg("%s: %p: CON %08lx\n", __func__
, base
, con
);
665 static int samsung_gpiolib_4bit2_output(struct gpio_chip
*chip
,
666 unsigned int offset
, int value
)
668 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
669 void __iomem
*base
= ourchip
->base
;
670 void __iomem
*regcon
= base
;
673 unsigned con_offset
= offset
;
680 con
= __raw_readl(regcon
);
681 con
&= ~(0xf << con_4bit_shift(con_offset
));
682 con
|= 0x1 << con_4bit_shift(con_offset
);
684 dat
= __raw_readl(base
+ GPIODAT_OFF
);
689 dat
&= ~(1 << offset
);
691 __raw_writel(dat
, base
+ GPIODAT_OFF
);
692 __raw_writel(con
, regcon
);
693 __raw_writel(dat
, base
+ GPIODAT_OFF
);
695 gpio_dbg("%s: %p: CON %08lx, DAT %08lx\n", __func__
, base
, con
, dat
);
700 #ifdef CONFIG_PLAT_S3C24XX
701 /* The next set of routines are for the case of s3c24xx bank a */
703 static int s3c24xx_gpiolib_banka_input(struct gpio_chip
*chip
, unsigned offset
)
708 static int s3c24xx_gpiolib_banka_output(struct gpio_chip
*chip
,
709 unsigned offset
, int value
)
711 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
712 void __iomem
*base
= ourchip
->base
;
717 local_irq_save(flags
);
719 con
= __raw_readl(base
+ 0x00);
720 dat
= __raw_readl(base
+ 0x04);
722 dat
&= ~(1 << offset
);
726 __raw_writel(dat
, base
+ 0x04);
728 con
&= ~(1 << offset
);
730 __raw_writel(con
, base
+ 0x00);
731 __raw_writel(dat
, base
+ 0x04);
733 local_irq_restore(flags
);
738 /* The next set of routines are for the case of s5p64x0 bank r */
740 static int s5p64x0_gpiolib_rbank_input(struct gpio_chip
*chip
,
743 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
744 void __iomem
*base
= ourchip
->base
;
745 void __iomem
*regcon
= base
;
765 samsung_gpio_lock(ourchip
, flags
);
767 con
= __raw_readl(regcon
);
768 con
&= ~(0xf << con_4bit_shift(offset
));
769 __raw_writel(con
, regcon
);
771 samsung_gpio_unlock(ourchip
, flags
);
776 static int s5p64x0_gpiolib_rbank_output(struct gpio_chip
*chip
,
777 unsigned int offset
, int value
)
779 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
780 void __iomem
*base
= ourchip
->base
;
781 void __iomem
*regcon
= base
;
785 unsigned con_offset
= offset
;
787 switch (con_offset
) {
803 samsung_gpio_lock(ourchip
, flags
);
805 con
= __raw_readl(regcon
);
806 con
&= ~(0xf << con_4bit_shift(con_offset
));
807 con
|= 0x1 << con_4bit_shift(con_offset
);
809 dat
= __raw_readl(base
+ GPIODAT_OFF
);
813 dat
&= ~(1 << offset
);
815 __raw_writel(con
, regcon
);
816 __raw_writel(dat
, base
+ GPIODAT_OFF
);
818 samsung_gpio_unlock(ourchip
, flags
);
823 static void samsung_gpiolib_set(struct gpio_chip
*chip
,
824 unsigned offset
, int value
)
826 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
827 void __iomem
*base
= ourchip
->base
;
831 samsung_gpio_lock(ourchip
, flags
);
833 dat
= __raw_readl(base
+ 0x04);
834 dat
&= ~(1 << offset
);
837 __raw_writel(dat
, base
+ 0x04);
839 samsung_gpio_unlock(ourchip
, flags
);
842 static int samsung_gpiolib_get(struct gpio_chip
*chip
, unsigned offset
)
844 struct samsung_gpio_chip
*ourchip
= to_samsung_gpio(chip
);
847 val
= __raw_readl(ourchip
->base
+ 0x04);
855 * CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios
856 * for use with the configuration calls, and other parts of the s3c gpiolib
859 * Not all s3c support code will need this, as some configurations of cpu
860 * may only support one or two different configuration options and have an
861 * easy gpio to samsung_gpio_chip mapping function. If this is the case, then
862 * the machine support file should provide its own samsung_gpiolib_getchip()
863 * and any other necessary functions.
866 #ifdef CONFIG_S3C_GPIO_TRACK
867 struct samsung_gpio_chip
*s3c_gpios
[S3C_GPIO_END
];
869 static __init
void s3c_gpiolib_track(struct samsung_gpio_chip
*chip
)
874 gpn
= chip
->chip
.base
;
875 for (i
= 0; i
< chip
->chip
.ngpio
; i
++, gpn
++) {
876 BUG_ON(gpn
>= ARRAY_SIZE(s3c_gpios
));
877 s3c_gpios
[gpn
] = chip
;
880 #endif /* CONFIG_S3C_GPIO_TRACK */
883 * samsung_gpiolib_add() - add the Samsung gpio_chip.
884 * @chip: The chip to register
886 * This is a wrapper to gpiochip_add() that takes our specific gpio chip
887 * information and makes the necessary alterations for the platform and
888 * notes the information for use with the configuration systems and any
889 * other parts of the system.
892 static void __init
samsung_gpiolib_add(struct samsung_gpio_chip
*chip
)
894 struct gpio_chip
*gc
= &chip
->chip
;
901 spin_lock_init(&chip
->lock
);
903 if (!gc
->direction_input
)
904 gc
->direction_input
= samsung_gpiolib_2bit_input
;
905 if (!gc
->direction_output
)
906 gc
->direction_output
= samsung_gpiolib_2bit_output
;
908 gc
->set
= samsung_gpiolib_set
;
910 gc
->get
= samsung_gpiolib_get
;
913 if (chip
->pm
!= NULL
) {
914 if (!chip
->pm
->save
|| !chip
->pm
->resume
)
915 printk(KERN_ERR
"gpio: %s has missing PM functions\n",
918 printk(KERN_ERR
"gpio: %s has no PM function\n", gc
->label
);
921 /* gpiochip_add() prints own failure message on error. */
922 ret
= gpiochip_add(gc
);
924 s3c_gpiolib_track(chip
);
927 static void __init
s3c24xx_gpiolib_add_chips(struct samsung_gpio_chip
*chip
,
928 int nr_chips
, void __iomem
*base
)
931 struct gpio_chip
*gc
= &chip
->chip
;
933 for (i
= 0 ; i
< nr_chips
; i
++, chip
++) {
934 /* skip banks not present on SoC */
935 if (chip
->chip
.base
>= S3C_GPIO_END
)
939 chip
->config
= &s3c24xx_gpiocfg_default
;
941 chip
->pm
= __gpio_pm(&samsung_gpio_pm_2bit
);
942 if ((base
!= NULL
) && (chip
->base
== NULL
))
943 chip
->base
= base
+ ((i
) * 0x10);
945 if (!gc
->direction_input
)
946 gc
->direction_input
= samsung_gpiolib_2bit_input
;
947 if (!gc
->direction_output
)
948 gc
->direction_output
= samsung_gpiolib_2bit_output
;
950 samsung_gpiolib_add(chip
);
954 static void __init
samsung_gpiolib_add_2bit_chips(struct samsung_gpio_chip
*chip
,
955 int nr_chips
, void __iomem
*base
,
960 for (i
= 0 ; i
< nr_chips
; i
++, chip
++) {
961 chip
->chip
.direction_input
= samsung_gpiolib_2bit_input
;
962 chip
->chip
.direction_output
= samsung_gpiolib_2bit_output
;
965 chip
->config
= &samsung_gpio_cfgs
[7];
967 chip
->pm
= __gpio_pm(&samsung_gpio_pm_2bit
);
968 if ((base
!= NULL
) && (chip
->base
== NULL
))
969 chip
->base
= base
+ ((i
) * offset
);
971 samsung_gpiolib_add(chip
);
976 * samsung_gpiolib_add_4bit_chips - 4bit single register GPIO config.
977 * @chip: The gpio chip that is being configured.
978 * @nr_chips: The no of chips (gpio ports) for the GPIO being configured.
980 * This helper deal with the GPIO cases where the control register has 4 bits
981 * of control per GPIO, generally in the form of:
984 * others = Special functions (dependent on bank)
986 * Note, since the code to deal with the case where there are two control
987 * registers instead of one, we do not have a separate set of function
988 * (samsung_gpiolib_add_4bit2_chips)for each case.
991 static void __init
samsung_gpiolib_add_4bit_chips(struct samsung_gpio_chip
*chip
,
992 int nr_chips
, void __iomem
*base
)
996 for (i
= 0 ; i
< nr_chips
; i
++, chip
++) {
997 chip
->chip
.direction_input
= samsung_gpiolib_4bit_input
;
998 chip
->chip
.direction_output
= samsung_gpiolib_4bit_output
;
1001 chip
->config
= &samsung_gpio_cfgs
[2];
1003 chip
->pm
= __gpio_pm(&samsung_gpio_pm_4bit
);
1004 if ((base
!= NULL
) && (chip
->base
== NULL
))
1005 chip
->base
= base
+ ((i
) * 0x20);
1007 samsung_gpiolib_add(chip
);
1011 static void __init
samsung_gpiolib_add_4bit2_chips(struct samsung_gpio_chip
*chip
,
1014 for (; nr_chips
> 0; nr_chips
--, chip
++) {
1015 chip
->chip
.direction_input
= samsung_gpiolib_4bit2_input
;
1016 chip
->chip
.direction_output
= samsung_gpiolib_4bit2_output
;
1019 chip
->config
= &samsung_gpio_cfgs
[2];
1021 chip
->pm
= __gpio_pm(&samsung_gpio_pm_4bit
);
1023 samsung_gpiolib_add(chip
);
1027 static void __init
s5p64x0_gpiolib_add_rbank(struct samsung_gpio_chip
*chip
,
1030 for (; nr_chips
> 0; nr_chips
--, chip
++) {
1031 chip
->chip
.direction_input
= s5p64x0_gpiolib_rbank_input
;
1032 chip
->chip
.direction_output
= s5p64x0_gpiolib_rbank_output
;
1035 chip
->pm
= __gpio_pm(&samsung_gpio_pm_4bit
);
1037 samsung_gpiolib_add(chip
);
1041 int samsung_gpiolib_to_irq(struct gpio_chip
*chip
, unsigned int offset
)
1043 struct samsung_gpio_chip
*samsung_chip
= container_of(chip
, struct samsung_gpio_chip
, chip
);
1045 return samsung_chip
->irq_base
+ offset
;
1048 #ifdef CONFIG_PLAT_S3C24XX
1049 static int s3c24xx_gpiolib_fbank_to_irq(struct gpio_chip
*chip
, unsigned offset
)
1052 return IRQ_EINT0
+ offset
;
1055 return IRQ_EINT4
+ offset
- 4;
1061 #ifdef CONFIG_PLAT_S3C64XX
1062 static int s3c64xx_gpiolib_mbank_to_irq(struct gpio_chip
*chip
, unsigned pin
)
1064 return pin
< 5 ? IRQ_EINT(23) + pin
: -ENXIO
;
1067 static int s3c64xx_gpiolib_lbank_to_irq(struct gpio_chip
*chip
, unsigned pin
)
1069 return pin
>= 8 ? IRQ_EINT(16) + pin
- 8 : -ENXIO
;
1073 struct samsung_gpio_chip s3c24xx_gpios
[] = {
1074 #ifdef CONFIG_PLAT_S3C24XX
1076 .config
= &s3c24xx_gpiocfg_banka
,
1078 .base
= S3C2410_GPA(0),
1079 .owner
= THIS_MODULE
,
1082 .direction_input
= s3c24xx_gpiolib_banka_input
,
1083 .direction_output
= s3c24xx_gpiolib_banka_output
,
1087 .base
= S3C2410_GPB(0),
1088 .owner
= THIS_MODULE
,
1094 .base
= S3C2410_GPC(0),
1095 .owner
= THIS_MODULE
,
1101 .base
= S3C2410_GPD(0),
1102 .owner
= THIS_MODULE
,
1108 .base
= S3C2410_GPE(0),
1110 .owner
= THIS_MODULE
,
1115 .base
= S3C2410_GPF(0),
1116 .owner
= THIS_MODULE
,
1119 .to_irq
= s3c24xx_gpiolib_fbank_to_irq
,
1122 .irq_base
= IRQ_EINT8
,
1124 .base
= S3C2410_GPG(0),
1125 .owner
= THIS_MODULE
,
1128 .to_irq
= samsung_gpiolib_to_irq
,
1132 .base
= S3C2410_GPH(0),
1133 .owner
= THIS_MODULE
,
1138 /* GPIOS for the S3C2443 and later devices. */
1140 .base
= S3C2440_GPJCON
,
1142 .base
= S3C2410_GPJ(0),
1143 .owner
= THIS_MODULE
,
1148 .base
= S3C2443_GPKCON
,
1150 .base
= S3C2410_GPK(0),
1151 .owner
= THIS_MODULE
,
1156 .base
= S3C2443_GPLCON
,
1158 .base
= S3C2410_GPL(0),
1159 .owner
= THIS_MODULE
,
1164 .base
= S3C2443_GPMCON
,
1166 .base
= S3C2410_GPM(0),
1167 .owner
= THIS_MODULE
,
1176 * GPIO bank summary:
1178 * Bank GPIOs Style SlpCon ExtInt Group
1184 * F 16 2Bit Yes 4 [1]
1186 * H 10 4Bit[2] Yes 6
1187 * I 16 2Bit Yes None
1188 * J 12 2Bit Yes None
1189 * K 16 4Bit[2] No None
1190 * L 15 4Bit[2] No None
1191 * M 6 4Bit No IRQ_EINT
1192 * N 16 2Bit No IRQ_EINT
1197 * [1] BANKF pins 14,15 do not form part of the external interrupt sources
1198 * [2] BANK has two control registers, GPxCON0 and GPxCON1
1201 static struct samsung_gpio_chip s3c64xx_gpios_4bit
[] = {
1202 #ifdef CONFIG_PLAT_S3C64XX
1205 .base
= S3C64XX_GPA(0),
1206 .ngpio
= S3C64XX_GPIO_A_NR
,
1211 .base
= S3C64XX_GPB(0),
1212 .ngpio
= S3C64XX_GPIO_B_NR
,
1217 .base
= S3C64XX_GPC(0),
1218 .ngpio
= S3C64XX_GPIO_C_NR
,
1223 .base
= S3C64XX_GPD(0),
1224 .ngpio
= S3C64XX_GPIO_D_NR
,
1228 .config
= &samsung_gpio_cfgs
[0],
1230 .base
= S3C64XX_GPE(0),
1231 .ngpio
= S3C64XX_GPIO_E_NR
,
1235 .base
= S3C64XX_GPG_BASE
,
1237 .base
= S3C64XX_GPG(0),
1238 .ngpio
= S3C64XX_GPIO_G_NR
,
1242 .base
= S3C64XX_GPM_BASE
,
1243 .config
= &samsung_gpio_cfgs
[1],
1245 .base
= S3C64XX_GPM(0),
1246 .ngpio
= S3C64XX_GPIO_M_NR
,
1248 .to_irq
= s3c64xx_gpiolib_mbank_to_irq
,
1254 static struct samsung_gpio_chip s3c64xx_gpios_4bit2
[] = {
1255 #ifdef CONFIG_PLAT_S3C64XX
1257 .base
= S3C64XX_GPH_BASE
+ 0x4,
1259 .base
= S3C64XX_GPH(0),
1260 .ngpio
= S3C64XX_GPIO_H_NR
,
1264 .base
= S3C64XX_GPK_BASE
+ 0x4,
1265 .config
= &samsung_gpio_cfgs
[0],
1267 .base
= S3C64XX_GPK(0),
1268 .ngpio
= S3C64XX_GPIO_K_NR
,
1272 .base
= S3C64XX_GPL_BASE
+ 0x4,
1273 .config
= &samsung_gpio_cfgs
[1],
1275 .base
= S3C64XX_GPL(0),
1276 .ngpio
= S3C64XX_GPIO_L_NR
,
1278 .to_irq
= s3c64xx_gpiolib_lbank_to_irq
,
1284 static struct samsung_gpio_chip s3c64xx_gpios_2bit
[] = {
1285 #ifdef CONFIG_PLAT_S3C64XX
1287 .base
= S3C64XX_GPF_BASE
,
1288 .config
= &samsung_gpio_cfgs
[6],
1290 .base
= S3C64XX_GPF(0),
1291 .ngpio
= S3C64XX_GPIO_F_NR
,
1295 .config
= &samsung_gpio_cfgs
[7],
1297 .base
= S3C64XX_GPI(0),
1298 .ngpio
= S3C64XX_GPIO_I_NR
,
1302 .config
= &samsung_gpio_cfgs
[7],
1304 .base
= S3C64XX_GPJ(0),
1305 .ngpio
= S3C64XX_GPIO_J_NR
,
1309 .config
= &samsung_gpio_cfgs
[6],
1311 .base
= S3C64XX_GPO(0),
1312 .ngpio
= S3C64XX_GPIO_O_NR
,
1316 .config
= &samsung_gpio_cfgs
[6],
1318 .base
= S3C64XX_GPP(0),
1319 .ngpio
= S3C64XX_GPIO_P_NR
,
1323 .config
= &samsung_gpio_cfgs
[6],
1325 .base
= S3C64XX_GPQ(0),
1326 .ngpio
= S3C64XX_GPIO_Q_NR
,
1330 .base
= S3C64XX_GPN_BASE
,
1331 .irq_base
= IRQ_EINT(0),
1332 .config
= &samsung_gpio_cfgs
[5],
1334 .base
= S3C64XX_GPN(0),
1335 .ngpio
= S3C64XX_GPIO_N_NR
,
1337 .to_irq
= samsung_gpiolib_to_irq
,
1344 * S5P6440 GPIO bank summary:
1346 * Bank GPIOs Style SlpCon ExtInt Group
1350 * F 2 2Bit Yes 4 [1]
1352 * H 10 4Bit[2] Yes 6
1353 * I 16 2Bit Yes None
1354 * J 12 2Bit Yes None
1355 * N 16 2Bit No IRQ_EINT
1357 * R 15 4Bit[2] Yes 8
1360 static struct samsung_gpio_chip s5p6440_gpios_4bit
[] = {
1361 #ifdef CONFIG_CPU_S5P6440
1364 .base
= S5P6440_GPA(0),
1365 .ngpio
= S5P6440_GPIO_A_NR
,
1370 .base
= S5P6440_GPB(0),
1371 .ngpio
= S5P6440_GPIO_B_NR
,
1376 .base
= S5P6440_GPC(0),
1377 .ngpio
= S5P6440_GPIO_C_NR
,
1381 .base
= S5P64X0_GPG_BASE
,
1383 .base
= S5P6440_GPG(0),
1384 .ngpio
= S5P6440_GPIO_G_NR
,
1391 static struct samsung_gpio_chip s5p6440_gpios_4bit2
[] = {
1392 #ifdef CONFIG_CPU_S5P6440
1394 .base
= S5P64X0_GPH_BASE
+ 0x4,
1396 .base
= S5P6440_GPH(0),
1397 .ngpio
= S5P6440_GPIO_H_NR
,
1404 static struct samsung_gpio_chip s5p6440_gpios_rbank
[] = {
1405 #ifdef CONFIG_CPU_S5P6440
1407 .base
= S5P64X0_GPR_BASE
+ 0x4,
1408 .config
= &s5p64x0_gpio_cfg_rbank
,
1410 .base
= S5P6440_GPR(0),
1411 .ngpio
= S5P6440_GPIO_R_NR
,
1418 static struct samsung_gpio_chip s5p6440_gpios_2bit
[] = {
1419 #ifdef CONFIG_CPU_S5P6440
1421 .base
= S5P64X0_GPF_BASE
,
1422 .config
= &samsung_gpio_cfgs
[6],
1424 .base
= S5P6440_GPF(0),
1425 .ngpio
= S5P6440_GPIO_F_NR
,
1429 .base
= S5P64X0_GPI_BASE
,
1430 .config
= &samsung_gpio_cfgs
[4],
1432 .base
= S5P6440_GPI(0),
1433 .ngpio
= S5P6440_GPIO_I_NR
,
1437 .base
= S5P64X0_GPJ_BASE
,
1438 .config
= &samsung_gpio_cfgs
[4],
1440 .base
= S5P6440_GPJ(0),
1441 .ngpio
= S5P6440_GPIO_J_NR
,
1445 .base
= S5P64X0_GPN_BASE
,
1446 .config
= &samsung_gpio_cfgs
[5],
1448 .base
= S5P6440_GPN(0),
1449 .ngpio
= S5P6440_GPIO_N_NR
,
1453 .base
= S5P64X0_GPP_BASE
,
1454 .config
= &samsung_gpio_cfgs
[6],
1456 .base
= S5P6440_GPP(0),
1457 .ngpio
= S5P6440_GPIO_P_NR
,
1465 * S5P6450 GPIO bank summary:
1467 * Bank GPIOs Style SlpCon ExtInt Group
1473 * G 14 4Bit[2] Yes 5
1474 * H 10 4Bit[2] Yes 6
1475 * I 16 2Bit Yes None
1476 * J 12 2Bit Yes None
1478 * N 16 2Bit No IRQ_EINT
1480 * Q 14 2Bit Yes None
1481 * R 15 4Bit[2] Yes None
1484 * [1] BANKF pins 14,15 do not form part of the external interrupt sources
1485 * [2] BANK has two control registers, GPxCON0 and GPxCON1
1488 static struct samsung_gpio_chip s5p6450_gpios_4bit
[] = {
1489 #ifdef CONFIG_CPU_S5P6450
1492 .base
= S5P6450_GPA(0),
1493 .ngpio
= S5P6450_GPIO_A_NR
,
1498 .base
= S5P6450_GPB(0),
1499 .ngpio
= S5P6450_GPIO_B_NR
,
1504 .base
= S5P6450_GPC(0),
1505 .ngpio
= S5P6450_GPIO_C_NR
,
1510 .base
= S5P6450_GPD(0),
1511 .ngpio
= S5P6450_GPIO_D_NR
,
1515 .base
= S5P6450_GPK_BASE
,
1517 .base
= S5P6450_GPK(0),
1518 .ngpio
= S5P6450_GPIO_K_NR
,
1525 static struct samsung_gpio_chip s5p6450_gpios_4bit2
[] = {
1526 #ifdef CONFIG_CPU_S5P6450
1528 .base
= S5P64X0_GPG_BASE
+ 0x4,
1530 .base
= S5P6450_GPG(0),
1531 .ngpio
= S5P6450_GPIO_G_NR
,
1535 .base
= S5P64X0_GPH_BASE
+ 0x4,
1537 .base
= S5P6450_GPH(0),
1538 .ngpio
= S5P6450_GPIO_H_NR
,
1545 static struct samsung_gpio_chip s5p6450_gpios_rbank
[] = {
1546 #ifdef CONFIG_CPU_S5P6450
1548 .base
= S5P64X0_GPR_BASE
+ 0x4,
1549 .config
= &s5p64x0_gpio_cfg_rbank
,
1551 .base
= S5P6450_GPR(0),
1552 .ngpio
= S5P6450_GPIO_R_NR
,
1559 static struct samsung_gpio_chip s5p6450_gpios_2bit
[] = {
1560 #ifdef CONFIG_CPU_S5P6450
1562 .base
= S5P64X0_GPF_BASE
,
1563 .config
= &samsung_gpio_cfgs
[6],
1565 .base
= S5P6450_GPF(0),
1566 .ngpio
= S5P6450_GPIO_F_NR
,
1570 .base
= S5P64X0_GPI_BASE
,
1571 .config
= &samsung_gpio_cfgs
[4],
1573 .base
= S5P6450_GPI(0),
1574 .ngpio
= S5P6450_GPIO_I_NR
,
1578 .base
= S5P64X0_GPJ_BASE
,
1579 .config
= &samsung_gpio_cfgs
[4],
1581 .base
= S5P6450_GPJ(0),
1582 .ngpio
= S5P6450_GPIO_J_NR
,
1586 .base
= S5P64X0_GPN_BASE
,
1587 .config
= &samsung_gpio_cfgs
[5],
1589 .base
= S5P6450_GPN(0),
1590 .ngpio
= S5P6450_GPIO_N_NR
,
1594 .base
= S5P64X0_GPP_BASE
,
1595 .config
= &samsung_gpio_cfgs
[6],
1597 .base
= S5P6450_GPP(0),
1598 .ngpio
= S5P6450_GPIO_P_NR
,
1602 .base
= S5P6450_GPQ_BASE
,
1603 .config
= &samsung_gpio_cfgs
[5],
1605 .base
= S5P6450_GPQ(0),
1606 .ngpio
= S5P6450_GPIO_Q_NR
,
1610 .base
= S5P6450_GPS_BASE
,
1611 .config
= &samsung_gpio_cfgs
[6],
1613 .base
= S5P6450_GPS(0),
1614 .ngpio
= S5P6450_GPIO_S_NR
,
1622 * S5PC100 GPIO bank summary:
1624 * Bank GPIOs Style INT Type
1625 * A0 8 4Bit GPIO_INT0
1626 * A1 5 4Bit GPIO_INT1
1627 * B 8 4Bit GPIO_INT2
1628 * C 5 4Bit GPIO_INT3
1629 * D 7 4Bit GPIO_INT4
1630 * E0 8 4Bit GPIO_INT5
1631 * E1 6 4Bit GPIO_INT6
1632 * F0 8 4Bit GPIO_INT7
1633 * F1 8 4Bit GPIO_INT8
1634 * F2 8 4Bit GPIO_INT9
1635 * F3 4 4Bit GPIO_INT10
1636 * G0 8 4Bit GPIO_INT11
1637 * G1 3 4Bit GPIO_INT12
1638 * G2 7 4Bit GPIO_INT13
1639 * G3 7 4Bit GPIO_INT14
1640 * H0 8 4Bit WKUP_INT
1641 * H1 8 4Bit WKUP_INT
1642 * H2 8 4Bit WKUP_INT
1643 * H3 8 4Bit WKUP_INT
1644 * I 8 4Bit GPIO_INT15
1645 * J0 8 4Bit GPIO_INT16
1646 * J1 5 4Bit GPIO_INT17
1647 * J2 8 4Bit GPIO_INT18
1648 * J3 8 4Bit GPIO_INT19
1649 * J4 4 4Bit GPIO_INT20
1660 static struct samsung_gpio_chip s5pc100_gpios_4bit
[] = {
1661 #ifdef CONFIG_CPU_S5PC100
1664 .base
= S5PC100_GPA0(0),
1665 .ngpio
= S5PC100_GPIO_A0_NR
,
1670 .base
= S5PC100_GPA1(0),
1671 .ngpio
= S5PC100_GPIO_A1_NR
,
1676 .base
= S5PC100_GPB(0),
1677 .ngpio
= S5PC100_GPIO_B_NR
,
1682 .base
= S5PC100_GPC(0),
1683 .ngpio
= S5PC100_GPIO_C_NR
,
1688 .base
= S5PC100_GPD(0),
1689 .ngpio
= S5PC100_GPIO_D_NR
,
1694 .base
= S5PC100_GPE0(0),
1695 .ngpio
= S5PC100_GPIO_E0_NR
,
1700 .base
= S5PC100_GPE1(0),
1701 .ngpio
= S5PC100_GPIO_E1_NR
,
1706 .base
= S5PC100_GPF0(0),
1707 .ngpio
= S5PC100_GPIO_F0_NR
,
1712 .base
= S5PC100_GPF1(0),
1713 .ngpio
= S5PC100_GPIO_F1_NR
,
1718 .base
= S5PC100_GPF2(0),
1719 .ngpio
= S5PC100_GPIO_F2_NR
,
1724 .base
= S5PC100_GPF3(0),
1725 .ngpio
= S5PC100_GPIO_F3_NR
,
1730 .base
= S5PC100_GPG0(0),
1731 .ngpio
= S5PC100_GPIO_G0_NR
,
1736 .base
= S5PC100_GPG1(0),
1737 .ngpio
= S5PC100_GPIO_G1_NR
,
1742 .base
= S5PC100_GPG2(0),
1743 .ngpio
= S5PC100_GPIO_G2_NR
,
1748 .base
= S5PC100_GPG3(0),
1749 .ngpio
= S5PC100_GPIO_G3_NR
,
1754 .base
= S5PC100_GPI(0),
1755 .ngpio
= S5PC100_GPIO_I_NR
,
1760 .base
= S5PC100_GPJ0(0),
1761 .ngpio
= S5PC100_GPIO_J0_NR
,
1766 .base
= S5PC100_GPJ1(0),
1767 .ngpio
= S5PC100_GPIO_J1_NR
,
1772 .base
= S5PC100_GPJ2(0),
1773 .ngpio
= S5PC100_GPIO_J2_NR
,
1778 .base
= S5PC100_GPJ3(0),
1779 .ngpio
= S5PC100_GPIO_J3_NR
,
1784 .base
= S5PC100_GPJ4(0),
1785 .ngpio
= S5PC100_GPIO_J4_NR
,
1790 .base
= S5PC100_GPK0(0),
1791 .ngpio
= S5PC100_GPIO_K0_NR
,
1796 .base
= S5PC100_GPK1(0),
1797 .ngpio
= S5PC100_GPIO_K1_NR
,
1802 .base
= S5PC100_GPK2(0),
1803 .ngpio
= S5PC100_GPIO_K2_NR
,
1808 .base
= S5PC100_GPK3(0),
1809 .ngpio
= S5PC100_GPIO_K3_NR
,
1814 .base
= S5PC100_GPL0(0),
1815 .ngpio
= S5PC100_GPIO_L0_NR
,
1820 .base
= S5PC100_GPL1(0),
1821 .ngpio
= S5PC100_GPIO_L1_NR
,
1826 .base
= S5PC100_GPL2(0),
1827 .ngpio
= S5PC100_GPIO_L2_NR
,
1832 .base
= S5PC100_GPL3(0),
1833 .ngpio
= S5PC100_GPIO_L3_NR
,
1838 .base
= S5PC100_GPL4(0),
1839 .ngpio
= S5PC100_GPIO_L4_NR
,
1843 .base
= (S5P_VA_GPIO
+ 0xC00),
1844 .irq_base
= IRQ_EINT(0),
1846 .base
= S5PC100_GPH0(0),
1847 .ngpio
= S5PC100_GPIO_H0_NR
,
1849 .to_irq
= samsung_gpiolib_to_irq
,
1852 .base
= (S5P_VA_GPIO
+ 0xC20),
1853 .irq_base
= IRQ_EINT(8),
1855 .base
= S5PC100_GPH1(0),
1856 .ngpio
= S5PC100_GPIO_H1_NR
,
1858 .to_irq
= samsung_gpiolib_to_irq
,
1861 .base
= (S5P_VA_GPIO
+ 0xC40),
1862 .irq_base
= IRQ_EINT(16),
1864 .base
= S5PC100_GPH2(0),
1865 .ngpio
= S5PC100_GPIO_H2_NR
,
1867 .to_irq
= samsung_gpiolib_to_irq
,
1870 .base
= (S5P_VA_GPIO
+ 0xC60),
1871 .irq_base
= IRQ_EINT(24),
1873 .base
= S5PC100_GPH3(0),
1874 .ngpio
= S5PC100_GPIO_H3_NR
,
1876 .to_irq
= samsung_gpiolib_to_irq
,
1883 * Followings are the gpio banks in S5PV210/S5PC110
1885 * The 'config' member when left to NULL, is initialized to the default
1886 * structure samsung_gpio_cfgs[3] in the init function below.
1888 * The 'base' member is also initialized in the init function below.
1889 * Note: The initialization of 'base' member of samsung_gpio_chip structure
1890 * uses the above macro and depends on the banks being listed in order here.
1893 static struct samsung_gpio_chip s5pv210_gpios_4bit
[] = {
1894 #ifdef CONFIG_CPU_S5PV210
1897 .base
= S5PV210_GPA0(0),
1898 .ngpio
= S5PV210_GPIO_A0_NR
,
1903 .base
= S5PV210_GPA1(0),
1904 .ngpio
= S5PV210_GPIO_A1_NR
,
1909 .base
= S5PV210_GPB(0),
1910 .ngpio
= S5PV210_GPIO_B_NR
,
1915 .base
= S5PV210_GPC0(0),
1916 .ngpio
= S5PV210_GPIO_C0_NR
,
1921 .base
= S5PV210_GPC1(0),
1922 .ngpio
= S5PV210_GPIO_C1_NR
,
1927 .base
= S5PV210_GPD0(0),
1928 .ngpio
= S5PV210_GPIO_D0_NR
,
1933 .base
= S5PV210_GPD1(0),
1934 .ngpio
= S5PV210_GPIO_D1_NR
,
1939 .base
= S5PV210_GPE0(0),
1940 .ngpio
= S5PV210_GPIO_E0_NR
,
1945 .base
= S5PV210_GPE1(0),
1946 .ngpio
= S5PV210_GPIO_E1_NR
,
1951 .base
= S5PV210_GPF0(0),
1952 .ngpio
= S5PV210_GPIO_F0_NR
,
1957 .base
= S5PV210_GPF1(0),
1958 .ngpio
= S5PV210_GPIO_F1_NR
,
1963 .base
= S5PV210_GPF2(0),
1964 .ngpio
= S5PV210_GPIO_F2_NR
,
1969 .base
= S5PV210_GPF3(0),
1970 .ngpio
= S5PV210_GPIO_F3_NR
,
1975 .base
= S5PV210_GPG0(0),
1976 .ngpio
= S5PV210_GPIO_G0_NR
,
1981 .base
= S5PV210_GPG1(0),
1982 .ngpio
= S5PV210_GPIO_G1_NR
,
1987 .base
= S5PV210_GPG2(0),
1988 .ngpio
= S5PV210_GPIO_G2_NR
,
1993 .base
= S5PV210_GPG3(0),
1994 .ngpio
= S5PV210_GPIO_G3_NR
,
1999 .base
= S5PV210_GPI(0),
2000 .ngpio
= S5PV210_GPIO_I_NR
,
2005 .base
= S5PV210_GPJ0(0),
2006 .ngpio
= S5PV210_GPIO_J0_NR
,
2011 .base
= S5PV210_GPJ1(0),
2012 .ngpio
= S5PV210_GPIO_J1_NR
,
2017 .base
= S5PV210_GPJ2(0),
2018 .ngpio
= S5PV210_GPIO_J2_NR
,
2023 .base
= S5PV210_GPJ3(0),
2024 .ngpio
= S5PV210_GPIO_J3_NR
,
2029 .base
= S5PV210_GPJ4(0),
2030 .ngpio
= S5PV210_GPIO_J4_NR
,
2035 .base
= S5PV210_MP01(0),
2036 .ngpio
= S5PV210_GPIO_MP01_NR
,
2041 .base
= S5PV210_MP02(0),
2042 .ngpio
= S5PV210_GPIO_MP02_NR
,
2047 .base
= S5PV210_MP03(0),
2048 .ngpio
= S5PV210_GPIO_MP03_NR
,
2053 .base
= S5PV210_MP04(0),
2054 .ngpio
= S5PV210_GPIO_MP04_NR
,
2059 .base
= S5PV210_MP05(0),
2060 .ngpio
= S5PV210_GPIO_MP05_NR
,
2064 .base
= (S5P_VA_GPIO
+ 0xC00),
2065 .irq_base
= IRQ_EINT(0),
2067 .base
= S5PV210_GPH0(0),
2068 .ngpio
= S5PV210_GPIO_H0_NR
,
2070 .to_irq
= samsung_gpiolib_to_irq
,
2073 .base
= (S5P_VA_GPIO
+ 0xC20),
2074 .irq_base
= IRQ_EINT(8),
2076 .base
= S5PV210_GPH1(0),
2077 .ngpio
= S5PV210_GPIO_H1_NR
,
2079 .to_irq
= samsung_gpiolib_to_irq
,
2082 .base
= (S5P_VA_GPIO
+ 0xC40),
2083 .irq_base
= IRQ_EINT(16),
2085 .base
= S5PV210_GPH2(0),
2086 .ngpio
= S5PV210_GPIO_H2_NR
,
2088 .to_irq
= samsung_gpiolib_to_irq
,
2091 .base
= (S5P_VA_GPIO
+ 0xC60),
2092 .irq_base
= IRQ_EINT(24),
2094 .base
= S5PV210_GPH3(0),
2095 .ngpio
= S5PV210_GPIO_H3_NR
,
2097 .to_irq
= samsung_gpiolib_to_irq
,
2104 * Followings are the gpio banks in EXYNOS4210
2106 * The 'config' member when left to NULL, is initialized to the default
2107 * structure samsung_gpio_cfgs[3] in the init function below.
2109 * The 'base' member is also initialized in the init function below.
2110 * Note: The initialization of 'base' member of samsung_gpio_chip structure
2111 * uses the above macro and depends on the banks being listed in order here.
2114 static struct samsung_gpio_chip exynos4_gpios_1
[] = {
2115 #ifdef CONFIG_ARCH_EXYNOS4
2118 .base
= EXYNOS4_GPA0(0),
2119 .ngpio
= EXYNOS4_GPIO_A0_NR
,
2124 .base
= EXYNOS4_GPA1(0),
2125 .ngpio
= EXYNOS4_GPIO_A1_NR
,
2130 .base
= EXYNOS4_GPB(0),
2131 .ngpio
= EXYNOS4_GPIO_B_NR
,
2136 .base
= EXYNOS4_GPC0(0),
2137 .ngpio
= EXYNOS4_GPIO_C0_NR
,
2142 .base
= EXYNOS4_GPC1(0),
2143 .ngpio
= EXYNOS4_GPIO_C1_NR
,
2148 .base
= EXYNOS4_GPD0(0),
2149 .ngpio
= EXYNOS4_GPIO_D0_NR
,
2154 .base
= EXYNOS4_GPD1(0),
2155 .ngpio
= EXYNOS4_GPIO_D1_NR
,
2160 .base
= EXYNOS4_GPE0(0),
2161 .ngpio
= EXYNOS4_GPIO_E0_NR
,
2166 .base
= EXYNOS4_GPE1(0),
2167 .ngpio
= EXYNOS4_GPIO_E1_NR
,
2172 .base
= EXYNOS4_GPE2(0),
2173 .ngpio
= EXYNOS4_GPIO_E2_NR
,
2178 .base
= EXYNOS4_GPE3(0),
2179 .ngpio
= EXYNOS4_GPIO_E3_NR
,
2184 .base
= EXYNOS4_GPE4(0),
2185 .ngpio
= EXYNOS4_GPIO_E4_NR
,
2190 .base
= EXYNOS4_GPF0(0),
2191 .ngpio
= EXYNOS4_GPIO_F0_NR
,
2196 .base
= EXYNOS4_GPF1(0),
2197 .ngpio
= EXYNOS4_GPIO_F1_NR
,
2202 .base
= EXYNOS4_GPF2(0),
2203 .ngpio
= EXYNOS4_GPIO_F2_NR
,
2208 .base
= EXYNOS4_GPF3(0),
2209 .ngpio
= EXYNOS4_GPIO_F3_NR
,
2216 static struct samsung_gpio_chip exynos4_gpios_2
[] = {
2217 #ifdef CONFIG_ARCH_EXYNOS4
2220 .base
= EXYNOS4_GPJ0(0),
2221 .ngpio
= EXYNOS4_GPIO_J0_NR
,
2226 .base
= EXYNOS4_GPJ1(0),
2227 .ngpio
= EXYNOS4_GPIO_J1_NR
,
2232 .base
= EXYNOS4_GPK0(0),
2233 .ngpio
= EXYNOS4_GPIO_K0_NR
,
2238 .base
= EXYNOS4_GPK1(0),
2239 .ngpio
= EXYNOS4_GPIO_K1_NR
,
2244 .base
= EXYNOS4_GPK2(0),
2245 .ngpio
= EXYNOS4_GPIO_K2_NR
,
2250 .base
= EXYNOS4_GPK3(0),
2251 .ngpio
= EXYNOS4_GPIO_K3_NR
,
2256 .base
= EXYNOS4_GPL0(0),
2257 .ngpio
= EXYNOS4_GPIO_L0_NR
,
2262 .base
= EXYNOS4_GPL1(0),
2263 .ngpio
= EXYNOS4_GPIO_L1_NR
,
2268 .base
= EXYNOS4_GPL2(0),
2269 .ngpio
= EXYNOS4_GPIO_L2_NR
,
2273 .config
= &samsung_gpio_cfgs
[8],
2275 .base
= EXYNOS4_GPY0(0),
2276 .ngpio
= EXYNOS4_GPIO_Y0_NR
,
2280 .config
= &samsung_gpio_cfgs
[8],
2282 .base
= EXYNOS4_GPY1(0),
2283 .ngpio
= EXYNOS4_GPIO_Y1_NR
,
2287 .config
= &samsung_gpio_cfgs
[8],
2289 .base
= EXYNOS4_GPY2(0),
2290 .ngpio
= EXYNOS4_GPIO_Y2_NR
,
2294 .config
= &samsung_gpio_cfgs
[8],
2296 .base
= EXYNOS4_GPY3(0),
2297 .ngpio
= EXYNOS4_GPIO_Y3_NR
,
2301 .config
= &samsung_gpio_cfgs
[8],
2303 .base
= EXYNOS4_GPY4(0),
2304 .ngpio
= EXYNOS4_GPIO_Y4_NR
,
2308 .config
= &samsung_gpio_cfgs
[8],
2310 .base
= EXYNOS4_GPY5(0),
2311 .ngpio
= EXYNOS4_GPIO_Y5_NR
,
2315 .config
= &samsung_gpio_cfgs
[8],
2317 .base
= EXYNOS4_GPY6(0),
2318 .ngpio
= EXYNOS4_GPIO_Y6_NR
,
2322 .base
= (S5P_VA_GPIO2
+ 0xC00),
2323 .config
= &samsung_gpio_cfgs
[9],
2324 .irq_base
= IRQ_EINT(0),
2326 .base
= EXYNOS4_GPX0(0),
2327 .ngpio
= EXYNOS4_GPIO_X0_NR
,
2329 .to_irq
= samsung_gpiolib_to_irq
,
2332 .base
= (S5P_VA_GPIO2
+ 0xC20),
2333 .config
= &samsung_gpio_cfgs
[9],
2334 .irq_base
= IRQ_EINT(8),
2336 .base
= EXYNOS4_GPX1(0),
2337 .ngpio
= EXYNOS4_GPIO_X1_NR
,
2339 .to_irq
= samsung_gpiolib_to_irq
,
2342 .base
= (S5P_VA_GPIO2
+ 0xC40),
2343 .config
= &samsung_gpio_cfgs
[9],
2344 .irq_base
= IRQ_EINT(16),
2346 .base
= EXYNOS4_GPX2(0),
2347 .ngpio
= EXYNOS4_GPIO_X2_NR
,
2349 .to_irq
= samsung_gpiolib_to_irq
,
2352 .base
= (S5P_VA_GPIO2
+ 0xC60),
2353 .config
= &samsung_gpio_cfgs
[9],
2354 .irq_base
= IRQ_EINT(24),
2356 .base
= EXYNOS4_GPX3(0),
2357 .ngpio
= EXYNOS4_GPIO_X3_NR
,
2359 .to_irq
= samsung_gpiolib_to_irq
,
2365 static struct samsung_gpio_chip exynos4_gpios_3
[] = {
2366 #ifdef CONFIG_ARCH_EXYNOS4
2369 .base
= EXYNOS4_GPZ(0),
2370 .ngpio
= EXYNOS4_GPIO_Z_NR
,
2377 /* TODO: cleanup soc_is_* */
2378 static __init
int samsung_gpiolib_init(void)
2380 struct samsung_gpio_chip
*chip
;
2384 samsung_gpiolib_set_cfg(samsung_gpio_cfgs
, ARRAY_SIZE(samsung_gpio_cfgs
));
2386 if (soc_is_s3c24xx()) {
2387 s3c24xx_gpiolib_add_chips(s3c24xx_gpios
,
2388 ARRAY_SIZE(s3c24xx_gpios
), S3C24XX_VA_GPIO
);
2389 } else if (soc_is_s3c64xx()) {
2390 samsung_gpiolib_add_2bit_chips(s3c64xx_gpios_2bit
,
2391 ARRAY_SIZE(s3c64xx_gpios_2bit
),
2392 S3C64XX_VA_GPIO
+ 0xE0, 0x20);
2393 samsung_gpiolib_add_4bit_chips(s3c64xx_gpios_4bit
,
2394 ARRAY_SIZE(s3c64xx_gpios_4bit
),
2396 samsung_gpiolib_add_4bit2_chips(s3c64xx_gpios_4bit2
,
2397 ARRAY_SIZE(s3c64xx_gpios_4bit2
));
2398 } else if (soc_is_s5p6440()) {
2399 samsung_gpiolib_add_2bit_chips(s5p6440_gpios_2bit
,
2400 ARRAY_SIZE(s5p6440_gpios_2bit
), NULL
, 0x0);
2401 samsung_gpiolib_add_4bit_chips(s5p6440_gpios_4bit
,
2402 ARRAY_SIZE(s5p6440_gpios_4bit
), S5P_VA_GPIO
);
2403 samsung_gpiolib_add_4bit2_chips(s5p6440_gpios_4bit2
,
2404 ARRAY_SIZE(s5p6440_gpios_4bit2
));
2405 s5p64x0_gpiolib_add_rbank(s5p6440_gpios_rbank
,
2406 ARRAY_SIZE(s5p6440_gpios_rbank
));
2407 } else if (soc_is_s5p6450()) {
2408 samsung_gpiolib_add_2bit_chips(s5p6450_gpios_2bit
,
2409 ARRAY_SIZE(s5p6450_gpios_2bit
), NULL
, 0x0);
2410 samsung_gpiolib_add_4bit_chips(s5p6450_gpios_4bit
,
2411 ARRAY_SIZE(s5p6450_gpios_4bit
), S5P_VA_GPIO
);
2412 samsung_gpiolib_add_4bit2_chips(s5p6450_gpios_4bit2
,
2413 ARRAY_SIZE(s5p6450_gpios_4bit2
));
2414 s5p64x0_gpiolib_add_rbank(s5p6450_gpios_rbank
,
2415 ARRAY_SIZE(s5p6450_gpios_rbank
));
2416 } else if (soc_is_s5pc100()) {
2418 chip
= s5pc100_gpios_4bit
;
2419 nr_chips
= ARRAY_SIZE(s5pc100_gpios_4bit
);
2421 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
2422 if (!chip
->config
) {
2423 chip
->config
= &samsung_gpio_cfgs
[3];
2424 chip
->group
= group
++;
2427 samsung_gpiolib_add_4bit_chips(s5pc100_gpios_4bit
, nr_chips
, S5P_VA_GPIO
);
2428 #if defined(CONFIG_CPU_S5PC100) && defined(CONFIG_S5P_GPIO_INT)
2429 s5p_register_gpioint_bank(IRQ_GPIOINT
, 0, S5P_GPIOINT_GROUP_MAXNR
);
2431 } else if (soc_is_s5pv210()) {
2433 chip
= s5pv210_gpios_4bit
;
2434 nr_chips
= ARRAY_SIZE(s5pv210_gpios_4bit
);
2436 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
2437 if (!chip
->config
) {
2438 chip
->config
= &samsung_gpio_cfgs
[3];
2439 chip
->group
= group
++;
2442 samsung_gpiolib_add_4bit_chips(s5pv210_gpios_4bit
, nr_chips
, S5P_VA_GPIO
);
2443 #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_S5P_GPIO_INT)
2444 s5p_register_gpioint_bank(IRQ_GPIOINT
, 0, S5P_GPIOINT_GROUP_MAXNR
);
2446 } else if (soc_is_exynos4210()) {
2450 chip
= exynos4_gpios_1
;
2451 nr_chips
= ARRAY_SIZE(exynos4_gpios_1
);
2453 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
2454 if (!chip
->config
) {
2455 chip
->config
= &exynos4_gpio_cfg
;
2456 chip
->group
= group
++;
2459 samsung_gpiolib_add_4bit_chips(exynos4_gpios_1
, nr_chips
, S5P_VA_GPIO1
);
2462 chip
= exynos4_gpios_2
;
2463 nr_chips
= ARRAY_SIZE(exynos4_gpios_2
);
2465 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
2466 if (!chip
->config
) {
2467 chip
->config
= &exynos4_gpio_cfg
;
2468 chip
->group
= group
++;
2471 samsung_gpiolib_add_4bit_chips(exynos4_gpios_2
, nr_chips
, S5P_VA_GPIO2
);
2474 chip
= exynos4_gpios_3
;
2475 nr_chips
= ARRAY_SIZE(exynos4_gpios_3
);
2477 for (i
= 0; i
< nr_chips
; i
++, chip
++) {
2478 if (!chip
->config
) {
2479 chip
->config
= &exynos4_gpio_cfg
;
2480 chip
->group
= group
++;
2483 samsung_gpiolib_add_4bit_chips(exynos4_gpios_3
, nr_chips
, S5P_VA_GPIO3
);
2485 #if defined(CONFIG_CPU_EXYNOS4210) && defined(CONFIG_S5P_GPIO_INT)
2486 s5p_register_gpioint_bank(IRQ_GPIO_XA
, 0, IRQ_GPIO1_NR_GROUPS
);
2487 s5p_register_gpioint_bank(IRQ_GPIO_XB
, IRQ_GPIO1_NR_GROUPS
, IRQ_GPIO2_NR_GROUPS
);
2490 WARN(1, "Unknown SoC in gpio-samsung, no GPIOs added\n");
2496 core_initcall(samsung_gpiolib_init
);
2498 int s3c_gpio_cfgpin(unsigned int pin
, unsigned int config
)
2500 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2501 unsigned long flags
;
2508 offset
= pin
- chip
->chip
.base
;
2510 samsung_gpio_lock(chip
, flags
);
2511 ret
= samsung_gpio_do_setcfg(chip
, offset
, config
);
2512 samsung_gpio_unlock(chip
, flags
);
2516 EXPORT_SYMBOL(s3c_gpio_cfgpin
);
2518 int s3c_gpio_cfgpin_range(unsigned int start
, unsigned int nr
,
2523 for (; nr
> 0; nr
--, start
++) {
2524 ret
= s3c_gpio_cfgpin(start
, cfg
);
2531 EXPORT_SYMBOL_GPL(s3c_gpio_cfgpin_range
);
2533 int s3c_gpio_cfgall_range(unsigned int start
, unsigned int nr
,
2534 unsigned int cfg
, samsung_gpio_pull_t pull
)
2538 for (; nr
> 0; nr
--, start
++) {
2539 s3c_gpio_setpull(start
, pull
);
2540 ret
= s3c_gpio_cfgpin(start
, cfg
);
2547 EXPORT_SYMBOL_GPL(s3c_gpio_cfgall_range
);
2549 unsigned s3c_gpio_getcfg(unsigned int pin
)
2551 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2552 unsigned long flags
;
2557 offset
= pin
- chip
->chip
.base
;
2559 samsung_gpio_lock(chip
, flags
);
2560 ret
= samsung_gpio_do_getcfg(chip
, offset
);
2561 samsung_gpio_unlock(chip
, flags
);
2566 EXPORT_SYMBOL(s3c_gpio_getcfg
);
2568 int s3c_gpio_setpull(unsigned int pin
, samsung_gpio_pull_t pull
)
2570 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2571 unsigned long flags
;
2577 offset
= pin
- chip
->chip
.base
;
2579 samsung_gpio_lock(chip
, flags
);
2580 ret
= samsung_gpio_do_setpull(chip
, offset
, pull
);
2581 samsung_gpio_unlock(chip
, flags
);
2585 EXPORT_SYMBOL(s3c_gpio_setpull
);
2587 samsung_gpio_pull_t
s3c_gpio_getpull(unsigned int pin
)
2589 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2590 unsigned long flags
;
2595 offset
= pin
- chip
->chip
.base
;
2597 samsung_gpio_lock(chip
, flags
);
2598 pup
= samsung_gpio_do_getpull(chip
, offset
);
2599 samsung_gpio_unlock(chip
, flags
);
2602 return (__force samsung_gpio_pull_t
)pup
;
2604 EXPORT_SYMBOL(s3c_gpio_getpull
);
2606 /* gpiolib wrappers until these are totally eliminated */
2608 void s3c2410_gpio_pullup(unsigned int pin
, unsigned int to
)
2612 WARN_ON(to
); /* should be none of these left */
2615 /* if pull is enabled, try first with up, and if that
2616 * fails, try using down */
2618 ret
= s3c_gpio_setpull(pin
, S3C_GPIO_PULL_UP
);
2620 s3c_gpio_setpull(pin
, S3C_GPIO_PULL_DOWN
);
2622 s3c_gpio_setpull(pin
, S3C_GPIO_PULL_NONE
);
2625 EXPORT_SYMBOL(s3c2410_gpio_pullup
);
2627 void s3c2410_gpio_setpin(unsigned int pin
, unsigned int to
)
2629 /* do this via gpiolib until all users removed */
2631 gpio_request(pin
, "temporary");
2632 gpio_set_value(pin
, to
);
2635 EXPORT_SYMBOL(s3c2410_gpio_setpin
);
2637 unsigned int s3c2410_gpio_getpin(unsigned int pin
)
2639 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2640 unsigned long offs
= pin
- chip
->chip
.base
;
2642 return __raw_readl(chip
->base
+ 0x04) & (1 << offs
);
2644 EXPORT_SYMBOL(s3c2410_gpio_getpin
);
2646 #ifdef CONFIG_S5P_GPIO_DRVSTR
2647 s5p_gpio_drvstr_t
s5p_gpio_get_drvstr(unsigned int pin
)
2649 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2658 off
= pin
- chip
->chip
.base
;
2660 reg
= chip
->base
+ 0x0C;
2662 drvstr
= __raw_readl(reg
);
2663 drvstr
= drvstr
>> shift
;
2666 return (__force s5p_gpio_drvstr_t
)drvstr
;
2668 EXPORT_SYMBOL(s5p_gpio_get_drvstr
);
2670 int s5p_gpio_set_drvstr(unsigned int pin
, s5p_gpio_drvstr_t drvstr
)
2672 struct samsung_gpio_chip
*chip
= samsung_gpiolib_getchip(pin
);
2681 off
= pin
- chip
->chip
.base
;
2683 reg
= chip
->base
+ 0x0C;
2685 tmp
= __raw_readl(reg
);
2686 tmp
&= ~(0x3 << shift
);
2687 tmp
|= drvstr
<< shift
;
2689 __raw_writel(tmp
, reg
);
2693 EXPORT_SYMBOL(s5p_gpio_set_drvstr
);
2694 #endif /* CONFIG_S5P_GPIO_DRVSTR */
2696 #ifdef CONFIG_PLAT_S3C24XX
2697 unsigned int s3c2410_modify_misccr(unsigned int clear
, unsigned int change
)
2699 unsigned long flags
;
2700 unsigned long misccr
;
2702 local_irq_save(flags
);
2703 misccr
= __raw_readl(S3C24XX_MISCCR
);
2706 __raw_writel(misccr
, S3C24XX_MISCCR
);
2707 local_irq_restore(flags
);
2711 EXPORT_SYMBOL(s3c2410_modify_misccr
);