From 6eb81e2dc8a42bc14c752339d8225e7193594d93 Mon Sep 17 00:00:00 2001 From: Greg White Date: Thu, 4 Jan 2007 11:35:09 +0000 Subject: ATA reads now use DMA git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11904 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c | 54 +++++++++++++++++++++++- firmware/target/arm/gigabeat/meg-fx/ata-target.h | 4 ++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c index ec0f3fe6ca..de4626e288 100644 --- a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c @@ -5,9 +5,9 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id$ + * $Id $ * - * Copyright (C) 2006 by Linus Nielsen Feltzing + * Copyright (C) 2006,2007 by Marcoen Hirschberg * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -22,7 +22,10 @@ #include "kernel.h" #include "system.h" #include "power.h" +#include "panic.h" #include "pcf50606.h" +#include "ata-target.h" +#include "mmu-meg-fx.h" void ata_reset(void) { @@ -48,3 +51,50 @@ bool ata_is_coldstart(void) void ata_device_init(void) { } + +void copy_read_sectors(unsigned char* buf, int wordcount) +{ + /* This should never happen, but worth watching for */ + if(wordcount > (1 << 18)) + panicf("atd-meg-fx.c: copy_read_sectors: too many sectors per read!"); +#undef GIGABEAT_DEBUG_ATA +#ifdef GIGABEAT_DEBUG_ATA + static int line = 0; + static char str[256]; + snprintf(str, sizeof(str), "DMA to %08x, %d", buf, wordcount); + lcd_puts(16, line, str); + line = (line+1) % 32; + lcd_update(); +#endif + /* Reset the channel */ + DMASKTRIG0 |= 4; + /* Wait for DMA controller to be ready */ + while(DMASKTRIG0 & 0x2) + ; + while(DSTAT0 & (1 << 20)) + ; + /* Source is ATA_DATA, on AHB Bus, Fixed */ + DISRC0 = (int) 0x18000000; + DISRCC0 = 0x1; + /* Dest mapped to physical address, on AHB bus, increment */ + DIDST0 = (int) (buf + 0x30000000); + DIDSTC0 = 0; + + /* DACK/DREQ Sync to AHB, Int on Transfer complete, Whole service, No reload, 16-bit transfers */ + DCON0 = ((1 << 30) | (1<<27) | (1<<22) | (1<<20)) | wordcount; + + /* Activate the channel */ + DMASKTRIG0 = 0x2; + + /* Dump cache for the buffer */ + dump_dcache_range((void *)buf, wordcount*2); + + /* Start DMA */ + DMASKTRIG0 |= 0x1; + + /* Wait for transfer to complete */ + while((DSTAT0 & 0x000fffff)) + yield(); +} + + diff --git a/firmware/target/arm/gigabeat/meg-fx/ata-target.h b/firmware/target/arm/gigabeat/meg-fx/ata-target.h index 95b66ab1bd..95e3e110f2 100644 --- a/firmware/target/arm/gigabeat/meg-fx/ata-target.h +++ b/firmware/target/arm/gigabeat/meg-fx/ata-target.h @@ -22,6 +22,10 @@ /* Plain C read & write loops */ #define PREFER_C_READING #define PREFER_C_WRITING +#if !defined(BOOTLOADER) +#define ATA_OPTIMIZED_READING +void copy_read_sectors(unsigned char* buf, int wordcount); +#endif #define ATA_IOBASE 0x18000000 #define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE))) -- cgit v1.2.3