aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2009-11-17 02:41:23 -0500
committerBen Dooks <ben-linux@fluff.org>2009-11-30 20:33:17 -0500
commit86cd4f5f83acbfa481c513c74666ad360b49d73b (patch)
treefadf026dc26dc06b7d6fc3d8405aa96795db23e9
parent067f131d09d89bd56864f1f4b3144cc778024b33 (diff)
ARM: S5PC1xx: add platform helpers for SDHCI host controllers
Samsung S5PC100 has 3 SDHCI controllers compatible with the one known from previous SoCs series. Add required platform setup and support code that the devices can be used with sdhci-s3c driver. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r--arch/arm/mach-s5pc100/Kconfig6
-rw-r--r--arch/arm/mach-s5pc100/Makefile4
-rw-r--r--arch/arm/mach-s5pc100/cpu.c3
-rw-r--r--arch/arm/mach-s5pc100/setup-sdhci.c65
-rw-r--r--arch/arm/plat-s3c/Kconfig5
-rw-r--r--arch/arm/plat-s3c/Makefile1
-rw-r--r--arch/arm/plat-s3c/dev-hsmmc2.c65
-rw-r--r--arch/arm/plat-s3c/include/plat/sdhci.h55
-rw-r--r--arch/arm/plat-s5pc1xx/Kconfig6
-rw-r--r--arch/arm/plat-s5pc1xx/Makefile1
-rw-r--r--arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c86
11 files changed, 297 insertions, 0 deletions
diff --git a/arch/arm/mach-s5pc100/Kconfig b/arch/arm/mach-s5pc100/Kconfig
index 36e7e0046c15..21b182121945 100644
--- a/arch/arm/mach-s5pc100/Kconfig
+++ b/arch/arm/mach-s5pc100/Kconfig
@@ -14,6 +14,12 @@ config CPU_S5PC100
14 help 14 help
15 Enable S5PC100 CPU support 15 Enable S5PC100 CPU support
16 16
17config S5PC100_SETUP_SDHCI
18 bool
19 select S5PC1XX_SETUP_SDHCI_GPIO
20 help
21 Internal helper functions for S5PC100 based SDHCI systems
22
17config MACH_SMDKC100 23config MACH_SMDKC100
18 bool "SMDKC100" 24 bool "SMDKC100"
19 select CPU_S5PC100 25 select CPU_S5PC100
diff --git a/arch/arm/mach-s5pc100/Makefile b/arch/arm/mach-s5pc100/Makefile
index afc89b381d7a..809ff10f768f 100644
--- a/arch/arm/mach-s5pc100/Makefile
+++ b/arch/arm/mach-s5pc100/Makefile
@@ -13,5 +13,9 @@ obj- :=
13 13
14obj-$(CONFIG_CPU_S5PC100) += cpu.o 14obj-$(CONFIG_CPU_S5PC100) += cpu.o
15 15
16# Helper and device support
17
18obj-$(CONFIG_S5PC100_SETUP_SDHCI) += setup-sdhci.o
19
16# machine support 20# machine support
17obj-$(CONFIG_MACH_SMDKC100) += mach-smdkc100.o 21obj-$(CONFIG_MACH_SMDKC100) += mach-smdkc100.o
diff --git a/arch/arm/mach-s5pc100/cpu.c b/arch/arm/mach-s5pc100/cpu.c
index 1319e3d0ec39..d79e7574a852 100644
--- a/arch/arm/mach-s5pc100/cpu.c
+++ b/arch/arm/mach-s5pc100/cpu.c
@@ -75,6 +75,9 @@ void __init s5pc100_map_io(void)
75 iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc)); 75 iotable_init(s5pc100_iodesc, ARRAY_SIZE(s5pc100_iodesc));
76 76
77 /* initialise device information early */ 77 /* initialise device information early */
78 s5pc100_default_sdhci0();
79 s5pc100_default_sdhci1();
80 s5pc100_default_sdhci2();
78 81
79 /* the i2c devices are directly compatible with s3c2440 */ 82 /* the i2c devices are directly compatible with s3c2440 */
80 s3c_i2c0_setname("s3c2440-i2c"); 83 s3c_i2c0_setname("s3c2440-i2c");
diff --git a/arch/arm/mach-s5pc100/setup-sdhci.c b/arch/arm/mach-s5pc100/setup-sdhci.c
new file mode 100644
index 000000000000..4385986a3da0
--- /dev/null
+++ b/arch/arm/mach-s5pc100/setup-sdhci.c
@@ -0,0 +1,65 @@
1/* linux/arch/arm/mach-s5pc100/setup-sdhci.c
2 *
3 * Copyright 2008 Samsung Electronics
4 *
5 * S5PC100 - Helper functions for settign up SDHCI device(s) (HSMMC)
6 *
7 * Based on mach-s3c6410/setup-sdhci.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/platform_device.h>
18#include <linux/io.h>
19
20#include <linux/mmc/card.h>
21#include <linux/mmc/host.h>
22
23#include <plat/regs-sdhci.h>
24#include <plat/sdhci.h>
25
26/* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
27
28char *s5pc100_hsmmc_clksrcs[4] = {
29 [0] = "hsmmc",
30 [1] = "hsmmc",
31 /* [2] = "mmc_bus", not yet succesfuuly used yet */
32 /* [3] = "48m", - note not succesfully used yet */
33};
34
35
36void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
37 void __iomem *r,
38 struct mmc_ios *ios,
39 struct mmc_card *card)
40{
41 u32 ctrl2, ctrl3;
42
43 /* don't need to alter anything acording to card-type */
44
45 writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA, r + S3C64XX_SDHCI_CONTROL4);
46
47 ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
48 ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
49 ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
50 S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
51 S3C_SDHCI_CTRL2_ENFBCLKRX |
52 S3C_SDHCI_CTRL2_DFCNT_NONE |
53 S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
54
55 if (ios->clock < 25 * 1000000)
56 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
57 S3C_SDHCI_CTRL3_FCSEL2 |
58 S3C_SDHCI_CTRL3_FCSEL1 |
59 S3C_SDHCI_CTRL3_FCSEL0);
60 else
61 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
62
63 writel(ctrl2, r + S3C_SDHCI_CONTROL2);
64 writel(ctrl3, r + S3C_SDHCI_CONTROL3);
65}
diff --git a/arch/arm/plat-s3c/Kconfig b/arch/arm/plat-s3c/Kconfig
index f155a849e705..e139a72c2149 100644
--- a/arch/arm/plat-s3c/Kconfig
+++ b/arch/arm/plat-s3c/Kconfig
@@ -184,6 +184,11 @@ config S3C_DEV_HSMMC1
184 help 184 help
185 Compile in platform device definitions for HSMMC channel 1 185 Compile in platform device definitions for HSMMC channel 1
186 186
187config S3C_DEV_HSMMC2
188 bool
189 help
190 Compile in platform device definitions for HSMMC channel 2
191
187config S3C_DEV_I2C1 192config S3C_DEV_I2C1
188 bool 193 bool
189 help 194 help
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile
index 3c09109e9e84..50444da98425 100644
--- a/arch/arm/plat-s3c/Makefile
+++ b/arch/arm/plat-s3c/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_HAVE_PWM) += pwm.o
36 36
37obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o 37obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o
38obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o 38obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o
39obj-$(CONFIG_S3C_DEV_HSMMC2) += dev-hsmmc2.o
39obj-y += dev-i2c0.o 40obj-y += dev-i2c0.o
40obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o 41obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o
41obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o 42obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o
diff --git a/arch/arm/plat-s3c/dev-hsmmc2.c b/arch/arm/plat-s3c/dev-hsmmc2.c
new file mode 100644
index 000000000000..082e55a78ad7
--- /dev/null
+++ b/arch/arm/plat-s3c/dev-hsmmc2.c
@@ -0,0 +1,65 @@
1/* linux/arch/arm/plat-s3c/dev-hsmmc2.c
2 *
3 * Copyright (c) 2009 Samsung Electronics
4 *
5 * S3C series device definition for hsmmc device 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14#include <linux/mmc/host.h>
15
16#include <mach/map.h>
17#include <plat/sdhci.h>
18#include <plat/devs.h>
19
20#define S3C_SZ_HSMMC (0x1000)
21
22static struct resource s3c_hsmmc2_resource[] = {
23 [0] = {
24 .start = S3C_PA_HSMMC2,
25 .end = S3C_PA_HSMMC2 + S3C_SZ_HSMMC - 1,
26 .flags = IORESOURCE_MEM,
27 },
28 [1] = {
29 .start = IRQ_HSMMC2,
30 .end = IRQ_HSMMC2,
31 .flags = IORESOURCE_IRQ,
32 }
33};
34
35static u64 s3c_device_hsmmc2_dmamask = 0xffffffffUL;
36
37struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = {
38 .max_width = 4,
39 .host_caps = (MMC_CAP_4_BIT_DATA |
40 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
41};
42
43struct platform_device s3c_device_hsmmc2 = {
44 .name = "s3c-sdhci",
45 .id = 2,
46 .num_resources = ARRAY_SIZE(s3c_hsmmc2_resource),
47 .resource = s3c_hsmmc2_resource,
48 .dev = {
49 .dma_mask = &s3c_device_hsmmc2_dmamask,
50 .coherent_dma_mask = 0xffffffffUL,
51 .platform_data = &s3c_hsmmc2_def_platdata,
52 },
53};
54
55void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd)
56{
57 struct s3c_sdhci_platdata *set = &s3c_hsmmc2_def_platdata;
58
59 set->max_width = pd->max_width;
60
61 if (pd->cfg_gpio)
62 set->cfg_gpio = pd->cfg_gpio;
63 if (pd->cfg_card)
64 set->cfg_card = pd->cfg_card;
65}
diff --git a/arch/arm/plat-s3c/include/plat/sdhci.h b/arch/arm/plat-s3c/include/plat/sdhci.h
index f615308ccdfb..c71d07861840 100644
--- a/arch/arm/plat-s3c/include/plat/sdhci.h
+++ b/arch/arm/plat-s3c/include/plat/sdhci.h
@@ -57,6 +57,7 @@ struct s3c_sdhci_platdata {
57 */ 57 */
58extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd); 58extern void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd);
59extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd); 59extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
60extern void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd);
60 61
61/* Default platform data, exported so that per-cpu initialisation can 62/* Default platform data, exported so that per-cpu initialisation can
62 * set the correct one when there are more than one cpu type selected. 63 * set the correct one when there are more than one cpu type selected.
@@ -64,11 +65,15 @@ extern void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd);
64 65
65extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata; 66extern struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata;
66extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata; 67extern struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata;
68extern struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata;
67 69
68/* Helper function availablity */ 70/* Helper function availablity */
69 71
70extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w); 72extern void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
71extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w); 73extern void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
74extern void s5pc100_setup_sdhci0_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);
72 77
73/* S3C6400 SDHCI setup */ 78/* S3C6400 SDHCI setup */
74 79
@@ -145,4 +150,54 @@ static inline void s3c6410_default_sdhci0(void) { }
145static inline void s3c6410_default_sdhci1(void) { } 150static inline void s3c6410_default_sdhci1(void) { }
146#endif /* CONFIG_S3C6410_SETUP_SDHCI */ 151#endif /* CONFIG_S3C6410_SETUP_SDHCI */
147 152
153/* S5PC100 SDHCI setup */
154
155#ifdef CONFIG_S5PC100_SETUP_SDHCI
156extern char *s5pc100_hsmmc_clksrcs[4];
157
158extern void s5pc100_setup_sdhci0_cfg_card(struct platform_device *dev,
159 void __iomem *r,
160 struct mmc_ios *ios,
161 struct mmc_card *card);
162
163#ifdef CONFIG_S3C_DEV_HSMMC
164static inline void s5pc100_default_sdhci0(void)
165{
166 s3c_hsmmc0_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
167 s3c_hsmmc0_def_platdata.cfg_gpio = s5pc100_setup_sdhci0_cfg_gpio;
168 s3c_hsmmc0_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
169}
170#else
171static inline void s5pc100_default_sdhci0(void) { }
172#endif /* CONFIG_S3C_DEV_HSMMC */
173
174#ifdef CONFIG_S3C_DEV_HSMMC1
175static inline void s5pc100_default_sdhci1(void)
176{
177 s3c_hsmmc1_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
178 s3c_hsmmc1_def_platdata.cfg_gpio = s5pc100_setup_sdhci1_cfg_gpio;
179 s3c_hsmmc1_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
180}
181#else
182static inline void s5pc100_default_sdhci1(void) { }
183#endif /* CONFIG_S3C_DEV_HSMMC1 */
184
185#ifdef CONFIG_S3C_DEV_HSMMC2
186static inline void s5pc100_default_sdhci2(void)
187{
188 s3c_hsmmc2_def_platdata.clocks = s5pc100_hsmmc_clksrcs;
189 s3c_hsmmc2_def_platdata.cfg_gpio = s5pc100_setup_sdhci2_cfg_gpio;
190 s3c_hsmmc2_def_platdata.cfg_card = s5pc100_setup_sdhci0_cfg_card;
191}
192#else
193static inline void s5pc100_default_sdhci2(void) { }
194#endif /* CONFIG_S3C_DEV_HSMMC1 */
195
196
197#else
198static inline void s5pc100_default_sdhci0(void) { }
199static inline void s5pc100_default_sdhci1(void) { }
200static inline void s5pc100_default_sdhci2(void) { }
201#endif /* CONFIG_S5PC100_SETUP_SDHCI */
202
148#endif /* __PLAT_S3C_SDHCI_H */ 203#endif /* __PLAT_S3C_SDHCI_H */
diff --git a/arch/arm/plat-s5pc1xx/Kconfig b/arch/arm/plat-s5pc1xx/Kconfig
index 1fc25b9f2242..1608e62b0c9d 100644
--- a/arch/arm/plat-s5pc1xx/Kconfig
+++ b/arch/arm/plat-s5pc1xx/Kconfig
@@ -55,4 +55,10 @@ config S5PC1XX_SETUP_I2C1
55 bool 55 bool
56 help 56 help
57 Common setup code for i2c bus 1. 57 Common setup code for i2c bus 1.
58
59config S5PC1XX_SETUP_SDHCI_GPIO
60 bool
61 help
62 Common setup code for SDHCI gpio.
63
58endif 64endif
diff --git a/arch/arm/plat-s5pc1xx/Makefile b/arch/arm/plat-s5pc1xx/Makefile
index 40ee9571fb01..278f26806089 100644
--- a/arch/arm/plat-s5pc1xx/Makefile
+++ b/arch/arm/plat-s5pc1xx/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_S5P_GPIO_CFG_S5PC1XX) += gpio-config.o
28obj-$(CONFIG_S5PC1XX_SETUP_FB_24BPP) += setup-fb-24bpp.o 28obj-$(CONFIG_S5PC1XX_SETUP_FB_24BPP) += setup-fb-24bpp.o
29obj-$(CONFIG_S5PC1XX_SETUP_I2C0) += setup-i2c0.o 29obj-$(CONFIG_S5PC1XX_SETUP_I2C0) += setup-i2c0.o
30obj-$(CONFIG_S5PC1XX_SETUP_I2C1) += setup-i2c1.o 30obj-$(CONFIG_S5PC1XX_SETUP_I2C1) += setup-i2c1.o
31obj-$(CONFIG_S5PC1XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
diff --git a/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c b/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
new file mode 100644
index 000000000000..185c8941e644
--- /dev/null
+++ b/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
@@ -0,0 +1,86 @@
1/* linux/arch/arm/plat-s5pc1xx/setup-sdhci-gpio.c
2 *
3 * Copyright 2009 Samsung Eletronics
4 *
5 * S5PC1XX - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18#include <linux/mmc/host.h>
19#include <linux/mmc/card.h>
20
21#include <plat/gpio-cfg.h>
22#include <plat/regs-sdhci.h>
23
24void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
25{
26 unsigned int gpio;
27 unsigned int end;
28 unsigned int num;
29
30 num = width;
31 /* In case of 8 width, we should decrease the 2 */
32 if (width == 8)
33 num = width - 2;
34
35 end = S5PC100_GPG0(2 + num);
36
37 /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
38 for (gpio = S5PC100_GPG0(0); gpio < end; gpio++) {
39 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
40 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
41 }
42
43 if (width == 8) {
44 for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) {
45 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
46 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
47 }
48 }
49
50 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
51 s3c_gpio_cfgpin(S5PC100_GPG1(2), S3C_GPIO_SFN(2));
52}
53
54void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
55{
56 unsigned int gpio;
57 unsigned int end;
58
59 end = S5PC100_GPG2(2 + width);
60
61 /* Set all the necessary GPG2 pins to special-function 2 */
62 for (gpio = S5PC100_GPG2(0); gpio < end; gpio++) {
63 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
64 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
65 }
66
67 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
68 s3c_gpio_cfgpin(S5PC100_GPG2(6), S3C_GPIO_SFN(2));
69}
70
71void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
72{
73 unsigned int gpio;
74 unsigned int end;
75
76 end = S5PC100_GPG3(2 + width);
77
78 /* Set all the necessary GPG3 pins to special-function 2 */
79 for (gpio = S5PC100_GPG3(0); gpio < end; gpio++) {
80 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
81 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
82 }
83
84 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
85 s3c_gpio_cfgpin(S5PC100_GPG3(6), S3C_GPIO_SFN(2));
86}