summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pp/ata-sd-pp.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pp/ata-sd-pp.c')
-rw-r--r--firmware/target/arm/pp/ata-sd-pp.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/firmware/target/arm/pp/ata-sd-pp.c b/firmware/target/arm/pp/ata-sd-pp.c
index fb0a9e150e..b998afd21e 100644
--- a/firmware/target/arm/pp/ata-sd-pp.c
+++ b/firmware/target/arm/pp/ata-sd-pp.c
@@ -82,7 +82,7 @@
82#define STAT_TIME_OUT_RES (1 << 1) 82#define STAT_TIME_OUT_RES (1 << 1)
83#define STAT_TIME_OUT_READ (1) 83#define STAT_TIME_OUT_READ (1)
84#define STAT_ERROR_BITS (0x3f) 84#define STAT_ERROR_BITS (0x3f)
85 85
86/* MMC_CMDAT bits */ 86/* MMC_CMDAT bits */
87/* Some of the bits used by the OF don't make much sense with these */ 87/* Some of the bits used by the OF don't make much sense with these */
88/* definitions. So they're probably different between PXA and PP502x */ 88/* definitions. So they're probably different between PXA and PP502x */
@@ -101,7 +101,7 @@
101#define CMDAT_RES_TYPE3 (3) 101#define CMDAT_RES_TYPE3 (3)
102#define CMDAT_RES_TYPE2 (2) 102#define CMDAT_RES_TYPE2 (2)
103#define CMDAT_RES_TYPE1 (1) 103#define CMDAT_RES_TYPE1 (1)
104 104
105/* MMC_I_MASK bits */ 105/* MMC_I_MASK bits */
106/* PP502x apparently only has bits 0-3 */ 106/* PP502x apparently only has bits 0-3 */
107#define I_MASK_SDIO_SUSPEND_ACK (1 << 12) 107#define I_MASK_SDIO_SUSPEND_ACK (1 << 12)
@@ -499,18 +499,18 @@ static inline void copy_write_sectors(const unsigned char** buf)
499 { 499 {
500 asm volatile ( 500 asm volatile (
501 "ldmia %[buf]!, { r3, r5, r7, r9 } \r\n" 501 "ldmia %[buf]!, { r3, r5, r7, r9 } \r\n"
502 "mov r4, r3, lsr #16 \r\n" 502 "mov r4, r3, lsr #16 \r\n"
503 "mov r6, r5, lsr #16 \r\n" 503 "mov r6, r5, lsr #16 \r\n"
504 "mov r8, r7, lsr #16 \r\n" 504 "mov r8, r7, lsr #16 \r\n"
505 "mov r10, r9, lsr #16 \r\n" 505 "mov r10, r9, lsr #16 \r\n"
506 "stmia %[data], { r3-r10 } \r\n" 506 "stmia %[data], { r3-r10 } \r\n"
507 "ldmia %[buf]!, { r3, r5, r7, r9 } \r\n" 507 "ldmia %[buf]!, { r3, r5, r7, r9 } \r\n"
508 "mov r4, r3, lsr #16 \r\n" 508 "mov r4, r3, lsr #16 \r\n"
509 "mov r6, r5, lsr #16 \r\n" 509 "mov r6, r5, lsr #16 \r\n"
510 "mov r8, r7, lsr #16 \r\n" 510 "mov r8, r7, lsr #16 \r\n"
511 "mov %[t], r9, lsr #16 \r\n" 511 "mov %[t], r9, lsr #16 \r\n"
512 "stmia %[data], { r3-r9 } \r\n" 512 "stmia %[data], { r3-r9 } \r\n"
513 : [buf]"+&r"(*buf), [t]"=&r"(t) 513 : [buf]"+&r"(*buf), [t]"=&r"(t)
514 : [data]"r"(&MMC_DATA_FIFO) 514 : [data]"r"(&MMC_DATA_FIFO)
515 : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10" 515 : "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10"
516 ); 516 );
@@ -760,7 +760,7 @@ static void sd_init_device(int card_no)
760 currcard->csd[i] = temp_reg[3-i]; 760 currcard->csd[i] = temp_reg[3-i];
761 761
762 sd_parse_csd(currcard); 762 sd_parse_csd(currcard);
763 763
764 MMC_CLKRT = 0; /* switch to highest clock rate */ 764 MMC_CLKRT = 0; /* switch to highest clock rate */
765 765
766 ret = sd_command(SD_SELECT_CARD, currcard->rca, NULL, 766 ret = sd_command(SD_SELECT_CARD, currcard->rca, NULL,
@@ -849,7 +849,7 @@ static void sd_select_device(int card_no)
849 849
850/* API Functions */ 850/* API Functions */
851 851
852int sd_read_sectors(IF_MD(int drive,) unsigned long start, int incount, 852int sd_read_sectors(IF_MD(int drive,) sector_t start, int incount,
853 void* inbuf) 853 void* inbuf)
854{ 854{
855#ifndef HAVE_MULTIDRIVE 855#ifndef HAVE_MULTIDRIVE
@@ -857,8 +857,8 @@ int sd_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
857#endif 857#endif
858 int ret; 858 int ret;
859 unsigned char *buf, *buf_end; 859 unsigned char *buf, *buf_end;
860 unsigned int bank; 860 sector_t bank;
861 861
862 /* TODO: Add DMA support. */ 862 /* TODO: Add DMA support. */
863 863
864 mutex_lock(&sd_mtx); 864 mutex_lock(&sd_mtx);
@@ -894,7 +894,7 @@ sd_read_retry:
894 if (ret < 0) 894 if (ret < 0)
895 goto sd_read_error; 895 goto sd_read_error;
896 } 896 }
897 897
898 start -= bank * BLOCKS_PER_BANK; 898 start -= bank * BLOCKS_PER_BANK;
899 } 899 }
900 900
@@ -904,6 +904,8 @@ sd_read_retry:
904 904
905 MMC_NUMBLK = incount; 905 MMC_NUMBLK = incount;
906 906
907 // XXX 64-bit addresses..
908
907#ifdef HAVE_HOTSWAP 909#ifdef HAVE_HOTSWAP
908 if(currcard->ocr & (1<<30) ) 910 if(currcard->ocr & (1<<30) )
909 { 911 {
@@ -966,7 +968,7 @@ sd_read_error:
966 } 968 }
967} 969}
968 970
969int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count, 971int sd_write_sectors(IF_MD(int drive,) sector_t start, int count,
970 const void* outbuf) 972 const void* outbuf)
971{ 973{
972/* Write support is not finished yet */ 974/* Write support is not finished yet */
@@ -1010,7 +1012,7 @@ sd_write_retry:
1010 if (ret < 0) 1012 if (ret < 0)
1011 goto sd_write_error; 1013 goto sd_write_error;
1012 } 1014 }
1013 1015
1014 start -= bank * BLOCKS_PER_BANK; 1016 start -= bank * BLOCKS_PER_BANK;
1015 } 1017 }
1016 1018
@@ -1250,7 +1252,7 @@ int sd_num_drives(int first_drive)
1250#else 1252#else
1251 (void)first_drive; 1253 (void)first_drive;
1252#endif 1254#endif
1253 1255
1254#ifdef HAVE_MULTIDRIVE 1256#ifdef HAVE_MULTIDRIVE
1255 return 2; 1257 return 2;
1256#else 1258#else