Skip to content

Commit

Permalink
SD Temp changes
Browse files Browse the repository at this point in the history
Change-Id: I7a05f38015a544404eab5081e73a1e61bab8866d
  • Loading branch information
bahusoid committed Feb 29, 2024
1 parent c2b79d2 commit f44a4a6
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions firmware/target/arm/as3525/sd-as3525.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,13 @@ bool sd_present(IF_MD_NONVOID(int drive))
static int sd_wait_for_tran_state(const int drive)
{
unsigned long response = 0;
unsigned int timeout = current_tick + 5 * HZ;
unsigned int timeout = current_tick + 2 * HZ;

while (1)
{
response = 0;
if(!send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP,
&response))
return -1;
send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP,
&response);

if (((response >> 9) & 0xf) == SD_TRAN)
return 0;
Expand Down Expand Up @@ -847,29 +846,21 @@ static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
while(MCI_STATUS(drive) & MCI_TX_ACTIVE);
if(!send_cmd(drive, SD_STOP_TRANSMISSION, 0, MCI_RESP, &response))
{
ret = -22;
ret = -1000 - count;
break;
}

ret = sd_wait_for_tran_state(drive);
if (ret < 0)
{
ret -= 25;
break;
}
/* Clear old status flags */
MCI_CLEAR(drive) = 0x7ff;
MCI_DATA_CTRL(drive) = 0;

/* According to datasheet DMA channel should be automatically disabled
* when transfer completes. But it not true for DMA_PERI_SD.
* Disable DMA channel manually to prevent problems with DMA. */
dma_disable_channel(1);

/* Clear old status flags */
MCI_CLEAR(drive) = 0x7ff;
MCI_DATA_CTRL(drive) = 0;

if (transfer_error[drive])
{

if (--retry_data >= 0)
continue;

Expand All @@ -882,6 +873,13 @@ static int sd_transfer_sectors(IF_MD(int drive,) unsigned long start,
buf += transfer * SD_BLOCK_SIZE;
start += transfer;
count -= transfer;

ret = sd_wait_for_tran_state(drive);
if (ret < 0)
{
ret = -10000 - count;
break;
}
}

dma_release();
Expand Down

0 comments on commit f44a4a6

Please sign in to comment.