summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 9756d9e1f0..85913ec9dc 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -327,9 +327,6 @@
327static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SD_BLOCK_SIZE] __attribute__((aligned(32))); /* align on cache line size */ 327static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SD_BLOCK_SIZE] __attribute__((aligned(32))); /* align on cache line size */
328static unsigned char *uncached_buffer = AS3525_UNCACHED_ADDR(&aligned_buffer[0]); 328static unsigned char *uncached_buffer = AS3525_UNCACHED_ADDR(&aligned_buffer[0]);
329 329
330static void init_controller(void);
331static int sd_wait_for_tran_state(const int drive);
332
333static tCardInfo card_info[NUM_DRIVES]; 330static tCardInfo card_info[NUM_DRIVES];
334 331
335/* for compatibility */ 332/* for compatibility */
@@ -451,6 +448,30 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
451 return true; 448 return true;
452} 449}
453 450
451static int sd_wait_for_tran_state(const int drive)
452{
453 unsigned long response;
454 unsigned int timeout = current_tick + 5*HZ;
455
456 while (1)
457 {
458 while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response)));
459
460 if (((response >> 9) & 0xf) == SD_TRAN)
461 return 0;
462
463 if(TIME_AFTER(current_tick, timeout))
464 return -10 * ((response >> 9) & 0xf);
465
466 if (TIME_AFTER(current_tick, next_yield))
467 {
468 yield();
469 next_yield = current_tick + MIN_YIELD_PERIOD;
470 }
471 }
472}
473
474
454static int sd_init_card(const int drive) 475static int sd_init_card(const int drive)
455{ 476{
456 unsigned long response; 477 unsigned long response;
@@ -759,29 +780,6 @@ int sd_init(void)
759 return 0; 780 return 0;
760} 781}
761 782
762static int sd_wait_for_tran_state(const int drive)
763{
764 unsigned long response;
765 unsigned int timeout = current_tick + 5*HZ;
766
767 while (1)
768 {
769 while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response)));
770
771 if (((response >> 9) & 0xf) == SD_TRAN)
772 return 0;
773
774 if(TIME_AFTER(current_tick, timeout))
775 return -10 * ((response >> 9) & 0xf);
776
777 if (TIME_AFTER(current_tick, next_yield))
778 {
779 yield();
780 next_yield = current_tick + MIN_YIELD_PERIOD;
781 }
782 }
783}
784
785static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, 783static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
786 int count, void* buf, bool write) 784 int count, void* buf, bool write)
787{ 785{