summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg White <gwhite@rockbox.org>2007-01-04 11:35:09 +0000
committerGreg White <gwhite@rockbox.org>2007-01-04 11:35:09 +0000
commit6eb81e2dc8a42bc14c752339d8225e7193594d93 (patch)
treed0ddc828b2fea99141b44dcdca8f060b5d747b10
parent0b4f3d9cfa3bc9f86f8e86e196b9f9534515e870 (diff)
downloadrockbox-6eb81e2dc8a42bc14c752339d8225e7193594d93.zip
rockbox-6eb81e2dc8a42bc14c752339d8225e7193594d93.tar.gz
rockbox-6eb81e2dc8a42bc14c752339d8225e7193594d93.tar.bz2
rockbox-6eb81e2dc8a42bc14c752339d8225e7193594d93.tar.xz
ATA reads now use DMA
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11904 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c54
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/ata-target.h4
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 ec0f3fe..de4626e 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 95b66ab..95e3e11 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)))