Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit d1a51a9

Browse files
jeremy-compostellabuildslave
authored andcommitted
drivers/sdhci_mmc: remove unecessary 2 ms delay
Commit aae1bdf introduced some additional control at the beginning of the sdhci_send_cmd() function but the implementation is causing a 2 ms hit on most of the sdhci_send_cmd() calls. This patch keeps the same timeout values (keep the safety) but fixes the delay issue. Change-Id: I94f1a15e021ed9736ef48f2aab56739dfea7e219 Tracked-On: https://jira01.devtools.intel.com/browse/OAM-67687 Signed-off-by: Jeremy Compostella <[email protected]> Reviewed-on: https://android.intel.com:443/641719
1 parent 8e30804 commit d1a51a9

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

drivers/sdhci_mmc/sdhci.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -367,30 +367,32 @@ static uint16_t sdhci_make_cmd(struct cmd *c)
367367

368368
}
369369

370+
static void
371+
sdhci_wait_for_state_unset(struct sdhci *host, uint16_t bits, uint32_t timeout_us)
372+
{
373+
uint16_t value;
374+
375+
do {
376+
value = sdhci_read16(host, SDHCI_PRESENT_STATE);
377+
if (!(value & bits))
378+
break;
379+
udelay(1);
380+
} while (timeout_us-- > 0);
381+
382+
if (!timeout_us)
383+
ewerr("%s() timeout for 0x%x", __func__, bits);
384+
}
385+
370386
static void
371387
sdhci_send_cmd(struct mmc *m, struct cmd *c)
372388
{
373389
struct sdhci *host = m->host;
374390
uint16_t tmode = 0;
375-
uint16_t Timeout;
376-
uint32_t Data32;
377391

378-
Timeout = 10000;
379-
do
380-
{
381-
Data32 = sdhci_read16 (host, SDHCI_PRESENT_STATE);
382-
udelay(10);
383-
} while ((Timeout-- > 0) && (Data32 & SDHCI_CMD_INHIBIT));
392+
sdhci_wait_for_state_unset(host, SDHCI_CMD_INHIBIT, 100000);
384393

385-
if(c->index != CMD_MMC_SEND_TUNING_BLOCK_HS200)
386-
{
387-
Timeout = 90;
388-
do
389-
{
390-
Data32 = sdhci_read16 (host, SDHCI_PRESENT_STATE);
391-
mdelay(2);
392-
} while ((Timeout-- > 0) && (Data32 & SDHCI_DATA_INHIBIT));
393-
}
394+
if (c->index != CMD_MMC_SEND_TUNING_BLOCK_HS200)
395+
sdhci_wait_for_state_unset(host, SDHCI_DATA_INHIBIT, 180000);
394396

395397
/* clear irq_status/err_sts register */
396398
sdhci_write32(host, SDHCI_INT_STATUS, 0xffffffff);

0 commit comments

Comments
 (0)