From 14079c39f0525e4ddb3951e3cf8a2aa52b170d77 Mon Sep 17 00:00:00 2001 From: Jack Halpin Date: Sun, 11 Oct 2009 03:11:13 +0000 Subject: AMS Sansa: If SD card is HS capable set High Speed timings. This still doesn't solve the problem of the cards being overclocked at 62MHz but we can mitigate this a bit by switching to HS timings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23088 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/ata_sd_as3525.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index c848ba1dca..33816d4e61 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -94,6 +94,7 @@ static const int pl180_base[NUM_DRIVES] = { #endif }; +static int sd_wait_for_state(const int drive, unsigned int state); static int sd_select_bank(signed char bank); static int sd_init_card(const int drive); static void init_pl180_controller(const int drive); @@ -321,6 +322,15 @@ static int sd_init_card(const int drive) MCI_CLOCK(drive) |= MCI_CLOCK_BYPASS; /* full speed for controller clock */ mci_delay(); + /* If card is HS capable switch to HS timings */ + if(card_info[drive].speed > 125000) + { + if(sd_wait_for_state(drive, SD_TRAN)) + return -13; + if(!send_cmd(drive, SD_SWITCH_FUNC, 0x80fffff1, MCI_ARG, NULL)) + return -14; + } + /* * enable bank switching * without issuing this command, we only have access to 1/4 of the blocks @@ -331,7 +341,7 @@ static int sd_init_card(const int drive) { const int ret = sd_select_bank(-1); if(ret < 0) - return ret - 13; + return ret - 15; } return 0; -- cgit v1.2.3