summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 56dd50814a..066be4e987 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -42,7 +42,6 @@ static struct mutex sd_mtx;
42 42
43static int use_4bit; 43static int use_4bit;
44static int num_6; 44static int num_6;
45static int sd2_0;
46 45
47//#define SD_DMA_ENABLE 46//#define SD_DMA_ENABLE
48#define SD_DMA_INTERRUPT 0 47#define SD_DMA_INTERRUPT 0
@@ -598,7 +597,7 @@ static int jz_sd_transmit_data(struct sd_request *req)
598static inline unsigned int jz_sd_calc_clkrt(unsigned int rate) 597static inline unsigned int jz_sd_calc_clkrt(unsigned int rate)
599{ 598{
600 unsigned int clkrt; 599 unsigned int clkrt;
601 unsigned int clk_src = sd2_0 ? SD_CLOCK_HIGH : SD_CLOCK_FAST; 600 unsigned int clk_src = card.sd2plus ? SD_CLOCK_HIGH : SD_CLOCK_FAST;
602 601
603 clkrt = 0; 602 clkrt = 0;
604 while (rate < clk_src) 603 while (rate < clk_src)
@@ -716,7 +715,7 @@ static int jz_sd_exec_cmd(struct sd_request *request)
716 events = SD_EVENT_RX_DATA_DONE; 715 events = SD_EVENT_RX_DATA_DONE;
717 break; 716 break;
718 717
719 case 6: 718 case SD_SWITCH_FUNC:
720 if (num_6 < 2) 719 if (num_6 < 2)
721 { 720 {
722#if defined(SD_DMA_ENABLE) 721#if defined(SD_DMA_ENABLE)
@@ -1086,7 +1085,6 @@ static int sd_init_card_state(struct sd_request *request)
1086 (request->response[3+i*4]<< 8) | request->response[4+i*4]); 1085 (request->response[3+i*4]<< 8) | request->response[4+i*4]);
1087 1086
1088 sd_parse_csd(&card); 1087 sd_parse_csd(&card);
1089 sd2_0 = (card_extract_bits(card.csd, 127, 2) == 1);
1090 1088
1091 logf("CSD: %08lx%08lx%08lx%08lx", card.csd[0], card.csd[1], card.csd[2], card.csd[3]); 1089 logf("CSD: %08lx%08lx%08lx%08lx", card.csd[0], card.csd[1], card.csd[2], card.csd[3]);
1092 DEBUG("SD card is ready"); 1090 DEBUG("SD card is ready");
@@ -1155,7 +1153,7 @@ static int sd_select_card(void)
1155 if (retval) 1153 if (retval)
1156 return retval; 1154 return retval;
1157 1155
1158 if (sd2_0) 1156 if (card.sd2plus)
1159 { 1157 {
1160 retval = sd_read_switch(&request); 1158 retval = sd_read_switch(&request);
1161 if (!retval) 1159 if (!retval)
@@ -1188,7 +1186,6 @@ static int __sd_init_device(void)
1188 /* Initialise card data as blank */ 1186 /* Initialise card data as blank */
1189 memset(&card, 0, sizeof(tCardInfo)); 1187 memset(&card, 0, sizeof(tCardInfo));
1190 1188
1191 sd2_0 = 0;
1192 num_6 = 0; 1189 num_6 = 0;
1193 use_4bit = 0; 1190 use_4bit = 0;
1194 1191
@@ -1250,9 +1247,9 @@ static inline void sd_stop_transfer(void)
1250 mutex_unlock(&sd_mtx); 1247 mutex_unlock(&sd_mtx);
1251} 1248}
1252 1249
1253int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf) 1250int sd_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf)
1254{ 1251{
1255#ifdef HAVE_MULTIVOLUME 1252#ifdef HAVE_MULTIDRIVE
1256 (void)drive; 1253 (void)drive;
1257#endif 1254#endif
1258 sd_start_transfer(); 1255 sd_start_transfer();
@@ -1276,7 +1273,8 @@ int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf)
1276 if ((retval = sd_unpack_r1(&request, &r1))) 1273 if ((retval = sd_unpack_r1(&request, &r1)))
1277 goto err; 1274 goto err;
1278 1275
1279 if (sd2_0) 1276 // XXX 64-bit
1277 if (card.sd2plus)
1280 { 1278 {
1281 sd_send_cmd(&request, SD_READ_MULTIPLE_BLOCK, start, 1279 sd_send_cmd(&request, SD_READ_MULTIPLE_BLOCK, start,
1282 count, SD_BLOCK_SIZE, RESPONSE_R1, buf); 1280 count, SD_BLOCK_SIZE, RESPONSE_R1, buf);
@@ -1292,21 +1290,20 @@ int sd_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf)
1292 goto err; 1290 goto err;
1293 } 1291 }
1294 1292
1295 last_disk_activity = current_tick;
1296
1297 sd_simple_cmd(&request, SD_STOP_TRANSMISSION, 0, RESPONSE_R1B); 1293 sd_simple_cmd(&request, SD_STOP_TRANSMISSION, 0, RESPONSE_R1B);
1298 if ((retval = sd_unpack_r1(&request, &r1))) 1294 if ((retval = sd_unpack_r1(&request, &r1)))
1299 goto err; 1295 goto err;
1300 1296
1301err: 1297err:
1298 last_disk_activity = current_tick;
1302 sd_stop_transfer(); 1299 sd_stop_transfer();
1303 1300
1304 return retval; 1301 return retval;
1305} 1302}
1306 1303
1307int sd_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf) 1304int sd_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf)
1308{ 1305{
1309#ifdef HAVE_MULTIVOLUME 1306#ifdef HAVE_MULTIDRIVE
1310 (void)drive; 1307 (void)drive;
1311#endif 1308#endif
1312 sd_start_transfer(); 1309 sd_start_transfer();
@@ -1330,7 +1327,8 @@ int sd_write_sectors(IF_MV(int drive,) unsigned long start, int count, const voi
1330 if ((retval = sd_unpack_r1(&request, &r1))) 1327 if ((retval = sd_unpack_r1(&request, &r1)))
1331 goto err; 1328 goto err;
1332 1329
1333 if (sd2_0) 1330 // XXX 64-bit
1331 if (card.sd2plus)
1334 { 1332 {
1335 sd_send_cmd(&request, SD_WRITE_MULTIPLE_BLOCK, start, 1333 sd_send_cmd(&request, SD_WRITE_MULTIPLE_BLOCK, start,
1336 count, SD_BLOCK_SIZE, RESPONSE_R1, 1334 count, SD_BLOCK_SIZE, RESPONSE_R1,
@@ -1387,7 +1385,7 @@ int sd_soft_reset(void)
1387#ifdef HAVE_HOTSWAP 1385#ifdef HAVE_HOTSWAP
1388bool sd_removable(IF_MD_NONVOID(int drive)) 1386bool sd_removable(IF_MD_NONVOID(int drive))
1389{ 1387{
1390#ifdef HAVE_MULTIVOLUME 1388#ifdef HAVE_MULTIDRIVE
1391 (void)drive; 1389 (void)drive;
1392#endif 1390#endif
1393 return true; 1391 return true;
@@ -1415,7 +1413,7 @@ void MMC_CD_IRQ(void)
1415} 1413}
1416#endif 1414#endif
1417 1415
1418bool sd_present(IF_MV_NONVOID(int drive)) 1416bool sd_present(IF_MD_NONVOID(int drive))
1419{ 1417{
1420#ifdef HAVE_MULTIDRIVE 1418#ifdef HAVE_MULTIDRIVE
1421 (void)drive; 1419 (void)drive;