summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index fe4d60925a..0886753f61 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -148,6 +148,8 @@
148#define CMD_CCS_EXPECTED (1<<23) 148#define CMD_CCS_EXPECTED (1<<23)
149#define CMD_DONE_BIT (1<<31) 149#define CMD_DONE_BIT (1<<31)
150 150
151#define TRANSFER_CMD (cmd == SD_READ_MULTIPLE_BLOCK || \
152 cmd == SD_WRITE_MULTIPLE_BLOCK)
151 153
152#define MCI_RESP0 SD_REG(0x30) 154#define MCI_RESP0 SD_REG(0x30)
153#define MCI_RESP1 SD_REG(0x34) 155#define MCI_RESP1 SD_REG(0x34)
@@ -399,9 +401,6 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
399 } 401 }
400#endif 402#endif
401 403
402#define TRANSFER_CMD (cmd == SD_READ_MULTIPLE_BLOCK || \
403 cmd == SD_WRITE_MULTIPLE_BLOCK)
404
405/* RCRC & RTO interrupts should be set together with the CD interrupt but 404/* RCRC & RTO interrupts should be set together with the CD interrupt but
406 * in practice sometimes incorrectly precede the CD interrupt. If we leave 405 * in practice sometimes incorrectly precede the CD interrupt. If we leave
407 * them masked for now we can check them in the isr by reading raw status when 406 * them masked for now we can check them in the isr by reading raw status when
@@ -433,12 +432,10 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
433 432
434 MCI_MASK &= ~MCI_INT_CD; 433 MCI_MASK &= ~MCI_INT_CD;
435 434
436 /* Handle command responses */ 435 /* Handle command responses & errors */
437
438 /* TODO Check crc values to determine if the response was valid */
439 if(flags & MCI_RESP) 436 if(flags & MCI_RESP)
440 { 437 {
441 if(cmd_error & MCI_INT_RCRC) /* skipping timeout for now */ 438 if(cmd_error & (MCI_INT_RCRC | MCI_INT_RTO))
442 return false; 439 return false;
443 440
444 if(flags & MCI_LONG_RESP) 441 if(flags & MCI_LONG_RESP)
@@ -515,7 +512,7 @@ static int sd_init_card(const int drive)
515 512
516 /* Attempt to switch cards to HS timings, non HS cards just ignore this */ 513 /* Attempt to switch cards to HS timings, non HS cards just ignore this */
517 /* CMD7 w/rca: Select card to put it in TRAN state */ 514 /* CMD7 w/rca: Select card to put it in TRAN state */
518 if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_RESP, &response)) 515 if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_NO_RESP, NULL))
519 return -7; 516 return -7;
520 517
521 if(sd_wait_for_state(drive, SD_TRAN)) 518 if(sd_wait_for_state(drive, SD_TRAN))
@@ -527,7 +524,7 @@ static int sd_init_card(const int drive)
527 524
528 /* We need to go back to STBY state now so we can read csd */ 525 /* We need to go back to STBY state now so we can read csd */
529 /* CMD7 w/rca=0: Deselect card to put it in STBY state */ 526 /* CMD7 w/rca=0: Deselect card to put it in STBY state */
530 if(!send_cmd(drive, SD_DESELECT_CARD, 0, MCI_RESP, &response)) 527 if(!send_cmd(drive, SD_DESELECT_CARD, 0, MCI_NO_RESP, NULL))
531 return -10; 528 return -10;
532 529
533 /* CMD9 send CSD */ 530 /* CMD9 send CSD */
@@ -789,7 +786,7 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
789#ifdef HAVE_MULTIDRIVE 786#ifdef HAVE_MULTIDRIVE
790 /* CMD7 w/rca: Select card to put it in TRAN state */ 787 /* CMD7 w/rca: Select card to put it in TRAN state */
791 if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_NO_RESP, NULL)) 788 if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_NO_RESP, NULL))
792 return -6; 789 return -13;
793#endif 790#endif
794 791
795 last_disk_activity = current_tick; 792 last_disk_activity = current_tick;
@@ -882,7 +879,7 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
882 /* CMD lines are separate, not common, so we need to actively deselect */ 879 /* CMD lines are separate, not common, so we need to actively deselect */
883 /* CMD7 w/rca =0 : deselects card & puts it in STBY state */ 880 /* CMD7 w/rca =0 : deselects card & puts it in STBY state */
884 if(!send_cmd(drive, SD_DESELECT_CARD, 0, MCI_NO_RESP, NULL)) 881 if(!send_cmd(drive, SD_DESELECT_CARD, 0, MCI_NO_RESP, NULL))
885 return -6; 882 return -14;
886#endif 883#endif
887 884
888#ifndef BOOTLOADER 885#ifndef BOOTLOADER