diff options
author | Haojian Zhuang <haojian.zhuang@outlook.com> | 2016-08-04 12:32:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-04 12:32:01 +0800 |
commit | 77fe3a11fab686a3f8c796e2590d214edc896fb1 (patch) | |
tree | e81d3bbba4fd99d1c8d1b4239f358c1e09955ba1 | |
parent | 537db644f7761f0d9a431b13f76ea951777dcad5 (diff) | |
parent | 1cf5bdda8da6a99c395ce9d3a4611467086ec777 (diff) | |
download | OpenPlatformPkg-77fe3a11fab686a3f8c796e2590d214edc896fb1.tar.gz |
Merge pull request #28 from johnstultz-work/hikey-aosp
Use counter timeout instead of removing the wait-for-idle loops
-rw-r--r-- | Drivers/Mmc/DwSdDxe/DwSdDxe.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Drivers/Mmc/DwSdDxe/DwSdDxe.c b/Drivers/Mmc/DwSdDxe/DwSdDxe.c index eefc6c5..cbe6b77 100644 --- a/Drivers/Mmc/DwSdDxe/DwSdDxe.c +++ b/Drivers/Mmc/DwSdDxe/DwSdDxe.c @@ -37,6 +37,8 @@ #define DWSD_DMA_THRESHOLD 16 +#define MAX_IDLE_LOOPS 1000000 + typedef struct { UINT32 Des0; UINT32 Des1; @@ -165,7 +167,7 @@ DwSdSetClock ( IN UINTN ClockFreq ) { - UINT32 Divider, Rate, Data; + UINT32 Divider, Rate, Data, Count; EFI_STATUS Status; BOOLEAN Found = FALSE; @@ -180,8 +182,11 @@ DwSdSetClock ( return EFI_NOT_FOUND; // Wait until MMC is idle + Count = 0; do { Data = MmioRead32 (DWSD_STATUS); + if (Count++ > MAX_IDLE_LOOPS) + break; } while (Data & DWSD_STS_DATA_BUSY); // Disable MMC clock first @@ -282,11 +287,18 @@ SendCommand ( IN UINT32 Argument ) { - UINT32 Data, ErrMask; + UINT32 Data, ErrMask, Count; MmioWrite32 (DWSD_RINTSTS, ~0); MmioWrite32 (DWSD_CMDARG, Argument); MicroSecondDelay(500); + // Wait until MMC is idle + Count = 0; + do { + Data = MmioRead32 (DWSD_STATUS); + if (Count++ > MAX_IDLE_LOOPS) + break; + } while (Data & DWSD_STS_DATA_BUSY); MmioWrite32 (DWSD_CMD, MmcCmd); |