<br><br><div class="gmail_quote">On Tue, Jun 22, 2010 at 4:16 PM, Yauhen Kharuzhy <span dir="ltr"><<a href="mailto:jekhor@gmail.com">jekhor@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Samsung S3C2416 has two SDHCI controllers compatible with other<br>
Samsung's SoCs (S3C64XX, S5PC100 etc...).<br>
<br>
Add required platform setup code that the devices can be used with<br>
sdhci-s3c driver.<br>
<br>
Signed-off-by: Yauhen Kharuzhy <<a href="mailto:jekhor@gmail.com">jekhor@gmail.com</a>><br>
---<br>
arch/arm/mach-s3c2416/Kconfig | 23 ++++++++++<br>
arch/arm/mach-s3c2416/Makefile | 5 ++<br>
arch/arm/mach-s3c2416/s3c2416.c | 5 ++<br>
arch/arm/mach-s3c2416/setup-sdhci-gpio.c | 60 +++++++++++++++++++++++++++<br>
arch/arm/mach-s3c2416/setup-sdhci.c | 62 ++++++++++++++++++++++++++++<br>
arch/arm/plat-samsung/include/plat/sdhci.h | 34 +++++++++++++++<br>
6 files changed, 189 insertions(+), 0 deletions(-)<br>
create mode 100644 arch/arm/mach-s3c2416/setup-sdhci-gpio.c<br>
create mode 100644 arch/arm/mach-s3c2416/setup-sdhci.c<br>
<br>
diff --git a/arch/arm/mach-s3c2416/Kconfig b/arch/arm/mach-s3c2416/Kconfig<br>
index eafb0ed..e055c7f 100644<br>
--- a/arch/arm/mach-s3c2416/Kconfig<br>
+++ b/arch/arm/mach-s3c2416/Kconfig<br>
@@ -25,6 +25,17 @@ config S3C2416_DMA<br>
help<br>
Internal config node for S3C2416 DMA support<br>
<br>
+config S3C2416_SETUP_SDHCI<br>
+ bool<br>
+ select S3C2416_SETUP_SDHCI_GPIO<br>
+ help<br>
+ Internal helper functions for S3C2416 based SDHCI systems<br>
+<br>
+config S3C2416_SETUP_SDHCI_GPIO<br>
+ bool<br>
+ help<br>
+ Common setup code for SDHCI gpio.<br>
+<br>
menu "S3C2416 Machines"<br>
<br>
config MACH_SMDK2416<br>
@@ -36,7 +47,19 @@ config MACH_SMDK2416<br>
select S3C_DEV_HSMMC1<br>
select S3C_DEV_NAND<br>
select S3C_DEV_USB_HOST<br>
+ select S3C2416_SETUP_SDHCI<br>
help<br>
Say Y here if you are using an SMDK2416<br>
<br>
+config MACH_HANLIN_V3C<br>
+ bool "Hanlin eReader V3C"<br>
+ select CPU_S3C2416<br>
+ select S3C_DEV_HSMMC<br>
+ select S3C_DEV_HSMMC1<br>
+ select S3C_DEV_NAND<br>
+ select S3C_DEV_USB_HOST<br>
+ select S3C2416_SETUP_SDHCI<br>
+ help<br>
+ Say Y here if you are using an Jinke's Hanlin V3C eReader<br>
+<br>
endmenu<br>
diff --git a/arch/arm/mach-s3c2416/Makefile b/arch/arm/mach-s3c2416/Makefile<br>
index 6c12c7b..678e148 100644<br>
--- a/arch/arm/mach-s3c2416/Makefile<br>
+++ b/arch/arm/mach-s3c2416/Makefile<br>
@@ -14,6 +14,11 @@ obj-$(CONFIG_CPU_S3C2416) += irq.o<br>
<br>
#obj-$(CONFIG_S3C2416_DMA) += dma.o<br>
<br>
+# Device setup<br>
+obj-$(CONFIG_S3C2416_SETUP_SDHCI) += setup-sdhci.o<br>
+obj-$(CONFIG_S3C2416_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o<br>
+<br>
# Machine support<br>
<br>
obj-$(CONFIG_MACH_SMDK2416) += mach-smdk2416.o<br>
+obj-$(CONFIG_MACH_HANLIN_V3C) += mach-v3c.o<br>
diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c2416/s3c2416.c<br>
index 355ab62..06eacf8 100644<br>
--- a/arch/arm/mach-s3c2416/s3c2416.c<br>
+++ b/arch/arm/mach-s3c2416/s3c2416.c<br>
@@ -53,6 +53,7 @@<br>
#include <plat/s3c2416.h><br>
#include <plat/devs.h><br>
#include <plat/cpu.h><br>
+#include <plat/sdhci.h><br>
<br>
#include <plat/iic-core.h><br>
<br>
@@ -115,6 +116,10 @@ void __init s3c2416_map_io(void)<br>
s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_updown;<br>
s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_updown;<br>
<br>
+ /* initialize device information early */<br>
+ s3c2416_default_sdhci0();<br>
+ s3c2416_default_sdhci1();<br>
+<br>
iotable_init(s3c2416_iodesc, ARRAY_SIZE(s3c2416_iodesc));<br>
}<br>
<br>
diff --git a/arch/arm/mach-s3c2416/setup-sdhci-gpio.c b/arch/arm/mach-s3c2416/setup-sdhci-gpio.c<br>
new file mode 100644<br>
index 0000000..ebdab15<br>
--- /dev/null<br>
+++ b/arch/arm/mach-s3c2416/setup-sdhci-gpio.c<br>
@@ -0,0 +1,60 @@<br>
+/* linux/arch/arm/plat-s3c2416/setup-sdhci-gpio.c<br>
+ *<br>
+ * Copyright 2010 Promwad Innovation Company<br>
+ * Yauhen Kharuzhy <<a href="mailto:yauhen.kharuzhy@promwad.com">yauhen.kharuzhy@promwad.com</a>><br>
+ *<br>
+ * S3C2416 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)<br>
+ *<br>
+ * Based on mach-s3c64xx/setup-sdhci-gpio.c<br>
+ *<br>
+ * This program is free software; you can redistribute it and/or modify<br>
+ * it under the terms of the GNU General Public License version 2 as<br>
+ * published by the Free Software Foundation.<br>
+*/<br>
+<br>
+#include <linux/kernel.h><br>
+#include <linux/types.h><br>
+#include <linux/interrupt.h><br>
+#include <linux/platform_device.h><br>
+#include <linux/io.h><br>
+<br>
+#include <mach/gpio.h><br>
+#include <mach/regs-gpio.h><br>
+#include <plat/gpio-cfg.h><br>
+<br>
+/* Note: hsmmc1 and hsmmc0 are swapped versus datasheet */<br></blockquote><div><br>would be nice to provide more accurate link to information source (document version, page).<br>And there is a bit tricky place: clock ids are swapped and names of helper functions are not.<br>
So, it's not clear which helper function corresponds to real physical SDHC interface.<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
+<br>
+void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)<br>
+{<br>
+ unsigned int gpio;<br>
+ unsigned int end;<br>
+<br>
+ end = S3C2410_GPE(7 + width);<br>
+<br>
+ /* Set all the necessary GPE pins to special-function 0 */<br>
+ for (gpio = S3C2410_GPE(5); gpio < end; gpio++) {<br>
+ s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));<br>
+ s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);<br>
+ }<br>
+}<br>
+<br>
+void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)<br>
+{<br>
+ unsigned int gpio;<br>
+ unsigned int end;<br>
+<br>
+ end = S3C2410_GPL(0 + width);<br>
+<br>
+ /* Set all the necessary GPG pins to special-function 0 */<br>
+ for (gpio = S3C2410_GPL(0); gpio < end; gpio++) {<br>
+ s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));<br>
+ s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);<br>
+ }<br>
+<br>
+ s3c_gpio_cfgpin(S3C2410_GPL(8), S3C_GPIO_SFN(2));<br>
+ s3c_gpio_setpull(S3C2410_GPL(8), S3C_GPIO_PULL_NONE);<br>
+ s3c_gpio_cfgpin(S3C2410_GPL(9), S3C_GPIO_SFN(2));<br>
+ s3c_gpio_setpull(S3C2410_GPL(9), S3C_GPIO_PULL_NONE);<br>
+}<br>
+<br>
+<br>
diff --git a/arch/arm/mach-s3c2416/setup-sdhci.c b/arch/arm/mach-s3c2416/setup-sdhci.c<br>
new file mode 100644<br>
index 0000000..345ddd1<br>
--- /dev/null<br>
+++ b/arch/arm/mach-s3c2416/setup-sdhci.c<br>
@@ -0,0 +1,62 @@<br>
+/* linux/arch/arm/mach-s3c2416/setup-sdhci.c<br>
+ *<br>
+ * Copyright 2010 Promwad Innovation Company<br>
+ * Yauhen Kharuzhy <<a href="mailto:yauhen.kharuzhy@promwad.com">yauhen.kharuzhy@promwad.com</a>><br>
+ *<br>
+ * S3C2416 - Helper functions for settign up SDHCI device(s) (HSMMC)<br>
+ *<br>
+ * Based on mach-s3c64xx/setup-sdhci.c<br>
+ *<br>
+ * This program is free software; you can redistribute it and/or modify<br>
+ * it under the terms of the GNU General Public License version 2 as<br>
+ * published by the Free Software Foundation.<br>
+*/<br>
+<br>
+#include <linux/kernel.h><br>
+#include <linux/types.h><br>
+#include <linux/interrupt.h><br>
+#include <linux/platform_device.h><br>
+#include <linux/io.h><br>
+<br>
+#include <linux/mmc/card.h><br>
+#include <linux/mmc/host.h><br>
+<br>
+#include <plat/regs-sdhci.h><br>
+#include <plat/sdhci.h><br>
+<br>
+/* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */<br>
+<br>
+char *s3c2416_hsmmc_clksrcs[4] = {<br>
+ [0] = "hsmmc",<br>
+ [1] = "hsmmc",<br>
+ [2] = "hsmmc-if",<br>
+ /* [3] = "48m", - note not successfully used yet */<br>
+};<br>
+<br>
+void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,<br>
+ void __iomem *r,<br>
+ struct mmc_ios *ios,<br>
+ struct mmc_card *card)<br>
+{<br>
+ u32 ctrl2, ctrl3;<br>
+<br>
+ ctrl2 = readl(r + S3C_SDHCI_CONTROL2);<br>
+ ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;<br>
+ ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |<br>
+ S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |<br>
+ S3C_SDHCI_CTRL2_ENFBCLKRX |<br>
+ S3C_SDHCI_CTRL2_DFCNT_NONE |<br>
+ S3C_SDHCI_CTRL2_ENCLKOUTHOLD);<br>
+<br>
+ if (ios->clock < 25 * 1000000)<br>
+ ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |<br>
+ S3C_SDHCI_CTRL3_FCSEL2 |<br>
+ S3C_SDHCI_CTRL3_FCSEL1 |<br>
+ S3C_SDHCI_CTRL3_FCSEL0);<br>
+ else<br>
+ ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);<br>
+<br>
+ writel(ctrl2, r + S3C_SDHCI_CONTROL2);<br>
+ writel(ctrl3, r + S3C_SDHCI_CONTROL3);<br>
+}<br>
+<br>
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h<br>
index 13f9fb2..d408140 100644<br>
--- a/arch/arm/plat-samsung/include/plat/sdhci.h<br>
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h<br>
@@ -78,6 +78,8 @@ extern void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *, int w);<br>
extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);<br>
extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);<br>
extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);<br>
+extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);<br>
+extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);<br>
<br>
/* S3C6400 SDHCI setup */<br>
<br>
@@ -270,6 +272,38 @@ static inline void s5pv210_default_sdhci1(void) { }<br>
static inline void s5pv210_default_sdhci2(void) { }<br>
#endif /* CONFIG_S5PC100_SETUP_SDHCI */<br>
<br>
+/* S3C2416 SDHCI setup */<br>
+#ifdef CONFIG_S3C2416_SETUP_SDHCI<br>
+extern char *s3c2416_hsmmc_clksrcs[4];<br>
+<br>
+extern void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,<br>
+ void __iomem *r,<br>
+ struct mmc_ios *ios,<br>
+ struct mmc_card *card);<br>
+<br>
+#ifdef CONFIG_S3C_DEV_HSMMC<br>
+static inline void s3c2416_default_sdhci0(void)<br>
+{<br>
+ s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;<br>
+ s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;<br>
+ s3c_hsmmc0_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;<br></blockquote><div><br>helper id 0 gets to interface 0 - not swapped.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
+}<br>
+#else<br>
+static inline void s3c2416_default_sdhci0(void) { }<br>
+#endif /* CONFIG_S3C_DEV_HSMMC */<br>
+<br>
+#ifdef CONFIG_S3C_DEV_HSMMC1<br>
+static inline void s3c2416_default_sdhci1(void)<br>
+{<br>
+ s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;<br>
+ s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;<br>
+ s3c_hsmmc1_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;<br></blockquote><div><br>helper id 1 gets to interface 1 - not swapped.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
+}<br>
+#else<br>
+static inline void s3c2416_default_sdhci1(void) { }<br>
+#endif /* CONFIG_S3C_DEV_HSMMC1 */<br>
+<br>
+#endif /* CONFIG_S3C2416_SETUP_SDHCI */<br>
<font color="#888888"><br>
<br>
<br>
--<br>
1.6.6.1<br>
<br>
</font></blockquote></div><br>