Skip to contentSkip to conversation

MMC: DWMMC: Correct the CLKDIV register value

PATCH RESEND New Rajeshwari Shinde 4 participants 5 messages Feb 5, 2014 – Feb 7, 2014

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

PATCH RESEND 1/1 MMC: DWMMC: Correct the CLKDIV register value

From: Rajeshwari S Shinde <[email protected]>

This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value.
as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)

Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register.

This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec

---
 arch/arm/include/asm/arch-exynos/dwmmc.h |  4 ++++
 drivers/mmc/dw_mmc.c                     |  2 +-
 drivers/mmc/exynos_dw_mmc.c              | 17 +++++++++++++++--
 include/dwmmc.h                          |  2 +-
 4 files changed, 21 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-exynos/dwmmc.h +4 -0
index 09d739d..a7ca12c 100644
@@ -23,6 +23,10 @@
 #define MPSCTRL_ENCRYPTION		(0x1<<1)
 #define MPSCTRL_VALID			(0x1<<0)
 
+/* CLKSEL Register */
+#define DWMCI_DIVRATIO_BIT		24
+#define DWMCI_DIVRATIO_MASK		0x7
+
 #ifdef CONFIG_OF_CONTROL
 int exynos_dwmmc_init(const void *blob);
 #endif
drivers/mmc/dw_mmc.c +1 -1
index 4cec5aa..d45c15c 100644
@@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	 * host->bus_hz should be set from user.
 	 */
 	if (host->get_mmc_clk)
-		sclk = host->get_mmc_clk(host->dev_index);
+		sclk = host->get_mmc_clk(host);
 	else if (host->bus_hz)
 		sclk = host->bus_hz;
 	else {
drivers/mmc/exynos_dw_mmc.c +15 -2
index b3e5c5e..de8cdcc 100644
@@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
 	dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
 }
 
-unsigned int exynos_dwmci_get_clk(int dev_index)
+unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
 {
-	return get_mmc_clk(dev_index);
+	unsigned long sclk;
+	int8_t clk_div;
+
+	/*
+	 * Since SDCLKIN is divided inside controller by the DIVRATIO
+	 * value set in the CLKSEL register, we need to use the same output
+	 * clock value to calculate the CLKDIV value.
+	 * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
+	 */
+	clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
+			& DWMCI_DIVRATIO_MASK) + 1;
+	sclk = get_mmc_clk(host->dev_index);
+
+	return sclk / clk_div;
 }
 
 static void exynos_dwmci_board_init(struct dwmci_host *host)
include/dwmmc.h +1 -1
index a02dd67..b641558 100644
@@ -142,7 +142,7 @@ struct dwmci_host {
 
 	void (*clksel)(struct dwmci_host *host);
 	void (*board_init)(struct dwmci_host *host);
-	unsigned int (*get_mmc_clk)(int dev_index);
+	unsigned int (*get_mmc_clk)(struct dwmci_host *host);
 };
 
 struct dwmci_idmac {
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH RESEND 1/1 MMC: DWMMC: Correct the CLKDIV register value

Hi All,

CCing Jaehoon Chung.

Regards,
Rajeshwari

Quoted 99 lines · Rajeshwari Shinde

From: Rajeshwari S Shinde <[email protected]>

This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value.
as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)

Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register.

This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec

---
 arch/arm/include/asm/arch-exynos/dwmmc.h |  4 ++++
 drivers/mmc/dw_mmc.c                     |  2 +-
 drivers/mmc/exynos_dw_mmc.c              | 17 +++++++++++++++--
 include/dwmmc.h                          |  2 +-
 4 files changed, 21 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-exynos/dwmmc.h +4 -0
index 09d739d..a7ca12c 100644
@@ -23,6 +23,10 @@
 #define MPSCTRL_ENCRYPTION             (0x1<<1)
 #define MPSCTRL_VALID                  (0x1<<0)
 
+/* CLKSEL Register */
+#define DWMCI_DIVRATIO_BIT             24
+#define DWMCI_DIVRATIO_MASK            0x7
+
 #ifdef CONFIG_OF_CONTROL
 int exynos_dwmmc_init(const void *blob);
 #endif
drivers/mmc/dw_mmc.c +1 -1
index 4cec5aa..d45c15c 100644
@@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
         * host->bus_hz should be set from user.
         */
        if (host->get_mmc_clk)
-               sclk = host->get_mmc_clk(host->dev_index);
+               sclk = host->get_mmc_clk(host);
        else if (host->bus_hz)
                sclk = host->bus_hz;
        else {
drivers/mmc/exynos_dw_mmc.c +15 -2
index b3e5c5e..de8cdcc 100644
@@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
        dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
 }
 
-unsigned int exynos_dwmci_get_clk(int dev_index)
+unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
 {
-       return get_mmc_clk(dev_index);
+       unsigned long sclk;
+       int8_t clk_div;
+
+       /*
+        * Since SDCLKIN is divided inside controller by the DIVRATIO
+        * value set in the CLKSEL register, we need to use the same output
+        * clock value to calculate the CLKDIV value.
+        * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
+        */
+       clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
+                       & DWMCI_DIVRATIO_MASK) + 1;
+       sclk = get_mmc_clk(host->dev_index);
+
+       return sclk / clk_div;
 }
 
 static void exynos_dwmci_board_init(struct dwmci_host *host)
