mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-22 18:01:29 +01:00
mmc: dw_mmc: properly address command completion in dwmci_control_clken()
The current implementation polls for the DWMCI_CMD register, for the DWMCI_CMD_START bit to turn off, which indicates that the command has been completed. The problem with this approach is that it doesn't address the DWMCI_INTMSK_CDONE bit in the interrupt register, DWMCI_RINTSTS. As a result, subsequent commands result in timeout errors. Re-implement the waiting logic by polling for said interrupt status bit and setting it low if raised. Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
3a5b187b5c
commit
ae46019592
@ -507,20 +507,21 @@ static int dwmci_control_clken(struct dwmci_host *host, bool on)
|
|||||||
{
|
{
|
||||||
const u32 val = on ? DWMCI_CLKEN_ENABLE | DWMCI_CLKEN_LOW_PWR : 0;
|
const u32 val = on ? DWMCI_CLKEN_ENABLE | DWMCI_CLKEN_LOW_PWR : 0;
|
||||||
const u32 cmd_only_clk = DWMCI_CMD_PRV_DAT_WAIT | DWMCI_CMD_UPD_CLK;
|
const u32 cmd_only_clk = DWMCI_CMD_PRV_DAT_WAIT | DWMCI_CMD_UPD_CLK;
|
||||||
int timeout = 10000;
|
int i, timeout = 10000;
|
||||||
u32 status;
|
u32 mask;
|
||||||
|
|
||||||
dwmci_writel(host, DWMCI_CLKENA, val);
|
dwmci_writel(host, DWMCI_CLKENA, val);
|
||||||
|
|
||||||
/* Inform CIU */
|
/* Inform CIU */
|
||||||
dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_START | cmd_only_clk);
|
dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_START | cmd_only_clk);
|
||||||
do {
|
|
||||||
status = dwmci_readl(host, DWMCI_CMD);
|
for (i = 0; i < timeout; i++) {
|
||||||
if (timeout-- < 0) {
|
mask = dwmci_readl(host, DWMCI_RINTSTS);
|
||||||
debug("%s: Timeout!\n", __func__);
|
if (mask & DWMCI_INTMSK_CDONE) {
|
||||||
return -ETIMEDOUT;
|
dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_CDONE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (status & DWMCI_CMD_START);
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user