Commit graph

101 commits

Author SHA1 Message Date
Jack Halpin
f37fe25638 Sansa AMS: Run all SD cards within SD Specification frequencies.
Addition of a small write delay avoids data crc failures at lower MCICLK frequencies.
Check the actual speed value from the card's CSD register to determine HS status.  HS cards can run at twice the speed of standard speed SD cards.
Internal cards & standard speed uSD now run at PCLK/4 = 15.5 MHz.  HS uSD cards run at PCLK/2 = 31 MHz.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23901 a1c6a512-1295-4272-9138-f99709370657
2009-12-08 20:26:31 +00:00
Jack Halpin
472bab654b Sansa AMS: Move the boost from SD ident to operating frequency to after the cards get switched to HS timings.
It seems that lowering the operating frequency for the SD cards has made some uSD cards have problems with the init process.
By moving the boost from ident to operating frequency to after the switch to HS timing these card now seem to init normally.
We still need to fix the problem where the internal cards and non HS uSD cards are still slightly overclocked at 31 MHz.
As of now we experience data crc failures during writes at the next lower frequency of 15.5 MHz.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23870 a1c6a512-1295-4272-9138-f99709370657
2009-12-06 07:32:40 +00:00
Jack Halpin
43991cdc8f Sansa AMS: The internal SD does not use the IDE AHB interface so remove references to it. It does use the other non AHB interface.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23836 a1c6a512-1295-4272-9138-f99709370657
2009-12-03 20:06:46 +00:00
Jack Halpin
d414b0a027 Sansa AMS: Reduce MCICLK speed on SD cards to 31 MHz.
This is within the SD Spec for v2 High Speed cards but still over the 25 MHz limit for v1 and non-HS v2 cards.
Test_disk write & verify passes on both internal and uSD.
The v1 cards still need to be lowered to 15 MHz but that causes data crc failures at this point.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23835 a1c6a512-1295-4272-9138-f99709370657
2009-12-03 20:06:40 +00:00
Jack Halpin
7f88cc44aa Sansa AMS: Use some new macros to set the MCICLK frequency to help avoid missing the bypass bit when resetting frequencies with MCI_CLOCK register.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23831 a1c6a512-1295-4272-9138-f99709370657
2009-12-03 17:22:09 +00:00
Jack Halpin
40629be046 Sansa AMS: Wait until sd_init_card() to turn on the clocks for the pl180 controller.
Currently the bypass bit is not cleared so it's possible to enter the identification phase at bypass speed instead of ident speed.
The simplest solution to ensure the bypass bit is not set is to set the register with an = operation instead of |=.
This makes setting the MCI_CLOCK register at the end of the controller init unnecessary.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23830 a1c6a512-1295-4272-9138-f99709370657
2009-12-03 17:22:03 +00:00
Jack Halpin
d8f420a48d Sansa AMS: Add read/write and drive info to panic message for SD transfer errors.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23829 a1c6a512-1295-4272-9138-f99709370657
2009-12-03 17:21:56 +00:00
Jack Halpin
c67ce499f3 Sansa AMS: Check if SD controllers are already enabled before attempting to enable in order to read the registers.
If the controllers were already enabled there was a chance we could try to read the MCI_CLOCK registers while the cards were buffering and then disable the controllers prematurely.

I guess funman knows and sees all!!  Thanks funman.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23811 a1c6a512-1295-4272-9138-f99709370657
2009-12-01 21:23:11 +00:00
Jack Halpin
a22ab34649 Sansa AMS: Reorganize sd_enable() and add/change comments. No real functional changes.
Enabling/disabling of the NAF and IDE clocks is now grouped together as both are related to the internal SD.
Sequence for disabling SD now mirrors the enable sequence.
Comments added to make it easier to follow the configuration change for XPD from gpio to mci-sd and back.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23808 a1c6a512-1295-4272-9138-f99709370657
2009-12-01 18:22:25 +00:00
Thomas Martitz
ee7cf6c63c Remove unused card_detect(), and make card_detect_target() static inline in each sd driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23757 a1c6a512-1295-4272-9138-f99709370657
2009-11-26 00:51:09 +00:00
Jack Halpin
84f04a57ee AMS Sansa: For consistency, replace references to SECTOR_SIZE with SD_BLOCK_SIZE which is defined in sd.h as 512 bytes.
We had 3 different references to the same value.  Rockbox always uses a blocksize of 512 bytes for SD and we were using SECTOR_SIZE, SD_BLOCK_SIZE, & card_info[drive].blocksize to use this value.  Now the only reference being used is SD_BLOCK_SIZE.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23746 a1c6a512-1295-4272-9138-f99709370657
2009-11-25 03:24:28 +00:00
Jack Halpin
cb9dff0a95 AMS Sansa: Include time spent yielding when figuring timeout in sd_wait_for_state().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23738 a1c6a512-1295-4272-9138-f99709370657
2009-11-24 17:43:53 +00:00
Rafaël Carré
ed13fd6dca Sansa AMS: VIC_INT_ENABLE register is not a mask
When read it returns all enabled interrupt sources
When written it enables interrupt sources for each bit set
So just like VIC_INT_EN_CLEAR, we don't have to read the previous value
before writing to it (VIC_INT_EN_CLEAR is write-only anyway)

