Skip to contentSkip to conversation

mmc/dw_mmc: Fix clock divider calculation error for bypass mode

PATCH New Chin Liang See 2 participants 2 messages Jun 10, 2014 – Aug 1, 2014 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc/dw_mmc: Fix clock divider calculation error for bypass mode

To fix the clock divider calculation error when the controller clock same as the operating frequency. This is known as bypass mode. In this mode, the divider should be 0.

Cc Pantelis Antoniou <[email protected]>
Cc Rajeshwari Shinde <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Mischa Jonker <[email protected]>
---
 drivers/mmc/dw_mmc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +4 -1
index 5bf36a0..0df30bc 100644
@@ -245,7 +245,10 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 		return -EINVAL;
 	}
 
-	div = DIV_ROUND_UP(sclk, 2 * freq);
+	if (sclk == freq)
+		div = 0;	/* bypass mode */
+	else
+		div = DIV_ROUND_UP(sclk, 2 * freq);
 
 	dwmci_writel(host, DWMCI_CLKENA, 0);
 	dwmci_writel(host, DWMCI_CLKSRC, 0);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 mmc/dw_mmc: Fix clock divider calculation error for bypass mode

Hi Chin,

Quoted 32 lines · Chin Liang See

To fix the clock divider calculation error when the controller clock same as the operating frequency. This is known as bypass mode. In this mode, the divider should be 0.

Cc Pantelis Antoniou <[email protected]>
Cc Rajeshwari Shinde <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Mischa Jonker <[email protected]>

---
drivers/mmc/dw_mmc.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +4 -1
index 5bf36a0..0df30bc 100644
@@ -245,7 +245,10 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
 		return -EINVAL;
 	}
 
-	div = DIV_ROUND_UP(sclk, 2 * freq);
+	if (sclk == freq)
+		div = 0;	/* bypass mode */
+	else
+		div = DIV_ROUND_UP(sclk, 2 * freq);
 
 	dwmci_writel(host, DWMCI_CLKENA, 0);
 	dwmci_writel(host, DWMCI_CLKSRC, 0);
Signature · 1 line
1.7.9.5

Applied, thanks.

-- Pantelis