diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index 0ec1791928..084fdb66d0 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | |||
@@ -342,7 +342,6 @@ struct mmc_request | |||
342 | }; | 342 | }; |
343 | 343 | ||
344 | #define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */ | 344 | #define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */ |
345 | //#define MMC_OCR_ARG 0x40300000 | ||
346 | 345 | ||
347 | /*********************************************************************** | 346 | /*********************************************************************** |
348 | * MMC Events | 347 | * MMC Events |
@@ -978,7 +977,7 @@ static int jz_mmc_transmit_data(struct mmc_request *req) | |||
978 | static inline unsigned int jz_mmc_calc_clkrt(int is_sd, unsigned int rate) | 977 | static inline unsigned int jz_mmc_calc_clkrt(int is_sd, unsigned int rate) |
979 | { | 978 | { |
980 | unsigned int clkrt; | 979 | unsigned int clkrt; |
981 | unsigned int clk_src = is_sd ? 24000000 : 20000000; | 980 | unsigned int clk_src = is_sd ? (sd2_0 ? 48000000 : 24000000) : 20000000; |
982 | 981 | ||
983 | clkrt = 0; | 982 | clkrt = 0; |
984 | while (rate < clk_src) | 983 | while (rate < clk_src) |
@@ -1002,7 +1001,8 @@ static void jz_mmc_set_clock(int sd, unsigned int rate) | |||
1002 | { | 1001 | { |
1003 | __cpm_select_msc_hs_clk(sd); /* select clock source from CPM */ | 1002 | __cpm_select_msc_hs_clk(sd); /* select clock source from CPM */ |
1004 | REG_CPM_CPCCR |= CPM_CPCCR_CE; | 1003 | REG_CPM_CPCCR |= CPM_CPCCR_CE; |
1005 | REG_MSC_CLKRT = 0; | 1004 | clkrt = jz_mmc_calc_clkrt(sd, rate); |
1005 | REG_MSC_CLKRT = clkrt; | ||
1006 | } | 1006 | } |
1007 | else | 1007 | else |
1008 | { | 1008 | { |
@@ -1439,6 +1439,7 @@ static int mmc_init_card_state(struct mmc_request *request) | |||
1439 | break; | 1439 | break; |
1440 | 1440 | ||
1441 | case SD_SEND_IF_COND: | 1441 | case SD_SEND_IF_COND: |
1442 | retval = mmc_unpack_r1(request, &r1); | ||
1442 | mmc_simple_cmd(request, MMC_APP_CMD, 0, RESPONSE_R1); | 1443 | mmc_simple_cmd(request, MMC_APP_CMD, 0, RESPONSE_R1); |
1443 | break; | 1444 | break; |
1444 | 1445 | ||
@@ -1451,7 +1452,7 @@ static int mmc_init_card_state(struct mmc_request *request) | |||
1451 | limit_41++; | 1452 | limit_41++; |
1452 | mmc_simple_cmd(request, SD_SEND_OP_COND, ocr, RESPONSE_R3); | 1453 | mmc_simple_cmd(request, SD_SEND_OP_COND, ocr, RESPONSE_R3); |
1453 | } else if (limit_41 < 100) { | 1454 | } else if (limit_41 < 100) { |
1454 | limit_41++; | 1455 | limit_41++; |
1455 | mmc_simple_cmd(request, SD_SEND_OP_COND, ocr, RESPONSE_R3); | 1456 | mmc_simple_cmd(request, SD_SEND_OP_COND, ocr, RESPONSE_R3); |
1456 | } else{ | 1457 | } else{ |
1457 | /* reset the card to idle*/ | 1458 | /* reset the card to idle*/ |
@@ -1619,8 +1620,8 @@ int mmc_select_card(void) | |||
1619 | retval = mmc_unpack_r1(&request, &r1); | 1620 | retval = mmc_unpack_r1(&request, &r1); |
1620 | if (retval) | 1621 | if (retval) |
1621 | return retval; | 1622 | return retval; |
1622 | 1623 | ||
1623 | return retval; | 1624 | return 0; |
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | int sd_init(void) | 1627 | int sd_init(void) |
@@ -1636,8 +1637,8 @@ int sd_init(void) | |||
1636 | inited = true; | 1637 | inited = true; |
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | mmc_send_cmd(&init_req, MMC_CIM_RESET, 0, 0, 0, RESPONSE_NONE, NULL); | 1640 | mmc_simple_cmd(&init_req, MMC_CIM_RESET, 0, RESPONSE_NONE); |
1640 | mmc_send_cmd(&init_req, SD_GO_IDLE_STATE, 0, 0, 0, RESPONSE_NONE, NULL); | 1641 | mmc_simple_cmd(&init_req, SD_GO_IDLE_STATE, 0, RESPONSE_NONE); |
1641 | 1642 | ||
1642 | while ((retval = mmc_init_card_state(&init_req)) == MMC_INIT_DOING); | 1643 | while ((retval = mmc_init_card_state(&init_req)) == MMC_INIT_DOING); |
1643 | 1644 | ||
@@ -1676,9 +1677,9 @@ tCardInfo* card_get_info_target(int card_no) | |||
1676 | card.initialized = true; | 1677 | card.initialized = true; |
1677 | card.ocr = 0; | 1678 | card.ocr = 0; |
1678 | for(i=0; i<4; i++) | 1679 | for(i=0; i<4; i++) |
1679 | card.csd[i] = (*((unsigned long*)&mmcinfo.csd+4*i)); | 1680 | card.csd[i] = ((unsigned long*)&mmcinfo.csd)[i]; |
1680 | for(i=0; i<4; i++) | 1681 | for(i=0; i<4; i++) |
1681 | card.cid[i] = (*((unsigned long*)&mmcinfo.cid+4*i)); | 1682 | card.cid[i] = ((unsigned long*)&mmcinfo.cid)[i]; |
1682 | temp = card_extract_bits(card.csd, 29, 3); | 1683 | temp = card_extract_bits(card.csd, 29, 3); |
1683 | card.speed = sd_mantissa[card_extract_bits(card.csd, 25, 4)] | 1684 | card.speed = sd_mantissa[card_extract_bits(card.csd, 25, 4)] |
1684 | * sd_exponent[temp > 2 ? 7 : temp + 4]; | 1685 | * sd_exponent[temp > 2 ? 7 : temp + 4]; |