Thanks to Fred Bauer for spotting

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23734 a1c6a512-1295-4272-9138-f99709370657
2009-11-24 12:05:53 +00:00
Jack Halpin
4314ceb73b AMS Sansa: Remove MCI_RX_ACTIVE FIFO check following SD transfers.
We don't need to check the FIFO for MCI_RX_ACTIVE because we don't experience problems reading from the SD cards.
We need the MCI_TX_ACTIVE FIFO check during writes because some SD cards spend longer times in the PRG state
programming the data that has been written to them.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23733 a1c6a512-1295-4272-9138-f99709370657
2009-11-24 06:37:36 +00:00
Jack Halpin
9e9db20357 AMS Sansa: Remove wait_for_state() following transfer in sd_select_bank() function.
We use wait_for_state() before any command that requires a state prior to being sent.  Waiting after a transfer is not needed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23732 a1c6a512-1295-4272-9138-f99709370657
2009-11-24 06:12:17 +00:00
Jack Halpin
fab80009bc AMS Sansa: Handle responses to SD Commands so that response crc checking is accounted for. Adjust sd error codes appropriately.
The crc check on responses to sd commands was being bypassed due to a SD_APP_OP_COND special case.  Now a short response is returned
even if the crc check fails so we can check the busy bit.  The send_cmd() function still returns a false value but it loads the response
variable with the cmd response.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23718 a1c6a512-1295-4272-9138-f99709370657
2009-11-23 04:22:11 +00:00
Jack Halpin
ecbb01fe0a AMS Sansa: Remove a now redundant sd_wait_for_state() and adjust error codes in ata_sd_as3525.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23698 a1c6a512-1295-4272-9138-f99709370657
2009-11-22 14:13:39 +00:00
Jack Halpin
6df98f690d AMS Sansa: Make send_cmd() function a bit less complicated and save ~96 bytes.
Also move sd_wait_for_state() to immediately precede SD_READ/WRITE_MULTIPLE_BLOCK commands.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23692 a1c6a512-1295-4272-9138-f99709370657
2009-11-22 04:50:26 +00:00
Thomas Martitz
a1bc3401f1 Fix a few possible problems discovered in -O0 / eabi experiments.
- two essential parts of Sansa AMS drivers are optimzed away in newer gcc, so mark them volatile.
- use "r" instead of "i" (which is apparently invalid syntax) for the input list in some inline assembly

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23634 a1c6a512-1295-4272-9138-f99709370657
2009-11-15 17:23:25 +00:00
Jack Halpin
03986d4ec7 Revert r23350 "AMS Sansa: Assume IDECLK is MCLK for the internal SD Disk."
More information makes this assumption seem incorrect.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23356 a1c6a512-1295-4272-9138-f99709370657
2009-10-26 07:06:37 +00:00
Jack Halpin
ec43287aa0 AMS Sansa: Assume IDECLK is MCLK for the internal SD Disk. Reduce IDECLK to 62 MHz for now to be consistent with MCLK for uSD which is PCLK.
Adjust SD timeouts accordingly.

Adjust code in debug-as3525.c to display correct frequencies on system/debug/View disk info page.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23350 a1c6a512-1295-4272-9138-f99709370657
2009-10-25 18:31:44 +00:00
Jack Halpin
5897249c1e Add #ifdef HAVE_MULTIDRIVE to HS timings switch for uSD cards.
Internal cards are v1 sd cards so no need to include this code for the clip.

Move transition from STBY -> TRAN-> STBY states inside the if(sd_v2) conditional check for HS switch as it's not needed for non HS cards.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23331 a1c6a512-1295-4272-9138-f99709370657
2009-10-24 16:42:24 +00:00
Jack Halpin
c5a3f93ac3 AMS Sansa: Adjust SD Card frequency to Identification frequency at beginning of card init instead of the end of pl180 controller init.
If a card is reinitialized now the ident frequency is used instead of the bypass frequency during the identification phase.

Added comments throughout sd_init_card() to help follow init process and highlight indent stage.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23256 a1c6a512-1295-4272-9138-f99709370657
2009-10-19 05:34:25 +00:00
Bertrik Sikken
d24d885aa4 Use wrap-safe TIME_BEFORE/TIME_AFTER macros to compare times with current_time, instead of comparing them directly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23246 a1c6a512-1295-4272-9138-f99709370657
2009-10-18 15:50:30 +00:00
Jack Halpin
562e41bae5 AMS Sansa: FS#10669 Reimplement Voltage scaling.
Reimplement voltage scaling on AMS Sansas at 1.10v during unboosted operation to improve runtimes.  The voltage is now also boosted during disk access if a µSD is present.  This prevents the µSD problems we saw on the last implementation.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23193 a1c6a512-1295-4272-9138-f99709370657
2009-10-15 19:48:26 +00:00
Rafaël Carré
5303ab101b Sansa AMS SD driver: cleanup defines and comments
Remove useless E200V2 || FUZE || C200V2 : all those models have
MULTIDRIVE and/or HOTSWAP defined and have no specific difference.

Correct some comments

Remove HAVE_MULTIDRIVE within HAVE_HOTSWAP since HOTSWAP imply MULTIDRIVE

Change HOTSWAP to MULTIDRIVE where needed

Use NUM_DRIVES in sd_num_drives()

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23180 a1c6a512-1295-4272-9138-f99709370657
2009-10-15 07:16:38 +00:00
Jack Halpin
7331bd5381 AMS Sansa: Remove BUSWIDTH and BLOCKLEN commands and revise strategy for High Speed SD Card.
We are unable to successfully put the pl180 controller into 4 bit mode so we should not put the cards into widebus mode for now.
The blocklength is hardcoded to 512 in sd.c and BLOCKLEN defaults to 512 so this command is not needed.
It appears the internal SD card is not HS capable but sending it the HS switch command does not seem to hinder it's init process.
Assume all SD_V2 cards are HS capable and send them the HS switch command.
If View disk info shows 50.0 MBit/s the card has HS timings.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23137 a1c6a512-1295-4272-9138-f99709370657
2009-10-12 18:55:10 +00:00
Jack Halpin
14079c39f0 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
2009-10-11 03:11:13 +00:00
Rafaël Carré
7cc6202c03 Sansa AMS SD: relax requirement for APP_CMD response, some uSD cards seem to not set correctly the response bits
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23001 a1c6a512-1295-4272-9138-f99709370657
2009-10-07 20:34:58 +00:00
Jack Halpin
1c36835b80 AMS Sansa: Replace another simple delay with a more intelligent MCI FIFO status check.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22864 a1c6a512-1295-4272-9138-f99709370657
2009-10-01 03:54:36 +00:00
Jack Halpin
bf3d60b25e AMS Sansa: Rename variable sdhc to sd_v2 to more accurately reflect the information it holds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22862 a1c6a512-1295-4272-9138-f99709370657
2009-09-30 20:33:40 +00:00
Jack Halpin
37265d308b AMS Sansa: Replace simple write delay with a smarter check on status of MCI FIFO.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22850 a1c6a512-1295-4272-9138-f99709370657
2009-09-29 16:32:24 +00:00
Bertrik Sikken
69b40e704d Clean up duplicate #includes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22845 a1c6a512-1295-4272-9138-f99709370657
2009-09-27 14:46:44 +00:00
Jack Halpin
68089db6db AMS Sansa: Add delay for µSD writes to fix CRC failures with class 6 µSD cards.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22825 a1c6a512-1295-4272-9138-f99709370657
2009-09-25 01:38:51 +00:00
Frank Gevaerts
a7548d3bc7 Make sd_present() and mmc_present() look only at the actual presence of a card, not at initialisation state
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21981 a1c6a512-1295-4272-9138-f99709370657
2009-07-20 13:47:21 +00:00
Frank Gevaerts
c0a5a67387 Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
2009-07-17 22:28:49 +00:00
Thomas Martitz
fd17a8d637 Apply the same fix as r21930 did for the ramdisk for the AMS Sansa driver.
Nothing should change, since the value of transfer didn't change in the == case, but it saves executing this case at least.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21931 a1c6a512-1295-4272-9138-f99709370657
2009-07-17 21:50:36 +00:00
Rafaël Carré
17ac0d7ff9 fix yellow : panicf() is declared in panic.h
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21780 a1c6a512-1295-4272-9138-f99709370657
2009-07-11 15:26:58 +00:00
Rafaël Carré
405d12de7e Sansa AMS: panic with the PL180 controller status register in case of errors
The maximum number of errors is 10 (arbitrary)
A recovery mechanism is not in place (yet) but could be implemented in the future

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21776 a1c6a512-1295-4272-9138-f99709370657
2009-07-11 14:27:26 +00:00
Rafaël Carré
75fa699814 Sansa AMS: handle properly SD transfer errors
clocks disabling and mutex unlocking were not made in case of errors

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21773 a1c6a512-1295-4272-9138-f99709370657
2009-07-11 13:46:10 +00:00
Thomas Martitz
161cb164ca Adding last minutes comments to explain things is only cool if you close it also (aka fix yellow).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21745 a1c6a512-1295-4272-9138-f99709370657
2009-07-10 15:44:38 +00:00
Thomas Martitz
e7f0c3f397 Rearrange things a bit for less #ifdefs and less duplication.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21744 a1c6a512-1295-4272-9138-f99709370657
2009-07-10 15:32:02 +00:00
Rafaël Carré
c51e26a43d Sansa AMS SD driver: fix error checking in µSD insertion
If µSD init fails, rockbox will panic and give an error number
Use a maximal delay of 1 second for µSD (and internal storage) init, as
specified in the SD Specification 2.00

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21742 a1c6a512-1295-4272-9138-f99709370657
2009-07-10 12:51:50 +00:00
Rafaël Carré
03fe562a95 Sansa AMS: display the virtual led icon on disk transfers
Sansa PP: directly use led() function, remove useless sd_led()

