Skip to content

Commit

Permalink
RK356x: add additional timeouts to MshcDxe
Browse files Browse the repository at this point in the history
  • Loading branch information
Manawyrm authored and jaredmcneill committed May 25, 2024
1 parent b813ba3 commit 585f501
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions edk2-rockchip/Silicon/Rockchip/Rk356x/Drivers/MshcDxe/MshcDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,16 @@ MshcWriteBlockData (
ASSERT ((mMshcCommand & BIT_CMD_WRITE) == BIT_CMD_WRITE);

if (mMshcCommand & BIT_CMD_WAIT_PRVDATA_COMPLETE) {
TimeOut = 100000;
do {
Data = MmioRead32 (DWEMMC_STATUS);
} while (Data & DWEMMC_STS_DATA_BUSY);
TimeOut--;
} while ((Data & DWEMMC_STS_DATA_BUSY) && (TimeOut > 0));

if (TimeOut == 0) {
DEBUG ((DEBUG_ERROR, "%a(): CMD=%d Timeout waiting for DWEMMC_STATUS DWEMMC_STS_DATA_BUSY\n", __func__, mMshcCommand&0x3f));
return EFI_DEVICE_ERROR;
}
}

if (!(((mMshcCommand&0x3f) == 6) || ((mMshcCommand&0x3f) == 51))) {
Expand Down Expand Up @@ -650,8 +657,16 @@ MshcWriteBlockData (
}

for (Count = 0; Count < Size32; Count++) {
while(MMC_GET_FCNT(MmioRead32(DWEMMC_STATUS)) >32)
MicroSecondDelay(1);
TimeOut = 100000;
while((MMC_GET_FCNT(MmioRead32(DWEMMC_STATUS)) >32) && (TimeOut > 0))
{
MicroSecondDelay(1);
TimeOut--;
}
if (TimeOut == 0) {
DEBUG ((DEBUG_ERROR, "%a(): CMD=%d DWEMMC_STATUS timeout\n", __func__, mMshcCommand&0x3f));
return EFI_DEVICE_ERROR;
}
MmioWrite32(DWEMMC_DATA, *DataBuffer++);
}

Expand Down

0 comments on commit 585f501

Please sign in to comment.