Skip to content

Commit

Permalink
mmc: dw_mmc-rockchip: Always fix ID mode clk request into 375KHz for …
Browse files Browse the repository at this point in the history
…RK356X

RK356X SoCs only support 375KHz for ID mode, otherwise it will be always
failed to set clk if the first attempt to identify cards.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Change-Id: I99ba322b3eeb4c4658869dc88b7a9f303081e12e
  • Loading branch information
shawn1221 authored and rkhuangtao committed Aug 2, 2021
1 parent 30f84d3 commit d80d506
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions drivers/mmc/host/dw_mmc-rockchip.c
Expand Up @@ -24,6 +24,7 @@ struct dw_mci_rockchip_priv_data {
int num_phases;
bool use_v2_tuning;
int last_degree;
u32 f_min;
};

static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios)
Expand All @@ -45,6 +46,9 @@ static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios)
* Note: div can only be 0 or 1, but div must be set to 1 for eMMC
* DDR52 8-bit mode.
*/
if (ios->clock < priv->f_min)
ios->clock = priv->f_min;

if (ios->bus_width == MMC_BUS_WIDTH_8 &&
ios->timing == MMC_TIMING_MMC_DDR52)
cclkin = 2 * ios->clock * RK3288_CLKGEN_DIV;
Expand Down Expand Up @@ -312,6 +316,17 @@ static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
if (!priv)
return -ENOMEM;

/*
* RK356X SoCs only support 375KHz for ID mode, so any clk request
* that less than 1.6MHz(2 * 400KHz * RK3288_CLKGEN_DIV) should be
* wrapped into 375KHz
*/
if (of_device_is_compatible(host->dev->of_node,
"rockchip,rk3568-dw-mshc"))
priv->f_min = 375000;
else
priv->f_min = 100000;

if (of_property_read_u32(np, "rockchip,desired-num-phases",
&priv->num_phases))
priv->num_phases = 360;
Expand Down Expand Up @@ -345,9 +360,7 @@ static int dw_mci_rockchip_init(struct dw_mci *host)
"rockchip,rk3288-dw-mshc"))
host->bus_hz /= RK3288_CLKGEN_DIV;


host->need_xfer_timer = true;

return 0;
}

Expand Down

0 comments on commit d80d506

Please sign in to comment.