Skip to contentSkip to conversation

ARM: S5P: Add SCLK SDHCI configuration functionality

PATCH In review Thomas Abraham 2 participants 2 messages Mar 9, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: S5P: Add SCLK SDHCI configuration functionality

The SDHCI SCLK clock in Samsung's S5P SoC's can be configured for required clock speeds. This patch adds SDHCI SCLK configuration functionality for S5P SoC's.

---
 arch/arm/plat-s5p/clock.c                  |   21 +++++++++++++++++++++
 arch/arm/plat-s5p/include/plat/s5p-clock.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
arch/arm/plat-s5p/clock.c +21 -0
index aa96e33..12970ed 100644
@@ -19,11 +19,13 @@
 #include <linux/clk.h>
 #include <linux/sysdev.h>
 #include <linux/io.h>
+#include <linux/platform_device.h>
 #include <asm/div64.h>
 
 #include <plat/clock.h>
 #include <plat/clock-clksrc.h>
 #include <plat/s5p-clock.h>
+#include <plat/sdhci.h>
 
 /* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
  * clk_ext_xtal_mux.
@@ -147,3 +149,22 @@ void __init s5p_register_clocks(unsigned long xtal_freq)
 	if (ret > 0)
 		printk(KERN_ERR "Failed to register s5p clocks\n");
 }
+
+#ifdef CONFIG_MMC_SDHCI_S3C
+int s5p_setup_sdhci_sclk(struct platform_device *pdev, struct clk *parent)
+{
+	struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct clk *sclk_mmc;
+
+	sclk_mmc = clk_get(dev, "mmc_bus");
+	if (IS_ERR(sclk_mmc)) {
+		dev_err(dev, "failed to get mmc_bus clock\n");
+		return PTR_ERR(sclk_mmc);
+	}
+
+	sclk_mmc->ops->set_parent(sclk_mmc, parent);
+	sclk_mmc->ops->set_rate(sclk_mmc, pdata->sclk_mmc_freq);
+	return 0;
+}
+#endif /* CONFIG_MMC_SDHCI_S3C */
arch/arm/plat-s5p/include/plat/s5p-clock.h +2 -0
index 56fb8b4..3855f74 100644
@@ -36,5 +36,7 @@ extern struct clksrc_sources clk_src_epll;
 
 extern int s5p6440_clk48m_ctrl(struct clk *clk, int enable);
 extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable);
+extern int s5p_setup_sdhci_sclk(struct platform_device *pdev,
+					struct clk *parent);
 
 #endif /* __ASM_PLAT_S5P_CLOCK_H */
Signature · 1 line
1.6.6.rc2
#1 lore raw

arch/arm/plat-s5p/clock.c void __init s5p_register_clocks(unsigned long xtal_freq) · line 164

Quoted 12 lines · Thomas Abraham
arch/arm/plat-s5p/clock.c +12 -0
+#ifdef CONFIG_MMC_SDHCI_S3C
+int s5p_setup_sdhci_sclk(struct platform_device *pdev, struct clk *parent)
+{
+	struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data;
+	struct device *dev = &pdev->dev;
+	struct clk *sclk_mmc;
+
+	sclk_mmc = clk_get(dev, "mmc_bus");
+	if (IS_ERR(sclk_mmc)) {
+		dev_err(dev, "failed to get mmc_bus clock\n");
+		return PTR_ERR(sclk_mmc);
+	}

There doesn't seem to be a matching clk_put for this.

arch/arm/plat-s5p/clock.c void __init s5p_register_clocks(unsigned long xtal_freq) · line 166

Quoted 1 line
arch/arm/plat-s5p/clock.c +1 -0
+	sclk_mmc->ops->set_parent(sclk_mmc, parent);

Given that the user of this API needs to know enough about the clock structure of the chip to know which parent clock to set (and already have that parent clock) it's not clear to me what this API is intended to do - as far as I can see it would live as well in the SDHCI driver as it is at present.