diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/creative-zvm')
8 files changed, 978 insertions, 978 deletions
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c index dfb88d513e..e891b98eac 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/adc-creativezvm.c | |||
@@ -1,35 +1,35 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $ | 8 | * $Id: adc-mr500.c 14817 2007-09-22 15:43:38Z kkurbjun $ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Karl Kurbjun | 10 | * Copyright (C) 2007 by Karl Kurbjun |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "cpu.h" | 22 | #include "cpu.h" |
23 | #include "adc.h" | 23 | #include "adc.h" |
24 | #include "adc-target.h" | 24 | #include "adc-target.h" |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | 26 | ||
27 | void adc_init(void) | 27 | void adc_init(void) |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | /* Called to get the recent ADC reading */ | 31 | /* Called to get the recent ADC reading */ |
32 | inline unsigned short adc_read(int channel) | 32 | inline unsigned short adc_read(int channel) |
33 | { | 33 | { |
34 | return (short)channel; | 34 | return (short)channel; |
35 | } | 35 | } |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c index 5670a65b47..a55cda4c14 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | |||
@@ -1,489 +1,489 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by Maurus Cuelenaere | 10 | * Copyright (C) 2008 by Maurus Cuelenaere |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "cpu.h" | 23 | #include "cpu.h" |
24 | #include "kernel.h" | 24 | #include "kernel.h" |
25 | #include "thread.h" | 25 | #include "thread.h" |
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "power.h" | 27 | #include "power.h" |
28 | #include "panic.h" | 28 | #include "panic.h" |
29 | #include "ata-target.h" | 29 | #include "ata-target.h" |
30 | #include "dm320.h" | 30 | #include "dm320.h" |
31 | #include "ata.h" | 31 | #include "ata.h" |
32 | #include "string.h" | 32 | #include "string.h" |
33 | #include "buffer.h" | 33 | #include "buffer.h" |
34 | 34 | ||
35 | #undef ata_read_sectors | 35 | #undef ata_read_sectors |
36 | #undef ata_write_sectors | 36 | #undef ata_write_sectors |
37 | 37 | ||
38 | static void sleep_ms(int ms) | 38 | static void sleep_ms(int ms) |
39 | { | 39 | { |
40 | sleep(ms*HZ/1000); | 40 | sleep(ms*HZ/1000); |
41 | } | 41 | } |
42 | 42 | ||
43 | void ide_power_enable(bool on) | 43 | void ide_power_enable(bool on) |
44 | { | 44 | { |
45 | /* Disabled until figured out what's wrong */ | 45 | /* Disabled until figured out what's wrong */ |
46 | #if 0 | 46 | #if 0 |
47 | int old_level = disable_irq_save(); | 47 | int old_level = disable_irq_save(); |
48 | if(on) | 48 | if(on) |
49 | { | 49 | { |
50 | IO_GIO_BITSET0 = (1 << 14); | 50 | IO_GIO_BITSET0 = (1 << 14); |
51 | ata_reset(); | 51 | ata_reset(); |
52 | } | 52 | } |
53 | else | 53 | else |
54 | IO_GIO_BITCLR0 = (1 << 14); | 54 | IO_GIO_BITCLR0 = (1 << 14); |
55 | restore_irq(old_level); | 55 | restore_irq(old_level); |
56 | #else | 56 | #else |
57 | (void)on; | 57 | (void)on; |
58 | #endif | 58 | #endif |
59 | } | 59 | } |
60 | 60 | ||
61 | inline bool ide_powered() | 61 | inline bool ide_powered() |
62 | { | 62 | { |
63 | #if 0 | 63 | #if 0 |
64 | return (IO_GIO_BITSET0 & (1 << 14)); | 64 | return (IO_GIO_BITSET0 & (1 << 14)); |
65 | #else | 65 | #else |
66 | return true; | 66 | return true; |
67 | #endif | 67 | #endif |
68 | } | 68 | } |
69 | 69 | ||
70 | void ata_reset(void) | 70 | void ata_reset(void) |
71 | { | 71 | { |
72 | int old_level = disable_irq_save(); | 72 | int old_level = disable_irq_save(); |
73 | if(!ide_powered()) | 73 | if(!ide_powered()) |
74 | { | 74 | { |
75 | ide_power_enable(true); | 75 | ide_power_enable(true); |
76 | sleep_ms(150); | 76 | sleep_ms(150); |
77 | } | 77 | } |
78 | else | 78 | else |
79 | { | 79 | { |
80 | IO_GIO_BITSET0 = (1 << 5); | 80 | IO_GIO_BITSET0 = (1 << 5); |
81 | IO_GIO_BITCLR0 = (1 << 3); | 81 | IO_GIO_BITCLR0 = (1 << 3); |
82 | sleep_ms(1); | 82 | sleep_ms(1); |
83 | } | 83 | } |
84 | IO_GIO_BITCLR0 = (1 << 5); | 84 | IO_GIO_BITCLR0 = (1 << 5); |
85 | sleep_ms(10); | 85 | sleep_ms(10); |
86 | IO_GIO_BITSET0 = (1 << 3); | 86 | IO_GIO_BITSET0 = (1 << 3); |
87 | while(!(ATA_COMMAND & STATUS_RDY)) | 87 | while(!(ATA_COMMAND & STATUS_RDY)) |
88 | sleep_ms(10); | 88 | sleep_ms(10); |
89 | restore_irq(old_level); | 89 | restore_irq(old_level); |
90 | } | 90 | } |
91 | 91 | ||
92 | void ata_enable(bool on) | 92 | void ata_enable(bool on) |
93 | { | 93 | { |
94 | (void)on; | 94 | (void)on; |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | 97 | ||
98 | bool ata_is_coldstart(void) | 98 | bool ata_is_coldstart(void) |
99 | { | 99 | { |
100 | return true; | 100 | return true; |
101 | } | 101 | } |
102 | 102 | ||
103 | void ata_device_init(void) | 103 | void ata_device_init(void) |
104 | { | 104 | { |
105 | IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */ | 105 | IO_INTC_EINT1 |= INTR_EINT1_EXT2; /* enable GIO2 interrupt */ |
106 | /* TODO: mimic OF inits... */ | 106 | /* TODO: mimic OF inits... */ |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | 109 | ||
110 | void GIO2(void) | 110 | void GIO2(void) |
111 | { | 111 | { |
112 | #ifdef DEBUG | 112 | #ifdef DEBUG |
113 | logf("GIO2 interrupt..."); | 113 | logf("GIO2 interrupt..."); |
114 | #endif | 114 | #endif |
115 | IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */ | 115 | IO_INTC_IRQ1 = INTR_IRQ1_EXT2; /* Mask GIO2 interrupt */ |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | 118 | ||
119 | /* | 119 | /* |
120 | --------------------------------------------------------------------------- | 120 | --------------------------------------------------------------------------- |
121 | CreativeFileSystem parsing/handling code | 121 | CreativeFileSystem parsing/handling code |
122 | --------------------------------------------------------------------------- | 122 | --------------------------------------------------------------------------- |
123 | */ | 123 | */ |
124 | 124 | ||
125 | #define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */ | 125 | #define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */ |
126 | 126 | ||
127 | extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); | 127 | extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf); |
128 | extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); | 128 | extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf); |
129 | 129 | ||
130 | struct main_header | 130 | struct main_header |
131 | { | 131 | { |
132 | char mblk[4]; | 132 | char mblk[4]; |
133 | unsigned int sector_size; | 133 | unsigned int sector_size; |
134 | long long disk_size; | 134 | long long disk_size; |
135 | struct partition_header | 135 | struct partition_header |
136 | { | 136 | { |
137 | unsigned long end; | 137 | unsigned long end; |
138 | unsigned long start; | 138 | unsigned long start; |
139 | char name[8]; | 139 | char name[8]; |
140 | } partitions[31]; | 140 | } partitions[31]; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | struct cfs_header | 143 | struct cfs_header |
144 | { | 144 | { |
145 | unsigned int unk; | 145 | unsigned int unk; |
146 | unsigned int unk2; | 146 | unsigned int unk2; |
147 | unsigned int sector_size; | 147 | unsigned int sector_size; |
148 | unsigned int unk4; | 148 | unsigned int unk4; |
149 | unsigned int unk5; | 149 | unsigned int unk5; |
150 | char identifier[4]; | 150 | char identifier[4]; |
151 | unsigned int first_inode; | 151 | unsigned int first_inode; |
152 | unsigned int unk8; | 152 | unsigned int unk8; |
153 | unsigned int unk9; | 153 | unsigned int unk9; |
154 | unsigned int unk10; | 154 | unsigned int unk10; |
155 | unsigned int unk11; | 155 | unsigned int unk11; |
156 | }; | 156 | }; |
157 | 157 | ||
158 | struct cfs_inode | 158 | struct cfs_inode |
159 | { | 159 | { |
160 | unsigned char magic[4]; | 160 | unsigned char magic[4]; |
161 | unsigned int number; | 161 | unsigned int number; |
162 | unsigned int parent; | 162 | unsigned int parent; |
163 | unsigned int unk; | 163 | unsigned int unk; |
164 | unsigned int type; | 164 | unsigned int type; |
165 | unsigned int created_time; | 165 | unsigned int created_time; |
166 | unsigned int lastmodified_time; | 166 | unsigned int lastmodified_time; |
167 | unsigned int unk2; | 167 | unsigned int unk2; |
168 | unsigned int first_class_chain[12]; | 168 | unsigned int first_class_chain[12]; |
169 | unsigned int unk3; | 169 | unsigned int unk3; |
170 | unsigned int unk4; | 170 | unsigned int unk4; |
171 | unsigned int second_class_chain_first_cluster; | 171 | unsigned int second_class_chain_first_cluster; |
172 | unsigned int unk9; | 172 | unsigned int unk9; |
173 | unsigned int unk10; | 173 | unsigned int unk10; |
174 | unsigned int second_class_chain_second_cluster; | 174 | unsigned int second_class_chain_second_cluster; |
175 | unsigned int unk11; | 175 | unsigned int unk11; |
176 | unsigned int unk12; | 176 | unsigned int unk12; |
177 | unsigned int unk13; | 177 | unsigned int unk13; |
178 | unsigned int filesize; | 178 | unsigned int filesize; |
179 | unsigned int serial_number; | 179 | unsigned int serial_number; |
180 | unsigned int number_of_metadata_records; | 180 | unsigned int number_of_metadata_records; |
181 | }; | 181 | }; |
182 | 182 | ||
183 | struct cfs_direntry | 183 | struct cfs_direntry |
184 | { | 184 | { |
185 | unsigned char identifier[4]; | 185 | unsigned char identifier[4]; |
186 | unsigned int unk; | 186 | unsigned int unk; |
187 | unsigned int items; | 187 | unsigned int items; |
188 | unsigned int unk2; | 188 | unsigned int unk2; |
189 | unsigned char maxlen[2]; | 189 | unsigned char maxlen[2]; |
190 | unsigned char padding[202]; | 190 | unsigned char padding[202]; |
191 | /* struct cfs_direntry_item _items[items]; */ | 191 | /* struct cfs_direntry_item _items[items]; */ |
192 | }; | 192 | }; |
193 | struct cfs_direntry_item | 193 | struct cfs_direntry_item |
194 | { | 194 | { |
195 | unsigned int inode_number; | 195 | unsigned int inode_number; |
196 | unsigned short strlen; | 196 | unsigned short strlen; |
197 | unsigned short bytesperchar; | 197 | unsigned short bytesperchar; |
198 | char string[32]; | 198 | char string[32]; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | static bool cfs_inited = false; | 201 | static bool cfs_inited = false; |
202 | static unsigned long cfs_start; | 202 | static unsigned long cfs_start; |
203 | static unsigned long *sectors; | 203 | static unsigned long *sectors; |
204 | 204 | ||
205 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) | 205 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) |
206 | #define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 ) | 206 | #define CFS_CLUSTER2CLUSTER(x) ( CFS_START+((x)-1)*64 ) |
207 | 207 | ||
208 | /* Limited version of UCS -> ASCII */ | 208 | /* Limited version of UCS -> ASCII */ |
209 | static char* ucs2letostring(unsigned char* s) | 209 | static char* ucs2letostring(unsigned char* s) |
210 | { | 210 | { |
211 | static char res[256]; | 211 | static char res[256]; |
212 | int i; | 212 | int i; |
213 | 213 | ||
214 | for(i=0; (s[i] == 0 && s[i+1] == 0); i++) | 214 | for(i=0; (s[i] == 0 && s[i+1] == 0); i++) |
215 | res[i] = s[i*2]; | 215 | res[i] = s[i*2]; |
216 | 216 | ||
217 | return (char*)&res; | 217 | return (char*)&res; |
218 | } | 218 | } |
219 | 219 | ||
220 | static void cfs_init(void) | 220 | static void cfs_init(void) |
221 | { | 221 | { |
222 | struct main_header *hdr; | 222 | struct main_header *hdr; |
223 | struct cfs_header *cfs; | 223 | struct cfs_header *cfs; |
224 | struct cfs_inode *root_inode, *vfat_inode, *inode; | 224 | struct cfs_inode *root_inode, *vfat_inode, *inode; |
225 | struct cfs_direntry *root_direntry, *vfat_direntry; | 225 | struct cfs_direntry *root_direntry, *vfat_direntry; |
226 | struct cfs_direntry_item *root_direntry_items, *vfat_direntry_items; | 226 | struct cfs_direntry_item *root_direntry_items, *vfat_direntry_items; |
227 | unsigned int i, j, k, vfat_inode_nr=0, vfat_inodes_nr[10], vfat_sector_count; | 227 | unsigned int i, j, k, vfat_inode_nr=0, vfat_inodes_nr[10], vfat_sector_count; |
228 | unsigned char sector[512]; | 228 | unsigned char sector[512]; |
229 | static unsigned int vfat_data[2][0x8000]; | 229 | static unsigned int vfat_data[2][0x8000]; |
230 | static unsigned char sector2[0x8000]; | 230 | static unsigned char sector2[0x8000]; |
231 | 231 | ||
232 | if(cfs_inited) | 232 | if(cfs_inited) |
233 | return; | 233 | return; |
234 | 234 | ||
235 | /* Read MBLK */ | 235 | /* Read MBLK */ |
236 | _ata_read_sectors(0, 1, §or); | 236 | _ata_read_sectors(0, 1, §or); |
237 | hdr = (struct main_header*)§or; | 237 | hdr = (struct main_header*)§or; |
238 | 238 | ||
239 | //printf("CFS is at 0x%x", CFS_START); | 239 | //printf("CFS is at 0x%x", CFS_START); |
240 | 240 | ||
241 | /* Read CFS header */ | 241 | /* Read CFS header */ |
242 | _ata_read_sectors(CFS_START/512, 64, §or2); | 242 | _ata_read_sectors(CFS_START/512, 64, §or2); |
243 | cfs = (struct cfs_header*)§or2; | 243 | cfs = (struct cfs_header*)§or2; |
244 | 244 | ||
245 | //printf("First inode = %d", cfs->first_inode); | 245 | //printf("First inode = %d", cfs->first_inode); |
246 | 246 | ||
247 | /* Read root inode */ | 247 | /* Read root inode */ |
248 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2); | 248 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(cfs->first_inode), 64, §or2); |
249 | root_inode = (struct cfs_inode*)§or2; | 249 | root_inode = (struct cfs_inode*)§or2; |
250 | 250 | ||
251 | /* Read root inode's first sector */ | 251 | /* Read root inode's first sector */ |
252 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2); | 252 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(root_inode->first_class_chain[0]), 64, §or2); |
253 | root_direntry = (struct cfs_direntry*)§or2; | 253 | root_direntry = (struct cfs_direntry*)§or2; |
254 | root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); | 254 | root_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); |
255 | 255 | ||
256 | /* Search VFAT inode */ | 256 | /* Search VFAT inode */ |
257 | for(i=0; i < root_direntry->items; i++) | 257 | for(i=0; i < root_direntry->items; i++) |
258 | { | 258 | { |
259 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number); | 259 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&root_direntry_items[i].string[0]), root_direntry_items[i].inode_number); |
260 | if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0) | 260 | if(strcmp(ucs2letostring(&root_direntry_items[i].string[0]), "VFAT") == 0) |
261 | vfat_inode_nr = root_direntry_items[i].inode_number; | 261 | vfat_inode_nr = root_direntry_items[i].inode_number; |
262 | } | 262 | } |
263 | 263 | ||
264 | /* Read VFAT inode */ | 264 | /* Read VFAT inode */ |
265 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2); | 265 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode_nr), 64, §or2); |
266 | vfat_inode = (struct cfs_inode*)§or2; | 266 | vfat_inode = (struct cfs_inode*)§or2; |
267 | 267 | ||
268 | /* Read VFAT inode's first sector */ | 268 | /* Read VFAT inode's first sector */ |
269 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2); | 269 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inode->first_class_chain[0]), 64, §or2); |
270 | vfat_direntry = (struct cfs_direntry*)§or2; | 270 | vfat_direntry = (struct cfs_direntry*)§or2; |
271 | vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); | 271 | vfat_direntry_items = (struct cfs_direntry_item*)(§or2+sizeof(struct cfs_direntry)); |
272 | 272 | ||
273 | /* Search for VFAT's subinodes */ | 273 | /* Search for VFAT's subinodes */ |
274 | for(i=0; i < vfat_direntry->items; i++) | 274 | for(i=0; i < vfat_direntry->items; i++) |
275 | { | 275 | { |
276 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number); | 276 | //printf(" * [%s] at 0x%x\n", ucs2letostring(&vfat_direntry_items[i].string[0]), vfat_direntry_items[i].inode_number); |
277 | if(i > 0) | 277 | if(i > 0) |
278 | vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number; | 278 | vfat_inodes_nr[i-1] = vfat_direntry_items[i].inode_number; |
279 | } | 279 | } |
280 | 280 | ||
281 | /* Determine size of VFAT file */ | 281 | /* Determine size of VFAT file */ |
282 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); | 282 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); |
283 | inode = (struct cfs_inode*)§or; | 283 | inode = (struct cfs_inode*)§or; |
284 | sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); | 284 | sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); |
285 | 285 | ||
286 | //printf("VFAT file size: 0x%x", inode->filesize); | 286 | //printf("VFAT file size: 0x%x", inode->filesize); |
287 | 287 | ||
288 | /* Clear data sectors */ | 288 | /* Clear data sectors */ |
289 | memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long)); | 289 | memset(§ors, 0, VFAT_SECTOR_SIZE(inode->filesize)*sizeof(unsigned long)); |
290 | 290 | ||
291 | /* Read all data sectors' addresses in memory */ | 291 | /* Read all data sectors' addresses in memory */ |
292 | vfat_sector_count = 0; | 292 | vfat_sector_count = 0; |
293 | for(i=0; vfat_inodes_nr[i] != 0; i++) | 293 | for(i=0; vfat_inodes_nr[i] != 0; i++) |
294 | { | 294 | { |
295 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or); | 295 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[i]), 1, §or); |
296 | inode = (struct cfs_inode*)§or; | 296 | inode = (struct cfs_inode*)§or; |
297 | 297 | ||
298 | /* Read second & third class chain */ | 298 | /* Read second & third class chain */ |
299 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]); | 299 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_first_cluster), 64, &vfat_data[0]); |
300 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); | 300 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); |
301 | 301 | ||
302 | /* First class chain */ | 302 | /* First class chain */ |
303 | for(j=0; j<12; j++) | 303 | for(j=0; j<12; j++) |
304 | { | 304 | { |
305 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && | 305 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && |
306 | inode->first_class_chain[j] != 0 | 306 | inode->first_class_chain[j] != 0 |
307 | ) | 307 | ) |
308 | sectors[vfat_sector_count++] = inode->first_class_chain[j]; | 308 | sectors[vfat_sector_count++] = inode->first_class_chain[j]; |
309 | } | 309 | } |
310 | 310 | ||
311 | /* Second class chain */ | 311 | /* Second class chain */ |
312 | for(j=0; j<0x8000/4; j++) | 312 | for(j=0; j<0x8000/4; j++) |
313 | { | 313 | { |
314 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && | 314 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && |
315 | vfat_data[0][j] != 0 | 315 | vfat_data[0][j] != 0 |
316 | ) | 316 | ) |
317 | sectors[vfat_sector_count++] = vfat_data[0][j]; | 317 | sectors[vfat_sector_count++] = vfat_data[0][j]; |
318 | } | 318 | } |
319 | 319 | ||
320 | /* Third class chain */ | 320 | /* Third class chain */ |
321 | for(j=0; j<0x8000/4; j++) | 321 | for(j=0; j<0x8000/4; j++) |
322 | { | 322 | { |
323 | if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF && | 323 | if( (vfat_data[1][j] & 0xFFFF) != 0xFFFF && |
324 | vfat_data[1][j] != 0 | 324 | vfat_data[1][j] != 0 |
325 | ) | 325 | ) |
326 | { | 326 | { |
327 | memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int)); | 327 | memset(&vfat_data[0], 0, 0x8000*sizeof(unsigned int)); |
328 | 328 | ||
329 | /* Read third class subchain(s) */ | 329 | /* Read third class subchain(s) */ |
330 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); | 330 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); |
331 | 331 | ||
332 | for(k=0; k<0x8000/4; k++) | 332 | for(k=0; k<0x8000/4; k++) |
333 | { | 333 | { |
334 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && | 334 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && |
335 | vfat_data[0][k] != 0 | 335 | vfat_data[0][k] != 0 |
336 | ) | 336 | ) |
337 | sectors[vfat_sector_count++] = vfat_data[0][k]; | 337 | sectors[vfat_sector_count++] = vfat_data[0][k]; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | //printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count); | 343 | //printf("Sector count: %d 0x%x", vfat_sector_count, vfat_sector_count); |
344 | 344 | ||
345 | cfs_inited = true; | 345 | cfs_inited = true; |
346 | } | 346 | } |
347 | 347 | ||
348 | static inline unsigned long map_sector(unsigned long sector) | 348 | static inline unsigned long map_sector(unsigned long sector) |
349 | { | 349 | { |
350 | /* | 350 | /* |
351 | * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part | 351 | * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part |
352 | * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. | 352 | * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. |
353 | */ | 353 | */ |
354 | return cfs_start+sectors[sector/64]*64+sector%64; | 354 | return cfs_start+sectors[sector/64]*64+sector%64; |
355 | } | 355 | } |
356 | 356 | ||
357 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) | 357 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) |
358 | { | 358 | { |
359 | if(!cfs_inited) | 359 | if(!cfs_inited) |
360 | cfs_init(); | 360 | cfs_init(); |
361 | 361 | ||
362 | /* Check if count is lesser than or equal to 1 native CFS sector */ | 362 | /* Check if count is lesser than or equal to 1 native CFS sector */ |
363 | if(count <= 64) | 363 | if(count <= 64) |
364 | return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf); | 364 | return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf); |
365 | else | 365 | else |
366 | { | 366 | { |
367 | int i, ret; | 367 | int i, ret; |
368 | unsigned char* dest = (unsigned char*)buf; | 368 | unsigned char* dest = (unsigned char*)buf; |
369 | 369 | ||
370 | /* Read sectors in parts of 0x8000 */ | 370 | /* Read sectors in parts of 0x8000 */ |
371 | for(i=0; i<count; i+=64) | 371 | for(i=0; i<count; i+=64) |
372 | { | 372 | { |
373 | ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest); | 373 | ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest); |
374 | if(ret != 0) | 374 | if(ret != 0) |
375 | return ret; | 375 | return ret; |
376 | 376 | ||
377 | dest += (count-i >= 64 ? 0x8000 : (count-i)*512); | 377 | dest += (count-i >= 64 ? 0x8000 : (count-i)*512); |
378 | } | 378 | } |
379 | 379 | ||
380 | return ret; | 380 | return ret; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) | 384 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) |
385 | { | 385 | { |
386 | if(!cfs_inited) | 386 | if(!cfs_inited) |
387 | cfs_init(); | 387 | cfs_init(); |
388 | 388 | ||
389 | /* Check if count is lesser than or equal to 1 native CFS sector */ | 389 | /* Check if count is lesser than or equal to 1 native CFS sector */ |
390 | if(count <= 64) | 390 | if(count <= 64) |
391 | return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf); | 391 | return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf); |
392 | else | 392 | else |
393 | { | 393 | { |
394 | int i, ret; | 394 | int i, ret; |
395 | unsigned char* dest = (unsigned char*)buf; | 395 | unsigned char* dest = (unsigned char*)buf; |
396 | 396 | ||
397 | /* Read sectors in parts of 0x8000 */ | 397 | /* Read sectors in parts of 0x8000 */ |
398 | for(i=0; i<count; i+=64) | 398 | for(i=0; i<count; i+=64) |
399 | { | 399 | { |
400 | ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest); | 400 | ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest); |
401 | if(ret != 0) | 401 | if(ret != 0) |
402 | return ret; | 402 | return ret; |
403 | 403 | ||
404 | dest += (count-i >= 64 ? 0x8000 : (count-i)*512); | 404 | dest += (count-i >= 64 ? 0x8000 : (count-i)*512); |
405 | } | 405 | } |
406 | 406 | ||
407 | return ret; | 407 | return ret; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | /* | 411 | /* |
412 | --------------------------------------------------------------------------- | 412 | --------------------------------------------------------------------------- |
413 | MiniFileSystem parsing code | 413 | MiniFileSystem parsing code |
414 | --------------------------------------------------------------------------- | 414 | --------------------------------------------------------------------------- |
415 | */ | 415 | */ |
416 | 416 | ||
417 | struct minifs_file | 417 | struct minifs_file |
418 | { | 418 | { |
419 | char name[0x10]; | 419 | char name[0x10]; |
420 | unsigned int unk; | 420 | unsigned int unk; |
421 | unsigned long size; | 421 | unsigned long size; |
422 | unsigned int chain1; | 422 | unsigned int chain1; |
423 | unsigned int chain2; | 423 | unsigned int chain2; |
424 | }; | 424 | }; |
425 | 425 | ||
426 | struct minifs_chain | 426 | struct minifs_chain |
427 | { | 427 | { |
428 | unsigned int unknown; | 428 | unsigned int unknown; |
429 | unsigned short chain[0x27FE]; | 429 | unsigned short chain[0x27FE]; |
430 | unsigned int unknown2; | 430 | unsigned int unknown2; |
431 | unsigned long length; | 431 | unsigned long length; |
432 | }; | 432 | }; |
433 | 433 | ||
434 | 434 | ||
435 | #define DIR_BITMAP_START 0x0143 | 435 | #define DIR_BITMAP_START 0x0143 |
436 | #define DIR_START 0x0144 | 436 | #define DIR_START 0x0144 |
437 | #define DATASPACE_BITMAP_START 0x0145 | 437 | #define DATASPACE_BITMAP_START 0x0145 |
438 | #define DATASPACE_START 0x0146 | 438 | #define DATASPACE_START 0x0146 |
439 | 439 | ||
440 | #define CLUSTER_CHAIN_SIZE 0x5008 | 440 | #define CLUSTER_CHAIN_SIZE 0x5008 |
441 | #define CLUSTER_CHAIN_HEAD 0x0000 | 441 | #define CLUSTER_CHAIN_HEAD 0x0000 |
442 | #define CLUSTER_CHAIN_BITMAP 0x0001 | 442 | #define CLUSTER_CHAIN_BITMAP 0x0001 |
443 | #define CLUSTER_CHAIN_CHAIN 0x0002 | 443 | #define CLUSTER_CHAIN_CHAIN 0x0002 |
444 | 444 | ||
445 | 445 | ||
446 | int load_minifs_file(char* filename, unsigned char* location) | 446 | int load_minifs_file(char* filename, unsigned char* location) |
447 | { | 447 | { |
448 | struct main_header *hdr; | 448 | struct main_header *hdr; |
449 | static struct minifs_file files[128]; | 449 | static struct minifs_file files[128]; |
450 | struct minifs_chain *chain; | 450 | struct minifs_chain *chain; |
451 | unsigned int i; | 451 | unsigned int i; |
452 | int found = -1; | 452 | int found = -1; |
453 | unsigned char sector[512]; | 453 | unsigned char sector[512]; |
454 | static unsigned char chain_data[42*512]; /* stack overflow if not static */ | 454 | static unsigned char chain_data[42*512]; /* stack overflow if not static */ |
455 | 455 | ||
456 | /* Read MBLK */ | 456 | /* Read MBLK */ |
457 | _ata_read_sectors(0, 1, §or); | 457 | _ata_read_sectors(0, 1, §or); |
458 | hdr = (struct main_header*)§or; | 458 | hdr = (struct main_header*)§or; |
459 | 459 | ||
460 | /* Read directory listing */ | 460 | /* Read directory listing */ |
461 | #define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) ) | 461 | #define CLUSTER2SECTOR(x) ( (hdr->partitions[0].start + (x)*8) ) |
462 | _ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files); | 462 | _ata_read_sectors(CLUSTER2SECTOR(DIR_START), 8, &files); |
463 | 463 | ||
464 | for(i=0; i<127; i++) | 464 | for(i=0; i<127; i++) |
465 | { | 465 | { |
466 | if(strcmp(files[i].name, filename) == 0) | 466 | if(strcmp(files[i].name, filename) == 0) |
467 | found = i; | 467 | found = i; |
468 | } | 468 | } |
469 | 469 | ||
470 | if(found == -1) | 470 | if(found == -1) |
471 | return -1; | 471 | return -1; |
472 | 472 | ||
473 | #define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE ) | 473 | #define GET_CHAIN(x) ( CLUSTER2SECTOR(CLUSTER_CHAIN_CHAIN)*512 + (x)*CLUSTER_CHAIN_SIZE ) |
474 | #define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) ) | 474 | #define FILE2SECTOR(x) ( CLUSTER2SECTOR(DATASPACE_START + (x)) ) |
475 | 475 | ||
476 | /* Read chain list */ | 476 | /* Read chain list */ |
477 | _ata_read_sectors(GET_CHAIN(files[found].chain1)/512, 41, &chain_data[0]); | 477 | _ata_read_sectors(GET_CHAIN(files[found].chain1)/512, 41, &chain_data[0]); |
478 | 478 | ||
479 | chain = (struct minifs_chain*)&chain_data[GET_CHAIN(files[found].chain1)%512]; | 479 | chain = (struct minifs_chain*)&chain_data[GET_CHAIN(files[found].chain1)%512]; |
480 | 480 | ||
481 | /* Copy data */ | 481 | /* Copy data */ |
482 | for(i=0; i<chain->length; i++) | 482 | for(i=0; i<chain->length; i++) |
483 | { | 483 | { |
484 | _ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location); | 484 | _ata_read_sectors(FILE2SECTOR(chain->chain[i]), 8, location); |
485 | location += 0x1000; | 485 | location += 0x1000; |
486 | } | 486 | } |
487 | 487 | ||
488 | return files[found].size; | 488 | return files[found].size; |
489 | } | 489 | } |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/dma-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/dma-creativezvm.c index 201dd1b24c..c229b9957a 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/dma-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/dma-creativezvm.c | |||
@@ -1,130 +1,130 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by Maurus Cuelenaere | 10 | * Copyright (C) 2008 by Maurus Cuelenaere |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "kernel.h" | 23 | #include "kernel.h" |
24 | #include "thread.h" | 24 | #include "thread.h" |
25 | #include "system.h" | 25 | #include "system.h" |
26 | #include "dma-target.h" | 26 | #include "dma-target.h" |
27 | #include "dm320.h" | 27 | #include "dm320.h" |
28 | #include "ata-target.h" | 28 | #include "ata-target.h" |
29 | #include <stdbool.h> | 29 | #include <stdbool.h> |
30 | 30 | ||
31 | #define CS1_START 0x50000000 | 31 | #define CS1_START 0x50000000 |
32 | #define CS2_START 0x60000000 | 32 | #define CS2_START 0x60000000 |
33 | #define SDRAM_START 0x00900000 | 33 | #define SDRAM_START 0x00900000 |
34 | #define FLASH_START 0x00100000 | 34 | #define FLASH_START 0x00100000 |
35 | #define CF_START 0x40000000 | 35 | #define CF_START 0x40000000 |
36 | #define SSFDC_START 0x48000000 | 36 | #define SSFDC_START 0x48000000 |
37 | 37 | ||
38 | static struct wakeup transfer_completion_signal; | 38 | static struct wakeup transfer_completion_signal; |
39 | 39 | ||
40 | static bool dma_in_progress = false; | 40 | static bool dma_in_progress = false; |
41 | 41 | ||
42 | void MTC0(void) | 42 | void MTC0(void) |
43 | { | 43 | { |
44 | IO_INTC_IRQ1 = INTR_IRQ1_MTC0; | 44 | IO_INTC_IRQ1 = INTR_IRQ1_MTC0; |
45 | wakeup_signal(&transfer_completion_signal); | 45 | wakeup_signal(&transfer_completion_signal); |
46 | dma_in_progress = false; | 46 | dma_in_progress = false; |
47 | } | 47 | } |
48 | 48 | ||
49 | void dma_start(const void* addr, size_t size) | 49 | void dma_start(const void* addr, size_t size) |
50 | { | 50 | { |
51 | /* Compatibility with Gigabeat S in dma_start.c */ | 51 | /* Compatibility with Gigabeat S in dma_start.c */ |
52 | (void) addr; | 52 | (void) addr; |
53 | (void) size; | 53 | (void) size; |
54 | } | 54 | } |
55 | 55 | ||
56 | #define ATA_DEST (ATA_IOBASE-CS1_START) | 56 | #define ATA_DEST (ATA_IOBASE-CS1_START) |
57 | void dma_ata_read(unsigned char* buf, int shortcount) | 57 | void dma_ata_read(unsigned char* buf, int shortcount) |
58 | { | 58 | { |
59 | if(dma_in_progress) | 59 | if(dma_in_progress) |
60 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 60 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
61 | 61 | ||
62 | while((unsigned long)buf & 0x1F) | 62 | while((unsigned long)buf & 0x1F) |
63 | { | 63 | { |
64 | unsigned short tmp; | 64 | unsigned short tmp; |
65 | tmp = ATA_DATA; | 65 | tmp = ATA_DATA; |
66 | *buf++ = tmp & 0xFF; | 66 | *buf++ = tmp & 0xFF; |
67 | *buf++ = tmp >> 8; | 67 | *buf++ = tmp >> 8; |
68 | shortcount--; | 68 | shortcount--; |
69 | } | 69 | } |
70 | 70 | ||
71 | if (!shortcount) | 71 | if (!shortcount) |
72 | return; | 72 | return; |
73 | 73 | ||
74 | IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */ | 74 | IO_SDRAM_SDDMASEL = 0x0820; /* 32-byte burst mode transfer */ |
75 | IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ | 75 | IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ |
76 | IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */ | 76 | IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & 0x7FFF; /* Set variable address */ |
77 | IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; | 77 | IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; |
78 | IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ | 78 | IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ |
79 | IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; | 79 | IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; |
80 | IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */ | 80 | IO_EMIF_DMASIZE = shortcount/2; /* 16-bits *2 = 1 word */ |
81 | IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */ | 81 | IO_EMIF_DMACTL = 3; /* Select MTC->AHB and start transfer */ |
82 | 82 | ||
83 | dma_in_progress = true; | 83 | dma_in_progress = true; |
84 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 84 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
85 | 85 | ||
86 | if(shortcount % 2) | 86 | if(shortcount % 2) |
87 | { | 87 | { |
88 | unsigned short tmp; | 88 | unsigned short tmp; |
89 | tmp = ATA_DATA; | 89 | tmp = ATA_DATA; |
90 | *buf++ = tmp & 0xFF; | 90 | *buf++ = tmp & 0xFF; |
91 | *buf++ = tmp >> 8; | 91 | *buf++ = tmp >> 8; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | void dma_ata_write(unsigned char* buf, int wordcount) | 95 | void dma_ata_write(unsigned char* buf, int wordcount) |
96 | { | 96 | { |
97 | if(dma_in_progress) | 97 | if(dma_in_progress) |
98 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 98 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
99 | 99 | ||
100 | while((unsigned long)buf & 0x1F) | 100 | while((unsigned long)buf & 0x1F) |
101 | { | 101 | { |
102 | unsigned short tmp; | 102 | unsigned short tmp; |
103 | tmp = (unsigned short) *buf++; | 103 | tmp = (unsigned short) *buf++; |
104 | tmp |= (unsigned short) *buf++ << 8; | 104 | tmp |= (unsigned short) *buf++ << 8; |
105 | SET_16BITREG(ATA_DATA, tmp); | 105 | SET_16BITREG(ATA_DATA, tmp); |
106 | wordcount--; | 106 | wordcount--; |
107 | } | 107 | } |
108 | 108 | ||
109 | if (!wordcount) | 109 | if (!wordcount) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */ | 112 | IO_SDRAM_SDDMASEL = 0x0830; /* 32-byte burst mode transfer */ |
113 | IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ | 113 | IO_EMIF_DMAMTCSEL = 1; /* Select CS1 */ |
114 | IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */ | 114 | IO_EMIF_AHBADDH = ((unsigned long)buf >> 16) & ~(1 << 15); /* Set variable address */ |
115 | IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; | 115 | IO_EMIF_AHBADDL = (unsigned long)buf & 0xFFFF; |
116 | IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ | 116 | IO_EMIF_MTCADDH = ( (1 << 15) | (ATA_DEST >> 16) ); /* Set fixed address */ |
117 | IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; | 117 | IO_EMIF_MTCADDL = ATA_DEST & 0xFFFF; |
118 | IO_EMIF_DMASIZE = (wordcount+1)/2; | 118 | IO_EMIF_DMASIZE = (wordcount+1)/2; |
119 | IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */ | 119 | IO_EMIF_DMACTL = 1; /* Select AHB->MTC and start transfer */ |
120 | 120 | ||
121 | dma_in_progress = true; | 121 | dma_in_progress = true; |
122 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 122 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
123 | } | 123 | } |
124 | 124 | ||
125 | void dma_init(void) | 125 | void dma_init(void) |
126 | { | 126 | { |
127 | IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */ | 127 | IO_INTC_EINT1 |= INTR_EINT1_MTC0; /* enable MTC interrupt */ |
128 | wakeup_init(&transfer_completion_signal); | 128 | wakeup_init(&transfer_completion_signal); |
129 | dma_in_progress = false; | 129 | dma_in_progress = false; |
130 | } | 130 | } |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/dma-target.h b/firmware/target/arm/tms320dm320/creative-zvm/dma-target.h index 6432673dd5..f7e1d76626 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/dma-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/dma-target.h | |||
@@ -1,30 +1,30 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by Maurus Cuelenaere | 10 | * Copyright (C) 2008 by Maurus Cuelenaere |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef DMA_TARGET_H | 22 | #ifndef DMA_TARGET_H |
23 | #define DMA_TARGET_H | 23 | #define DMA_TARGET_H |
24 | 24 | ||
25 | void dma_start(const void* addr, size_t size); /* Compatibility with Gigabeat S in dma_start.c */ | 25 | void dma_start(const void* addr, size_t size); /* Compatibility with Gigabeat S in dma_start.c */ |
26 | void dma_ata_read(unsigned char* buf, int wordcount); | 26 | void dma_ata_read(unsigned char* buf, int wordcount); |
27 | void dma_ata_write(unsigned char* buf, int wordcount); | 27 | void dma_ata_write(unsigned char* buf, int wordcount); |
28 | void dma_init(void); | 28 | void dma_init(void); |
29 | 29 | ||
30 | #endif | 30 | #endif |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c index 7d372dec16..34425fa63d 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/pcm-creativezvm.c | |||
@@ -1,117 +1,117 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Karl Kurbjun | 10 | * Copyright (C) 2007 by Karl Kurbjun |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "system.h" | 21 | #include "system.h" |
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "logf.h" | 23 | #include "logf.h" |
24 | #include "audio.h" | 24 | #include "audio.h" |
25 | #include "sound.h" | 25 | #include "sound.h" |
26 | #include "file.h" | 26 | #include "file.h" |
27 | #include "dm320.h" | 27 | #include "dm320.h" |
28 | #include "audiohw.h" | 28 | #include "audiohw.h" |
29 | #include "dsp-target.h" | 29 | #include "dsp-target.h" |
30 | 30 | ||
31 | void pcm_play_dma_init(void) | 31 | void pcm_play_dma_init(void) |
32 | { | 32 | { |
33 | IO_CLK_O1DIV = 3; | 33 | IO_CLK_O1DIV = 3; |
34 | /* Set GIO25 to CLKOUT1A */ | 34 | /* Set GIO25 to CLKOUT1A */ |
35 | IO_GIO_FSEL2 |= 3; | 35 | IO_GIO_FSEL2 |= 3; |
36 | sleep(5); | 36 | sleep(5); |
37 | 37 | ||
38 | audiohw_init(); | 38 | audiohw_init(); |
39 | 39 | ||
40 | audiohw_set_frequency(1); | 40 | audiohw_set_frequency(1); |
41 | 41 | ||
42 | /* init DSP */ | 42 | /* init DSP */ |
43 | dsp_init(); | 43 | dsp_init(); |
44 | } | 44 | } |
45 | 45 | ||
46 | void pcm_postinit(void) | 46 | void pcm_postinit(void) |
47 | { | 47 | { |
48 | audiohw_postinit(); | 48 | audiohw_postinit(); |
49 | /* wake DSP */ | 49 | /* wake DSP */ |
50 | dsp_wake(); | 50 | dsp_wake(); |
51 | } | 51 | } |
52 | 52 | ||
53 | /* set frequency used by the audio hardware */ | 53 | /* set frequency used by the audio hardware */ |
54 | void pcm_set_frequency(unsigned int frequency) | 54 | void pcm_set_frequency(unsigned int frequency) |
55 | { | 55 | { |
56 | int index; | 56 | int index; |
57 | 57 | ||
58 | switch(frequency) | 58 | switch(frequency) |
59 | { | 59 | { |
60 | case SAMPR_11: | 60 | case SAMPR_11: |
61 | case SAMPR_22: | 61 | case SAMPR_22: |
62 | index = 0; | 62 | index = 0; |
63 | break; | 63 | break; |
64 | default: | 64 | default: |
65 | case SAMPR_44: | 65 | case SAMPR_44: |
66 | index = 1; | 66 | index = 1; |
67 | break; | 67 | break; |
68 | case SAMPR_88: | 68 | case SAMPR_88: |
69 | index = 2; | 69 | index = 2; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | 72 | ||
73 | audiohw_set_frequency(index); | 73 | audiohw_set_frequency(index); |
74 | } /* pcm_set_frequency */ | 74 | } /* pcm_set_frequency */ |
75 | 75 | ||
76 | const void * pcm_play_dma_get_peak_buffer(int *count) | 76 | const void * pcm_play_dma_get_peak_buffer(int *count) |
77 | { | 77 | { |
78 | (void) count; | 78 | (void) count; |
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | void pcm_apply_settings(void) | 82 | void pcm_apply_settings(void) |
83 | { | 83 | { |
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | void pcm_play_dma_start(const void *addr, size_t size) | 87 | void pcm_play_dma_start(const void *addr, size_t size) |
88 | { | 88 | { |
89 | (void)addr; | 89 | (void)addr; |
90 | (void)size; | 90 | (void)size; |
91 | DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size); | 91 | DEBUGF("pcm_play_dma_start(0x%x, %d)", addr, size); |
92 | } | 92 | } |
93 | 93 | ||
94 | void pcm_play_dma_stop(void) | 94 | void pcm_play_dma_stop(void) |
95 | { | 95 | { |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void pcm_play_lock(void) | 99 | void pcm_play_lock(void) |
100 | { | 100 | { |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | void pcm_play_unlock(void) | 104 | void pcm_play_unlock(void) |
105 | { | 105 | { |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | void pcm_play_dma_pause(bool pause) | 109 | void pcm_play_dma_pause(bool pause) |
110 | { | 110 | { |
111 | (void) pause; | 111 | (void) pause; |
112 | } | 112 | } |
113 | 113 | ||
114 | size_t pcm_get_bytes_waiting(void) | 114 | size_t pcm_get_bytes_waiting(void) |
115 | { | 115 | { |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c index 1d26c68177..a76e827bec 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c | |||
@@ -1,70 +1,70 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $ | 8 | * $Id: power-mr500.c 15599 2007-11-12 18:49:53Z amiconn $ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Karl Kurbjun | 10 | * Copyright (C) 2007 by Karl Kurbjun |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "cpu.h" | 23 | #include "cpu.h" |
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "power.h" | 27 | #include "power.h" |
28 | #include "backlight.h" | 28 | #include "backlight.h" |
29 | #include "backlight-target.h" | 29 | #include "backlight-target.h" |
30 | 30 | ||
31 | #ifndef SIMULATOR | 31 | #ifndef SIMULATOR |
32 | 32 | ||
33 | void power_init(void) | 33 | void power_init(void) |
34 | { | 34 | { |
35 | /* Initialize IDE power pin */ | 35 | /* Initialize IDE power pin */ |
36 | /* set ATA power on and output */ | 36 | /* set ATA power on and output */ |
37 | /* Charger detect */ | 37 | /* Charger detect */ |
38 | } | 38 | } |
39 | 39 | ||
40 | bool charger_inserted(void) | 40 | bool charger_inserted(void) |
41 | { | 41 | { |
42 | return false; | 42 | return false; |
43 | } | 43 | } |
44 | 44 | ||
45 | /* Returns true if the unit is charging the batteries. */ | 45 | /* Returns true if the unit is charging the batteries. */ |
46 | bool charging_state(void) { | 46 | bool charging_state(void) { |
47 | return false; | 47 | return false; |
48 | } | 48 | } |
49 | 49 | ||
50 | void power_off(void) | 50 | void power_off(void) |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | #else /* SIMULATOR */ | 54 | #else /* SIMULATOR */ |
55 | 55 | ||
56 | bool charger_inserted(void) | 56 | bool charger_inserted(void) |
57 | { | 57 | { |
58 | return false; | 58 | return false; |
59 | } | 59 | } |
60 | 60 | ||
61 | void charger_enable(bool on) | 61 | void charger_enable(bool on) |
62 | { | 62 | { |
63 | (void)on; | 63 | (void)on; |
64 | } | 64 | } |
65 | 65 | ||
66 | void power_off(void) | 66 | void power_off(void) |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | #endif /* SIMULATOR */ | 70 | #endif /* SIMULATOR */ |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c index 14c4926fde..d85ade18c3 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c | |||
@@ -1,59 +1,59 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Karl Kurbjun | 10 | * Copyright (C) 2007 by Karl Kurbjun |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "adc.h" | 23 | #include "adc.h" |
24 | #include "powermgmt.h" | 24 | #include "powermgmt.h" |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | 26 | ||
27 | /* THIS CONTAINS CURRENTLY DUMMY CODE! */ | 27 | /* THIS CONTAINS CURRENTLY DUMMY CODE! */ |
28 | 28 | ||
29 | unsigned short current_voltage = 3910; | 29 | unsigned short current_voltage = 3910; |
30 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 30 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
31 | { | 31 | { |
32 | 0 | 32 | 0 |
33 | }; | 33 | }; |
34 | 34 | ||
35 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | 35 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = |
36 | { | 36 | { |
37 | 0 | 37 | 0 |
38 | }; | 38 | }; |
39 | 39 | ||
40 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | 40 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ |
41 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | 41 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = |
42 | { | 42 | { |
43 | { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 }, | 43 | { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 }, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | 46 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ |
47 | const unsigned short percent_to_volt_charge[11] = | 47 | const unsigned short percent_to_volt_charge[11] = |
48 | { | 48 | { |
49 | 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, | 49 | 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, |
50 | }; | 50 | }; |
51 | void read_battery_inputs(void) | 51 | void read_battery_inputs(void) |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | /* Returns battery voltage from ADC [millivolts] */ | 55 | /* Returns battery voltage from ADC [millivolts] */ |
56 | unsigned int battery_adc_voltage(void) | 56 | unsigned int battery_adc_voltage(void) |
57 | { | 57 | { |
58 | return current_voltage; | 58 | return current_voltage; |
59 | } | 59 | } |
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h index 9ac8dd2fa6..260ddad7cf 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/usb-target.h | |||
@@ -1,81 +1,81 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | 2 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2008 by Maurus Cuelenaere | 10 | * Copyright (C) 2008 by Maurus Cuelenaere |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef USB_TARGET_H | 22 | #ifndef USB_TARGET_H |
23 | #define USB_TARGET_H | 23 | #define USB_TARGET_H |
24 | 24 | ||
25 | #include "dm320.h" | 25 | #include "dm320.h" |
26 | 26 | ||
27 | /* General purpose memory region #2 */ | 27 | /* General purpose memory region #2 */ |
28 | #define ISP1583_IOBASE 0x60FFC000 | 28 | #define ISP1583_IOBASE 0x60FFC000 |
29 | #define ISP1583_H_OVERRIDE | 29 | #define ISP1583_H_OVERRIDE |
30 | 30 | ||
31 | #define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char | 31 | #define ISP1583_INIT_ADDRESS (*((volatile unsigned char*)(ISP1583_IOBASE+0x0))) //char |
32 | #define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2))) | 32 | #define ISP1583_INIT_MODE (*((volatile unsigned short*)(ISP1583_IOBASE+0xC*2))) |
33 | #define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char | 33 | #define ISP1583_INIT_INTCONF (*((volatile unsigned char*)(ISP1583_IOBASE+0x10*2))) //char |
34 | #define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char | 34 | #define ISP1583_INIT_OTG (*((volatile unsigned char*)(ISP1583_IOBASE+0x12*2))) //char |
35 | #define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2))) | 35 | #define ISP1583_INIT_INTEN_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2))) |
36 | #define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4))) | 36 | #define ISP1583_INIT_INTEN_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x14*2+4))) |
37 | #define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) ) | 37 | #define ISP1583_INIT_INTEN_READ (unsigned long)( (ISP1583_INIT_INTEN_A & 0xFFFF) | ((ISP1583_INIT_INTEN_B & 0xFFFF) << 16) ) |
38 | /* Data flow registers */ | 38 | /* Data flow registers */ |
39 | #define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char | 39 | #define ISP1583_DFLOW_EPINDEX (*((volatile unsigned char*)(ISP1583_IOBASE+0xC2*2))) //char |
40 | #define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char | 40 | #define ISP1583_DFLOW_CTRLFUN (*((volatile unsigned char*)(ISP1583_IOBASE+0x28*2))) //char |
41 | #define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2))) | 41 | #define ISP1583_DFLOW_DATA (*((volatile unsigned short*)(ISP1583_IOBASE+0x20*2))) |
42 | #define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2))) | 42 | #define ISP1583_DFLOW_BUFLEN (*((volatile unsigned short*)(ISP1583_IOBASE+0x1C*2))) |
43 | #define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char | 43 | #define ISP1583_DFLOW_BUFSTAT (*((volatile unsigned char*)(ISP1583_IOBASE+0x1E*2))) //char |
44 | #define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2))) | 44 | #define ISP1583_DFLOW_MAXPKSZ (*((volatile unsigned short*)(ISP1583_IOBASE+0x04*2))) |
45 | #define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2))) | 45 | #define ISP1583_DFLOW_EPTYPE (*((volatile unsigned short*)(ISP1583_IOBASE+0x08*2))) |
46 | /* DMA registers */ | 46 | /* DMA registers */ |
47 | #define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2))) | 47 | #define ISP1583_DMA_ENDPOINT (*((volatile unsigned char*)(ISP1583_IOBASE+0x58*2))) |
48 | /* General registers */ | 48 | /* General registers */ |
49 | #define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2))) | 49 | #define ISP1583_GEN_INT_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2))) |
50 | #define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4))) | 50 | #define ISP1583_GEN_INT_B (*((volatile unsigned short*)(ISP1583_IOBASE+0x18*2+4))) |
51 | #define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16)) | 51 | #define ISP1583_GEN_INT_READ (unsigned long)( (ISP1583_GEN_INT_A & 0xFFFF) | ((ISP1583_GEN_INT_B & 0xFFFF) << 16)) |
52 | #define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2))) | 52 | #define ISP1583_GEN_CHIPID_A (*((volatile unsigned short*)(ISP1583_IOBASE+0x70*2))) |
53 | #define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char | 53 | #define ISP1583_GEN_CHIPID_B (*((volatile unsigned char*)(ISP1583_IOBASE+0x70*2+4))) //char |
54 | #define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) ) | 54 | #define ISP1583_GEN_CHIPID (unsigned long)( (ISP1583_GEN_CHIPID_A & 0xFFFF) | ((ISP1583_GEN_CHIPID_B & 0xFFFF) << 16) ) |
55 | #define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2))) | 55 | #define ISP1583_GEN_FRAMEN0 (*((volatile unsigned short*)(ISP1583_IOBASE+0x74*2))) |
56 | #define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2))) | 56 | #define ISP1583_GEN_SCRATCH (*((volatile unsigned short*)(ISP1583_IOBASE+0x78*2))) |
57 | #define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2))) | 57 | #define ISP1583_GEN_UNLCKDEV (*((volatile unsigned short*)(ISP1583_IOBASE+0x7C*2))) |
58 | #define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char | 58 | #define ISP1583_GEN_TSTMOD (*((volatile unsigned char*)(ISP1583_IOBASE+0x84*2))) //char |
59 | 59 | ||
60 | #define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7 | 60 | #define EN_INT_CPU_TARGET IO_INTC_EINT1 |= INTR_EINT1_EXT7 |
61 | #define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7 | 61 | #define DIS_INT_CPU_TARGET IO_INTC_EINT1 &= ~INTR_EINT1_EXT7 |
62 | #define INT_CONF_TARGET 0 | 62 | #define INT_CONF_TARGET 0 |
63 | //#define INT_CONF_TARGET 2 | 63 | //#define INT_CONF_TARGET 2 |
64 | #define set_int_value(a,b,value) a = value & 0xFFFF; \ | 64 | #define set_int_value(a,b,value) a = value & 0xFFFF; \ |
65 | b = value >> 16; | 65 | b = value >> 16; |
66 | 66 | ||
67 | 67 | ||
68 | #define ZVM_SPECIFIC asm volatile( \ | 68 | #define ZVM_SPECIFIC asm volatile( \ |
69 | "LDR R12, =0x50FFC000\n" \ | 69 | "LDR R12, =0x50FFC000\n" \ |
70 | "LDRH R12, [R12]\n" \ | 70 | "LDRH R12, [R12]\n" \ |
71 | : : : "r12") | 71 | : : : "r12") |
72 | //#define ZVM_SPECIFIC | 72 | //#define ZVM_SPECIFIC |
73 | 73 | ||
74 | #define USE_IRAM | 74 | #define USE_IRAM |
75 | 75 | ||
76 | #include <stdbool.h> | 76 | #include <stdbool.h> |
77 | int usb_detect(void); | 77 | int usb_detect(void); |
78 | void usb_init_device(void); | 78 | void usb_init_device(void); |
79 | bool usb_drv_connected(void); | 79 | bool usb_drv_connected(void); |
80 | 80 | ||
81 | #endif | 81 | #endif |