From 1396c335ac4d83701c9ed699156e0e78015c174b Mon Sep 17 00:00:00 2001 From: Tobias Diedrich Date: Tue, 22 Jun 2010 21:49:33 +0000 Subject: [PATCH] The mci_delay()s should be unnecessary if we properly tell the controller to wait for the response these commands send back to the host. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27066 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/sd-as3525.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c index 02b0d725f7..7e61fa509f 100644 --- a/firmware/target/arm/as3525/sd-as3525.c +++ b/firmware/target/arm/as3525/sd-as3525.c @@ -319,9 +319,8 @@ static int sd_init_card(const int drive) if(sd_v2) { /* CMD7 w/rca: Select card to put it in TRAN state */ - if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_ARG, NULL)) + if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_RESP|MCI_ARG, &response)) return -5; - mci_delay(); if(sd_wait_for_tran_state(drive)) return -6; @@ -359,9 +358,8 @@ static int sd_init_card(const int drive) #endif /* CMD7 w/rca: Select card to put it in TRAN state */ - if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_ARG, NULL)) + if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_RESP|MCI_ARG, &response)) return -10; - mci_delay(); #ifndef BOOTLOADER /* Switch to to 4 bit widebus mode */ @@ -395,7 +393,7 @@ static int sd_init_card(const int drive) if(ret < 0) return ret -16; - /* CMD7 w/rca = 0: Select card to put it in STBY state */ + /* CMD7 w/rca = 0: Unselect card to put it in STBY state */ if(!send_cmd(drive, SD_SELECT_CARD, 0, MCI_ARG, NULL)) return -17; mci_delay(); @@ -410,9 +408,8 @@ static int sd_init_card(const int drive) card_info[INTERNAL_AS3525].numblocks -= AMS_OF_SIZE; /* CMD7 w/rca: Select card to put it in TRAN state */ - if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_ARG, NULL)) + if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_RESP|MCI_ARG, &response)) return -19; - mci_delay(); } card_info[drive].initialized = 1; @@ -729,6 +726,7 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, const int cmd = write ? SD_WRITE_MULTIPLE_BLOCK : SD_READ_MULTIPLE_BLOCK; unsigned long bank_start = start; + unsigned long status; /* Only switch banks for internal storage */ if(drive == INTERNAL_AS3525) @@ -816,7 +814,7 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, last_disk_activity = current_tick; - if(!send_cmd(drive, SD_STOP_TRANSMISSION, 0, MCI_NO_FLAGS, NULL)) + if(!send_cmd(drive, SD_STOP_TRANSMISSION, 0, MCI_RESP, &status)) { ret = -4*20; goto sd_transfer_error;