summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 0afe735e53..5ccb659e00 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -241,15 +241,13 @@ static bool send_cmd(const int drive, const int cmd, const int arg,
241 if(status & MCI_RESPONSE_ERROR) /* timeout or crc failure */ 241 if(status & MCI_RESPONSE_ERROR) /* timeout or crc failure */
242 return false; 242 return false;
243 243
244 if(status & MCI_CMD_RESP_END) /*Response passed CRC check */ 244 if(status & MCI_CMD_RESP_END) /* Response passed CRC check */
245 { 245 {
246 if(flags & MCI_LONG_RESP) 246 if(flags & MCI_LONG_RESP)
247 { /* replace short response with long response */ 247 { /* response[0] has already been read */
248 /* store the response in reverse words order */ 248 response[1] = MCI_RESP1(drive);
249 response[0] = MCI_RESP3(drive); 249 response[2] = MCI_RESP2(drive);
250 response[1] = MCI_RESP2(drive); 250 response[3] = MCI_RESP3(drive);
251 response[2] = MCI_RESP1(drive);
252 response[3] = MCI_RESP0(drive);
253 } 251 }
254 return true; 252 return true;
255 } 253 }
@@ -270,9 +268,6 @@ static int sd_init_card(const int drive)
270 unsigned long response; 268 unsigned long response;
271 long init_timeout; 269 long init_timeout;
272 bool sd_v2 = false; 270 bool sd_v2 = false;
273 unsigned long temp_reg[4];
274 int i;
275
276 271
277 /* MCLCK on and set to 400kHz ident frequency */ 272 /* MCLCK on and set to 400kHz ident frequency */
278 MCI_CLOCK(drive) = MCI_IDENTSPEED; 273 MCI_CLOCK(drive) = MCI_IDENTSPEED;
@@ -310,12 +305,9 @@ static int sd_init_card(const int drive)
310 305
311 /* CMD2 send CID */ 306 /* CMD2 send CID */
312 if(!send_cmd(drive, SD_ALL_SEND_CID, 0, MCI_RESP|MCI_LONG_RESP|MCI_ARG, 307 if(!send_cmd(drive, SD_ALL_SEND_CID, 0, MCI_RESP|MCI_LONG_RESP|MCI_ARG,
313 temp_reg)) 308 card_info[drive].cid))
314 return -3; 309 return -3;
315 310
316 for(i=0; i<4; i++)
317 card_info[drive].cid[3-i] = temp_reg[i];
318
319 /* CMD3 send RCA */ 311 /* CMD3 send RCA */
320 if(!send_cmd(drive, SD_SEND_RELATIVE_ADDR, 0, MCI_RESP|MCI_ARG, 312 if(!send_cmd(drive, SD_SEND_RELATIVE_ADDR, 0, MCI_RESP|MCI_ARG,
321 &card_info[drive].rca)) 313 &card_info[drive].rca))
@@ -350,12 +342,9 @@ static int sd_init_card(const int drive)
350 342
351 /* CMD9 send CSD */ 343 /* CMD9 send CSD */
352 if(!send_cmd(drive, SD_SEND_CSD, card_info[drive].rca, 344 if(!send_cmd(drive, SD_SEND_CSD, card_info[drive].rca,
353 MCI_RESP|MCI_LONG_RESP|MCI_ARG, temp_reg)) 345 MCI_RESP|MCI_LONG_RESP|MCI_ARG, card_info[drive].csd))
354 return -9; 346 return -9;
355 347
356 for(i=0; i<4; i++)
357 card_info[drive].csd[3-i] = temp_reg[i];
358
359 sd_parse_csd(&card_info[drive]); 348 sd_parse_csd(&card_info[drive]);
360 349
361#if defined(HAVE_MULTIDRIVE) 350#if defined(HAVE_MULTIDRIVE)