Commit graph

354 commits

Author SHA1 Message Date
Jack Halpin
87770d2439 Sansa AMS: Implement 4 bit widebus mode for SD cards.
Both the internal and uSD cards are now put into 4 bit widebus mode during initialization except for bootloader.
Add MCI_START_BIT_ERR to MCI_ERROR list and change name to MCI_DATA_ERROR for clarity.
Make appropriate changes to SD error codes.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23977 a1c6a512-1295-4272-9138-f99709370657
2009-12-13 20:37:55 +00:00
Jack Halpin
c03871ab80 Sansa AMS: Assume IDE_CLK is used as MCLK for internal SD. We assumed PCLK previously.
This patch changes all references/assumptions of PCLK to IDE_CLK for the internal pl180 controller.
Lower the AS3525_IDE_FREQ to 50 MHz in order to be able to divide by 2 for 25 MHz on the internal SD card.
Adjust the code in debug-as3525.c to account for the change and the frequencies reported should be correct.
Add some #if defined(HAVE_MULTIDRIVE) conditionals to cut out the code dealing with uSD for the clip.
Isolate the write delay needed for low frequency writes to only run for standard speed uSD cards. That is the only case for an MCICLK at 15.5 MHz.

Internal cards run at 25 MHz, HS uSD at 31 MHz, and standard speed uSD cards at 15.5 MHz.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23929 a1c6a512-1295-4272-9138-f99709370657
2009-12-11 04:53:22 +00:00
Jack Halpin
fae4eab4b2 Sansa AMS: Add extra delay to the uSD init sequence to enhance card compatability,
Some cards need this delay now that we're running at ident speed during this part of the init stage.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23919 a1c6a512-1295-4272-9138-f99709370657
2009-12-10 17:42:03 +00:00
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
5bd4ec0c87 Sansa AMS: Force sd_enable(true) when using the Debug View HW info page so we can read the registers immediately.
Because we turn off the clocks to the SD controllers between disk accesses we were unable to read the MCI_CLOCK registers until there was a disk access.  Now we can read them immediately.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23810 a1c6a512-1295-4272-9138-f99709370657
2009-12-01 20:12:25 +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
Rafaël Carré
231e54d80f Sansa AMS : fix recording
Flyspray: FS#10371
Authors: Fred Bauer and myself

Only enabled on e200v2 and Fuze (crashes on clipv1)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23739 a1c6a512-1295-4272-9138-f99709370657
2009-11-24 17:59:25 +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
f5b59cdf5e AMS Sansa: dma-pl081.c: dma_enable_channel() Add step to clear pending interrupts from the previous operation. Add comments and make construction
of the CH_CONTROL and CH_CONFIGURATION registers easier to follow.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23725 a1c6a512-1295-4272-9138-f99709370657
2009-11-23 19:44:13 +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
Michael Chicoine
bbc8b1b8cb FS#10796 - Clip - prevent power switch activation when coming out of hold
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23686 a1c6a512-1295-4272-9138-f99709370657
2009-11-21 21:16:08 +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
Michael Chicoine
a06feaa7ec Fix FS#10751 - Fuze freezes when using radio while charging
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23517 a1c6a512-1295-4272-9138-f99709370657
2009-11-04 15:58:18 +00:00
Thomas Martitz
310346ebcc Fix a #elif without condion (is an error with newer gcc/cpp versions).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23502 a1c6a512-1295-4272-9138-f99709370657
2009-11-03 21:20:02 +00:00
Jeffrey Goode
9d842683eb Comment out LOGF_ENABLE defines everywhere, replace evil comments
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23497 a1c6a512-1295-4272-9138-f99709370657
2009-11-03 16:25:03 +00:00
Rafaël Carré
9b46960baf Sansa AMS PCM : cleanup
Init CGU_AUDIO with correct clock source (for play & rec)
Do not disable recording clocks when starting playback, they are already disabled
Move clock enable/disable code from dma callback to init

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23493 a1c6a512-1295-4272-9138-f99709370657
2009-11-03 08:14:28 +00:00
Rafaël Carré
d06aafc03a Sansa AMS: fix system_exception_wait()
If a panicf() is called while a button is still pressed, the Sansa would
reboot immediately with no chance to see the message

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23490 a1c6a512-1295-4272-9138-f99709370657
2009-11-03 07:42:42 +00:00
Rafaël Carré
fb126d4305 Sansa AMS : reduce size of interrupt source/isr mapping table
INT_GPIOB is not used
INT_MCI0 and INT_GPIOA are only put in the table if needed

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23481 a1c6a512-1295-4272-9138-f99709370657
2009-11-01 23:41:10 +00:00
Rafaël Carré
f64a3fe149 Sansa AMS PCM: remove runtime sanity checks
Unaligned memory ops will cause a data abort anyway
Make the check for samplerate at buildtime

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23480 a1c6a512-1295-4272-9138-f99709370657
2009-11-01 23:35:34 +00:00
Rafaël Carré
9b4057bbd4 Sansa AMS recording support (Microphone and FM)
Still disabled on all targets:
- Fuze and e200v2 see spurious interrupts with no source defined
- Clip/m200v4 deadlock instantly when starting recording (perhaps due to low memory size)