include/dwmmc.h +1 -2
index a02dd67..b641558 100644
@@ -142,7 +142,7 @@ struct dwmci_host {
 
        void (*clksel)(struct dwmci_host *host);
        void (*board_init)(struct dwmci_host *host);
-       unsigned int (*get_mmc_clk)(int dev_index);
+       unsigned int (*get_mmc_clk)(struct dwmci_host *host);
 };
 
 struct dwmci_idmac {
--

1.7.12.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 2 lines
Regards,
Rajeshwari Shinde
#2 lore raw

PATCH RESEND 1/1 MMC: DWMMC: Correct the CLKDIV register value

Hi.

Right, It's reasonable. Looks good to me.

Best Regards,
Jaehoon Chung

Quoted 111 lines · Rajeshwari Birje

Hi All,

CCing Jaehoon Chung.

Regards,
Rajeshwari

Quoted 99 lines · Rajeshwari Shinde

From: Rajeshwari S Shinde <[email protected]>

This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value.
as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)

Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register.

This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec

---
 arch/arm/include/asm/arch-exynos/dwmmc.h |  4 ++++
 drivers/mmc/dw_mmc.c                     |  2 +-
 drivers/mmc/exynos_dw_mmc.c              | 17 +++++++++++++++--
 include/dwmmc.h                          |  2 +-
 4 files changed, 21 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-exynos/dwmmc.h +4 -0
index 09d739d..a7ca12c 100644
@@ -23,6 +23,10 @@
 #define MPSCTRL_ENCRYPTION             (0x1<<1)
 #define MPSCTRL_VALID                  (0x1<<0)
 
+/* CLKSEL Register */
+#define DWMCI_DIVRATIO_BIT             24
+#define DWMCI_DIVRATIO_MASK            0x7
+
 #ifdef CONFIG_OF_CONTROL
 int exynos_dwmmc_init(const void *blob);
 #endif
drivers/mmc/dw_mmc.c +1 -1
index 4cec5aa..d45c15c 100644
@@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
         * host->bus_hz should be set from user.
         */
        if (host->get_mmc_clk)
-               sclk = host->get_mmc_clk(host->dev_index);
+               sclk = host->get_mmc_clk(host);
        else if (host->bus_hz)
                sclk = host->bus_hz;
        else {
drivers/mmc/exynos_dw_mmc.c +15 -2
index b3e5c5e..de8cdcc 100644
@@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
        dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
 }
 
-unsigned int exynos_dwmci_get_clk(int dev_index)
+unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
 {
-       return get_mmc_clk(dev_index);
+       unsigned long sclk;
+       int8_t clk_div;
+
+       /*
+        * Since SDCLKIN is divided inside controller by the DIVRATIO
+        * value set in the CLKSEL register, we need to use the same output
+        * clock value to calculate the CLKDIV value.
+        * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
+        */
+       clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
+                       & DWMCI_DIVRATIO_MASK) + 1;
+       sclk = get_mmc_clk(host->dev_index);
+
+       return sclk / clk_div;
 }
 
 static void exynos_dwmci_board_init(struct dwmci_host *host)
include/dwmmc.h +1 -2
index a02dd67..b641558 100644
@@ -142,7 +142,7 @@ struct dwmci_host {
 
        void (*clksel)(struct dwmci_host *host);
        void (*board_init)(struct dwmci_host *host);
-       unsigned int (*get_mmc_clk)(int dev_index);
+       unsigned int (*get_mmc_clk)(struct dwmci_host *host);
 };
 
 struct dwmci_idmac {
--

1.7.12.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

PATCH RESEND 1/1 MMC: DWMMC: Correct the CLKDIV register value

Hi Pantelis Antoniou,

Please do let me know if any coments on the same.

Regards,
Rajeshwari

Quoted 122 lines · Jaehoon Chung

Hi.

Right, It's reasonable. Looks good to me.

Best Regards,
Jaehoon Chung

Quoted 111 lines · Rajeshwari Birje

Hi All,

CCing Jaehoon Chung.

Regards,
Rajeshwari

Quoted 99 lines · Rajeshwari Shinde

From: Rajeshwari S Shinde <[email protected]>

This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value.
as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)

Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register.

This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec

---
 arch/arm/include/asm/arch-exynos/dwmmc.h |  4 ++++
 drivers/mmc/dw_mmc.c                     |  2 +-
 drivers/mmc/exynos_dw_mmc.c              | 17 +++++++++++++++--
 include/dwmmc.h                          |  2 +-
 4 files changed, 21 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-exynos/dwmmc.h +4 -0
index 09d739d..a7ca12c 100644
@@ -23,6 +23,10 @@
 #define MPSCTRL_ENCRYPTION             (0x1<<1)
 #define MPSCTRL_VALID                  (0x1<<0)
 
