aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-samsung
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2010-01-05 12:28:20 -0500
committerBen Dooks <ben-linux@fluff.org>2010-01-15 03:10:13 -0500
commit4f830db9629e413e7c5523085ab009b0de5ae6d0 (patch)
tree8d3feb830483426e2e5f263dd1b65e564890a598 /arch/arm/plat-samsung
parentb6a604137bb978d9f65b1228cf0bb691ece45cba (diff)
ARM: SAMSUNG: Move gpio-config.c into plat-samsung
The arch/arm/plat-s3c/gpio-config.c file is common to pretty much all the Samsung SoCs, so move it to arch/arm/plat-samsung Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-samsung')
-rw-r--r--arch/arm/plat-samsung/Kconfig35
-rw-r--r--arch/arm/plat-samsung/Makefile1
-rw-r--r--arch/arm/plat-samsung/gpio-config.c166
3 files changed, 202 insertions, 0 deletions
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 5a72a5235573..9e7daf29b86a 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -19,6 +19,41 @@ config SAMSUNG_CLKSRC
19 Select the clock code for the clksrc implementation 19 Select the clock code for the clksrc implementation
20 used by newer systems such as the S3C64XX. 20 used by newer systems such as the S3C64XX.
21 21
22# options for gpio configuration support
23
24config S3C_GPIO_CFG_S3C24XX
25 bool
26 help
27 Internal configuration to enable S3C24XX style GPIO configuration
28 functions.
29
30config S3C_GPIO_CFG_S3C64XX
31 bool
32 help
33 Internal configuration to enable S3C64XX style GPIO configuration
34 functions.
35
36config S5P_GPIO_CFG_S5PC1XX
37 bool
38 help
39 Internal configuration to enable S5PC1XX style GPIO configuration
40 functions.
41
42config S3C_GPIO_PULL_UPDOWN
43 bool
44 help
45 Internal configuration to enable the correct GPIO pull helper
46
47config S3C_GPIO_PULL_DOWN
48 bool
49 help
50 Internal configuration to enable the correct GPIO pull helper
51
52config S3C_GPIO_PULL_UP
53 bool
54 help
55 Internal configuration to enable the correct GPIO pull helper
56
22# device definitions to compile in 57# device definitions to compile in
23 58
24config S3C_DEV_HSMMC 59config S3C_DEV_HSMMC
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 32f03e549d0a..2c0143713ea9 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -13,6 +13,7 @@ obj- :=
13 13
14obj-y += clock.o 14obj-y += clock.o
15obj-y += pwm-clock.o 15obj-y += pwm-clock.o
16obj-y += gpio-config.o
16 17
17obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o 18obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o
18 19
diff --git a/arch/arm/plat-samsung/gpio-config.c b/arch/arm/plat-samsung/gpio-config.c
new file mode 100644
index 000000000000..456969b6fa0d
--- /dev/null
+++ b/arch/arm/plat-samsung/gpio-config.c
@@ -0,0 +1,166 @@
1/* linux/arch/arm/plat-s3c/gpio-config.c
2 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
7 *
8 * S3C series GPIO configuration core
9 *
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.
13*/
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/gpio.h>
18#include <linux/io.h>
19
20#include <mach/gpio-core.h>
21#include <plat/gpio-cfg.h>
22#include <plat/gpio-cfg-helpers.h>
23
24int s3c_gpio_cfgpin(unsigned int pin, unsigned int config)
25{
26 struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
27 unsigned long flags;
28 int offset;
29 int ret;
30
31 if (!chip)
32 return -EINVAL;
33
34 offset = pin - chip->chip.base;
35
36 local_irq_save(flags);
37 ret = s3c_gpio_do_setcfg(chip, offset, config);
38 local_irq_restore(flags);
39
40 return ret;
41}
42EXPORT_SYMBOL(s3c_gpio_cfgpin);
43
44int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull)
45{
46 struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
47 unsigned long flags;
48 int offset, ret;
49
50 if (!chip)
51 return -EINVAL;
52
53 offset = pin - chip->chip.base;
54
55 local_irq_save(flags);
56 ret = s3c_gpio_do_setpull(chip, offset, pull);
57 local_irq_restore(flags);
58
59 return ret;
60}
61EXPORT_SYMBOL(s3c_gpio_setpull);
62
63#ifdef CONFIG_S3C_GPIO_CFG_S3C24XX
64int s3c_gpio_setcfg_s3c24xx_banka(struct s3c_gpio_chip *chip,
65 unsigned int off, unsigned int cfg)
66{
67 void __iomem *reg = chip->base;
68 unsigned int shift = off;
69 u32 con;
70
71 if (s3c_gpio_is_cfg_special(cfg)) {
72 cfg &= 0xf;
73
74 /* Map output to 0, and SFN2 to 1 */
75 cfg -= 1;
76 if (cfg > 1)
77 return -EINVAL;
78
79 cfg <<= shift;
80 }
81
82 con = __raw_readl(reg);
83 con &= ~(0x1 << shift);
84 con |= cfg;
85 __raw_writel(con, reg);
86
87 return 0;
88}
89
90int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip *chip,
91 unsigned int off, unsigned int cfg)
92{
93 void __iomem *reg = chip->base;
94 unsigned int shift = off * 2;
95 u32 con;
96
97 if (s3c_gpio_is_cfg_special(cfg)) {
98 cfg &= 0xf;
99 if (cfg > 3)
100 return -EINVAL;
101
102 cfg <<= shift;
103 }
104
105 con = __raw_readl(reg);
106 con &= ~(0x3 << shift);
107 con |= cfg;
108 __raw_writel(con, reg);
109
110 return 0;
111}
112#endif
113
114#ifdef CONFIG_S3C_GPIO_CFG_S3C64XX
115int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip,
116 unsigned int off, unsigned int cfg)
117{
118 void __iomem *reg = chip->base;
119 unsigned int shift = (off & 7) * 4;
120 u32 con;
121
122 if (off < 8 && chip->chip.ngpio > 8)
123 reg -= 4;
124
125 if (s3c_gpio_is_cfg_special(cfg)) {
126 cfg &= 0xf;
127 cfg <<= shift;
128 }
129
130 con = __raw_readl(reg);
131 con &= ~(0xf << shift);
132 con |= cfg;
133 __raw_writel(con, reg);
134
135 return 0;
136}
137#endif /* CONFIG_S3C_GPIO_CFG_S3C64XX */
138
139#ifdef CONFIG_S3C_GPIO_PULL_UPDOWN
140int s3c_gpio_setpull_updown(struct s3c_gpio_chip *chip,
141 unsigned int off, s3c_gpio_pull_t pull)
142{
143 void __iomem *reg = chip->base + 0x08;
144 int shift = off * 2;
145 u32 pup;
146
147 pup = __raw_readl(reg);
148 pup &= ~(3 << shift);
149 pup |= pull << shift;
150 __raw_writel(pup, reg);
151
152 return 0;
153}
154
155s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip,
156 unsigned int off)
157{
158 void __iomem *reg = chip->base + 0x08;
159 int shift = off * 2;
160 u32 pup = __raw_readl(reg);
161
162 pup >>= shift;
163 pup &= 0x3;
164 return (__force s3c_gpio_pull_t)pup;
165}
166#endif