All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: rockchip_dw_mmc: fix DDR52 8-bit mode handling
@ 2023-01-17 17:07 John Keeping
  2023-01-31 12:44 ` Jaehoon Chung
  0 siblings, 1 reply; 2+ messages in thread
From: John Keeping @ 2023-01-17 17:07 UTC (permalink / raw)
  To: u-boot
  Cc: John Keeping, Peng Fan, Jaehoon Chung, Simon Glass,
	Philipp Tomsich, Kever Yang

The RK3288 TRM states that, for 8-bit DDR modes:

	The CLKDIV register should always be programmed with a value
	higher than zero (0); that is, a clock divider should always be
	used for 8-bit DDR mode.

In Linux, the driver applies this logic for all SoCs using the driver
and does not distinguish RK3288, so presumably this requirement is the
same for all other Rockchip SoCs using this IP.

Add the necessary code to double the clock frequency when 8-bit DDR is
selected.  The dw_mmc core already handles setting CLKDIV correctly
given the input clock and desired bus clock.

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/mmc/rockchip_dw_mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 573bf16c87..3661ce3314 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -41,6 +41,14 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
 	struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
 	int ret;
 
+	/*
+	 * The clock frequency chosen here affects CLKDIV in the dw_mmc core.
+	 * That can be either 0 or 1, but it must be set to 1 for eMMC DDR52
+	 * 8-bit mode.  It will be set to 0 for all other modes.
+	 */
+	if (host->mmc->selected_mode == MMC_DDR_52 && host->mmc->bus_width == 8)
+		freq *= 2;
+
 	ret = clk_set_rate(&priv->clk, freq);
 	if (ret < 0) {
 		debug("%s: err=%d\n", __func__, ret);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: rockchip_dw_mmc: fix DDR52 8-bit mode handling
  2023-01-17 17:07 [PATCH] mmc: rockchip_dw_mmc: fix DDR52 8-bit mode handling John Keeping
@ 2023-01-31 12:44 ` Jaehoon Chung
  0 siblings, 0 replies; 2+ messages in thread
From: Jaehoon Chung @ 2023-01-31 12:44 UTC (permalink / raw)
  To: John Keeping, u-boot
  Cc: Peng Fan, Jaehoon Chung, Simon Glass, Philipp Tomsich, Kever Yang

Hi,

On 1/18/23 02:07, John Keeping wrote:
> The RK3288 TRM states that, for 8-bit DDR modes:
> 
> 	The CLKDIV register should always be programmed with a value
> 	higher than zero (0); that is, a clock divider should always be
> 	used for 8-bit DDR mode.
> 
> In Linux, the driver applies this logic for all SoCs using the driver
> and does not distinguish RK3288, so presumably this requirement is the
> same for all other Rockchip SoCs using this IP.
> 
> Add the necessary code to double the clock frequency when 8-bit DDR is
> selected.  The dw_mmc core already handles setting CLKDIV correctly
> given the input clock and desired bus clock.
> 
> Signed-off-by: John Keeping <john@metanate.com>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/rockchip_dw_mmc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
> index 573bf16c87..3661ce3314 100644
> --- a/drivers/mmc/rockchip_dw_mmc.c
> +++ b/drivers/mmc/rockchip_dw_mmc.c
> @@ -41,6 +41,14 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
>  	struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
>  	int ret;
>  
> +	/*
> +	 * The clock frequency chosen here affects CLKDIV in the dw_mmc core.
> +	 * That can be either 0 or 1, but it must be set to 1 for eMMC DDR52
> +	 * 8-bit mode.  It will be set to 0 for all other modes.
> +	 */
> +	if (host->mmc->selected_mode == MMC_DDR_52 && host->mmc->bus_width == 8)
> +		freq *= 2;
> +
>  	ret = clk_set_rate(&priv->clk, freq);
>  	if (ret < 0) {
>  		debug("%s: err=%d\n", __func__, ret);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-31 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 17:07 [PATCH] mmc: rockchip_dw_mmc: fix DDR52 8-bit mode handling John Keeping
2023-01-31 12:44 ` Jaehoon Chung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.