Skip to contentSkip to conversation

sdhci-s3c: Add support S5PV310/S5PC210 HSMMC

PATCH New Kukjin Kim 3 participants 5 messages Oct 8, 2010 – Oct 11, 2010

Subsystems (4)
lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

cover sdhci-s3c: Add support S5PV310/S5PC210 HSMMC

This patch adds support S5PV310/S5PC210 HSMMC and additional host capabilities. HSMMC of S5PV310 does not have internal clock divider so need to update for it.

Changes since v2:
- Changed clock control method to overriding from using quirk
- This patch is referred from that of Jaehoon Chung's support non-standard clock setting

Changes since v1:
- Separated to each topic

NOTE:
- This patch depends on following.
[PATCH 4/5] ARM: SAMSUNG : Add clock types into platform data

This includes following.
[PATCH RESEND 1/2] sdhci-s3c: Add support additional host capabilities [PATCH V3 2/2] sdhci-s3c: Add support no internal clock divider in host controller

author
#1 lore raw

PATCH RESEND 1/2 sdhci-s3c: Add support additional host capabilities

From: Jeongbae Seo <[email protected]>

This patch adds to support additional host capabilities like SD/MMC high speed, SDHCI bus width and etc.

---
 drivers/mmc/host/sdhci-s3c.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-s3c.c +4 -0
index aacb862..a7710f5 100644
@@ -427,6 +427,10 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 	/* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
 	host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
 
+	/* It supports additional host capabilities if needed */
+	if (pdata->host_caps)
+		host->mmc->caps |= pdata->host_caps;
+
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_err(dev, "sdhci_add_host() failed\n");
Signature · 1 line
1.6.2.5
author
#2 lore raw

PATCH v3 2/2 sdhci-s3c: Add support no internal clock divider in host controller

In reply to Kukjin Kim

From: Jeongbae Seo <[email protected]>

This patch adds to support no internal clock divider in SDHCI. The external clock divider can be used to make a proper clock because SDHCI doesn't support internal clock divider by itself.

If external clock divider type is selected, some functions related with clock control will be overridened by other functions.

The current clock control index is added to let you know which clock bus is used for SDHCI when using overriding functions.

The checking functions is added into sdhci_s3c_consider_clock, because clock divider step is different from that of host controller.

---
Changes since v2:
- Changed clock control method to overriding from using quirk
- This patch is referred from that of Jaehoon Chung's support non-standard clock setting

Changes since v1:
- Separated to each topic

NOTE :
- This patch depends on following.
[PATCH 4/5] ARM: SAMSUNG : Add clock types into platform data

 drivers/mmc/host/sdhci-s3c.c |   62 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-s3c.c +62 -0
index a7710f5..1720358 100644
@@ -130,6 +130,15 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
 	if (!clksrc)
 		return UINT_MAX;
 
+	/*
+	 * Clock divider's step is different as 1 from that of host controller
+	 * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL.
+	 */
+	if (ourhost->pdata->clk_type) {
+		rate = clk_round_rate(clksrc, wanted);
+		return wanted - rate;
+	}
+
 	rate = clk_get_rate(clksrc);
 
 	for (div = 1; div < 256; div *= 2) {
@@ -232,6 +241,42 @@ static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
 	return min;
 }
 
