1
0
Fork 0
forked from len0rd/rockbox

Sansa Connect: Add udelay() in sdmmc card initialization to prevent dead locks.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31388 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomasz Moń 2011-12-21 09:58:03 +00:00
parent 01415ad1b7
commit 013384f138
2 changed files with 10 additions and 4 deletions

View file

@ -348,6 +348,9 @@ static int sd_init_card(const int card_no)
bitclr16(&IO_MMC_CONTROL, MMC_CTRL_WIDTH); bitclr16(&IO_MMC_CONTROL, MMC_CTRL_WIDTH);
sd_set_clock_rate(INITIAL_CLK); sd_set_clock_rate(INITIAL_CLK);
/* Prevent dead lock */
udelay(100);
ret = sd_command(SD_GO_IDLE_STATE, 0, MMC_CMD_INITCLK, NULL); ret = sd_command(SD_GO_IDLE_STATE, 0, MMC_CMD_INITCLK, NULL);
if (ret < 0) if (ret < 0)
@ -424,6 +427,9 @@ static int sd_init_card(const int card_no)
sd_set_clock_rate(currcard->speed); sd_set_clock_rate(currcard->speed);
/* Prevent dead lock */
udelay(100);
ret = sd_command(SD_SELECT_CARD, currcard->rca, ret = sd_command(SD_SELECT_CARD, currcard->rca,
SDHC_RESP_FMT_1, NULL); SDHC_RESP_FMT_1, NULL);
if (ret < 0) if (ret < 0)
@ -893,7 +899,7 @@ int sd_init(void)
/* mmc module clock: 75 Mhz (AHB) / 2 = ~37.5 Mhz /* mmc module clock: 75 Mhz (AHB) / 2 = ~37.5 Mhz
* (Frequencies above are taken from Sansa Connect's OF source code) */ * (Frequencies above are taken from Sansa Connect's OF source code) */
IO_CLK_DIV3 = (IO_CLK_DIV3 & 0xFF00) | 0x02; /* OF uses 1 */ IO_CLK_DIV3 = (IO_CLK_DIV3 & 0xFF00) | 0x01;
bitset16(&IO_CLK_MOD2, CLK_MOD2_MMC); bitset16(&IO_CLK_MOD2, CLK_MOD2_MMC);
@ -932,8 +938,8 @@ int sd_init(void)
sd_select_device(1); sd_select_device(1);
/* Enable Memory Card CLK */ /* Disable Memory Card CLK - it is enabled on demand by TMS320DM320 */
bitset16(&IO_MMC_MEM_CLK_CONTROL, (1 << 8)); bitclr16(&IO_MMC_MEM_CLK_CONTROL, (1 << 8));
queue_init(&sd_queue, true); queue_init(&sd_queue, true);
sd_thread_id = create_thread(sd_thread, sd_stack, sizeof(sd_stack), sd_thread_id = create_thread(sd_thread, sd_stack, sizeof(sd_stack),

View file

@ -435,7 +435,7 @@ void udelay(int usec) {
if (stop < count) if (stop < count)
{ {
/* udelay will end after counter reset (tick) */ /* udelay will end after counter reset (tick) */
while (((IO_TIMER1_TMCNT < stop) && (current_tick != prev_tick)) || while ((IO_TIMER1_TMCNT < stop) ||
(current_tick == prev_tick)); /* ensure new tick */ (current_tick == prev_tick)); /* ensure new tick */
} }
else else