+/* CLKSEL Register */
+#define DWMCI_DIVRATIO_BIT             24
+#define DWMCI_DIVRATIO_MASK            0x7
+
 #ifdef CONFIG_OF_CONTROL
 int exynos_dwmmc_init(const void *blob);
 #endif
drivers/mmc/dw_mmc.c +1 -1
index 4cec5aa..d45c15c 100644
@@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
         * host->bus_hz should be set from user.
         */
        if (host->get_mmc_clk)
-               sclk = host->get_mmc_clk(host->dev_index);
+               sclk = host->get_mmc_clk(host);
        else if (host->bus_hz)
                sclk = host->bus_hz;
        else {
drivers/mmc/exynos_dw_mmc.c +15 -2
index b3e5c5e..de8cdcc 100644
@@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
        dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
 }
 
-unsigned int exynos_dwmci_get_clk(int dev_index)
+unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
 {
-       return get_mmc_clk(dev_index);
+       unsigned long sclk;
+       int8_t clk_div;
+
+       /*
+        * Since SDCLKIN is divided inside controller by the DIVRATIO
+        * value set in the CLKSEL register, we need to use the same output
+        * clock value to calculate the CLKDIV value.
+        * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
+        */
+       clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
+                       & DWMCI_DIVRATIO_MASK) + 1;
+       sclk = get_mmc_clk(host->dev_index);
+
+       return sclk / clk_div;
 }
 
 static void exynos_dwmci_board_init(struct dwmci_host *host)
include/dwmmc.h +1 -2
index a02dd67..b641558 100644
@@ -142,7 +142,7 @@ struct dwmci_host {
 
        void (*clksel)(struct dwmci_host *host);
        void (*board_init)(struct dwmci_host *host);
-       unsigned int (*get_mmc_clk)(int dev_index);
+       unsigned int (*get_mmc_clk)(struct dwmci_host *host);
 };
 
 struct dwmci_idmac {
--

1.7.12.4

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 2 lines
Regards,
Rajeshwari Shinde
#4 lore raw

PATCH RESEND 1/1 MMC: DWMMC: Correct the CLKDIV register value

In reply to Rajeshwari Shinde

Hi Rajesh,

Sorry for the delay, patch looks good.

Quoted 95 lines · Rajeshwari Shinde

From: Rajeshwari S Shinde <[email protected]>

This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value.
as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1)

Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register.

This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec

---

arch/arm/include/asm/arch-exynos/dwmmc.h |  4 ++++
drivers/mmc/dw_mmc.c                     |  2 +-
drivers/mmc/exynos_dw_mmc.c              | 17 +++++++++++++++--
include/dwmmc.h                          |  2 +-
4 files changed, 21 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-exynos/dwmmc.h +4 -0
index 09d739d..a7ca12c 100644
@@ -23,6 +23,10 @@
 #define MPSCTRL_ENCRYPTION		(0x1<<1)
 #define MPSCTRL_VALID			(0x1<<0)
 
+/* CLKSEL Register */
+#define DWMCI_DIVRATIO_BIT		24
+#define DWMCI_DIVRATIO_MASK		0x7
+
 #ifdef CONFIG_OF_CONTROL
 int exynos_dwmmc_init(const void *blob);
 #endif
drivers/mmc/dw_mmc.c +1 -1
index 4cec5aa..d45c15c 100644
@@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 	 * host->bus_hz should be set from user.
 	 */
 	if (host->get_mmc_clk)
-		sclk = host->get_mmc_clk(host->dev_index);
+		sclk = host->get_mmc_clk(host);
 	else if (host->bus_hz)
 		sclk = host->bus_hz;
 	else {
drivers/mmc/exynos_dw_mmc.c +15 -2
index b3e5c5e..de8cdcc 100644
@@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host)
 	dwmci_writel(host, DWMCI_CLKSEL, host->clksel_val);
 }
 
-unsigned int exynos_dwmci_get_clk(int dev_index)
+unsigned int exynos_dwmci_get_clk(struct dwmci_host *host)
 {
-	return get_mmc_clk(dev_index);
+	unsigned long sclk;
+	int8_t clk_div;
+
+	/*
+	 * Since SDCLKIN is divided inside controller by the DIVRATIO
+	 * value set in the CLKSEL register, we need to use the same output
+	 * clock value to calculate the CLKDIV value.
+	 * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1)
+	 */
+	clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) >> DWMCI_DIVRATIO_BIT)
+			& DWMCI_DIVRATIO_MASK) + 1;
+	sclk = get_mmc_clk(host->dev_index);
+
+	return sclk / clk_div;
 }
 
 static void exynos_dwmci_board_init(struct dwmci_host *host)
include/dwmmc.h +1 -1
index a02dd67..b641558 100644
@@ -142,7 +142,7 @@ struct dwmci_host {
 
 	void (*clksel)(struct dwmci_host *host);
 	void (*board_init)(struct dwmci_host *host);
-	unsigned int (*get_mmc_clk)(int dev_index);
+	unsigned int (*get_mmc_clk)(struct dwmci_host *host);
 };
 
 struct dwmci_idmac {
Signature · 1 line
1.7.12.4

Applied, Thanks