+/* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
+static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
+{
+	struct sdhci_s3c *ourhost = to_s3c(host);
+
+	return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], UINT_MAX);
+}
+
+/* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
+static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
+{
+	struct sdhci_s3c *ourhost = to_s3c(host);
+
+	/*
+	 * initial clock can be in the frequency range of
+	 * 100KHz-400KHz, so we set it as max value.
+	 */
+	return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], 400000);
+}
+
+/* sdhci_cmu_set_clock - callback on clock change.*/
+static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	struct sdhci_s3c *ourhost = to_s3c(host);
+
+	/* don't bother if the clock is going off */
+	if (clock == 0)
+		return;
+
+	sdhci_s3c_set_clock(host, clock);
+
+	clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
+
+	host->clock = clock;
+}
+
 static struct sdhci_ops sdhci_s3c_ops = {
 	.get_max_clock		= sdhci_s3c_get_max_clk,
 	.set_clock		= sdhci_s3c_set_clock,
@@ -361,6 +406,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 
 		clks++;
 		sc->clk_bus[ptr] = clk;
+
+		/*
+		 * save current clock index to know which clock bus
+		 * is used later in overriding functions.
+		 */
+		sc->cur_clk = ptr;
+
 		clk_enable(clk);
 
 		dev_info(dev, "clock source %d: %s (%ld Hz)\n",
@@ -427,6 +479,16 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 	/* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
 	host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
 
+	/*
+	 * If controller does not have internal clock divider,
+	 * we can use overriding functions instead of default.
+	 */
+	if (pdata->clk_type) {
+		sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
+		sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
+		sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
+	}
+
 	/* It supports additional host capabilities if needed */
 	if (pdata->host_caps)
 		host->mmc->caps |= pdata->host_caps;
Signature · 1 line
1.6.2.5
#3 lore raw

PATCH v3 2/2 sdhci-s3c: Add support no internal clock divider in host controller

Quoted 15 lines · Kukjin Kim

From: Jeongbae Seo <[email protected]>

This patch adds to support no internal clock divider in SDHCI. The external clock divider can be used to make a proper clock because SDHCI doesn't support internal clock divider by itself.

If external clock divider type is selected, some functions related with clock control will be overridened by other functions.

The current clock control index is added to let you know which clock bus is used for SDHCI when using overriding functions.

The checking functions is added into sdhci_s3c_consider_clock, because clock divider step is different from that of host controller.

Quoted 8 lines

---
Changes since v2:
- Changed clock control method to overriding from using quirk
- This patch is referred from that of Jaehoon Chung's support non-standard clock setting

I don't know how to handle this case. Just "CC" the Jaehoon is enough?

Quoted 16 lines

Changes since v1:
- Separated to each topic

NOTE :
- This patch depends on following.
?[PATCH 4/5] ARM: SAMSUNG : Add clock types into platform data

?drivers/mmc/host/sdhci-s3c.c | ? 62 ++++++++++++++++++++++++++++++++++++++++++ ?1 files changed, 62 insertions(+), 0 deletions(-)

drivers/mmc/host/sdhci-s3c.c +0 -0
index a7710f5..1720358 100644

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, · line 137

Quoted 8 lines
drivers/mmc/host/sdhci-s3c.c +5 -0
@@ -130,6 +130,15 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
 ? ? ? ?if (!clksrc)
 ? ? ? ? ? ? ? ?return UINT_MAX;
 
+ ? ? ? /*
+ ? ? ? ?* Clock divider's step is different as 1 from that of host controller
+ ? ? ? ?* when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL.
+ ? ? ? ?*/
+ ? ? ? if (ourhost->pdata->clk_type) {

I'm still confusing the 'clk_type" word, if you assume it's just two values, 0, and 1 at this time. then compare it with CLK_DIV_EXTERNAL. or change it as clk_exteranl it's more clear.

Quoted 89 lines
drivers/mmc/host/sdhci-s3c.c +47 -0
+ ? ? ? ? ? ? ? rate = clk_round_rate(clksrc, wanted);
+ ? ? ? ? ? ? ? return wanted - rate;
+ ? ? ? }
+
 ? ? ? ?rate = clk_get_rate(clksrc);
 
 ? ? ? ?for (div = 1; div < 256; div *= 2) {
@@ -232,6 +241,42 @@ static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
 ? ? ? ?return min;
 ?}
 
+/* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
+static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
+{
+ ? ? ? struct sdhci_s3c *ourhost = to_s3c(host);
+
+ ? ? ? return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], UINT_MAX);
+}
+
+/* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
+static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
+{
+ ? ? ? struct sdhci_s3c *ourhost = to_s3c(host);
+
+ ? ? ? /*
+ ? ? ? ?* initial clock can be in the frequency range of
+ ? ? ? ?* 100KHz-400KHz, so we set it as max value.
+ ? ? ? ?*/
+ ? ? ? return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], 400000);
+}
+
+/* sdhci_cmu_set_clock - callback on clock change.*/
+static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+ ? ? ? struct sdhci_s3c *ourhost = to_s3c(host);
+
+ ? ? ? /* don't bother if the clock is going off */
+ ? ? ? if (clock == 0)
+ ? ? ? ? ? ? ? return;
+
+ ? ? ? sdhci_s3c_set_clock(host, clock);
+
+ ? ? ? clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
+
+ ? ? ? host->clock = clock;
+}
+
 ?static struct sdhci_ops sdhci_s3c_ops = {
 ? ? ? ?.get_max_clock ? ? ? ? ?= sdhci_s3c_get_max_clk,
 ? ? ? ?.set_clock ? ? ? ? ? ? ?= sdhci_s3c_set_clock,
@@ -361,6 +406,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 
 ? ? ? ? ? ? ? ?clks++;
 ? ? ? ? ? ? ? ?sc->clk_bus[ptr] = clk;
+
+ ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ?* save current clock index to know which clock bus
+ ? ? ? ? ? ? ? ?* is used later in overriding functions.
+ ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? sc->cur_clk = ptr;
+
 ? ? ? ? ? ? ? ?clk_enable(clk);
 
 ? ? ? ? ? ? ? ?dev_info(dev, "clock source %d: %s (%ld Hz)\n",
@@ -427,6 +479,16 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)

? ? ? ?/* HSMMC on Samsung SoCs uses SDCLK as timeout clock */ ? ? ? ?host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;

+ ? ? ? /*
+ ? ? ? ?* If controller does not have internal clock divider,
+ ? ? ? ?* we can use overriding functions instead of default.
+ ? ? ? ?*/
+ ? ? ? if (pdata->clk_type) {
+ ? ? ? ? ? ? ? sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
+ ? ? ? ? ? ? ? sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
+ ? ? ? ? ? ? ? sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
+ ? ? ? }
+
? ? ? ?/* It supports additional host capabilities if needed */ ? ? ? ?if (pdata->host_caps)
? ? ? ? ? ? ? ?host->mmc->caps |= pdata->host_caps;
--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH v3 2/2 sdhci-s3c: Add support no internal clock divider in host controller

Quoted 24 lines · Kukjin Kim
Quoted 15 lines

From: Jeongbae Seo <[email protected]>

This patch adds to support no internal clock divider in SDHCI. The external clock divider can be used to make a proper clock because SDHCI doesn't support internal clock divider by itself.

If external clock divider type is selected, some functions related with clock control will be overridened by other functions.

The current clock control index is added to let you know which clock bus is used for SDHCI when using overriding functions.

The checking functions is added into sdhci_s3c_consider_clock, because clock divider step is different from that of host controller.

Quoted 8 lines

---
Changes since v2:
- Changed clock control method to overriding from using quirk
- This patch is referred from that of Jaehoon Chung's support non-

Quoted 3 lines

standard clock setting

I don't know how to handle this case. Just "CC" the Jaehoon is enough?

Could you let me know what you mean in more detail?

Quoted 23 lines
Quoted 9 lines

Changes since v1:
- Separated to each topic

NOTE :
- This patch depends on following.
 [PATCH 4/5] ARM: SAMSUNG : Add clock types into platform data

 drivers/mmc/host/sdhci-s3c.c |   62

++++++++++++++++++++++++++++++++++++++++++

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_consider_clock(struct

Quoted 7 lines
 1 files changed, 62 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-s3c.c +0 -0
index a7710f5..1720358 100644
@@ -130,6 +130,15 @@ static unsigned int sdhci_s3c_consider_clock(struct

sdhci_s3c *ourhost,

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,

Quoted 5 lines
drivers/mmc/host/sdhci-s3c.c +2 -0
        if (!clksrc)
                return UINT_MAX;
 
+       /*
+        * Clock divider's step is different as 1 from that of host
Quoted 7 lines

controller

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, · line 137

Quoted 3 lines
drivers/mmc/host/sdhci-s3c.c +3 -0
+        * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL.
+        */
+       if (ourhost->pdata->clk_type) {

I'm still confusing the 'clk_type" word, if you assume it's just two values, 0, and 1 at this time. then compare it with CLK_DIV_EXTERNAL. or change it as clk_exteranl it's more clear.

Okay, thanks. Comparing it with CLK_DIV_EXTERNAL looks good to me.

Regards
Jeongbae Seo

Quoted 23 lines

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_get_min_clock(struct

Quoted 8 lines
drivers/mmc/host/sdhci-s3c.c +4 -0
+               rate = clk_round_rate(clksrc, wanted);
+               return wanted - rate;
+       }
+
        rate = clk_get_rate(clksrc);
 
        for (div = 1; div < 256; div *= 2) {
@@ -232,6 +241,42 @@ static unsigned int sdhci_s3c_get_min_clock(struct

sdhci_host *host)

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)

Quoted 9 lines
drivers/mmc/host/sdhci-s3c.c +6 -0
        return min;
  }
 
+/* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
+static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
+{
+       struct sdhci_s3c *ourhost = to_s3c(host);
+
+       return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk],

UINT_MAX);

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,

Quoted 3 lines
drivers/mmc/host/sdhci-s3c.c +3 -0
+}
+
+/* sdhci_cmu_get_min_clock - callback to get minimal supported clock

value. */

Quoted 9 lines

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)

Quoted 9 lines
drivers/mmc/host/sdhci-s3c.c +9 -0
+static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
+{
+       struct sdhci_s3c *ourhost = to_s3c(host);
+
+       /*
+        * initial clock can be in the frequency range of
+        * 100KHz-400KHz, so we set it as max value.
+        */
+       return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk],

400000);

Quoted 69 lines

drivers/mmc/host/sdhci-s3c.c static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)