Having the code in SVN will make working on this feature easier

Also add keymaps for Fuze, and correct Frequency section of recording
options : the 22.05kHz limitation of e200v1 and c200v1 doesn't apply to
Sansa AMS (different I2S hardware, unrelated to as3514)

Flyspray: FS#10371
Authors: Fred Bauer and myself

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23476 a1c6a512-1295-4272-9138-f99709370657
2009-11-01 22:51:31 +00:00
Michael Chicoine
4eafd23f42 FS#10744 - Fuze: Last line of screen's pixels doesn't change when switching themes and using plugins
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23452 a1c6a512-1295-4272-9138-f99709370657
2009-10-31 23:15:33 +00:00
Jack Halpin
6d20102a9c AMS Sansa: Change some #defines in debug-as3525 from "(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)" to HAVE_MULTIDRIVE
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23361 a1c6a512-1295-4272-9138-f99709370657
2009-10-26 17:22:05 +00:00
Michael Chicoine
10f46b3c8a fix an off-by-one error in lcd_update_rect()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23359 a1c6a512-1295-4272-9138-f99709370657
2009-10-26 15:42:26 +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
Thomas Martitz
e4921d6ab5 Speed up lcd_update_rect by ~2.5% by counting towards 0 in the loop.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23329 a1c6a512-1295-4272-9138-f99709370657
2009-10-24 16:01:53 +00:00
Thomas Martitz
d85c3ec410 Convert lcd_activation callbacks to use the event system to allow for multiple parallel callbacks (for custom statusbar).
Increase maximum event count as we need more (I actually had a report about it during custom statusbar testing).
Removed corresponding functions from the core and plugin api. Bump min version and sort.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23302 a1c6a512-1295-4272-9138-f99709370657
2009-10-20 21:54:59 +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
Nils Wallménius
f34a841b0c Revise r23225 a bit, removing the debug_printf function and implementing more generic lcd_(remote)_putsf function(s) instead and use those in more places
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23233 a1c6a512-1295-4272-9138-f99709370657
2009-10-17 18:02:48 +00:00
Jack Halpin
000cff5bae AMS Sansa: Lower ADC checkvalue for voltage scaling to 1.175V as some players run slightly low.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23205 a1c6a512-1295-4272-9138-f99709370657
2009-10-16 17:44:23 +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é
19d70fce20 Sansa Fuze & e200v2 : do not enable USBSTACK in the bootloader
Don't implement usb_enable() is HAVE_USBSTACK is not defined

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23185 a1c6a512-1295-4272-9138-f99709370657
2009-10-15 10:23:18 +00:00
Rafaël Carré
8bd8d06842 Sansa AMS USB driver : still not working
Implement usb_enable()
Reorder/Modify usb_drv_init() to match closer the OF and remove a freeze
(USB registers were accessed before the USB module was enabled)
Add a panic in USB isr to be sure we notice when it's called
Reset GPIOA direction for usb_detect() to notice extraction
Add some comments

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23184 a1c6a512-1295-4272-9138-f99709370657
2009-10-15 10:03:20 +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