summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-07-02 00:42:10 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-07-02 00:45:00 +0200
commit20ee453edce207a4285638f0399926b0b9f506df (patch)
treee5a035e8a841fee8fee3a14a607e31290e48ed28
parentd8024df1052966aa554424d88712244ae5978f2a (diff)
downloadrockbox-20ee453.tar.gz
rockbox-20ee453.zip
imx233: fix sd init sequence
Implement the switch function as specified by the specification, that is wait for the response AND transfer 64 bytes of data. This fixes some issue when the SD card take a long time to switch. In particular waiting 100ms (max per spec) will not work if no data is transfered in some cases. Change-Id: Ia22350468018b842e57ce6f6c1a8d676eba97fb8
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index b74c21c08c..c389a1d2c8 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -353,8 +353,17 @@ static int init_sd_card(int drive)
return -6;
/* CMD6 */
- if(!send_cmd(drive, SD_SWITCH_FUNC, 0x80fffff1, MCI_RESP, NULL))
- return -7;
+ {
+ /* only transfer 64 bytes */
+ imx233_ssp_set_block_size(ssp, /*log2(64)*/6);
+ if(imx233_ssp_sd_mmc_transfer(ssp, SD_SWITCH_FUNC, 0x80fffff1,
+ SSP_SHORT_RESP, aligned_buffer[drive], 1, true, true, NULL))
+ {
+ imx233_ssp_set_block_size(ssp, /*log2(512)*/9);
+ return -12;
+ }
+ imx233_ssp_set_block_size(ssp, /*log2(512)*/9);
+ }
/* go back to STBY state so we can read csd */
/* CMD7 w/rca=0: Deselect card to put it in STBY state */
@@ -465,10 +474,9 @@ static int init_mmc_drive(int drive)
/* read extended CSD */
{
- uint8_t ext_csd[512];
+ uint8_t *ext_csd = aligned_buffer[drive];
if(imx233_ssp_sd_mmc_transfer(ssp, 8, 0, SSP_SHORT_RESP, aligned_buffer[drive], 1, true, true, &status))
return -12;
- memcpy(ext_csd, aligned_buffer[drive], 512);
uint32_t *sec_count = (void *)&ext_csd[212];
window_start[drive] = 0;
window_end[drive] = *sec_count;