aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2010-05-20 02:13:07 -0400
committerBen Dooks <ben-linux@fluff.org>2010-05-20 05:24:03 -0400
commite6f66a9f9668762f2c3f47728b29781ffc7fbad2 (patch)
tree886346d81f6574693ce2b8dbb1247c89314ad6b7
parentc8d833bf5830f141c4680dae8f617d0d0a33605d (diff)
ARM: S5PV210: add common HSMMC device helpers
This patch adds sdhci platform helpers required by sdhci-s3c driver. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r--arch/arm/mach-s5pv210/Kconfig21
-rw-r--r--arch/arm/mach-s5pv210/Makefile2
-rw-r--r--arch/arm/mach-s5pv210/cpu.c6
-rw-r--r--arch/arm/mach-s5pv210/include/mach/map.h5
-rw-r--r--arch/arm/mach-s5pv210/setup-sdhci-gpio.c104
-rw-r--r--arch/arm/mach-s5pv210/setup-sdhci.c63
-rw-r--r--arch/arm/plat-samsung/include/plat/sdhci.h55
7 files changed, 256 insertions, 0 deletions
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index 7d8d93feb63..9e970036082 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -25,11 +25,32 @@ config MACH_AQUILA
25 help 25 help
26 Machine support for the Samsung Aquila target based on S5PC110 SoC 26 Machine support for the Samsung Aquila target based on S5PC110 SoC
27 27
28config S5PV210_SETUP_I2C1
29 bool
30 help
31 Common setup code for i2c bus 1.
32
33config S5PV210_SETUP_I2C2
34 bool
35 help
36 Common setup code for i2c bus 2.
37
28config S5PV210_SETUP_FB_24BPP 38config S5PV210_SETUP_FB_24BPP
29 bool 39 bool
30 help 40 help
31 Common setup code for S5PV210 with an 24bpp RGB display helper. 41 Common setup code for S5PV210 with an 24bpp RGB display helper.
32 42
43config S5PV210_SETUP_SDHCI
44 bool
45 select S5PV210_SETUP_SDHCI_GPIO
46 help
47 Internal helper functions for S5PV210 based SDHCI systems
48
49config S5PV210_SETUP_SDHCI_GPIO
50 bool
51 help
52 Common setup code for SDHCI gpio.
53
33config MACH_SMDKV210 54config MACH_SMDKV210
34 bool "SMDKV210" 55 bool "SMDKV210"
35 select CPU_S5PV210 56 select CPU_S5PV210
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index c9aad7faf1f..0b334c79816 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -27,3 +27,5 @@ obj-y += dev-audio.o
27obj-$(CONFIG_S5PV210_SETUP_FB_24BPP) += setup-fb-24bpp.o 27obj-$(CONFIG_S5PV210_SETUP_FB_24BPP) += setup-fb-24bpp.o
28obj-$(CONFIG_S5PV210_SETUP_I2C1) += setup-i2c1.o 28obj-$(CONFIG_S5PV210_SETUP_I2C1) += setup-i2c1.o
29obj-$(CONFIG_S5PV210_SETUP_I2C2) += setup-i2c2.o 29obj-$(CONFIG_S5PV210_SETUP_I2C2) += setup-i2c2.o
30obj-$(CONFIG_S5PV210_SETUP_SDHCI) += setup-sdhci.o
31obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 2d4a3d2221c..c5d53abc92f 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -33,6 +33,7 @@
33#include <plat/clock.h> 33#include <plat/clock.h>
34#include <plat/s5pv210.h> 34#include <plat/s5pv210.h>
35#include <plat/iic-core.h> 35#include <plat/iic-core.h>
36#include <plat/sdhci.h>
36 37
37/* Initial IO mappings */ 38/* Initial IO mappings */
38 39
@@ -77,6 +78,11 @@ void __init s5pv210_map_io(void)
77{ 78{
78 iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc)); 79 iotable_init(s5pv210_iodesc, ARRAY_SIZE(s5pv210_iodesc));
79 80
81 /* initialise device information early */
82 s5pv210_default_sdhci0();
83 s5pv210_default_sdhci1();
84 s5pv210_default_sdhci2();
85
80 /* the i2c devices are directly compatible with s3c2440 */ 86 /* the i2c devices are directly compatible with s3c2440 */
81 s3c_i2c0_setname("s3c2440-i2c"); 87 s3c_i2c0_setname("s3c2440-i2c");
82 s3c_i2c1_setname("s3c2440-i2c"); 88 s3c_i2c1_setname("s3c2440-i2c");
diff --git a/arch/arm/mach-s5pv210/include/mach/map.h b/arch/arm/mach-s5pv210/include/mach/map.h
index 0254e08590e..eeb1ca79a6f 100644
--- a/arch/arm/mach-s5pv210/include/mach/map.h
+++ b/arch/arm/mach-s5pv210/include/mach/map.h
@@ -51,6 +51,8 @@
51 51
52#define S5PV210_PA_FB (0xF8000000) 52#define S5PV210_PA_FB (0xF8000000)
53 53
54#define S5PV210_PA_HSMMC(x) (0xEB000000 + ((x) * 0x100000))
55
54#define S5PV210_PA_VIC0 (0xF2000000) 56#define S5PV210_PA_VIC0 (0xF2000000)
55#define S5P_PA_VIC0 S5PV210_PA_VIC0 57#define S5P_PA_VIC0 S5PV210_PA_VIC0
56 58
@@ -81,6 +83,9 @@
81 83
82/* compatibiltiy defines. */ 84/* compatibiltiy defines. */
83#define S3C_PA_UART S5PV210_PA_UART 85#define S3C_PA_UART S5PV210_PA_UART
86#define S3C_PA_HSMMC0 S5PV210_PA_HSMMC(0)
87#define S3C_PA_HSMMC1 S5PV210_PA_HSMMC(1)
88#define S3C_PA_HSMMC2 S5PV210_PA_HSMMC(2)
84#define S3C_PA_IIC S5PV210_PA_IIC0 89#define S3C_PA_IIC S5PV210_PA_IIC0
85#define S3C_PA_IIC1 S5PV210_PA_IIC1 90#define S3C_PA_IIC1 S5PV210_PA_IIC1
86#define S3C_PA_IIC2 S5PV210_PA_IIC2 91#define S3C_PA_IIC2 S5PV210_PA_IIC2
diff --git a/arch/arm/mach-s5pv210/setup-sdhci-gpio.c b/arch/arm/mach-s5pv210/setup-sdhci-gpio.c
new file mode 100644
index 00000000000..fe7d86dad14
--- /dev/null
+++ b/arch/arm/mach-s5pv210/setup-sdhci-gpio.c
@@ -0,0 +1,104 @@
1/* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV210 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18#include <linux/mmc/host.h>
19#include <linux/mmc/card.h>
20
21#include <mach/gpio.h>
22#include <plat/gpio-cfg.h>
23#include <plat/regs-sdhci.h>
24
25void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
26{
27 unsigned int gpio;
28
29 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
30 for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++) {
31 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
32 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
33 }
34 switch (width) {
35 case 8:
36 /* GPG1[3:6] special-funtion 3 */
37 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) {
38 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
39 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
40 }
41 case 4:
42 /* GPG0[3:6] special-funtion 2 */
43 for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++) {
44 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
45 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
46 }
47 default:
48 break;
49 }
50
51 s3c_gpio_setpull(S5PV210_GPG0(2), S3C_GPIO_PULL_UP);
52 s3c_gpio_cfgpin(S5PV210_GPG0(2), S3C_GPIO_SFN(2));
53}
54
55void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
56{
57 unsigned int gpio;
58
59 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
60 for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++) {
61 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
62 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
63 }
64
65 /* Data pin GPG1[3:6] to special-function 2 */
66 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) {
67 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
68 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
69 }
70
71 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
72 s3c_gpio_cfgpin(S5PV210_GPG1(2), S3C_GPIO_SFN(2));
73}
74
75void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
76{
77 unsigned int gpio;
78
79 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
80 for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++) {
81 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
82 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
83 }
84
85 switch (width) {
86 case 8:
87 /* Data pin GPG3[3:6] to special-function 3 */
88 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) {
89 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
90 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
91 }
92 case 4:
93 /* Data pin GPG2[3:6] to special-function 2 */
94 for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++) {
95 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
96 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
97 }
98 default:
99 break;
100 }
101
102 s3c_gpio_setpull(S5PV210_GPG2(2), S3C_GPIO_PULL_UP);
103 s3c_gpio_cfgpin(S5PV210_GPG2(2), S3C_GPIO_SFN(2));
104}
diff --git a/arch/arm/mach-s5pv210/setup-sdhci.c b/arch/arm/mach-s5pv210/setup-sdhci.c
new file mode 100644
index 00000000000..51815ec60c2
--- /dev/null
+++ b/arch/arm/mach-s5pv210/setup-sdhci.c
@@ -0,0 +1,63 @@
1/* linux/arch/arm/mach-s5pv210/setup-sdhci.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV210 - Helper functions for settign up SDHCI device(s) (HSMMC)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18
19#include <linux/mmc/card.h>
20#include <linux/mmc/host.h>
21
22#include <plat/regs-sdhci.h>
23#include <plat/sdhci.h>
24
25/* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
26
27char *s5pv210_hsmmc_clksrcs[4] = {
28 [0] = "hsmmc", /* HCLK */
29 [1] = "hsmmc", /* HCLK */
30 [2] = "sclk_mmc", /* mmc_bus */
31 /*[4] = reserved */
32};
33
34void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
35 void __iomem *r,
36 struct mmc_ios *ios,
37 struct mmc_card *card)
38{
39 u32 ctrl2, ctrl3;
40
41 /* don't need to alter anything acording to card-type */
42
43 writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA, r + S3C64XX_SDHCI_CONTROL4);
44
45 ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
46 ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
47 ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
48 S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
49 S3C_SDHCI_CTRL2_ENFBCLKRX |
50 S3C_SDHCI_CTRL2_DFCNT_NONE |
51 S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
52
53 if (ios->clock < 25 * 1000000)
54 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
55 S3C_SDHCI_CTRL3_FCSEL2 |
56 S3C_SDHCI_CTRL3_FCSEL1 |
57 S3C_SDHCI_CTRL3_FCSEL0);
58 else
59 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
60
61 writel(ctrl2, r + S3C_SDHCI_CONTROL2);
62 writel(ctrl3, r + S3C_SDHCI_CONTROL3);
63}
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h
index 7d07cd7aa4f..13f9fb20900 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -75,6 +75,9 @@ extern void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
75extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w); 75extern void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
76extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w); 76extern void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
77extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w); 77extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
78extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
79extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
80extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
78 81
79/* S3C6400 SDHCI setup */ 82/* S3C6400 SDHCI setup */
80 83
@@ -218,4 +221,56 @@ static inline void s5pc100_default_sdhci1(void) { }
218static inline void s5pc100_default_sdhci2(void) { } 221static inline void s5pc100_default_sdhci2(void) { }
219#endif /* CONFIG_S5PC100_SETUP_SDHCI */ 222#endif /* CONFIG_S5PC100_SETUP_SDHCI */
220 223
224
225/* S5PC110 SDHCI setup */
226#ifdef CONFIG_S5PV210_SETUP_SDHCI
227extern char *s5pv210_hsmmc_clksrcs[4];
228
229extern void s5pv210_setup_sdhci_cfg_card(struct platform_device *dev,
230 void __iomem *r,
231 struct mmc_ios *ios,
232 struct mmc_card *card);
233
234#ifdef CONFIG_S3C_DEV_HSMMC
235static inline void s5pv210_default_sdhci0(void)
236{
237 s3c_hsmmc0_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
238 s3c_hsmmc0_def_platdata.cfg_gpio = s5pv210_setup_sdhci0_cfg_gpio;
239 s3c_hsmmc0_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
240}
241#else
242static inline void s5pc100_default_sdhci0(void) { }
243#endif /* CONFIG_S3C_DEV_HSMMC */
244
245#ifdef CONFIG_S3C_DEV_HSMMC1
246static inline void s5pv210_default_sdhci1(void)
247{
248 s3c_hsmmc1_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
249 s3c_hsmmc1_def_platdata.cfg_gpio = s5pv210_setup_sdhci1_cfg_gpio;
250 s3c_hsmmc1_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
251}
252#else
253static inline void s5pv210_default_sdhci1(void) { }
254#endif /* CONFIG_S3C_DEV_HSMMC1 */
255
256#ifdef CONFIG_S3C_DEV_HSMMC2
257static inline void s5pv210_default_sdhci2(void)
258{
259 s3c_hsmmc2_def_platdata.clocks = s5pv210_hsmmc_clksrcs;
260 s3c_hsmmc2_def_platdata.cfg_gpio = s5pv210_setup_sdhci2_cfg_gpio;
261 s3c_hsmmc2_def_platdata.cfg_card = s5pv210_setup_sdhci_cfg_card;
262}
263#else
264static inline void s5pv210_default_sdhci2(void) { }
265#endif /* CONFIG_S3C_DEV_HSMMC2 */
266
267#else
268static inline void s5pv210_default_sdhci0(void) { }
269static inline void s5pv210_default_sdhci1(void) { }
270static inline void s5pv210_default_sdhci2(void) { }
271#endif /* CONFIG_S5PC100_SETUP_SDHCI */
272
273
274
275
221#endif /* __PLAT_S3C_SDHCI_H */ 276#endif /* __PLAT_S3C_SDHCI_H */