Quoted 4 lines
drivers/mmc/host/sdhci-s3c.c +4 -0
+}
+
+/* sdhci_cmu_set_clock - callback on clock change.*/
+static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int

clock)

drivers/mmc/host/sdhci-s3c.c static int __devinit sdhci_s3c_probe(struct

Quoted 18 lines
drivers/mmc/host/sdhci-s3c.c +14 -0
+{
+       struct sdhci_s3c *ourhost = to_s3c(host);
+
+       /* don't bother if the clock is going off */
+       if (clock == 0)
+               return;
+
+       sdhci_s3c_set_clock(host, clock);
+
+       clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
+
+       host->clock = clock;
+}
+
  static struct sdhci_ops sdhci_s3c_ops = {
        .get_max_clock          = sdhci_s3c_get_max_clk,
        .set_clock              = sdhci_s3c_set_clock,
@@ -361,6 +406,13 @@ static int __devinit sdhci_s3c_probe(struct

platform_device *pdev)

drivers/mmc/host/sdhci-s3c.c static int __devinit sdhci_s3c_probe(struct

Quoted 14 lines
drivers/mmc/host/sdhci-s3c.c +7 -0
                clks++;
                sc->clk_bus[ptr] = clk;
+
+               /*
+                * save current clock index to know which clock bus
+                * is used later in overriding functions.
+                */
+               sc->cur_clk = ptr;
+
                clk_enable(clk);
 
                dev_info(dev, "clock source %d: %s (%ld Hz)\n",
@@ -427,6 +479,16 @@ static int __devinit sdhci_s3c_probe(struct

platform_device *pdev)

Quoted 19 lines
drivers/mmc/host/sdhci-s3c.c +10 -1
        /* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
        host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
 
+       /*
+        * If controller does not have internal clock divider,
+        * we can use overriding functions instead of default.
+        */
+       if (pdata->clk_type) {
+               sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
+               sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
+               sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
+       }
+
        /* It supports additional host capabilities if needed */
        if (pdata->host_caps)
                host->mmc->caps |= pdata->host_caps;
--

1.6.2.5

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-

soc" in

Quoted 3 lines

the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel