1
0
Fork 0
forked from len0rd/rockbox

Enable ATA DMA on pp5020 based players with ATA drives.

DMA is only used for reading because writing seems to be slower with DMA.
Only requests which are cacheline aligned (16 bytes) will use DMA, so many
requests will still use PIO at this point; a later change will align more
reads.

Part of FS#9708, original DMA code by Boris Gjenero (dreamlayers).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24405 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Torne Wuff 2010-01-31 11:07:29 +00:00
parent c0e2d9fe1b
commit 533cf7737b
16 changed files with 286 additions and 0 deletions

View file

@ -81,3 +81,37 @@ void copy_write_sectors(const unsigned char* buf, int wordcount);
void ata_reset(void);
bool ata_is_coldstart(void);
void ata_device_init(void);
#ifdef HAVE_ATA_DMA
/* IDE DMA controller registers */
#define IDE_DMA_CONTROL (*(volatile unsigned long *)(0xc3000400))
#define IDE_DMA_LENGTH (*(volatile unsigned long *)(0xc3000408))
#define IDE_DMA_ADDR (*(volatile unsigned long *)(0xc300040C))
/* Maximum multi-word DMA mode supported by the controller */
#define ATA_MAX_MWDMA 2
#ifndef BOOTLOADER
/* The PP5020 supports UDMA 4, but it needs cpu boosting and only
* improves performance by ~10% with a stock disk.
* UDMA 2 is stable at 30 Mhz.
* UDMA 1 is stable at 24 Mhz.
*/
#if CPUFREQ_NORMAL >= 30000000
#define ATA_MAX_UDMA 2
#elif CPUFREQ_NORMAL >= 24000000
#define ATA_MAX_UDMA 1
#else
#error "CPU speeds under 24Mhz have not been tested with DMA"
#endif
#else
/* The bootloader runs at 24 Mhz and needs a slower mode */
#define ATA_MAX_UDMA 1
#endif
void ata_dma_set_mode(unsigned char mode);
bool ata_dma_setup(void *addr, unsigned long bytes, bool write);
bool ata_dma_finish(void);
#endif /* HAVE_ATA_DMA */