Message ID | 20210724081009.15761-7-ashok.reddy.soma@xilinx.com |
---|---|
State | Superseded |
Delegated to: | Michal Simek |
Headers | show |
Series | Arasan sdhci driver updates | expand |
On 7/24/21 5:10 PM, Ashok Reddy Soma wrote: > From: T Karthik Reddy <t.karthik.reddy@xilinx.com> > > As per SD spec when SD host controller is reset, it takes 1000msec > to detect the card state. In case, if we enable the sd bus voltage & > card detect state is not stable, then host controller will disable > the sd bus voltage. > > In case of warm/subsystem reboot, due to unstable card detect state > host controller is disabling the sd bus voltage to sd card causing > sd card timeout error. So we wait for a maximum of 1000msec to get > the card detect state stable before we enable the sd bus voltage. > > This current fix is workaround for now, this needs to be analysed > further. Zynqmp platform should behave the same as Versal, but we > did not encounter this issue as of now. So we are fixing it for > Versal only. > > Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> > --- > > drivers/mmc/zynq_sdhci.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c > index 8ffa8c1269..a192f60320 100644 > --- a/drivers/mmc/zynq_sdhci.c > +++ b/drivers/mmc/zynq_sdhci.c > @@ -686,6 +686,23 @@ static int arasan_sdhci_probe(struct udevice *dev) > return ret; > upriv->mmc = host->mmc; > > + /* > + * Wait for 1000msec till the card detect state gets stable > + * else host controller will set sd power bus voltage to 0. > + */ > + if (IS_ENABLED(CONFIG_ARCH_VERSAL)) { > + u32 timeout = 1000; > + > + while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & > + SDHCI_CARD_STATE_STABLE) == 0) && timeout--) { > + mdelay(1); > + } > + if (!timeout) { > + dev_err(dev, "Sdhci card detect state not stable\n"); > + return -EIO; -EIO is not correct, -ETIMEDOUT or -EBUSY? Best Regards, Jaehoon Chung > + } > + } > + > return sdhci_probe(dev); > } > >
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 8ffa8c1269..a192f60320 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -686,6 +686,23 @@ static int arasan_sdhci_probe(struct udevice *dev) return ret; upriv->mmc = host->mmc; + /* + * Wait for 1000msec till the card detect state gets stable + * else host controller will set sd power bus voltage to 0. + */ + if (IS_ENABLED(CONFIG_ARCH_VERSAL)) { + u32 timeout = 1000; + + while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & + SDHCI_CARD_STATE_STABLE) == 0) && timeout--) { + mdelay(1); + } + if (!timeout) { + dev_err(dev, "Sdhci card detect state not stable\n"); + return -EIO; + } + } + return sdhci_probe(dev); }