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.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index ce8a3d7479..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,7 +1247,7 @@ 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_MULTIDRIVE 1252#ifdef HAVE_MULTIDRIVE
1256 (void)drive; 1253 (void)drive;
@@ -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,19 +1290,18 @@ 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_MD(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_MULTIDRIVE 1306#ifdef HAVE_MULTIDRIVE
1310 (void)drive; 1307 (void)drive;
@@ -1330,7 +1327,8 @@ int sd_write_sectors(IF_MD(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,