From: Andreas Fenkart <afenkart@xxxxxxxxx> Date: Thu, 17 Jan 2019 15:39:52 +0100 Subject: [PATCH] mmc: meson-gx: enable signal re-sampling together with tuning card detection fails on some p212 derived boards if enabled too early mmc1: error -110 whilst initialising MMC card Signed-off-by: Andreas Fenkart <afenkart@xxxxxxxxx> --- drivers/mmc/host/meson-gx-mmc.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index c2690c1a50ff..b65ec4bea980 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -709,7 +709,8 @@ static int meson_mmc_find_tuning_point(unsigned long *test) static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode, struct clk *clk) { - int point, ret; + struct meson_host *host = mmc_priv(mmc); + int point, ret, adj = 0; DECLARE_BITMAP(test, CLK_PHASE_POINT_NUM); dev_dbg(mmc_dev(mmc), "%s phase/delay tunning...\n", @@ -729,6 +730,10 @@ static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode, if (point < 0) return point; /* tuning failed */ + /* enable signal resampling w/o delay */ + adj = ADJUST_ADJ_EN; + writel(adj, host->regs + host->data->adjust); + clk_set_phase(clk, point * CLK_PHASE_STEP); dev_dbg(mmc_dev(mmc), "success with phase: %d\n", clk_get_phase(clk)); @@ -768,6 +773,9 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (!IS_ERR(mmc->supply.vmmc)) mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); + /* disable signal resampling w/o delay */ + writel(0, host->regs + host->data->adjust); + /* Reset rx phase */ clk_set_phase(host->rx_clk, 0); @@ -1166,7 +1174,7 @@ static int meson_mmc_get_cd(struct mmc_host *mmc) static void meson_mmc_cfg_init(struct meson_host *host) { - u32 cfg = 0, adj = 0; + u32 cfg = 0; cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK, ilog2(SD_EMMC_CFG_RESP_TIMEOUT)); @@ -1177,10 +1185,6 @@ static void meson_mmc_cfg_init(struct meson_host *host) cfg |= CFG_ERR_ABORT; writel(cfg, host->regs + SD_EMMC_CFG); - - /* enable signal resampling w/o delay */ - adj = ADJUST_ADJ_EN; - writel(adj, host->regs + host->data->adjust); } static int meson_mmc_card_busy(struct mmc_host *mmc) -- 2.20.1 Am Do., 17. Jan. 2019 um 15:11 Uhr schrieb Jerome Brunet <jbrunet@xxxxxxxxxxxx>: > > On Thu, 2019-01-17 at 14:56 +0100, Andreas Fenkart wrote: > > Am Do., 17. Jan. 2019 um 13:35 Uhr schrieb Andreas Fenkart < > > afenkart@xxxxxxxxx>: > > > Hi Jerome > > > > Here your eMMC timedout during init, so even before an attempt is made > > > > to tune > > > > which is odd. Could you try to enable signal resampling only when going > > > > forhigh speed modes ? > > > > card is found with this patch: > > > > --- a/drivers/mmc/host/meson-gx-mmc.c > > +++ b/drivers/mmc/host/meson-gx-mmc.c > > @@ -432,12 +432,17 @@ static int meson_mmc_clk_set(struct meson_host > > *host, struct mmc_ios *ios) > > struct mmc_host *mmc = host->mmc; > > unsigned long rate = ios->clock; > > int ret; > > - u32 cfg; > > + u32 cfg = 0, adj = 0; > > > > /* DDR modes require higher module clock */ > > if (meson_mmc_timing_is_ddr(ios)) > > rate <<= 1; > > > > /* Same request - bail-out */ > > if (host->req_rate == rate) > > return 0; > > @@ -475,6 +480,13 @@ static int meson_mmc_clk_set(struct meson_host > > *host, struct mmc_ios *ios) > > if (ios->clock != mmc->actual_clock) > > dev_dbg(host->dev, "requested rate was %u\n", ios->clock); > > > > + if (rate >= 200000000) { > > + printk("enable signal resampling"); > > + /* enable signal resampling w/o delay */ > > + adj = ADJUST_ADJ_EN; > > + writel(adj, host->regs + host->data->adjust); > > + } > > + > > 200Mhz is a bit arbitrary. > I would prefer if you enabled resampling when starting a tuning > And disable it on power up, in the set_ios() callaback. > > > /* (re)start clock */ > > meson_mmc_clk_ungate(host); > > > > /Andi > >