summaryrefslogtreecommitdiff
path: root/firmware/target/arm/gigabeat/meg-fx
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/gigabeat/meg-fx')
-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 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 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id $
9 * 9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing 10 * Copyright (C) 2006,2007 by Marcoen Hirschberg
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -22,7 +22,10 @@
22#include "kernel.h" 22#include "kernel.h"
23#include "system.h" 23#include "system.h"
24#include "power.h" 24#include "power.h"
25#include "panic.h"
25#include "pcf50606.h" 26#include "pcf50606.h"
27#include "ata-target.h"
28#include "mmu-meg-fx.h"
26 29
27void ata_reset(void) 30void ata_reset(void)
28{ 31{
@@ -48,3 +51,50 @@ bool ata_is_coldstart(void)
48void ata_device_init(void) 51void ata_device_init(void)
49{ 52{
50} 53}
54
55void copy_read_sectors(unsigned char* buf, int wordcount)
56{
57 /* This should never happen, but worth watching for */
58 if(wordcount > (1 << 18))
59 panicf("atd-meg-fx.c: copy_read_sectors: too many sectors per read!");
60#undef GIGABEAT_DEBUG_ATA
61#ifdef GIGABEAT_DEBUG_ATA
62 static int line = 0;
63 static char str[256];
64 snprintf(str, sizeof(str), "DMA to %08x, %d", buf, wordcount);
65 lcd_puts(16, line, str);
66 line = (line+1) % 32;
67 lcd_update();
68#endif
69 /* Reset the channel */
70 DMASKTRIG0 |= 4;
71 /* Wait for DMA controller to be ready */
72 while(DMASKTRIG0 & 0x2)
73 ;
74 while(DSTAT0 & (1 << 20))
75 ;
76 /* Source is ATA_DATA, on AHB Bus, Fixed */
77 DISRC0 = (int) 0x18000000;
78 DISRCC0 = 0x1;
79 /* Dest mapped to physical address, on AHB bus, increment */
80 DIDST0 = (int) (buf + 0x30000000);
81 DIDSTC0 = 0;
82
83 /* DACK/DREQ Sync to AHB, Int on Transfer complete, Whole service, No reload, 16-bit transfers */
84 DCON0 = ((1 << 30) | (1<<27) | (1<<22) | (1<<20)) | wordcount;
85
86 /* Activate the channel */
87 DMASKTRIG0 = 0x2;
88
89 /* Dump cache for the buffer */
90 dump_dcache_range((void *)buf, wordcount*2);
91
92 /* Start DMA */
93 DMASKTRIG0 |= 0x1;
94
95 /* Wait for transfer to complete */
96 while((DSTAT0 & 0x000fffff))
97 yield();
98}
99
100
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 @@
22/* Plain C read & write loops */ 22/* Plain C read & write loops */
23#define PREFER_C_READING 23#define PREFER_C_READING
24#define PREFER_C_WRITING 24#define PREFER_C_WRITING
25#if !defined(BOOTLOADER)
26#define ATA_OPTIMIZED_READING
27void copy_read_sectors(unsigned char* buf, int wordcount);
28#endif
25 29
26#define ATA_IOBASE 0x18000000 30#define ATA_IOBASE 0x18000000
27#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE))) 31#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE)))