summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pp
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pp')
-rw-r--r--firmware/target/arm/pp/ata-pp5020.c24
-rw-r--r--firmware/target/arm/pp/ata-sd-pp.c40
2 files changed, 34 insertions, 30 deletions
diff --git a/firmware/target/arm/pp/ata-pp5020.c b/firmware/target/arm/pp/ata-pp5020.c
index 176e74993c..7351215693 100644
--- a/firmware/target/arm/pp/ata-pp5020.c
+++ b/firmware/target/arm/pp/ata-pp5020.c
@@ -48,8 +48,8 @@ bool ata_is_coldstart()
48 rest are the same. They go in IDE0_PRI_TIMING0. 48 rest are the same. They go in IDE0_PRI_TIMING0.
49 49
50 Rockbox used to use 0x10, and test_disk shows that leads to faster PIO. 50 Rockbox used to use 0x10, and test_disk shows that leads to faster PIO.
51 However on some disks connected with mSATA adapters this causes corrupt data 51 However when used with mSATA and some SD adapters this causes corrupt data
52 so we now just use these timings from the OF. 52 so we now unconditionally use these timings from the OF.
53*/ 53*/
54static const unsigned long pio80mhz[] = { 54static const unsigned long pio80mhz[] = {
55 0xC293, 0x43A2, 0x11A1, 0x7232, 0x3131 55 0xC293, 0x43A2, 0x11A1, 0x7232, 0x3131
@@ -83,10 +83,7 @@ void ata_device_init()
83/* Setup the timing for PIO mode */ 83/* Setup the timing for PIO mode */
84void ata_set_pio_timings(int mode) 84void ata_set_pio_timings(int mode)
85{ 85{
86 if (ata_disk_isssd()) 86 IDE0_PRI_TIMING0 = pio80mhz[mode];
87 IDE0_PRI_TIMING0 = pio80mhz[mode];
88 else
89 IDE0_PRI_TIMING0 = 0x10;
90} 87}
91 88
92#ifdef HAVE_ATA_DMA 89#ifdef HAVE_ATA_DMA
@@ -109,6 +106,8 @@ static bool dma_boosted = false;
109static bool dma_needs_boost; 106static bool dma_needs_boost;
110#endif 107#endif
111 108
109static int ata_is_ssd = 0;
110
112/* This function sets up registers for 80 Mhz. 111/* This function sets up registers for 80 Mhz.
113 Ultra DMA mode 2 works at 30 Mhz. 112 Ultra DMA mode 2 works at 30 Mhz.
114 */ 113 */
@@ -136,6 +135,8 @@ void ata_dma_set_mode(unsigned char mode) {
136#if !defined(IPOD_NANO) 135#if !defined(IPOD_NANO)
137 IDE0_CFG |= 0x20000000; /* >= 50 Mhz */ 136 IDE0_CFG |= 0x20000000; /* >= 50 Mhz */
138#endif 137#endif
138
139 ata_is_ssd = ata_disk_isssd();
139} 140}
140 141
141#define IDE_CFG_INTRQ 8 142#define IDE_CFG_INTRQ 8
@@ -175,11 +176,12 @@ bool ata_dma_setup(void *addr, unsigned long bytes, bool write) {
175 /* Writes only need to be word-aligned, but by default DMA 176 /* Writes only need to be word-aligned, but by default DMA
176 * is not used for writing on non-SSDs as it appears to be slower. 177 * is not used for writing on non-SSDs as it appears to be slower.
177 */ 178 */
178 if (!ata_disk_isssd()) 179 if (write) {
179 return false; 180 if ((unsigned long)addr & 3)
180 181 return false;
181 if (write && ((unsigned long)addr & 3)) 182 if (!ata_is_ssd)
182 return false; 183 return false;
184 }
183 185
184#if ATA_MAX_UDMA > 2 186#if ATA_MAX_UDMA > 2
185 if (dma_needs_boost && !dma_boosted) { 187 if (dma_needs_boost && !dma_boosted) {
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