From: jekhor@gmail.com (Yauhen Kharuzhy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/10] ARM: S3C2416: Add platform helpers for setup SDHCI
Date: Sun, 28 Nov 2010 20:30:21 +0200 [thread overview]
Message-ID: <1290969027-10178-3-git-send-email-jekhor@gmail.com> (raw)
In-Reply-To: <1290969027-10178-1-git-send-email-jekhor@gmail.com>
Samsung S3C2416 has two SDHCI controllers compatible with other
Samsung's SoCs (S3C64XX, S5PC100 etc...).
Add required platform setup code that the devices can be used with
sdhci-s3c driver.
Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
arch/arm/mach-s3c2416/Kconfig | 12 +++++
arch/arm/mach-s3c2416/Makefile | 4 ++
arch/arm/mach-s3c2416/s3c2416.c | 5 ++
arch/arm/mach-s3c2416/setup-sdhci-gpio.c | 58 ++++++++++++++++++++++++++
arch/arm/mach-s3c2416/setup-sdhci.c | 62 ++++++++++++++++++++++++++++
arch/arm/plat-samsung/include/plat/sdhci.h | 35 ++++++++++++++++
6 files changed, 176 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-s3c2416/setup-sdhci-gpio.c
create mode 100644 arch/arm/mach-s3c2416/setup-sdhci.c
diff --git a/arch/arm/mach-s3c2416/Kconfig b/arch/arm/mach-s3c2416/Kconfig
index 27b3e7c..2eaadcf 100644
--- a/arch/arm/mach-s3c2416/Kconfig
+++ b/arch/arm/mach-s3c2416/Kconfig
@@ -30,6 +30,17 @@ config S3C2416_PM
help
Internal config node to apply S3C2416 power management
+config S3C2416_SETUP_SDHCI
+ bool
+ select S3C2416_SETUP_SDHCI_GPIO
+ help
+ Internal helper functions for S3C2416 based SDHCI systems
+
+config S3C2416_SETUP_SDHCI_GPIO
+ bool
+ help
+ Common setup code for SDHCI gpio.
+
menu "S3C2416 Machines"
config MACH_SMDK2416
@@ -41,6 +52,7 @@ config MACH_SMDK2416
select S3C_DEV_HSMMC1
select S3C_DEV_NAND
select S3C_DEV_USB_HOST
+ select S3C2416_SETUP_SDHCI
select S3C2416_PM if PM
help
Say Y here if you are using an SMDK2416
diff --git a/arch/arm/mach-s3c2416/Makefile b/arch/arm/mach-s3c2416/Makefile
index ef038d6..7b805b2 100644
--- a/arch/arm/mach-s3c2416/Makefile
+++ b/arch/arm/mach-s3c2416/Makefile
@@ -14,6 +14,10 @@ obj-$(CONFIG_CPU_S3C2416) += irq.o
obj-$(CONFIG_S3C2416_PM) += pm.o
#obj-$(CONFIG_S3C2416_DMA) += dma.o
+# Device setup
+obj-$(CONFIG_S3C2416_SETUP_SDHCI) += setup-sdhci.o
+obj-$(CONFIG_S3C2416_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
+
# Machine support
obj-$(CONFIG_MACH_SMDK2416) += mach-smdk2416.o
diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c2416/s3c2416.c
index 63f39cd..ba7fd87 100644
--- a/arch/arm/mach-s3c2416/s3c2416.c
+++ b/arch/arm/mach-s3c2416/s3c2416.c
@@ -53,6 +53,7 @@
#include <plat/s3c2416.h>
#include <plat/devs.h>
#include <plat/cpu.h>
+#include <plat/sdhci.h>
#include <plat/iic-core.h>
#include <plat/fb-core.h>
@@ -115,6 +116,10 @@ void __init s3c2416_map_io(void)
s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_updown;
s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_updown;
+ /* initialize device information early */
+ s3c2416_default_sdhci0();
+ s3c2416_default_sdhci1();
+
iotable_init(s3c2416_iodesc, ARRAY_SIZE(s3c2416_iodesc));
}
diff --git a/arch/arm/mach-s3c2416/setup-sdhci-gpio.c b/arch/arm/mach-s3c2416/setup-sdhci-gpio.c
new file mode 100644
index 0000000..68ac523
--- /dev/null
+++ b/arch/arm/mach-s3c2416/setup-sdhci-gpio.c
@@ -0,0 +1,58 @@
+/* linux/arch/arm/plat-s3c2416/setup-sdhci-gpio.c
+ *
+ * Copyright 2010 Promwad Innovation Company
+ * Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
+ *
+ * S3C2416 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
+ *
+ * Based on mach-s3c64xx/setup-sdhci-gpio.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+
+#include <mach/gpio.h>
+#include <mach/regs-gpio.h>
+#include <plat/gpio-cfg.h>
+
+void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
+{
+ unsigned int gpio;
+ unsigned int end;
+
+ end = S3C2410_GPE(7 + width);
+
+ /* Set all the necessary GPE pins to special-function 0 */
+ for (gpio = S3C2410_GPE(5); gpio < end; gpio++) {
+ s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
+ s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
+ }
+}
+
+void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
+{
+ unsigned int gpio;
+ unsigned int end;
+
+ end = S3C2410_GPL(0 + width);
+
+ /* Set all the necessary GPG pins to special-function 0 */
+ for (gpio = S3C2410_GPL(0); gpio < end; gpio++) {
+ s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
+ s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
+ }
+
+ s3c_gpio_cfgpin(S3C2410_GPL(8), S3C_GPIO_SFN(2));
+ s3c_gpio_setpull(S3C2410_GPL(8), S3C_GPIO_PULL_NONE);
+ s3c_gpio_cfgpin(S3C2410_GPL(9), S3C_GPIO_SFN(2));
+ s3c_gpio_setpull(S3C2410_GPL(9), S3C_GPIO_PULL_NONE);
+}
+
+
diff --git a/arch/arm/mach-s3c2416/setup-sdhci.c b/arch/arm/mach-s3c2416/setup-sdhci.c
new file mode 100644
index 0000000..345ddd1
--- /dev/null
+++ b/arch/arm/mach-s3c2416/setup-sdhci.c
@@ -0,0 +1,62 @@
+/* linux/arch/arm/mach-s3c2416/setup-sdhci.c
+ *
+ * Copyright 2010 Promwad Innovation Company
+ * Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
+ *
+ * S3C2416 - Helper functions for settign up SDHCI device(s) (HSMMC)
+ *
+ * Based on mach-s3c64xx/setup-sdhci.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+
+#include <plat/regs-sdhci.h>
+#include <plat/sdhci.h>
+
+/* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
+
+char *s3c2416_hsmmc_clksrcs[4] = {
+ [0] = "hsmmc",
+ [1] = "hsmmc",
+ [2] = "hsmmc-if",
+ /* [3] = "48m", - note not successfully used yet */
+};
+
+void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,
+ void __iomem *r,
+ struct mmc_ios *ios,
+ struct mmc_card *card)
+{
+ u32 ctrl2, ctrl3;
+
+ ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
+ ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
+ ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
+ S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
+ S3C_SDHCI_CTRL2_ENFBCLKRX |
+ S3C_SDHCI_CTRL2_DFCNT_NONE |
+ S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
+
+ if (ios->clock < 25 * 1000000)
+ ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
+ S3C_SDHCI_CTRL3_FCSEL2 |
+ S3C_SDHCI_CTRL3_FCSEL1 |
+ S3C_SDHCI_CTRL3_FCSEL0);
+ else
+ ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
+
+ writel(ctrl2, r + S3C_SDHCI_CONTROL2);
+ writel(ctrl3, r + S3C_SDHCI_CONTROL3);
+}
+
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h
index 85853f8..81d801e 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -121,6 +121,8 @@ extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
+extern void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
+extern void s3c2416_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
/* S3C64XX SDHCI setup */
@@ -299,6 +301,39 @@ static inline void s5pv210_default_sdhci3(void) { }
#endif /* CONFIG_S5PV210_SETUP_SDHCI */
+/* S3C2416 SDHCI setup */
+#ifdef CONFIG_S3C2416_SETUP_SDHCI
+extern char *s3c2416_hsmmc_clksrcs[4];
+
+extern void s3c2416_setup_sdhci_cfg_card(struct platform_device *dev,
+ void __iomem *r,
+ struct mmc_ios *ios,
+ struct mmc_card *card);
+
+#ifdef CONFIG_S3C_DEV_HSMMC
+static inline void s3c2416_default_sdhci0(void)
+{
+ s3c_hsmmc0_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
+ s3c_hsmmc0_def_platdata.cfg_gpio = s3c2416_setup_sdhci0_cfg_gpio;
+ s3c_hsmmc0_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
+}
+#else
+static inline void s3c2416_default_sdhci0(void) { }
+#endif /* CONFIG_S3C_DEV_HSMMC */
+
+#ifdef CONFIG_S3C_DEV_HSMMC1
+static inline void s3c2416_default_sdhci1(void)
+{
+ s3c_hsmmc1_def_platdata.clocks = s3c2416_hsmmc_clksrcs;
+ s3c_hsmmc1_def_platdata.cfg_gpio = s3c2416_setup_sdhci1_cfg_gpio;
+ s3c_hsmmc1_def_platdata.cfg_card = s3c2416_setup_sdhci_cfg_card;
+}
+#else
+static inline void s3c2416_default_sdhci1(void) { }
+#endif /* CONFIG_S3C_DEV_HSMMC1 */
+
+#endif /* CONFIG_S3C2416_SETUP_SDHCI */
+
/* S5PV310 SDHCI setup */
#ifdef CONFIG_S5PV310_SETUP_SDHCI
extern char *s5pv310_hsmmc_clksrcs[4];
--
1.7.2.3
next prev parent reply other threads:[~2010-11-28 18:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-28 18:30 [PATCH 01/10] SMDK2416: Select MACH_SMDK, S3C_DEV_NAND, S3C_DEV_USB_HOST Yauhen Kharuzhy
2010-11-28 18:30 ` [PATCH 02/10] ARM S3C2416: Add address map and clock definitions for HSMMC0 Yauhen Kharuzhy
2010-11-30 7:21 ` Kukjin Kim
2010-11-30 8:21 ` Yauhen Kharuzhy
2010-12-03 12:46 ` Kukjin Kim
2010-11-28 18:30 ` Yauhen Kharuzhy [this message]
2010-11-30 7:37 ` [PATCH 03/10] ARM: S3C2416: Add platform helpers for setup SDHCI Kukjin Kim
2010-11-30 8:34 ` Yauhen Kharuzhy
2010-12-01 9:57 ` [PATCH v2] " Yauhen Kharuzhy
2010-12-02 20:06 ` Yauhen Kharuzhy
2010-12-10 1:35 ` Kukjin Kim
2010-11-28 18:30 ` [PATCH 04/10] ARM: S3C2416: Add support of SD/MMC card detect on SMDK2416 Yauhen Kharuzhy
2010-11-28 18:30 ` [PATCH 05/10] ARM S3C2443: Select properly ARM core type Yauhen Kharuzhy
2010-11-29 11:08 ` Kukjin Kim
2010-11-29 11:25 ` Yauhen Kharuzhy
2010-11-30 8:45 ` Ben Dooks
2010-11-28 18:30 ` [PATCH 06/10] ARM S3C24XX: Compile NAND device definition for SMDK boards Yauhen Kharuzhy
2010-11-30 7:45 ` Kukjin Kim
2010-11-30 8:27 ` Yauhen Kharuzhy
2010-12-03 12:37 ` Kukjin Kim
2010-12-03 13:24 ` Yauhen Kharuzhy
2010-11-28 18:30 ` [PATCH 07/10] ARM S3C2443: Implement GPIO pull-up/down configuration methods Yauhen Kharuzhy
2010-11-30 8:10 ` Kukjin Kim
2010-11-28 18:30 ` [PATCH 08/10] ARM SAMSUNG: Don't export __init functions to modules Yauhen Kharuzhy
2010-11-28 18:30 ` [PATCH 09/10] ARM S3C2412: Fix typo in CONFIG_CPU_S3C2412_ONLY definition Yauhen Kharuzhy
2010-11-30 7:38 ` Kukjin Kim
2010-11-30 8:47 ` Ben Dooks
2010-11-29 10:51 ` [PATCH 01/10] SMDK2416: Select MACH_SMDK, S3C_DEV_NAND, S3C_DEV_USB_HOST Kukjin Kim
2010-11-29 11:22 ` Yauhen Kharuzhy
2010-12-03 12:25 ` Kukjin Kim
2010-12-03 12:39 ` Yauhen Kharuzhy
2010-12-03 12:50 ` Kukjin Kim
2010-11-30 8:33 ` Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290969027-10178-3-git-send-email-jekhor@gmail.com \
--to=jekhor@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).