Thanks to mc2739 (Michael Chicoine)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21693 a1c6a512-1295-4272-9138-f99709370657
2009-07-06 16:44:57 +00:00
Rafaël Carré
e3636a8f32 Samsa SD driver : acknowledge USB events, now reboots on USB insertion
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21690 a1c6a512-1295-4272-9138-f99709370657
2009-07-06 14:20:52 +00:00
Rafaël Carré
293b499093 Move sd_get_info() into common sd code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21610 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 23:39:57 +00:00
Maurus Cuelenaere
ccbd8f4f31 * Move some more stuff to the general SD driver
* Ingenic SD driver: cleanup DMA part a bit (not working yet)


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21606 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 22:56:14 +00:00
Rafaël Carré
c0eb9aeb9e add firmware/driver/sd.c which contains common code between SD drivers
ingenic SD driver needs more cleanup so it still doesn't use the common code
correct a comment in hotswap.c: card_extract_bits assume most significant word of register first (so, use this order)
fix debug menu which used MMC specific commands / bits positions in csd/cid
move the default block size of 512 into sd.h
move the mantissa & exponent table into a single file (sd.c) to reduce binsize. we don't need to export it anymore anyway

TODO : ingenic cleanup (will happen soon so building sd.c is not conditional)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21601 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 21:49:13 +00:00
Rafaël Carré
e0e24cbf0a Merge tCardInfo struct (MMC) and tSDCardInfo struct (SD)
Put specific members under #ifdef (CONFIG_STORAGE & STORAGE_xx) (2 members for SD and 1 for MMC)
Fix a typo: tsac doesn't exist and must be read taac
Move card_get_info functions declaration inside hotswap.h to remove mutual inclusion of ata_mmc.h and hotswap.h
Move static const data structures from SD drivers into sd.h (sd_exponent and sd_mantissa)
Fix sd_command prototypes in SD drivers (card registers are unsigned long)
Fix speed calculation in Sansa AMS driver (PP SD driver needs to be checked)
Move ata-sd-target.h to sd-pp-target.h to reflect the PP specifity. Now it only contains declaration of microsd_int()
Remove unused ata-sd-target.h for injenic

TODO:
- check if CSD register bits are extracted correctly in PP driver
- correctly define read_timeout and write_timeout unit for MMC & SD, and use timeouts in Sansa AMS driver

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21586 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 10:07:22 +00:00
Rafaël Carré
ed75cc09f1 Sansa AMS : use the aligned buffer in bss for all DMA transfers
This was only used for data transfers, now use it also for card data
transfers in sd_select_bank, to save runtime alignement and stack usage.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21564 a1c6a512-1295-4272-9138-f99709370657
2009-06-29 18:14:26 +00:00