Hi Wolfram-san, Thank you for the patch! > From: Wolfram Sang, Sent: Wednesday, April 22, 2020 9:59 PM > To: linux-mmc@xxxxxxxxxxxxxxx > Cc: linux-renesas-soc@xxxxxxxxxxxxxxx; Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>; Takeshi Saito > <takeshi.saito.xv@xxxxxxxxxxx>; Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> > Subject: [PATCH 2/2] mmc: renesas_sdhi: avoid bad TAP in HS400 > > From: Takeshi Saito <takeshi.saito.xv@xxxxxxxxxxx> > > With R-Car Gen3, CRC error occue at the following TAPs. > > H3, M3W 1.3, M3N... TAP=2,3,6,7 > M3W 3.0 ... TAP=1,3,5,7 > > (Note: for 4tap SoCs, the numbers get divided by 2) > > Do not use these TAPs in HS400, and also don't use auto correction but > manual correction. > > We check for bad taps in two places: > > 1) After tuning HS400: Then, we select a neighbouring TAP. One of them > must be good, because there are never three bad taps in a row. > Retuning won't help because we just finished tuning. > > 2) After a manual correction request: Here, we can't switch to the > requested TAP. But we can retune (if the HS200 tuning was good) > because the environment might have changed since the last tuning. > If not, we stay on the same TAP. > > Signed-off-by: Takeshi Saito <takeshi.saito.xv@xxxxxxxxxxx> > [wsa: refactored to match upstream driver, reworded commit msg] > Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> > --- > drivers/mmc/host/renesas_sdhi.h | 1 + > drivers/mmc/host/renesas_sdhi_core.c | 56 ++++++++++++++++++++++++---- > 2 files changed, 49 insertions(+), 8 deletions(-) > > diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h > index 86efa9d5cd6d..14c64caefc64 100644 > --- a/drivers/mmc/host/renesas_sdhi.h > +++ b/drivers/mmc/host/renesas_sdhi.h > @@ -36,6 +36,7 @@ struct renesas_sdhi_of_data { > struct renesas_sdhi_quirks { > bool hs400_disabled; > bool hs400_4taps; > + u32 hs400_bad_taps; > }; > > struct tmio_mmc_dma { > diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c > index 33b51105c788..4fee26e6b66c 100644 > --- a/drivers/mmc/host/renesas_sdhi_core.c > +++ b/drivers/mmc/host/renesas_sdhi_core.c > @@ -325,6 +325,8 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc) > { > struct tmio_mmc_host *host = mmc_priv(mmc); > struct renesas_sdhi *priv = host_to_priv(host); > + u32 bad_taps = priv->quirks ? priv->quirks->hs400_bad_taps : 0; > + bool use_4tap = priv->quirks && priv->quirks->hs400_4taps; > > sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~CLK_CTL_SCLKEN & > sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); > @@ -352,10 +354,24 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc) > SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN | > 0x4 << SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT); > > + /* Avoid bad TAP */ > + if (bad_taps & BIT(priv->tap_set)) { > + u32 new_tap = (priv->tap_set + 1) % priv->tap_num; > + > + if (bad_taps & BIT(new_tap)) { > + new_tap = (priv->tap_set - 1) % priv->tap_num; > + } I think we can remove the braces. After removed it, Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx> Best regards, Yoshihiro Shimoda