diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-08-25 14:01:44 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-08-25 14:01:44 -0400 |
commit | 6920c089af4f5c2c3e4bf502617289a98228236f (patch) | |
tree | ed796e799f97fe7b07e9ab7fabbab2433ece1619 | |
parent | 0aa2197d9325159830bac3c6c8fde922e2b86482 (diff) | |
download | rockbox-6920c089af4f5c2c3e4bf502617289a98228236f.tar.gz rockbox-6920c089af4f5c2c3e4bf502617289a98228236f.zip |
jz4740: SD clock sequencing changes.
* Don't stop clock before switching speeds
* Don't stop clock prior to transactions
* Stop clock at the end of transactions
Will result in slightly better performance and some power saving when
we're not actively using the SD peripheral.
Change-Id: I1c82476cad97137b1469900645ecf7bb0887119a
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index 116d9849cc..0eb175c03f 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | |||
@@ -172,7 +172,7 @@ struct sd_response_r1 | |||
172 | }; | 172 | }; |
173 | 173 | ||
174 | struct sd_response_r3 | 174 | struct sd_response_r3 |
175 | { | 175 | { |
176 | unsigned int ocr; | 176 | unsigned int ocr; |
177 | }; | 177 | }; |
178 | 178 | ||
@@ -335,10 +335,10 @@ static int jz_sd_check_status(struct sd_request *request) | |||
335 | { | 335 | { |
336 | DEBUG("SD CRC error, MSC_STAT 0x%x", status); | 336 | DEBUG("SD CRC error, MSC_STAT 0x%x", status); |
337 | return SD_ERROR_CRC; | 337 | return SD_ERROR_CRC; |
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | /* Checking for FIFO empty */ | 342 | /* Checking for FIFO empty */ |
343 | /*if(status & MSC_STAT_DATA_FIFO_EMPTY && request->rtype != RESPONSE_NONE) | 343 | /*if(status & MSC_STAT_DATA_FIFO_EMPTY && request->rtype != RESPONSE_NONE) |
344 | { | 344 | { |
@@ -623,8 +623,6 @@ static void jz_sd_set_clock(unsigned int rate) | |||
623 | { | 623 | { |
624 | int clkrt; | 624 | int clkrt; |
625 | 625 | ||
626 | jz_sd_stop_clock(); | ||
627 | |||
628 | /* select clock source from CPM */ | 626 | /* select clock source from CPM */ |
629 | cpm_select_msc_clk(rate); | 627 | cpm_select_msc_clk(rate); |
630 | 628 | ||
@@ -676,9 +674,6 @@ static int jz_sd_exec_cmd(struct sd_request *request) | |||
676 | } | 674 | } |
677 | } | 675 | } |
678 | 676 | ||
679 | /* stop clock */ | ||
680 | jz_sd_stop_clock(); | ||
681 | |||
682 | /* mask all interrupts */ | 677 | /* mask all interrupts */ |
683 | //REG_MSC_IMASK = 0xffff; | 678 | //REG_MSC_IMASK = 0xffff; |
684 | /* clear status */ | 679 | /* clear status */ |
@@ -851,8 +846,8 @@ static int jz_sd_exec_cmd(struct sd_request *request) | |||
851 | { | 846 | { |
852 | if (request->cmd == SD_SEND_SCR) | 847 | if (request->cmd == SD_SEND_SCR) |
853 | { | 848 | { |
854 | /* SD card returns SCR register as data. | 849 | /* SD card returns SCR register as data. |
855 | SD core expect it in the response buffer, | 850 | SD core expect it in the response buffer, |
856 | after normal response. */ | 851 | after normal response. */ |
857 | request->buffer = | 852 | request->buffer = |
858 | (unsigned char *) ((unsigned int) request->response + 5); | 853 | (unsigned char *) ((unsigned int) request->response + 5); |
@@ -889,6 +884,7 @@ static int jz_sd_exec_cmd(struct sd_request *request) | |||
889 | } | 884 | } |
890 | 885 | ||
891 | /* Command completed */ | 886 | /* Command completed */ |
887 | jz_sd_stop_clock(); /* Stop SD clock since we're done */ | ||
892 | 888 | ||
893 | return SD_NO_ERROR; /* return successfully */ | 889 | return SD_NO_ERROR; /* return successfully */ |
894 | } | 890 | } |
@@ -1026,7 +1022,7 @@ static int sd_init_card_state(struct sd_request *request) | |||
1026 | retval = sd_unpack_r1(request, &r1); | 1022 | retval = sd_unpack_r1(request, &r1); |
1027 | if (retval & (limit_41 < 100)) | 1023 | if (retval & (limit_41 < 100)) |
1028 | { | 1024 | { |
1029 | DEBUG("sd_init_card_state: unable to SD_APP_CMD error=%d", | 1025 | DEBUG("sd_init_card_state: unable to SD_APP_CMD error=%d", |
1030 | retval); | 1026 | retval); |
1031 | limit_41++; | 1027 | limit_41++; |
1032 | sd_simple_cmd(request, SD_APP_OP_COND, ocr, RESPONSE_R3); | 1028 | sd_simple_cmd(request, SD_APP_OP_COND, ocr, RESPONSE_R3); |
@@ -1064,7 +1060,7 @@ static int sd_init_card_state(struct sd_request *request) | |||
1064 | 1060 | ||
1065 | case SD_ALL_SEND_CID: | 1061 | case SD_ALL_SEND_CID: |
1066 | for(i=0; i<4; i++) | 1062 | for(i=0; i<4; i++) |
1067 | card.cid[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | | 1063 | card.cid[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | |
1068 | (request->response[3+i*4]<< 8) | request->response[4+i*4]); | 1064 | (request->response[3+i*4]<< 8) | request->response[4+i*4]); |
1069 | 1065 | ||
1070 | logf("CID: %08lx%08lx%08lx%08lx", card.cid[0], card.cid[1], card.cid[2], card.cid[3]); | 1066 | logf("CID: %08lx%08lx%08lx%08lx", card.cid[0], card.cid[1], card.cid[2], card.cid[3]); |
@@ -1072,11 +1068,11 @@ static int sd_init_card_state(struct sd_request *request) | |||
1072 | break; | 1068 | break; |
1073 | case SD_SEND_RELATIVE_ADDR: | 1069 | case SD_SEND_RELATIVE_ADDR: |
1074 | retval = sd_unpack_r6(request, &r1, &card.rca); | 1070 | retval = sd_unpack_r6(request, &r1, &card.rca); |
1075 | card.rca = card.rca << 16; | 1071 | card.rca = card.rca << 16; |
1076 | DEBUG("sd_init_card_state: Get RCA from SD: 0x%04lx Status: %x", card.rca, r1.status); | 1072 | DEBUG("sd_init_card_state: Get RCA from SD: 0x%04lx Status: %x", card.rca, r1.status); |
1077 | if (retval) | 1073 | if (retval) |
1078 | { | 1074 | { |
1079 | DEBUG("sd_init_card_state: unable to SET_RELATIVE_ADDR error=%d", | 1075 | DEBUG("sd_init_card_state: unable to SET_RELATIVE_ADDR error=%d", |
1080 | retval); | 1076 | retval); |
1081 | return SD_INIT_FAILED; | 1077 | return SD_INIT_FAILED; |
1082 | } | 1078 | } |
@@ -1086,7 +1082,7 @@ static int sd_init_card_state(struct sd_request *request) | |||
1086 | 1082 | ||
1087 | case SD_SEND_CSD: | 1083 | case SD_SEND_CSD: |
1088 | for(i=0; i<4; i++) | 1084 | for(i=0; i<4; i++) |
1089 | card.csd[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | | 1085 | card.csd[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | |
1090 | (request->response[3+i*4]<< 8) | request->response[4+i*4]); | 1086 | (request->response[3+i*4]<< 8) | request->response[4+i*4]); |
1091 | 1087 | ||
1092 | sd_parse_csd(&card); | 1088 | sd_parse_csd(&card); |
@@ -1132,7 +1128,7 @@ static int sd_read_switch(struct sd_request *request) | |||
1132 | 1128 | ||
1133 | if (((unsigned char *)status)[13] & 0x02) | 1129 | if (((unsigned char *)status)[13] & 0x02) |
1134 | return 0; | 1130 | return 0; |
1135 | else | 1131 | else |
1136 | return 1; | 1132 | return 1; |
1137 | } | 1133 | } |
1138 | 1134 | ||