Skip to content

Commit 8e9f25a

Browse files
eladnachmanUlf Hansson
authored andcommitted
mmc: sdhci-xenon: fix PHY init clock stability
Each time SD/mmc phy is initialized, at times, in some of the attempts, phy fails to completes its initialization which results into timeout error. Per the HW spec, it is a pre-requisite to ensure a stable SD clock before a phy initialization is attempted. Fixes: 06c8b66 ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC") Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: stable@vger.kernel.org Signed-off-by: Elad Nachman <enachman@marvell.com> Link: https://lore.kernel.org/r/20240222200930.1277665-1-enachman@marvell.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 6b1ba3f commit 8e9f25a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/mmc/host/sdhci-xenon-phy.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/slab.h>
1212
#include <linux/delay.h>
1313
#include <linux/ktime.h>
14+
#include <linux/iopoll.h>
1415
#include <linux/of_address.h>
1516

1617
#include "sdhci-pltfm.h"
@@ -216,6 +217,19 @@ static int xenon_alloc_emmc_phy(struct sdhci_host *host)
216217
return 0;
217218
}
218219

220+
static int xenon_check_stability_internal_clk(struct sdhci_host *host)
221+
{
222+
u32 reg;
223+
int err;
224+
225+
err = read_poll_timeout(sdhci_readw, reg, reg & SDHCI_CLOCK_INT_STABLE,
226+
1100, 20000, false, host, SDHCI_CLOCK_CONTROL);
227+
if (err)
228+
dev_err(mmc_dev(host->mmc), "phy_init: Internal clock never stabilized.\n");
229+
230+
return err;
231+
}
232+
219233
/*
220234
* eMMC 5.0/5.1 PHY init/re-init.
221235
* eMMC PHY init should be executed after:
@@ -232,6 +246,11 @@ static int xenon_emmc_phy_init(struct sdhci_host *host)
232246
struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
233247
struct xenon_emmc_phy_regs *phy_regs = priv->emmc_phy_regs;
234248

249+
int ret = xenon_check_stability_internal_clk(host);
250+
251+
if (ret)
252+
return ret;
253+
235254
reg = sdhci_readl(host, phy_regs->timing_adj);
236255
reg |= XENON_PHY_INITIALIZAION;
237256
sdhci_writel(host, reg, phy_regs->timing_adj);

0 commit comments

Comments
 (0)