summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 94b46017da..5a8565e822 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -382,14 +382,11 @@ static bool send_cmd(const int cmd, const int arg, const int flags,
382 382
383 if(flags & MCI_LONG_RESP) 383 if(flags & MCI_LONG_RESP)
384 { 384 {
385 /* store the response in little endian order for the words */ 385 response[3] = MCI_RESP3;
386 response[0] = MCI_RESP3; 386 response[2] = MCI_RESP2;
387 response[1] = MCI_RESP2; 387 response[1] = MCI_RESP1;
388 response[2] = MCI_RESP1;
389 response[3] = MCI_RESP0;
390 } 388 }
391 else 389 response[0] = MCI_RESP0;
392 response[0] = MCI_RESP0;
393 } 390 }
394 return true; 391 return true;
395} 392}
@@ -397,10 +394,8 @@ static bool send_cmd(const int cmd, const int arg, const int flags,
397static int sd_init_card(void) 394static int sd_init_card(void)
398{ 395{
399 unsigned long response; 396 unsigned long response;
400 unsigned long temp_reg[4];
401 long init_timeout; 397 long init_timeout;
402 bool sd_v2 = false; 398 bool sd_v2 = false;
403 int i;
404 399
405 /* assume 24 MHz clock / 60 = 400 kHz */ 400 /* assume 24 MHz clock / 60 = 400 kHz */
406 MCI_CLKDIV = (MCI_CLKDIV & ~(0xFF)) | 0x3C; /* CLK_DIV_0 : bits 7:0 */ 401 MCI_CLKDIV = (MCI_CLKDIV & ~(0xFF)) | 0x3C; /* CLK_DIV_0 : bits 7:0 */
@@ -437,12 +432,9 @@ static int sd_init_card(void)
437 } while(!(card_info.ocr & (1<<31)) ); 432 } while(!(card_info.ocr & (1<<31)) );
438 433
439 /* CMD2 send CID */ 434 /* CMD2 send CID */
440 if(!send_cmd(SD_ALL_SEND_CID, 0, MCI_RESP|MCI_LONG_RESP, temp_reg)) 435 if(!send_cmd(SD_ALL_SEND_CID, 0, MCI_RESP|MCI_LONG_RESP, card_info.cid))
441 return -5; 436 return -5;
442 437
443 for(i=0; i<4; i++)
444 card_info.cid[3-i] = temp_reg[i];
445
446 /* CMD3 send RCA */ 438 /* CMD3 send RCA */
447 if(!send_cmd(SD_SEND_RELATIVE_ADDR, 0, MCI_RESP, &card_info.rca)) 439 if(!send_cmd(SD_SEND_RELATIVE_ADDR, 0, MCI_RESP, &card_info.rca))
448 return -4; 440 return -4;
@@ -451,12 +443,9 @@ static int sd_init_card(void)
451 443
452 /* CMD9 send CSD */ 444 /* CMD9 send CSD */
453 if(!send_cmd(SD_SEND_CSD, card_info.rca, 445 if(!send_cmd(SD_SEND_CSD, card_info.rca,
454 MCI_RESP|MCI_LONG_RESP, temp_reg)) 446 MCI_RESP|MCI_LONG_RESP, card_info.csd))
455 return -5; 447 return -5;
456 448
457 for(i=0; i<4; i++)
458 card_info.csd[3-i] = temp_reg[i];
459
460 sd_parse_csd(&card_info); 449 sd_parse_csd(&card_info);
461 450
462 /* Card back to full speed */ 451 /* Card back to full speed */