diff options
Diffstat (limited to 'firmware')
28 files changed, 0 insertions, 3591 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index b6f7688946..dd12c4953f 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -336,9 +336,6 @@ drivers/touchscreen.c | |||
336 | 336 | ||
337 | /* Storage */ | 337 | /* Storage */ |
338 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 338 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
339 | #if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_IFP7XX) | ||
340 | drivers/ata_flash.c | ||
341 | #endif | ||
342 | #if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_TCC) | 339 | #if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_TCC) |
343 | target/arm/ata-nand-telechips.c | 340 | target/arm/ata-nand-telechips.c |
344 | #endif | 341 | #endif |
@@ -1039,12 +1036,9 @@ target/coldfire/iaudio/audio-iaudio.c | |||
1039 | #endif | 1036 | #endif |
1040 | #endif /* IAUDIO_M3 */ | 1037 | #endif /* IAUDIO_M3 */ |
1041 | 1038 | ||
1042 | #ifdef IRIVER_IFP7XX_SERIES | ||
1043 | #ifdef STUB | 1039 | #ifdef STUB |
1044 | ifp_usb_serial.c | ||
1045 | libc/sscanf.c | 1040 | libc/sscanf.c |
1046 | #endif /* STUB */ | 1041 | #endif /* STUB */ |
1047 | #endif /* IRIVER_IFP7XX_SERIES */ | ||
1048 | 1042 | ||
1049 | #if defined(IRIVER_H300_SERIES) || defined(IRIVER_H100_SERIES) | 1043 | #if defined(IRIVER_H300_SERIES) || defined(IRIVER_H100_SERIES) |
1050 | target/coldfire/iriver/ata-iriver.c | 1044 | target/coldfire/iriver/ata-iriver.c |
@@ -1349,19 +1343,6 @@ target/arm/ipod/button-mini1g.c | |||
1349 | target/arm/ipod/button-clickwheel.c | 1343 | target/arm/ipod/button-clickwheel.c |
1350 | #endif /* IPOD_MINI2G */ | 1344 | #endif /* IPOD_MINI2G */ |
1351 | 1345 | ||
1352 | #ifdef IRIVER_IFP7XX | ||
1353 | target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c | ||
1354 | target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c | ||
1355 | target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c | ||
1356 | target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c | ||
1357 | target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c | ||
1358 | target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c | ||
1359 | target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c | ||
1360 | #ifndef BOOTLOADER | ||
1361 | target/arm/pnx0101/pcm-pnx0101.c | ||
1362 | #endif /* BOOTLOADER */ | ||
1363 | #endif /* IRIVER_IFP7XX */ | ||
1364 | |||
1365 | #ifdef SANSA_CLIPPLUS | 1346 | #ifdef SANSA_CLIPPLUS |
1366 | target/arm/as3525/sansa-clipplus/lcd-clip-plus.c | 1347 | target/arm/as3525/sansa-clipplus/lcd-clip-plus.c |
1367 | target/arm/as3525/sansa-clipplus/button-clip.c | 1348 | target/arm/as3525/sansa-clipplus/button-clip.c |
diff --git a/firmware/drivers/ata_flash.c b/firmware/drivers/ata_flash.c deleted file mode 100644 index fbdd7f04ee..0000000000 --- a/firmware/drivers/ata_flash.c +++ /dev/null | |||
@@ -1,484 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "storage.h" | ||
23 | #include <stdbool.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | #if CONFIG_CPU == PNX0101 | ||
27 | #include "pnx0101.h" | ||
28 | #endif | ||
29 | |||
30 | /* | ||
31 | #include "kernel.h" | ||
32 | #include "thread.h" | ||
33 | #include "led.h" | ||
34 | #include "cpu.h" | ||
35 | #include "system.h" | ||
36 | #include "debug.h" | ||
37 | #include "panic.h" | ||
38 | #include "usb.h" | ||
39 | #include "power.h" | ||
40 | #include "string.h" | ||
41 | */ | ||
42 | |||
43 | #define SECTOR_SIZE (512) | ||
44 | |||
45 | static long last_disk_activity = -1; | ||
46 | |||
47 | #if CONFIG_FLASH == FLASH_IFP7XX | ||
48 | static unsigned char flash_ce[4] = {0x20, 0x02, 0x10, 0x08}; | ||
49 | |||
50 | #define FLASH_IO_BASE 0x28000000 | ||
51 | #define FLASH_REG_DATA (*((volatile unsigned char*)(FLASH_IO_BASE))) | ||
52 | #define FLASH_REG_CMD (*((volatile unsigned char*)(FLASH_IO_BASE + 4))) | ||
53 | #define FLASH_REG_ADDR (*((volatile unsigned char*)(FLASH_IO_BASE + 8))) | ||
54 | |||
55 | #define SEGMENT_SIZE 1000 | ||
56 | #define MAX_N_SEGMENTS 8 | ||
57 | |||
58 | #endif | ||
59 | |||
60 | #define FLASH_MODEL_NONE 0 | ||
61 | #define FLASH_MODEL_256 1 | ||
62 | #define FLASH_MODEL_512 2 | ||
63 | |||
64 | struct flash_disk | ||
65 | { | ||
66 | unsigned short block_map[MAX_N_SEGMENTS][SEGMENT_SIZE]; | ||
67 | short cur_block; | ||
68 | int cur_phblock_start; | ||
69 | int n_chips; | ||
70 | unsigned char chip_no[4]; | ||
71 | unsigned char model; | ||
72 | }; | ||
73 | |||
74 | static struct flash_disk flash_disk; | ||
75 | |||
76 | static void flash_select_chip(int no, int sel) | ||
77 | { | ||
78 | #if CONFIG_FLASH == FLASH_IFP7XX | ||
79 | if (sel) | ||
80 | GPIO5_CLR = flash_ce[no]; | ||
81 | else | ||
82 | GPIO5_SET = flash_ce[no]; | ||
83 | #endif | ||
84 | } | ||
85 | |||
86 | static inline unsigned char flash_read_data(void) | ||
87 | { | ||
88 | return FLASH_REG_DATA; | ||
89 | } | ||
90 | |||
91 | static inline void flash_write_data(unsigned char data) | ||
92 | { | ||
93 | FLASH_REG_DATA = data; | ||
94 | } | ||
95 | |||
96 | /* TODO: these two doesn't work when inlined, probably some | ||
97 | delay is required */ | ||
98 | |||
99 | static void flash_write_cmd(unsigned char cmd) | ||
100 | { | ||
101 | FLASH_REG_CMD = cmd; | ||
102 | } | ||
103 | |||
104 | static void flash_write_addr(unsigned char addr) | ||
105 | { | ||
106 | FLASH_REG_ADDR = addr; | ||
107 | } | ||
108 | |||
109 | static void flash_wait_ready(void) | ||
110 | { | ||
111 | int i; | ||
112 | for (i = 0; i < 5; i++) | ||
113 | while ((GPIO6_READ & 8) == 0); | ||
114 | } | ||
115 | |||
116 | static unsigned char model_n_sectors_order[] = {0, 19, 20}; | ||
117 | |||
118 | static int flash_map_sector(int sector, int* chip, int* chip_sector) | ||
119 | { | ||
120 | int ord, c; | ||
121 | if (flash_disk.model == FLASH_MODEL_NONE) | ||
122 | return -1; | ||
123 | |||
124 | ord = model_n_sectors_order[flash_disk.model]; | ||
125 | c = sector >> ord; | ||
126 | *chip_sector = sector & ((1 << ord) - 1); | ||
127 | |||
128 | if (c >= flash_disk.n_chips) | ||
129 | return -1; | ||
130 | |||
131 | *chip = flash_disk.chip_no[c]; | ||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int flash_read_id(int no) { | ||
136 | int id; | ||
137 | |||
138 | flash_select_chip(no, 1); | ||
139 | flash_write_cmd(0x90); | ||
140 | flash_write_addr(0); | ||
141 | |||
142 | flash_read_data(); | ||
143 | id = flash_read_data(); | ||
144 | |||
145 | flash_select_chip(no, 0); | ||
146 | return id; | ||
147 | } | ||
148 | |||
149 | static int flash_read_sector(int sector, unsigned char* buf, | ||
150 | unsigned char* oob) | ||
151 | { | ||
152 | unsigned long *bufl = (unsigned long *)buf; | ||
153 | int chip, chip_sector; | ||
154 | int i; | ||
155 | |||
156 | if (flash_map_sector(sector, &chip, &chip_sector) < 0) | ||
157 | return -1; | ||
158 | |||
159 | flash_select_chip(chip, 1); | ||
160 | |||
161 | flash_write_cmd(0x00); | ||
162 | flash_write_addr(0); | ||
163 | flash_write_addr((chip_sector << 1) & 7); | ||
164 | flash_write_addr((chip_sector >> 2) & 0xff); | ||
165 | flash_write_addr((chip_sector >> 10) & 0xff); | ||
166 | flash_write_addr((chip_sector >> 18) & 0xff); | ||
167 | flash_write_cmd(0x30); | ||
168 | |||
169 | flash_wait_ready(); | ||
170 | |||
171 | if ((unsigned long)buf & 3) | ||
172 | { | ||
173 | for (i = 0; i < 512; i++) | ||
174 | buf[i] = flash_read_data(); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | for (i = 0; i < 512 / 4; i++) { | ||
179 | unsigned long v; | ||
180 | #ifdef ROCKBOX_LITTLE_ENDIAN | ||
181 | v = flash_read_data(); | ||
182 | v |= (unsigned long)flash_read_data() << 8; | ||
183 | v |= (unsigned long)flash_read_data() << 16; | ||
184 | v |= (unsigned long)flash_read_data() << 24; | ||
185 | #else | ||
186 | v = (unsigned long)flash_read_data() << 24; | ||
187 | v |= (unsigned long)flash_read_data() << 16; | ||
188 | v |= (unsigned long)flash_read_data() << 8; | ||
189 | v |= flash_read_data(); | ||
190 | #endif | ||
191 | bufl[i] = v; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | flash_write_cmd(0x05); | ||
196 | flash_write_addr((chip_sector & 3) * 0x10); | ||
197 | flash_write_addr(8); | ||
198 | flash_write_cmd(0xe0); | ||
199 | |||
200 | for (i = 0; i < 16; i++) | ||
201 | oob[i] = flash_read_data(); | ||
202 | |||
203 | flash_select_chip(chip, 0); | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static int flash_read_sector_oob(int sector, unsigned char* oob) | ||
208 | { | ||
209 | int chip, chip_sector; | ||
210 | int i; | ||
211 | |||
212 | if (flash_map_sector(sector, &chip, &chip_sector) < 0) | ||
213 | return -1; | ||
214 | |||
215 | flash_select_chip(chip, 1); | ||
216 | |||
217 | flash_write_cmd(0x00); | ||
218 | flash_write_addr((chip_sector & 3) * 0x10); | ||
219 | flash_write_addr(8); | ||
220 | flash_write_addr((chip_sector >> 2) & 0xff); | ||
221 | flash_write_addr((chip_sector >> 10) & 0xff); | ||
222 | flash_write_addr((chip_sector >> 18) & 0xff); | ||
223 | flash_write_cmd(0x30); | ||
224 | |||
225 | flash_wait_ready(); | ||
226 | |||
227 | for (i = 0; i < 16; i++) | ||
228 | oob[i] = flash_read_data(); | ||
229 | |||
230 | flash_select_chip(chip, 0); | ||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static unsigned char model_n_segments[] = {0, 2, 4}; | ||
235 | |||
236 | static inline int flash_get_n_segments(void) | ||
237 | { | ||
238 | return model_n_segments[flash_disk.model] * flash_disk.n_chips; | ||
239 | } | ||
240 | |||
241 | static inline int flash_get_n_phblocks(void) | ||
242 | { | ||
243 | return 1024; | ||
244 | } | ||
245 | |||
246 | static int model_n_sectors_in_block[] = {0, 256, 256}; | ||
247 | |||
248 | static int flash_get_n_sectors_in_block(void) | ||
249 | { | ||
250 | return model_n_sectors_in_block[flash_disk.model]; | ||
251 | } | ||
252 | |||
253 | static int flash_phblock_to_sector(int segment, int block) | ||
254 | { | ||
255 | return (segment * flash_get_n_phblocks() + block) | ||
256 | * flash_get_n_sectors_in_block(); | ||
257 | } | ||
258 | |||
259 | static int flash_is_bad_block(unsigned char* oob) | ||
260 | { | ||
261 | /* TODO: should we check two pages? (see datasheet) */ | ||
262 | return oob[0] != 0xff; | ||
263 | } | ||
264 | |||
265 | static int count_1(int n) { | ||
266 | int r = 0; | ||
267 | while (n != 0) { | ||
268 | r += (n & 1); | ||
269 | n >>= 1; | ||
270 | } | ||
271 | return r; | ||
272 | } | ||
273 | |||
274 | static int flash_get_logical_block_no(unsigned char* oob) | ||
275 | { | ||
276 | int no1, no2; | ||
277 | no1 = oob[6] + (oob[7] << 8); | ||
278 | no2 = oob[11] + (oob[12] << 8); | ||
279 | |||
280 | if (no1 == no2 && (no1 & 0xf000) == 0x1000) | ||
281 | return (no1 & 0xfff) >> 1; | ||
282 | |||
283 | if (count_1(no1 ^ no2) > 1) | ||
284 | return -1; | ||
285 | |||
286 | if ((no1 & 0xf000) == 0x1000 | ||
287 | && (count_1(no1) & 1) == 0) | ||
288 | return (no1 & 0xfff) >> 1; | ||
289 | |||
290 | if ((no2 & 0xf000) == 0x1000 | ||
291 | && (count_1(no2) & 1) == 0) | ||
292 | return (no2 & 0xfff) >> 1; | ||
293 | |||
294 | return -1; | ||
295 | } | ||
296 | |||
297 | static int flash_disk_scan(void) | ||
298 | { | ||
299 | int n_segments, n_phblocks; | ||
300 | unsigned char oob[16]; | ||
301 | int s, b; | ||
302 | |||
303 | /* TODO: checking for double blocks */ | ||
304 | |||
305 | n_segments = flash_get_n_segments(); | ||
306 | n_phblocks = flash_get_n_phblocks(); | ||
307 | |||
308 | flash_disk.cur_block = -1; | ||
309 | flash_disk.cur_phblock_start = -1; | ||
310 | |||
311 | for (s = 0; s < n_segments; s++) | ||
312 | { | ||
313 | for (b = 0; b < n_phblocks; b++) | ||
314 | { | ||
315 | int r; | ||
316 | r = flash_read_sector_oob(flash_phblock_to_sector(s, b), | ||
317 | oob); | ||
318 | if (r >= 0 && !flash_is_bad_block(oob)) | ||
319 | { | ||
320 | int lb; | ||
321 | lb = flash_get_logical_block_no(oob); | ||
322 | if (lb >= 0 && lb < SEGMENT_SIZE) | ||
323 | flash_disk.block_map[s][lb] = b; | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static int flash_disk_find_block(int block) | ||
331 | { | ||
332 | int seg, bmod, phb; | ||
333 | unsigned char oob[16]; | ||
334 | int r; | ||
335 | |||
336 | if (block >= SEGMENT_SIZE * flash_get_n_segments()) | ||
337 | return -1; | ||
338 | |||
339 | if (block == flash_disk.cur_block) | ||
340 | return flash_disk.cur_phblock_start; | ||
341 | |||
342 | seg = block / SEGMENT_SIZE; | ||
343 | bmod = block % SEGMENT_SIZE; | ||
344 | |||
345 | phb = flash_disk.block_map[seg][bmod]; | ||
346 | r = flash_read_sector_oob(flash_phblock_to_sector(seg, phb), oob); | ||
347 | if (r < 0) | ||
348 | return -1; | ||
349 | if (flash_is_bad_block(oob)) | ||
350 | return -1; | ||
351 | if (flash_get_logical_block_no(oob) != bmod) | ||
352 | return -1; | ||
353 | |||
354 | flash_disk.cur_block = block; | ||
355 | flash_disk.cur_phblock_start = flash_phblock_to_sector(seg, phb); | ||
356 | return flash_disk.cur_phblock_start; | ||
357 | } | ||
358 | |||
359 | static int flash_disk_read_sectors(unsigned long start, | ||
360 | int count, | ||
361 | void* buf) | ||
362 | { | ||
363 | int block, secmod, done; | ||
364 | int phb; | ||
365 | char oob[16]; | ||
366 | |||
367 | block = start / flash_get_n_sectors_in_block(); | ||
368 | secmod = start % flash_get_n_sectors_in_block(); | ||
369 | |||
370 | phb = flash_disk_find_block(block); | ||
371 | done = 0; | ||
372 | while (count > 0 && secmod < flash_get_n_sectors_in_block()) | ||
373 | { | ||
374 | if (phb >= 0) | ||
375 | flash_read_sector(phb + secmod, buf, oob); | ||
376 | else | ||
377 | memset(buf, 0, SECTOR_SIZE); | ||
378 | |||
379 | buf += SECTOR_SIZE; | ||
380 | count--; | ||
381 | secmod++; | ||
382 | done++; | ||
383 | } | ||
384 | return done; | ||
385 | } | ||
386 | |||
387 | int nand_read_sectors(IF_MD(int drive,) | ||
388 | unsigned long start, | ||
389 | int incount, | ||
390 | void* inbuf) | ||
391 | { | ||
392 | while (incount > 0) | ||
393 | { | ||
394 | int done = flash_disk_read_sectors(start, incount, inbuf); | ||
395 | if (done < 0) | ||
396 | return -1; | ||
397 | start += done; | ||
398 | incount -= done; | ||
399 | inbuf += SECTOR_SIZE * done; | ||
400 | } | ||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | int nand_write_sectors(IF_MD(int drive,) | ||
405 | unsigned long start, | ||
406 | int count, | ||
407 | const void* buf) | ||
408 | { | ||
409 | (void)start; | ||
410 | (void)count; | ||
411 | (void)buf; | ||
412 | return -1; | ||
413 | } | ||
414 | |||
415 | int nand_init(void) | ||
416 | { | ||
417 | int i, id, id2; | ||
418 | |||
419 | id = flash_read_id(0); | ||
420 | switch (id) | ||
421 | { | ||
422 | case 0xda: | ||
423 | flash_disk.model = FLASH_MODEL_256; | ||
424 | break; | ||
425 | case 0xdc: | ||
426 | flash_disk.model = FLASH_MODEL_512; | ||
427 | break; | ||
428 | default: | ||
429 | flash_disk.model = FLASH_MODEL_NONE; | ||
430 | return -1; | ||
431 | } | ||
432 | |||
433 | flash_disk.n_chips = 1; | ||
434 | flash_disk.chip_no[0] = 0; | ||
435 | for (i = 1; i < 4; i++) | ||
436 | { | ||
437 | id2 = flash_read_id(i); | ||
438 | if (id2 == id) | ||
439 | flash_disk.chip_no[flash_disk.n_chips++] = i; | ||
440 | } | ||
441 | |||
442 | if (flash_disk_scan() < 0) | ||
443 | return -2; | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | long nand_last_disk_activity(void) | ||
449 | { | ||
450 | return last_disk_activity; | ||
451 | } | ||
452 | |||
453 | #ifdef STORAGE_GET_INFO | ||
454 | void nand_get_info(struct storage_info *info) | ||
455 | { | ||
456 | unsigned long blocks; | ||
457 | int i; | ||
458 | |||
459 | /* firmware version */ | ||
460 | info->revision="0.00"; | ||
461 | |||
462 | /* vendor field, need better name? */ | ||
463 | info->vendor="Rockbox"; | ||
464 | /* model field, need better name? */ | ||
465 | info->product="TNFL"; | ||
466 | |||
467 | /* blocks count */ | ||
468 | info->num_sectors = 0; | ||
469 | info->sector_size=SECTOR_SIZE; | ||
470 | |||
471 | info->serial=0; | ||
472 | } | ||
473 | #endif | ||
474 | |||
475 | #ifdef CONFIG_STORAGE_MULTI | ||
476 | int nand_num_drives(int first_drive) | ||
477 | { | ||
478 | /* We don't care which logical drive number(s) we have been assigned */ | ||
479 | (void)first_drive; | ||
480 | |||
481 | return 1; | ||
482 | } | ||
483 | #endif | ||
484 | |||
diff --git a/firmware/export/config.h b/firmware/export/config.h index d23abfa086..b758bef49d 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -101,7 +101,6 @@ | |||
101 | #define IPOD_4G_PAD 7 | 101 | #define IPOD_4G_PAD 7 |
102 | #define IPOD_3G_PAD 8 | 102 | #define IPOD_3G_PAD 8 |
103 | #define IPOD_1G2G_PAD 9 | 103 | #define IPOD_1G2G_PAD 9 |
104 | #define IRIVER_IFP7XX_PAD 10 | ||
105 | #define GIGABEAT_PAD 11 | 104 | #define GIGABEAT_PAD 11 |
106 | #define IRIVER_H10_PAD 12 | 105 | #define IRIVER_H10_PAD 12 |
107 | #define SANSA_E200_PAD 13 | 106 | #define SANSA_E200_PAD 13 |
@@ -222,7 +221,6 @@ | |||
222 | #define LCD_IPODVIDEO 8 /* as used by iPod Video */ | 221 | #define LCD_IPODVIDEO 8 /* as used by iPod Video */ |
223 | #define LCD_IPOD2BPP 9 /* as used by all fullsize greyscale iPods */ | 222 | #define LCD_IPOD2BPP 9 /* as used by all fullsize greyscale iPods */ |
224 | #define LCD_IPODMINI 10 /* as used by iPod Mini g1/g2 */ | 223 | #define LCD_IPODMINI 10 /* as used by iPod Mini g1/g2 */ |
225 | #define LCD_IFP7XX 11 /* as used by iRiver iFP 7xx/8xx */ | ||
226 | #define LCD_GIGABEAT 12 | 224 | #define LCD_GIGABEAT 12 |
227 | #define LCD_H10_20GB 13 /* as used by iriver H10 20Gb */ | 225 | #define LCD_H10_20GB 13 /* as used by iriver H10 20Gb */ |
228 | #define LCD_H10_5GB 14 /* as used by iriver H10 5Gb */ | 226 | #define LCD_H10_5GB 14 /* as used by iriver H10 5Gb */ |
@@ -322,7 +320,6 @@ Lyre prototype 1 */ | |||
322 | /* else HW controlled LED (iRiver H1x0) */ | 320 | /* else HW controlled LED (iRiver H1x0) */ |
323 | 321 | ||
324 | /* CONFIG_NAND */ | 322 | /* CONFIG_NAND */ |
325 | #define NAND_IFP7XX 1 | ||
326 | #define NAND_TCC 2 | 323 | #define NAND_TCC 2 |
327 | #define NAND_SAMSUNG 3 | 324 | #define NAND_SAMSUNG 3 |
328 | #define NAND_CC 4 /* ChinaChip */ | 325 | #define NAND_CC 4 /* ChinaChip */ |
@@ -410,8 +407,6 @@ Lyre prototype 1 */ | |||
410 | #include "config/ipodnano2g.h" | 407 | #include "config/ipodnano2g.h" |
411 | #elif defined(IPOD_6G) | 408 | #elif defined(IPOD_6G) |
412 | #include "config/ipod6g.h" | 409 | #include "config/ipod6g.h" |
413 | #elif defined(IRIVER_IFP7XX) | ||
414 | #include "config/iriverifp7xx.h" | ||
415 | #elif defined(GIGABEAT_F) | 410 | #elif defined(GIGABEAT_F) |
416 | #include "config/gigabeatfx.h" | 411 | #include "config/gigabeatfx.h" |
417 | #elif defined(GIGABEAT_S) | 412 | #elif defined(GIGABEAT_S) |
diff --git a/firmware/export/config/iriverifp7xx.h b/firmware/export/config/iriverifp7xx.h deleted file mode 100644 index 0db9a7810d..0000000000 --- a/firmware/export/config/iriverifp7xx.h +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | /* | ||
2 | * This config file is for iriver iFP-799 | ||
3 | */ | ||
4 | |||
5 | #define IRIVER_IFP7XX_SERIES 1 | ||
6 | |||
7 | #define MODEL_NAME "iriver iFP-799" | ||
8 | |||
9 | /* For Rolo and boot loader */ | ||
10 | #define MODEL_NUMBER 6 | ||
11 | |||
12 | /* define this if you have recording possibility */ | ||
13 | /*#define HAVE_RECORDING*/ | ||
14 | |||
15 | |||
16 | |||
17 | |||
18 | /* define this if you would like tagcache to build on this target */ | ||
19 | /* #define HAVE_TAGCACHE */ | ||
20 | |||
21 | /* LCD dimensions */ | ||
22 | #define LCD_WIDTH 128 | ||
23 | #define LCD_HEIGHT 64 | ||
24 | /* sqrt(128^2 + 64^2) / 1.0 = 143.1 */ | ||
25 | #define LCD_DPI 143 | ||
26 | #define LCD_DEPTH 1 | ||
27 | |||
28 | #define LCD_PIXELFORMAT VERTICAL_PACKING | ||
29 | |||
30 | /* Display colours, for screenshots and sim (0xRRGGBB) */ | ||
31 | #define LCD_DARKCOLOR 0x000000 | ||
32 | #define LCD_BRIGHTCOLOR 0x5e6854 | ||
33 | #define LCD_BL_DARKCOLOR 0x000000 | ||
34 | #define LCD_BL_BRIGHTCOLOR 0x3ca0e6 | ||
35 | |||
36 | #define CONFIG_KEYPAD IRIVER_IFP7XX_PAD | ||
37 | |||
38 | #define CONFIG_STORAGE STORAGE_NAND | ||
39 | |||
40 | #define CONFIG_NAND NAND_IFP7XX | ||
41 | |||
42 | #define HAVE_FAT16SUPPORT | ||
43 | |||
44 | |||
45 | |||
46 | |||
47 | /* Define this if you have a software controlled poweroff */ | ||
48 | #define HAVE_SW_POWEROFF | ||
49 | |||
50 | /* The number of bytes reserved for loadable codecs */ | ||
51 | #define CODEC_SIZE 0x38000 | ||
52 | |||
53 | /* The number of bytes reserved for loadable plugins */ | ||
54 | #define PLUGIN_BUFFER_SIZE 0x10000 | ||
55 | |||
56 | /* Define this if you have the WM8975 audio codec */ | ||
57 | /* #define HAVE_WM8975 */ | ||
58 | |||
59 | #define HAVE_LCD_CONTRAST | ||
60 | |||
61 | #define MIN_CONTRAST_SETTING 5 | ||
62 | #define MAX_CONTRAST_SETTING 63 | ||
63 | #define DEFAULT_CONTRAST_SETTING 40 | ||
64 | |||
65 | /* define this if you have a flash memory storage */ | ||
66 | #define HAVE_FLASH_STORAGE | ||
67 | |||
68 | #define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */ | ||
69 | #define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */ | ||
70 | #define BATTERY_CAPACITY_MAX 2800 /* max. capacity selectable */ | ||
71 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | ||
72 | #define BATTERY_TYPES_COUNT 2 /* Alkalines or NiMH */ | ||
73 | |||
74 | #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE | ||
75 | |||
76 | /* define this if the unit should not shut down on low battery. */ | ||
77 | #define NO_LOW_BATTERY_SHUTDOWN | ||
78 | |||
79 | /* Define this if you have a Philips PNX0101 */ | ||
80 | #define CONFIG_CPU PNX0101 | ||
81 | |||
82 | /* Define this if you want to use the PNX0101 i2c interface */ | ||
83 | #define CONFIG_I2C I2C_PNX0101 | ||
84 | |||
85 | /* The start address index for ROM builds */ | ||
86 | #define ROM_START 0x00000000 | ||
87 | |||
88 | /* Define this for LCD backlight available */ | ||
89 | #define HAVE_BACKLIGHT | ||
90 | |||
91 | /* Define this to the CPU frequency */ | ||
92 | #define CPU_FREQ 48000000 | ||
93 | |||
94 | #define CONFIG_LCD LCD_IFP7XX | ||
95 | |||
96 | /* Offset ( in the firmware file's header ) to the file length */ | ||
97 | #define FIRMWARE_OFFSET_FILE_LENGTH 0 | ||
98 | |||
99 | /* Offset ( in the firmware file's header ) to the file CRC */ | ||
100 | #define FIRMWARE_OFFSET_FILE_CRC 0 | ||
101 | |||
102 | /* Offset ( in the firmware file's header ) to the real data */ | ||
103 | #define FIRMWARE_OFFSET_FILE_DATA 8 | ||
104 | |||
105 | #define USB_ISP1582 | ||
106 | |||
107 | #define HAVE_GDB_API | ||
108 | |||
109 | /* Define this if you have adjustable CPU frequency */ | ||
110 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
111 | |||
112 | #define BOOTFILE_EXT "iriver" | ||
113 | #define BOOTFILE "rockbox." BOOTFILE_EXT | ||
114 | #define BOOTDIR "/.rockbox" | ||
115 | |||
116 | #define IBSS_ATTR_VOICE_STACK | ||
117 | #define ICODE_ATTR_TREMOR_NOT_MDCT | ||
118 | #define ICODE_ATTR_TREMOR_MDCT | ||
119 | #define ICODE_ATTR_FLAC | ||
120 | #define IBSS_ATTR_FLAC_DECODED0 | ||
121 | #define ICONST_ATTR_MPA_HUFFMAN | ||
122 | #define IBSS_ATTR_MPC_SAMPLE_BUF | ||
123 | #define ICODE_ATTR_ALAC | ||
124 | #define IBSS_ATTR_SHORTEN_DECODED0 | ||
125 | |||
126 | #define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */ | ||
127 | |||
128 | /* Define this if a programmable hotkey is mapped */ | ||
129 | #define HAVE_HOTKEY | ||
diff --git a/firmware/export/gdb_api.h b/firmware/export/gdb_api.h index 1836c5992e..d2358ee3bb 100644 --- a/firmware/export/gdb_api.h +++ b/firmware/export/gdb_api.h | |||
@@ -25,9 +25,6 @@ | |||
25 | #include "config.h" | 25 | #include "config.h" |
26 | 26 | ||
27 | #define GDB_API_MAGIC 0x6db570b | 27 | #define GDB_API_MAGIC 0x6db570b |
28 | #ifdef IRIVER_IFP7XX_SERIES | ||
29 | #define GDB_API_ADDRESS 0xc06000 | ||
30 | #endif | ||
31 | 28 | ||
32 | struct gdb_api | 29 | struct gdb_api |
33 | { | 30 | { |
diff --git a/firmware/export/ifp_usb_serial.h b/firmware/export/ifp_usb_serial.h deleted file mode 100644 index b56e5fff86..0000000000 --- a/firmware/export/ifp_usb_serial.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _USB_SERIAL_H_ | ||
22 | #define _USB_SERIAL_H_ | ||
23 | |||
24 | void usb_serial_init(void); | ||
25 | void usb_serial_put_byte(int b); | ||
26 | int usb_serial_get_byte(void); | ||
27 | int usb_serial_try_put_byte(int b); | ||
28 | int usb_serial_try_get_byte(void); | ||
29 | |||
30 | #endif | ||
diff --git a/firmware/ifp_usb_serial.c b/firmware/ifp_usb_serial.c deleted file mode 100644 index f7e3a51858..0000000000 --- a/firmware/ifp_usb_serial.c +++ /dev/null | |||
@@ -1,1121 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | /* | ||
23 | #define LCD_DEBUG | ||
24 | #define BUTTONS | ||
25 | */ | ||
26 | |||
27 | /* #include "config.h" */ | ||
28 | #include <stdlib.h> | ||
29 | #include "pnx0101.h" | ||
30 | #include "ifp_usb_serial.h" | ||
31 | |||
32 | #ifdef BUTTONS | ||
33 | #include "kernel.h" | ||
34 | #include "button.h" | ||
35 | #include "system.h" | ||
36 | #endif | ||
37 | |||
38 | #ifdef LCD_DEBUG | ||
39 | #include "lcd.h" | ||
40 | #endif | ||
41 | |||
42 | |||
43 | #define ISP1582_BASE (0x24100000) | ||
44 | #define ISP1582_ADDRESS (*(volatile unsigned char *)ISP1582_BASE) | ||
45 | #define ISP1582_MODE (*(volatile unsigned short *)(ISP1582_BASE + 0xc)) | ||
46 | #define ISP1582_INTCONF (*(volatile unsigned char *)(ISP1582_BASE + 0x10)) | ||
47 | #define ISP1582_OTG (*(volatile unsigned char *)(ISP1582_BASE + 0x12)) | ||
48 | #define ISP1582_INTEN (*(volatile unsigned long *)(ISP1582_BASE + 0x14)) | ||
49 | |||
50 | #define ISP1582_EPINDEX (*(volatile unsigned char *)(ISP1582_BASE + 0x2c)) | ||
51 | #define ISP1582_CTRLFUN (*(volatile unsigned char *)(ISP1582_BASE + 0x28)) | ||
52 | #define ISP1582_DATA (*(volatile unsigned short *)(ISP1582_BASE + 0x20)) | ||
53 | #define ISP1582_BUFLEN (*(volatile unsigned short *)(ISP1582_BASE + 0x1c)) | ||
54 | #define ISP1582_BUFSTAT (*(volatile unsigned char *)(ISP1582_BASE + 0x1e)) | ||
55 | #define ISP1582_MAXPKSZ (*(volatile unsigned short *)(ISP1582_BASE + 0x04)) | ||
56 | #define ISP1582_EPTYPE (*(volatile unsigned short *)(ISP1582_BASE + 0x08)) | ||
57 | |||
58 | #define ISP1582_INT (*(volatile unsigned long *)(ISP1582_BASE + 0x18)) | ||
59 | #define ISP1582_CHIPID (*(volatile unsigned long *)(ISP1582_BASE + 0x70)) | ||
60 | #define ISP1582_FRAMENO (*(volatile unsigned short *)(ISP1582_BASE + 0x74)) | ||
61 | #define ISP1582_UNLOCK (*(volatile unsigned short *)(ISP1582_BASE + 0x7c)) | ||
62 | |||
63 | #define ISP1582_UNLOCK_CODE 0xaa37 | ||
64 | |||
65 | #define TYPE_BULK 2 | ||
66 | |||
67 | #define STATE_DEFAULT 0 | ||
68 | #define STATE_ADDRESS 1 | ||
69 | #define STATE_CONFIGURED 2 | ||
70 | |||
71 | #define N_ENDPOINTS 2 | ||
72 | |||
73 | struct usb_endpoint | ||
74 | { | ||
75 | unsigned char *out_buf; | ||
76 | short out_len; | ||
77 | short out_ptr; | ||
78 | void (*out_done)(int, unsigned char *, int); | ||
79 | unsigned char out_in_progress; | ||
80 | |||
81 | unsigned char *in_buf; | ||
82 | short in_min_len; | ||
83 | short in_max_len; | ||
84 | short in_ptr; | ||
85 | void (*in_done)(int, unsigned char *, int); | ||
86 | unsigned char in_ack; | ||
87 | |||
88 | unsigned char halt[2]; | ||
89 | unsigned char enabled[2]; | ||
90 | short max_pkt_size[2]; | ||
91 | }; | ||
92 | |||
93 | static char usb_connect_state; | ||
94 | |||
95 | static struct usb_endpoint endpoints[N_ENDPOINTS]; | ||
96 | |||
97 | static unsigned char setup_pkt_buf[8]; | ||
98 | static unsigned char setup_out_buf[8]; | ||
99 | static unsigned char usb_state; | ||
100 | static unsigned char usb_remote_wakeup; | ||
101 | |||
102 | #ifdef LCD_DEBUG | ||
103 | static unsigned char int_count[32]; | ||
104 | |||
105 | static int log_pos_x = 0; | ||
106 | static int log_pos_y = 3; | ||
107 | #endif | ||
108 | |||
109 | static void nop_f(void) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | #ifdef LCD_DEBUG | ||
114 | static void log_char(char c) | ||
115 | { | ||
116 | char s[2]; | ||
117 | |||
118 | s[0] = c; | ||
119 | s[1] = 0; | ||
120 | |||
121 | lcd_puts(log_pos_x, log_pos_y, s); | ||
122 | lcd_update(); | ||
123 | log_pos_x++; | ||
124 | if (log_pos_x >= 16) | ||
125 | { | ||
126 | log_pos_x = 0; | ||
127 | log_pos_y++; | ||
128 | if (log_pos_y > 5) | ||
129 | log_pos_y = 3; | ||
130 | } | ||
131 | } | ||
132 | #else | ||
133 | #define log_char(c) | ||
134 | #endif | ||
135 | |||
136 | #define SERIAL_BUF_SIZE 1024 | ||
137 | |||
138 | struct serial_fifo | ||
139 | { | ||
140 | unsigned char buf[SERIAL_BUF_SIZE]; | ||
141 | short head, tail; | ||
142 | }; | ||
143 | |||
144 | static struct serial_fifo serial_in_fifo; | ||
145 | static struct serial_fifo serial_out_fifo; | ||
146 | static unsigned char serial_in_pkt[64]; | ||
147 | |||
148 | static unsigned char device_descriptor[18] = { | ||
149 | 0x12, /* length */ | ||
150 | 0x01, /* descriptor type */ | ||
151 | 0x10, 0x01, /* USB version (1.1) */ | ||
152 | 0xff, 0xff, /* class and subclass */ | ||
153 | 0xff, /* protocol */ | ||
154 | 0x40, /* max packet size 0 */ | ||
155 | 0x02, 0x41, /* vendor (iRiver) */ | ||
156 | 0x07, 0xee, /* product (0xee07) */ | ||
157 | 0x01, 0x00, /* device version */ | ||
158 | 0x01, /* manufacturer string */ | ||
159 | 0x02, /* product string */ | ||
160 | 0x00, /* serial number string */ | ||
161 | 0x01 /* number of configurations */ | ||
162 | }; | ||
163 | |||
164 | static unsigned char cfg_descriptor[32] = { | ||
165 | 0x09, /* length */ | ||
166 | 0x02, /* descriptor type */ | ||
167 | 0x20, 0x00, /* total length */ | ||
168 | 0x01, /* number of interfaces */ | ||
169 | 0x01, /* configuration value */ | ||
170 | 0x00, /* configuration string */ | ||
171 | 0x80, /* attributes (none) */ | ||
172 | 0x32, /* max power (100 mA) */ | ||
173 | /* interface descriptor */ | ||
174 | 0x09, /* length */ | ||
175 | 0x04, /* descriptor type */ | ||
176 | 0x00, /* interface number */ | ||
177 | 0x00, /* alternate setting */ | ||
178 | 0x02, /* number of endpoints */ | ||
179 | 0xff, /* interface class */ | ||
180 | 0xff, /* interface subclass */ | ||
181 | 0xff, /* interface protocol */ | ||
182 | 0x00, /* interface string */ | ||
183 | /* endpoint IN */ | ||
184 | 0x07, /* length */ | ||
185 | 0x05, /* descriptor type */ | ||
186 | 0x81, /* endpoint 1 IN */ | ||
187 | 0x02, /* attributes (bulk) */ | ||
188 | 0x40, 0x00, /* max packet size */ | ||
189 | 0x00, /* interval */ | ||
190 | /* endpoint OUT */ | ||
191 | 0x07, /* length */ | ||
192 | 0x05, /* descriptor type */ | ||
193 | 0x01, /* endpoint 1 IN */ | ||
194 | 0x02, /* attributes (bulk) */ | ||
195 | 0x40, 0x00, /* max packet size */ | ||
196 | 0x00 /* interval */ | ||
197 | }; | ||
198 | |||
199 | static unsigned char lang_descriptor[4] = { | ||
200 | 0x04, /* length */ | ||
201 | 0x03, /* descriptor type */ | ||
202 | 0x09, 0x04 /* English (US) */ | ||
203 | }; | ||
204 | |||
205 | #define N_STRING_DESCRIPTORS 2 | ||
206 | |||
207 | static unsigned char string_descriptor_vendor[] = { | ||
208 | 0x2e, 0x03, | ||
209 | 'i', 0, 'R', 0, 'i', 0, 'v', 0, 'e', 0, 'r', 0, ' ', 0, 'L', 0, | ||
210 | 't', 0, 'd', 0, ' ', 0, 'a', 0, 'n', 0, 'd', 0, ' ', 0, 'R', 0, | ||
211 | 'o', 0, 'c', 0, 'k', 0, 'b', 0, 'o', 0, 'x', 0}; | ||
212 | |||
213 | static unsigned char string_descriptor_product[] = { | ||
214 | 0x1c, 0x03, | ||
215 | 'i', 0, 'R', 0, 'i', 0, 'v', 0, 'e', 0, 'r', 0, ' ', 0, 'i', 0, | ||
216 | 'F', 0, 'P', 0, '7', 0, '0', 0, '0', 0}; | ||
217 | |||
218 | static unsigned char *string_descriptor[N_STRING_DESCRIPTORS] = { | ||
219 | string_descriptor_vendor, | ||
220 | string_descriptor_product | ||
221 | }; | ||
222 | |||
223 | static inline int ep_index(int n, int dir) | ||
224 | { | ||
225 | return (n << 1) | dir; | ||
226 | } | ||
227 | |||
228 | static inline int epidx_dir(int idx) | ||
229 | { | ||
230 | return idx & 1; | ||
231 | } | ||
232 | |||
233 | static inline int epidx_n(int idx) | ||
234 | { | ||
235 | return idx >> 1; | ||
236 | } | ||
237 | |||
238 | int usb_connected(void) | ||
239 | { | ||
240 | return GPIO7_READ & 1; | ||
241 | } | ||
242 | |||
243 | static inline void usb_select_endpoint(int idx) | ||
244 | { | ||
245 | ISP1582_EPINDEX = idx; | ||
246 | } | ||
247 | |||
248 | static inline void usb_select_setup_endpoint(void) | ||
249 | { | ||
250 | ISP1582_EPINDEX = 0x20; | ||
251 | } | ||
252 | |||
253 | static void usb_setup_endpoint(int idx, int max_pkt_size, int type) | ||
254 | { | ||
255 | struct usb_endpoint *ep; | ||
256 | |||
257 | usb_select_endpoint(idx); | ||
258 | ISP1582_MAXPKSZ = max_pkt_size; | ||
259 | /* |= is in the original firmware */ | ||
260 | ISP1582_EPTYPE |= 0x1c | type; | ||
261 | /* clear buffer */ | ||
262 | ISP1582_CTRLFUN |= 0x10; | ||
263 | ISP1582_INTEN |= (1 << (10 + idx)); | ||
264 | |||
265 | ep = &(endpoints[epidx_n(idx)]); | ||
266 | ep->halt[epidx_dir(idx)] = 0; | ||
267 | ep->enabled[epidx_dir(idx)] = 1; | ||
268 | ep->out_in_progress = 0; | ||
269 | ep->in_min_len = -1; | ||
270 | ep->in_ack = 0; | ||
271 | ep->max_pkt_size[epidx_dir(idx)] = max_pkt_size; | ||
272 | } | ||
273 | |||
274 | static void usb_disable_endpoint(int idx) | ||
275 | { | ||
276 | usb_select_endpoint(idx); | ||
277 | ISP1582_EPTYPE &= 8; | ||
278 | ISP1582_INTEN &= ~(1 << (10 + idx)); | ||
279 | endpoints[epidx_n(idx)].enabled[epidx_dir(idx)] = 1; | ||
280 | } | ||
281 | |||
282 | void usb_reconnect(void) | ||
283 | { | ||
284 | int i; | ||
285 | ISP1582_MODE &= ~1; /* SOFTCT off */ | ||
286 | for (i = 0; i < 10000; i++) | ||
287 | nop_f(); | ||
288 | ISP1582_MODE |= 1; /* SOFTCT on */ | ||
289 | } | ||
290 | |||
291 | static void usb_cleanup(void) | ||
292 | { | ||
293 | ISP1582_MODE &= ~1; /* SOFTCT off */ | ||
294 | } | ||
295 | |||
296 | static void usb_setup(int reset) | ||
297 | { | ||
298 | int i; | ||
299 | |||
300 | for (i = 0; i < N_ENDPOINTS; i++) | ||
301 | endpoints[i].enabled[0] = endpoints[i].enabled[1] = 0; | ||
302 | |||
303 | ISP1582_UNLOCK = ISP1582_UNLOCK_CODE; | ||
304 | if (!reset) | ||
305 | ISP1582_MODE = 0x88; /* CLKAON | GLINTENA */ | ||
306 | ISP1582_INTCONF = 0x57; | ||
307 | ISP1582_INTEN = 0xd39; | ||
308 | |||
309 | ISP1582_ADDRESS = reset ? 0x80: 0; | ||
310 | |||
311 | usb_setup_endpoint(ep_index(0, DIR_RX), 64, 0); | ||
312 | usb_setup_endpoint(ep_index(0, DIR_TX), 64, 0); | ||
313 | |||
314 | ISP1582_MODE |= 1; /* SOFTCT on */ | ||
315 | |||
316 | usb_state = STATE_DEFAULT; | ||
317 | usb_remote_wakeup = 0; | ||
318 | } | ||
319 | |||
320 | static int usb_get_packet(unsigned char *buf, int max_len) | ||
321 | { | ||
322 | int len, i; | ||
323 | len = ISP1582_BUFLEN; | ||
324 | |||
325 | if (max_len < 0 || max_len > len) | ||
326 | max_len = len; | ||
327 | |||
328 | i = 0; | ||
329 | while (i < len) | ||
330 | { | ||
331 | unsigned short d = ISP1582_DATA; | ||
332 | if (i < max_len) | ||
333 | buf[i] = d & 0xff; | ||
334 | i++; | ||
335 | if (i < max_len) | ||
336 | buf[i] = (d >> 8) & 0xff; | ||
337 | i++; | ||
338 | } | ||
339 | return max_len; | ||
340 | } | ||
341 | |||
342 | static void usb_receive(int n) | ||
343 | { | ||
344 | int len; | ||
345 | |||
346 | if (endpoints[n].halt[DIR_RX] | ||
347 | || !endpoints[n].enabled[DIR_RX] | ||
348 | || endpoints[n].in_min_len < 0 | ||
349 | || !endpoints[n].in_ack) | ||
350 | return; | ||
351 | |||
352 | endpoints[n].in_ack = 0; | ||
353 | |||
354 | usb_select_endpoint(ep_index(n, DIR_RX)); | ||
355 | |||
356 | len = usb_get_packet(endpoints[n].in_buf + endpoints[n].in_ptr, | ||
357 | endpoints[n].in_max_len - endpoints[n].in_ptr); | ||
358 | endpoints[n].in_ptr += len; | ||
359 | if (endpoints[n].in_ptr >= endpoints[n].in_min_len) { | ||
360 | endpoints[n].in_min_len = -1; | ||
361 | if (endpoints[n].in_done) | ||
362 | (*(endpoints[n].in_done))(n, endpoints[n].in_buf, | ||
363 | endpoints[n].in_ptr); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | static int usb_out_buffer_full(int ep) | ||
368 | { | ||
369 | usb_select_endpoint(ep_index(ep, DIR_TX)); | ||
370 | if (ISP1582_EPTYPE & 4) | ||
371 | return (ISP1582_BUFSTAT & 3) == 3; | ||
372 | else | ||
373 | return (ISP1582_BUFSTAT & 3) != 0; | ||
374 | } | ||
375 | |||
376 | static void usb_send(int n) | ||
377 | { | ||
378 | int max_pkt_size, len; | ||
379 | int i; | ||
380 | unsigned char *p; | ||
381 | |||
382 | #ifdef LCD_DEBUG | ||
383 | if (endpoints[n].halt[DIR_TX]) | ||
384 | log_char('H'); | ||
385 | if (!endpoints[n].out_in_progress) | ||
386 | log_char('$'); | ||
387 | #endif | ||
388 | |||
389 | if (endpoints[n].halt[DIR_TX] | ||
390 | || !endpoints[n].enabled[DIR_TX] | ||
391 | || !endpoints[n].out_in_progress) | ||
392 | return; | ||
393 | |||
394 | if (endpoints[n].out_ptr < 0) | ||
395 | { | ||
396 | endpoints[n].out_in_progress = 0; | ||
397 | if (endpoints[n].out_done) | ||
398 | (*(endpoints[n].out_done))(n, endpoints[n].out_buf, | ||
399 | endpoints[n].out_len); | ||
400 | return; | ||
401 | } | ||
402 | |||
403 | if (usb_out_buffer_full(n)) | ||
404 | { | ||
405 | log_char('F'); | ||
406 | return; | ||
407 | } | ||
408 | |||
409 | usb_select_endpoint(ep_index(n, DIR_TX)); | ||
410 | max_pkt_size = endpoints[n].max_pkt_size[DIR_TX]; | ||
411 | len = endpoints[n].out_len - endpoints[n].out_ptr; | ||
412 | if (len > max_pkt_size) | ||
413 | len = max_pkt_size; | ||
414 | |||
415 | log_char('0' + (len % 10)); | ||
416 | ISP1582_BUFLEN = len; | ||
417 | p = endpoints[n].out_buf + endpoints[n].out_ptr; | ||
418 | i = 0; | ||
419 | while (len - i >= 2) { | ||
420 | ISP1582_DATA = p[i] | (p[i + 1] << 8); | ||
421 | i += 2; | ||
422 | } | ||
423 | if (i < len) | ||
424 | ISP1582_DATA = p[i]; | ||
425 | |||
426 | endpoints[n].out_ptr += len; | ||
427 | |||
428 | /* | ||
429 | if (endpoints[n].out_ptr == endpoints[n].out_len | ||
430 | && len < max_pkt_size) | ||
431 | */ | ||
432 | if (endpoints[n].out_ptr == endpoints[n].out_len) | ||
433 | endpoints[n].out_ptr = -1; | ||
434 | } | ||
435 | |||
436 | static void usb_stall_endpoint(int idx) | ||
437 | { | ||
438 | usb_select_endpoint(idx); | ||
439 | ISP1582_CTRLFUN |= 1; | ||
440 | endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 1; | ||
441 | } | ||
442 | |||
443 | static void usb_unstall_endpoint(int idx) | ||
444 | { | ||
445 | usb_select_endpoint(idx); | ||
446 | ISP1582_CTRLFUN &= ~1; | ||
447 | ISP1582_EPTYPE &= ~8; | ||
448 | ISP1582_EPTYPE |= 8; | ||
449 | ISP1582_CTRLFUN |= 0x10; | ||
450 | if (epidx_dir(idx) == DIR_TX) | ||
451 | endpoints[epidx_n(idx)].out_in_progress = 0; | ||
452 | else | ||
453 | { | ||
454 | endpoints[epidx_n(idx)].in_min_len = -1; | ||
455 | endpoints[epidx_n(idx)].in_ack = 0; | ||
456 | } | ||
457 | endpoints[epidx_n(idx)].halt[epidx_dir(idx)] = 0; | ||
458 | } | ||
459 | |||
460 | static void usb_status_ack(int dir) | ||
461 | { | ||
462 | log_char(dir ? '@' : '#'); | ||
463 | usb_select_endpoint(ep_index(0, dir)); | ||
464 | ISP1582_CTRLFUN |= 2; | ||
465 | } | ||
466 | |||
467 | static void usb_set_address(int adr) | ||
468 | { | ||
469 | ISP1582_ADDRESS = adr | 0x80; | ||
470 | } | ||
471 | |||
472 | static void usb_data_stage_enable(int dir) | ||
473 | { | ||
474 | usb_select_endpoint(ep_index(0, dir)); | ||
475 | ISP1582_CTRLFUN |= 4; | ||
476 | } | ||
477 | |||
478 | static void usb_request_error(void) | ||
479 | { | ||
480 | usb_stall_endpoint(ep_index(0, DIR_TX)); | ||
481 | usb_stall_endpoint(ep_index(0, DIR_RX)); | ||
482 | } | ||
483 | |||
484 | static void usb_receive_block(unsigned char *buf, int min_len, | ||
485 | int max_len, | ||
486 | void (*in_done)(int, unsigned char *, int), | ||
487 | int ep) | ||
488 | { | ||
489 | endpoints[ep].in_done = in_done; | ||
490 | endpoints[ep].in_buf = buf; | ||
491 | endpoints[ep].in_max_len = max_len; | ||
492 | endpoints[ep].in_min_len = min_len; | ||
493 | endpoints[ep].in_ptr = 0; | ||
494 | usb_receive(ep); | ||
495 | } | ||
496 | |||
497 | static void usb_send_block(unsigned char *buf, int len, | ||
498 | void (*done)(int, unsigned char *, int), | ||
499 | int ep) | ||
500 | { | ||
501 | endpoints[ep].out_done = done; | ||
502 | endpoints[ep].out_buf = buf; | ||
503 | endpoints[ep].out_len = len; | ||
504 | endpoints[ep].out_ptr = 0; | ||
505 | endpoints[ep].out_in_progress = 1; | ||
506 | usb_send(ep); | ||
507 | } | ||
508 | |||
509 | static void out_send_status(int n, unsigned char *buf, int len) | ||
510 | { | ||
511 | (void)n; | ||
512 | (void)buf; | ||
513 | (void)len; | ||
514 | usb_status_ack(DIR_RX); | ||
515 | } | ||
516 | |||
517 | static void usb_send_block_and_status(unsigned char *buf, int len, int ep) | ||
518 | { | ||
519 | usb_send_block(buf, len, out_send_status, ep); | ||
520 | } | ||
521 | |||
522 | static void usb_setup_set_address(int adr) | ||
523 | { | ||
524 | usb_set_address(adr); | ||
525 | usb_state = adr ? STATE_ADDRESS : STATE_DEFAULT; | ||
526 | usb_status_ack(DIR_TX); | ||
527 | } | ||
528 | |||
529 | static void usb_send_descriptor(unsigned char *device_descriptor, | ||
530 | int descriptor_len, int buffer_len) | ||
531 | { | ||
532 | int len = descriptor_len < buffer_len ? descriptor_len : buffer_len; | ||
533 | usb_send_block_and_status(device_descriptor, len, 0); | ||
534 | } | ||
535 | |||
536 | static void usb_setup_get_descriptor(int type, int index, int lang, int len) | ||
537 | { | ||
538 | (void)lang; | ||
539 | usb_data_stage_enable(DIR_TX); | ||
540 | switch (type) | ||
541 | { | ||
542 | case 1: | ||
543 | if (index == 0) | ||
544 | usb_send_descriptor(device_descriptor, | ||
545 | sizeof(device_descriptor), len); | ||
546 | else | ||
547 | usb_request_error(); | ||
548 | break; | ||
549 | case 2: | ||
550 | if (index == 0) | ||
551 | usb_send_descriptor(cfg_descriptor, | ||
552 | sizeof(cfg_descriptor), len); | ||
553 | else | ||
554 | usb_request_error(); | ||
555 | break; | ||
556 | case 3: | ||
557 | if (index == 0) | ||
558 | usb_send_descriptor(lang_descriptor, | ||
559 | sizeof(lang_descriptor), len); | ||
560 | else if (index <= N_STRING_DESCRIPTORS) | ||
561 | usb_send_descriptor(string_descriptor[index - 1], | ||
562 | string_descriptor[index - 1][0], | ||
563 | len); | ||
564 | else | ||
565 | usb_request_error(); | ||
566 | break; | ||
567 | default: | ||
568 | usb_request_error(); | ||
569 | } | ||
570 | } | ||
571 | |||
572 | static void usb_setup_get_configuration(void) | ||
573 | { | ||
574 | setup_out_buf[0] = (usb_state == STATE_CONFIGURED) ? 1 : 0; | ||
575 | usb_data_stage_enable(DIR_TX); | ||
576 | usb_send_block_and_status(setup_out_buf, 1, 0); | ||
577 | } | ||
578 | |||
579 | static void usb_setup_interface(void) | ||
580 | { | ||
581 | usb_setup_endpoint(ep_index(1, DIR_RX), 64, TYPE_BULK); | ||
582 | usb_setup_endpoint(ep_index(1, DIR_TX), 64, TYPE_BULK); | ||
583 | } | ||
584 | |||
585 | static void usb_setup_set_configuration(int value) | ||
586 | { | ||
587 | switch (value) | ||
588 | { | ||
589 | case 0: | ||
590 | usb_disable_endpoint(ep_index(1, DIR_RX)); | ||
591 | usb_disable_endpoint(ep_index(1, DIR_TX)); | ||
592 | usb_state = STATE_ADDRESS; | ||
593 | usb_status_ack(DIR_TX); | ||
594 | break; | ||
595 | case 1: | ||
596 | usb_setup_interface(); | ||
597 | usb_state = STATE_CONFIGURED; | ||
598 | usb_status_ack(DIR_TX); | ||
599 | break; | ||
600 | default: | ||
601 | usb_request_error(); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | static void usb_send_status(void) | ||
606 | { | ||
607 | usb_data_stage_enable(DIR_TX); | ||
608 | usb_send_block_and_status(setup_out_buf, 2, 0); | ||
609 | } | ||
610 | |||
611 | static void usb_setup_get_device_status(void) | ||
612 | { | ||
613 | setup_out_buf[0] = (usb_remote_wakeup != 0) ? 2 : 0; | ||
614 | setup_out_buf[1] = 0; | ||
615 | usb_send_status(); | ||
616 | } | ||
617 | |||
618 | static void usb_setup_clear_device_feature(int feature) | ||
619 | { | ||
620 | if (feature == 1) { | ||
621 | usb_remote_wakeup = 0; | ||
622 | usb_status_ack(DIR_TX); | ||
623 | } else | ||
624 | usb_request_error(); | ||
625 | } | ||
626 | |||
627 | static void usb_setup_set_device_feature(int feature) | ||
628 | { | ||
629 | if (feature == 1) { | ||
630 | usb_remote_wakeup = 1; | ||
631 | usb_status_ack(DIR_TX); | ||
632 | } else | ||
633 | usb_request_error(); | ||
634 | } | ||
635 | |||
636 | static void usb_setup_clear_endpoint_feature(int endpoint, int feature) | ||
637 | { | ||
638 | if (usb_state != STATE_CONFIGURED || feature != 0) | ||
639 | usb_request_error(); | ||
640 | else if ((endpoint & 0xf) == 1) | ||
641 | { | ||
642 | usb_unstall_endpoint(ep_index(endpoint & 0xf, endpoint >> 7)); | ||
643 | usb_status_ack(DIR_TX); | ||
644 | } | ||
645 | else | ||
646 | usb_request_error(); | ||
647 | } | ||
648 | |||
649 | static void usb_setup_set_endpoint_feature(int endpoint, int feature) | ||
650 | { | ||
651 | if (usb_state != STATE_CONFIGURED || feature != 0) | ||
652 | usb_request_error(); | ||
653 | else if ((endpoint & 0xf) == 1) | ||
654 | { | ||
655 | usb_stall_endpoint(ep_index(endpoint & 0xf, endpoint >> 7)); | ||
656 | usb_status_ack(DIR_TX); | ||
657 | } | ||
658 | else | ||
659 | usb_request_error(); | ||
660 | } | ||
661 | |||
662 | static void usb_setup_get_interface_status(int interface) | ||
663 | { | ||
664 | if (usb_state != STATE_CONFIGURED || interface != 0) | ||
665 | usb_request_error(); | ||
666 | else | ||
667 | { | ||
668 | setup_out_buf[0] = setup_out_buf[1] = 0; | ||
669 | usb_send_status(); | ||
670 | } | ||
671 | } | ||
672 | |||
673 | static void usb_setup_get_endpoint_status(int endpoint) | ||
674 | { | ||
675 | if ((usb_state == STATE_CONFIGURED && (endpoint & 0xf) <= 1) | ||
676 | || (usb_state == STATE_ADDRESS && (endpoint & 0xf) == 0)) | ||
677 | { | ||
678 | setup_out_buf[0] = endpoints[endpoint & 0xf].halt[endpoint >> 7]; | ||
679 | setup_out_buf[1] = 0; | ||
680 | usb_send_status(); | ||
681 | } | ||
682 | else | ||
683 | usb_request_error(); | ||
684 | } | ||
685 | |||
686 | static void usb_setup_get_interface(int interface) | ||
687 | { | ||
688 | if (usb_state != STATE_CONFIGURED || interface != 0) | ||
689 | usb_request_error(); | ||
690 | else | ||
691 | { | ||
692 | setup_out_buf[0] = 0; | ||
693 | usb_data_stage_enable(DIR_TX); | ||
694 | usb_send_block_and_status(setup_out_buf, 1, 0); | ||
695 | } | ||
696 | } | ||
697 | |||
698 | static void usb_setup_set_interface(int interface, int setting) | ||
699 | { | ||
700 | if (usb_state != STATE_CONFIGURED || interface != 0 || setting != 0) | ||
701 | usb_request_error(); | ||
702 | else | ||
703 | { | ||
704 | usb_setup_interface(); | ||
705 | usb_status_ack(DIR_TX); | ||
706 | } | ||
707 | } | ||
708 | |||
709 | static void usb_handle_setup_pkt(unsigned char *pkt) | ||
710 | { | ||
711 | switch ((pkt[0] << 8) | pkt[1]) | ||
712 | { | ||
713 | case 0x0005: | ||
714 | log_char('A'); | ||
715 | usb_setup_set_address(pkt[2]); | ||
716 | break; | ||
717 | case 0x8006: | ||
718 | log_char('D'); | ||
719 | usb_setup_get_descriptor(pkt[3], pkt[2], (pkt[5] << 8) | pkt[4], | ||
720 | (pkt[7] << 8) | pkt[6]); | ||
721 | break; | ||
722 | case 0x8008: | ||
723 | usb_setup_get_configuration(); | ||
724 | break; | ||
725 | case 0x0009: | ||
726 | usb_setup_set_configuration(pkt[2]); | ||
727 | break; | ||
728 | case 0x8000: | ||
729 | usb_setup_get_device_status(); | ||
730 | break; | ||
731 | case 0x8100: | ||
732 | usb_setup_get_interface_status(pkt[4]); | ||
733 | break; | ||
734 | case 0x8200: | ||
735 | usb_setup_get_endpoint_status(pkt[4]); | ||
736 | break; | ||
737 | case 0x0001: | ||
738 | usb_setup_clear_device_feature(pkt[2]); | ||
739 | break; | ||
740 | case 0x0201: | ||
741 | usb_setup_clear_endpoint_feature(pkt[4], pkt[2]); | ||
742 | break; | ||
743 | case 0x0003: | ||
744 | usb_setup_set_device_feature(pkt[2]); | ||
745 | break; | ||
746 | case 0x0203: | ||
747 | usb_setup_set_endpoint_feature(pkt[4], pkt[2]); | ||
748 | break; | ||
749 | case 0x810a: | ||
750 | usb_setup_get_interface(pkt[4]); | ||
751 | break; | ||
752 | case 0x010b: | ||
753 | usb_setup_set_interface(pkt[4], pkt[2]); | ||
754 | break; | ||
755 | case 0x0103: | ||
756 | /* set interface feature */ | ||
757 | case 0x0101: | ||
758 | /* clear interface feature */ | ||
759 | case 0x0007: | ||
760 | /* set descriptor */ | ||
761 | case 0x820c: | ||
762 | /* synch frame */ | ||
763 | default: | ||
764 | usb_request_error(); | ||
765 | } | ||
766 | } | ||
767 | |||
768 | static void usb_handle_setup_rx(void) | ||
769 | { | ||
770 | int len; | ||
771 | #ifdef LCD_DEBUG | ||
772 | char s[20]; | ||
773 | int i; | ||
774 | #endif | ||
775 | usb_select_setup_endpoint(); | ||
776 | len = usb_get_packet(setup_pkt_buf, 8); | ||
777 | |||
778 | if (len == 8) | ||
779 | usb_handle_setup_pkt(setup_pkt_buf); | ||
780 | |||
781 | #ifdef LCD_DEBUG | ||
782 | /* | ||
783 | snprintf(s, 10, "l%02x", len); | ||
784 | lcd_puts(0, 5, s); | ||
785 | */ | ||
786 | for (i = 0; i < 8; i++) | ||
787 | snprintf(s + i * 2, 3, "%02x", setup_pkt_buf[i]); | ||
788 | lcd_puts(0, 0, s); | ||
789 | lcd_update(); | ||
790 | #endif | ||
791 | } | ||
792 | |||
793 | static void usb_handle_data_int(int ep, int dir) | ||
794 | { | ||
795 | if (dir == DIR_TX) | ||
796 | usb_send(ep); | ||
797 | else | ||
798 | { | ||
799 | endpoints[ep].in_ack = 1; | ||
800 | usb_receive(ep); | ||
801 | } | ||
802 | } | ||
803 | |||
804 | static void usb_handle_int(int i) | ||
805 | { | ||
806 | #ifdef LCD_DEBUG | ||
807 | /* | ||
808 | char s[10]; | ||
809 | snprintf(s, sizeof(s), "%02d", i); | ||
810 | lcd_puts(0, 2, s); | ||
811 | lcd_update(); | ||
812 | */ | ||
813 | int_count[i]++; | ||
814 | if (i == 10) | ||
815 | log_char('o'); | ||
816 | if (i == 11) | ||
817 | log_char('i'); | ||
818 | if (i == 12) | ||
819 | log_char('O'); | ||
820 | if (i == 13) | ||
821 | log_char('I'); | ||
822 | #endif | ||
823 | |||
824 | if (i >= 10) | ||
825 | usb_handle_data_int((i - 10) / 2, i % 2); | ||
826 | else | ||
827 | { | ||
828 | switch (i) | ||
829 | { | ||
830 | case 0: | ||
831 | log_char('r'); | ||
832 | usb_setup(1); | ||
833 | break; | ||
834 | case 8: | ||
835 | log_char('s'); | ||
836 | usb_handle_setup_rx(); | ||
837 | break; | ||
838 | } | ||
839 | } | ||
840 | |||
841 | } | ||
842 | |||
843 | static void usb_handle_interrupts(void) | ||
844 | { | ||
845 | #ifdef LCD_DEBUG | ||
846 | char s[20]; | ||
847 | #endif | ||
848 | |||
849 | while (1) | ||
850 | { | ||
851 | unsigned long ints; | ||
852 | int i; | ||
853 | |||
854 | #ifdef LCD_DEBUG | ||
855 | /* | ||
856 | snprintf(s, sizeof(s), "i%08lx", ISP1582_INT); | ||
857 | lcd_puts(0, 2, s); | ||
858 | */ | ||
859 | #endif | ||
860 | |||
861 | ints = ISP1582_INT & ISP1582_INTEN; | ||
862 | if (!ints) break; | ||
863 | |||
864 | i = 0; | ||
865 | while (!(ints & (1 << i))) | ||
866 | i++; | ||
867 | ISP1582_INT = 1 << i; | ||
868 | usb_handle_int(i); | ||
869 | |||
870 | #ifdef LCD_DEBUG | ||
871 | for (i = 0; i < 8; i++) | ||
872 | snprintf(s + i * 2, 3, "%02x", int_count[i]); | ||
873 | lcd_puts(0, 6, s); | ||
874 | for (i = 0; i < 8; i++) | ||
875 | snprintf(s + i * 2, 3, "%02x", int_count[i + 8]); | ||
876 | lcd_puts(0, 7, s); | ||
877 | #endif | ||
878 | } | ||
879 | #ifdef LCD_DEBUG | ||
880 | /* | ||
881 | lcd_puts(0, 3, usb_connected() ? "C" : "N"); | ||
882 | lcd_update(); | ||
883 | */ | ||
884 | #endif | ||
885 | } | ||
886 | |||
887 | static inline int fifo_mod(int n) | ||
888 | { | ||
889 | return (n >= SERIAL_BUF_SIZE) ? n - SERIAL_BUF_SIZE : n; | ||
890 | } | ||
891 | |||
892 | static void fifo_init(struct serial_fifo *fifo) | ||
893 | { | ||
894 | fifo->head = fifo->tail = 0; | ||
895 | } | ||
896 | |||
897 | static int fifo_empty(struct serial_fifo *fifo) | ||
898 | { | ||
899 | return fifo->head == fifo->tail; | ||
900 | } | ||
901 | |||
902 | static int fifo_full(struct serial_fifo *fifo) | ||
903 | { | ||
904 | return fifo_mod(fifo->head + 1) == fifo->tail; | ||
905 | } | ||
906 | |||
907 | static void fifo_remove(struct serial_fifo *fifo, int n) | ||
908 | { | ||
909 | fifo->tail = fifo_mod(fifo->tail + n); | ||
910 | } | ||
911 | |||
912 | /* | ||
913 | Not used: | ||
914 | static void fifo_add(struct serial_fifo *fifo, int n) | ||
915 | { | ||
916 | fifo->head = fifo_mod(fifo->head + n); | ||
917 | } | ||
918 | |||
919 | static void fifo_free_block(struct serial_fifo *fifo, | ||
920 | unsigned char **ptr, int *len) | ||
921 | { | ||
922 | *ptr = fifo->buf + fifo->head; | ||
923 | if (fifo->head >= fifo->tail) | ||
924 | { | ||
925 | int l = SERIAL_BUF_SIZE - fifo->head; | ||
926 | if (fifo->tail == 0) | ||
927 | l--; | ||
928 | *len = l; | ||
929 | } | ||
930 | else | ||
931 | *len = fifo->tail - fifo->head - 1; | ||
932 | } | ||
933 | */ | ||
934 | |||
935 | static int fifo_free_space(struct serial_fifo *fifo) | ||
936 | { | ||
937 | if (fifo->head >= fifo->tail) | ||
938 | return SERIAL_BUF_SIZE - (fifo->head - fifo->tail) - 1; | ||
939 | else | ||
940 | return fifo->tail - fifo->head - 1; | ||
941 | } | ||
942 | |||
943 | static int fifo_get_byte(struct serial_fifo *fifo) | ||
944 | { | ||
945 | int r = fifo->buf[fifo->tail]; | ||
946 | fifo->tail = fifo_mod(fifo->tail + 1); | ||
947 | return r; | ||
948 | } | ||
949 | |||
950 | static void fifo_put_byte(struct serial_fifo *fifo, int b) | ||
951 | { | ||
952 | fifo->buf[fifo->head] = b; | ||
953 | fifo->head = fifo_mod(fifo->head + 1); | ||
954 | } | ||
955 | |||
956 | static void fifo_full_block(struct serial_fifo *fifo, | ||
957 | unsigned char **ptr, int *len) | ||
958 | { | ||
959 | *ptr = fifo->buf + fifo->tail; | ||
960 | if (fifo->head >= fifo->tail) | ||
961 | *len = fifo->head - fifo->tail; | ||
962 | else | ||
963 | *len = SERIAL_BUF_SIZE - fifo->tail; | ||
964 | } | ||
965 | |||
966 | static void serial_fill_in_fifo(int ep, unsigned char *buf, int len); | ||
967 | static void serial_free_out_fifo(int ep, unsigned char *buf, int len); | ||
968 | |||
969 | static void serial_restart_input(int ep) | ||
970 | { | ||
971 | if (fifo_free_space(&serial_in_fifo) >= 64) | ||
972 | usb_receive_block(serial_in_pkt, 1, 64, serial_fill_in_fifo, ep); | ||
973 | } | ||
974 | |||
975 | static void serial_fill_in_fifo(int ep, unsigned char *buf, int len) | ||
976 | { | ||
977 | int i; | ||
978 | for (i = 0; i < len; i++) | ||
979 | fifo_put_byte(&serial_in_fifo, buf[i]); | ||
980 | serial_restart_input(ep); | ||
981 | } | ||
982 | |||
983 | static void serial_restart_output(int ep) | ||
984 | { | ||
985 | unsigned char *block; | ||
986 | int blen; | ||
987 | fifo_full_block(&serial_out_fifo, &block, &blen); | ||
988 | if (blen) | ||
989 | { | ||
990 | #ifdef LCD_DEBUG | ||
991 | lcd_putsf(0, 2, "o%03lx/%03x", block - serial_out_fifo.buf, blen); | ||
992 | lcd_update(); | ||
993 | #endif | ||
994 | usb_send_block(block, blen, serial_free_out_fifo, ep); | ||
995 | } | ||
996 | } | ||
997 | |||
998 | static void serial_free_out_fifo(int ep, unsigned char *buf, int len) | ||
999 | { | ||
1000 | (void)buf; | ||
1001 | fifo_remove(&serial_out_fifo, len); | ||
1002 | serial_restart_output(ep); | ||
1003 | } | ||
1004 | |||
1005 | static void usb_serial_handle(void) | ||
1006 | { | ||
1007 | #ifdef BUTTONS | ||
1008 | static int t = 0; | ||
1009 | |||
1010 | t++; | ||
1011 | if (t >= 1000) | ||
1012 | { | ||
1013 | int b; | ||
1014 | t = 0; | ||
1015 | yield(); | ||
1016 | b = button_get(false); | ||
1017 | if (b == BUTTON_PLAY) | ||
1018 | system_reboot(); | ||
1019 | else if (b & BUTTON_REL) | ||
1020 | usb_reconnect(); | ||
1021 | } | ||
1022 | #endif | ||
1023 | |||
1024 | |||
1025 | if (!usb_connect_state) | ||
1026 | { | ||
1027 | if (usb_connected()) | ||
1028 | { | ||
1029 | int i; | ||
1030 | GPIO3_SET = 4; | ||
1031 | (*(volatile unsigned long *)0x80005004) = 2; | ||
1032 | (*(volatile unsigned long *)0x80005008) = 0; | ||
1033 | for (i = 0; i < 100000; i++) | ||
1034 | nop_f(); | ||
1035 | usb_setup(0); | ||
1036 | usb_connect_state = 1; | ||
1037 | } | ||
1038 | } | ||
1039 | else | ||
1040 | { | ||
1041 | if (!usb_connected()) | ||
1042 | { | ||
1043 | usb_connect_state = 0; | ||
1044 | usb_cleanup(); | ||
1045 | } | ||
1046 | else | ||
1047 | { | ||
1048 | usb_handle_interrupts(); | ||
1049 | |||
1050 | if (usb_state == STATE_CONFIGURED) | ||
1051 | { | ||
1052 | if (endpoints[1].in_min_len < 0) | ||
1053 | serial_restart_input(1); | ||
1054 | if (!endpoints[1].out_in_progress) | ||
1055 | serial_restart_output(1); | ||
1056 | } | ||
1057 | } | ||
1058 | } | ||
1059 | } | ||
1060 | |||
1061 | |||
1062 | /* | ||
1063 | Not used: | ||
1064 | static int usb_serial_in_empty(void) | ||
1065 | { | ||
1066 | return fifo_empty(&serial_in_fifo); | ||
1067 | } | ||
1068 | */ | ||
1069 | |||
1070 | int usb_serial_get_byte(void) | ||
1071 | { | ||
1072 | while (fifo_empty(&serial_in_fifo)) | ||
1073 | usb_serial_handle(); | ||
1074 | return fifo_get_byte(&serial_in_fifo); | ||
1075 | } | ||
1076 | |||
1077 | int usb_serial_try_get_byte(void) | ||
1078 | { | ||
1079 | int r; | ||
1080 | if (fifo_empty(&serial_in_fifo)) | ||
1081 | r = -1; | ||
1082 | else | ||
1083 | r = fifo_get_byte(&serial_in_fifo); | ||
1084 | usb_serial_handle(); | ||
1085 | return r; | ||
1086 | } | ||
1087 | |||
1088 | /* | ||
1089 | Not used: | ||
1090 | static int usb_serial_out_full(void) | ||
1091 | { | ||
1092 | return fifo_full(&serial_out_fifo); | ||
1093 | } | ||
1094 | */ | ||
1095 | |||
1096 | void usb_serial_put_byte(int b) | ||
1097 | { | ||
1098 | while (fifo_full(&serial_out_fifo)) | ||
1099 | usb_serial_handle(); | ||
1100 | fifo_put_byte(&serial_out_fifo, b); | ||
1101 | usb_serial_handle(); | ||
1102 | } | ||
1103 | |||
1104 | int usb_serial_try_put_byte(int b) | ||
1105 | { | ||
1106 | int r = -1; | ||
1107 | if (!fifo_full(&serial_out_fifo)) | ||
1108 | { | ||
1109 | fifo_put_byte(&serial_out_fifo, b); | ||
1110 | r = 0; | ||
1111 | } | ||
1112 | usb_serial_handle(); | ||
1113 | return r; | ||
1114 | } | ||
1115 | |||
1116 | void usb_serial_init(void) | ||
1117 | { | ||
1118 | fifo_init(&serial_in_fifo); | ||
1119 | fifo_init(&serial_out_fifo); | ||
1120 | usb_connect_state = 0; | ||
1121 | } | ||
diff --git a/firmware/rolo.c b/firmware/rolo.c index d435db977e..3496545cac 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c | |||
@@ -69,9 +69,6 @@ extern int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume | |||
69 | #include "backlight-target.h" | 69 | #include "backlight-target.h" |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #if !defined(IRIVER_IFP7XX_SERIES) | ||
73 | /* FIX: this doesn't work on iFP */ | ||
74 | |||
75 | #define IRQ0_EDGE_TRIGGER 0x80 | 72 | #define IRQ0_EDGE_TRIGGER 0x80 |
76 | 73 | ||
77 | static int rolo_handle; | 74 | static int rolo_handle; |
@@ -331,13 +328,3 @@ int rolo_load(const char* filename) | |||
331 | /* never reached */ | 328 | /* never reached */ |
332 | return 0; | 329 | return 0; |
333 | } | 330 | } |
334 | |||
335 | #else /* !defined(IRIVER_IFP7XX_SERIES) */ | ||
336 | int rolo_load(const char* filename) | ||
337 | { | ||
338 | /* dummy */ | ||
339 | (void)filename; | ||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | #endif /* !defined(IRIVER_IFP7XX_SERIES) */ | ||
diff --git a/firmware/target/arm/pnx0101/app.lds b/firmware/target/arm/pnx0101/app.lds deleted file mode 100644 index f14ef90129..0000000000 --- a/firmware/target/arm/pnx0101/app.lds +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | #include "config.h" | ||
2 | |||
3 | ENTRY(start) | ||
4 | |||
5 | OUTPUT_FORMAT(elf32-littlearm) | ||
6 | OUTPUT_ARCH(arm) | ||
7 | STARTUP(target/arm/pnx0101/crt0-pnx0101.o) | ||
8 | |||
9 | #define PLUGINSIZE PLUGIN_BUFFER_SIZE | ||
10 | #define CODECSIZE CODEC_SIZE | ||
11 | |||
12 | #ifdef DEBUG | ||
13 | #define STUBOFFSET 0x10000 | ||
14 | #else | ||
15 | #define STUBOFFSET 0 | ||
16 | #endif | ||
17 | |||
18 | #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE | ||
19 | |||
20 | #define DRAMORIG 0xc00000 + STUBOFFSET | ||
21 | #define IRAM0ORIG 0x000000 | ||
22 | #define IRAM0SIZE 0x7000 | ||
23 | #define IRAMORIG 0x400000 | ||
24 | #define IRAMSIZE 0x7000 | ||
25 | |||
26 | /* End of the audio buffer, where the codec buffer starts */ | ||
27 | #define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) | ||
28 | |||
29 | /* Where the codec buffer ends, and the plugin buffer starts */ | ||
30 | #define ENDADDR (ENDAUDIOADDR + CODECSIZE) | ||
31 | |||
32 | MEMORY | ||
33 | { | ||
34 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
35 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | ||
36 | IRAM0 : ORIGIN = IRAM0ORIG, LENGTH = IRAM0SIZE | ||
37 | } | ||
38 | |||
39 | SECTIONS | ||
40 | { | ||
41 | .text : | ||
42 | { | ||
43 | loadaddress = .; | ||
44 | _loadaddress = .; | ||
45 | . = ALIGN(0x200); | ||
46 | *(.init.text) | ||
47 | *(.text*) | ||
48 | *(.glue_7) | ||
49 | *(.glue_7t) | ||
50 | . = ALIGN(0x4); | ||
51 | } > DRAM | ||
52 | |||
53 | .rodata : | ||
54 | { | ||
55 | *(.rodata) /* problems without this, dunno why */ | ||
56 | *(.rodata*) | ||
57 | *(.rodata.str1.1) | ||
58 | *(.rodata.str1.4) | ||
59 | . = ALIGN(0x4); | ||
60 | } > DRAM | ||
61 | |||
62 | .data : | ||
63 | { | ||
64 | *(.data*) | ||
65 | . = ALIGN(0x4); | ||
66 | } > DRAM | ||
67 | |||
68 | /DISCARD/ : | ||
69 | { | ||
70 | *(.eh_frame) | ||
71 | } | ||
72 | |||
73 | .vectors 0x0 : | ||
74 | { | ||
75 | _vectorsstart = .; | ||
76 | KEEP(*(.vectors)); | ||
77 | _vectorsend = .; | ||
78 | *(.dmabuf) | ||
79 | } >IRAM0 AT> DRAM | ||
80 | |||
81 | _vectorscopy = LOADADDR(.vectors); | ||
82 | |||
83 | .iram IRAMORIG + SIZEOF(.vectors) : | ||
84 | { | ||
85 | _iramstart = .; | ||
86 | *(.icode) | ||
87 | *(.irodata) | ||
88 | *(.idata) | ||
89 | . = ALIGN(0x4); | ||
90 | _iramend = .; | ||
91 | } > IRAM AT> DRAM | ||
92 | |||
93 | _iramcopy = LOADADDR(.iram); | ||
94 | |||
95 | .ibss (NOLOAD) : | ||
96 | { | ||
97 | _iedata = .; | ||
98 | *(.ibss) | ||
99 | . = ALIGN(0x4); | ||
100 | _iend = .; | ||
101 | } > IRAM | ||
102 | |||
103 | .stack : | ||
104 | { | ||
105 | *(.stack) | ||
106 | stackbegin = .; | ||
107 | . += 0x2000; | ||
108 | stackend = .; | ||
109 | } > IRAM | ||
110 | |||
111 | .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors): | ||
112 | { | ||
113 | _edata = .; | ||
114 | *(.bss*) | ||
115 | *(COMMON) | ||
116 | . = ALIGN(0x4); | ||
117 | _end = .; | ||
118 | } > DRAM | ||
119 | |||
120 | .audiobuf ALIGN(4) : | ||
121 | { | ||
122 | _audiobuffer = .; | ||
123 | audiobuffer = .; | ||
124 | } > DRAM | ||
125 | |||
126 | .audiobufend ENDAUDIOADDR: | ||
127 | { | ||
128 | audiobufend = .; | ||
129 | _audiobufend = .; | ||
130 | } > DRAM | ||
131 | |||
132 | .codec ENDAUDIOADDR: | ||
133 | { | ||
134 | codecbuf = .; | ||
135 | _codecbuf = .; | ||
136 | } | ||
137 | |||
138 | .plugin ENDADDR: | ||
139 | { | ||
140 | _pluginbuf = .; | ||
141 | pluginbuf = .; | ||
142 | } | ||
143 | } | ||
144 | |||
diff --git a/firmware/target/arm/pnx0101/backlight-target.h b/firmware/target/arm/pnx0101/backlight-target.h deleted file mode 100644 index 7ebe85d66f..0000000000 --- a/firmware/target/arm/pnx0101/backlight-target.h +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: backlight-target.h 13136 2007-04-12 22:12:13Z amiconn $ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #define backlight_hw_init() true | ||
25 | void backlight_hw_on(void); | ||
26 | void backlight_hw_off(void); | ||
27 | |||
28 | #endif | ||
diff --git a/firmware/target/arm/pnx0101/crt0-pnx0101.S b/firmware/target/arm/pnx0101/crt0-pnx0101.S deleted file mode 100644 index 51be8c72a3..0000000000 --- a/firmware/target/arm/pnx0101/crt0-pnx0101.S +++ /dev/null | |||
@@ -1,225 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: crt0.S 11850 2006-12-29 02:49:12Z markun $ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #define ASM /* do not include structure definitions from pnx0101.h */ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | |||
26 | .section .init.text,"ax",%progbits | ||
27 | |||
28 | .global start | ||
29 | start: | ||
30 | |||
31 | /* Arm bootloader and startup code based on startup.s from the iPodLinux loader | ||
32 | * | ||
33 | * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org) | ||
34 | * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org> | ||
35 | * | ||
36 | */ | ||
37 | |||
38 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */ | ||
39 | |||
40 | #ifndef BOOTLOADER | ||
41 | #ifndef DEBUG | ||
42 | ldr r0, =0x80105000 | ||
43 | mov r1, #1 | ||
44 | str r1, [r0, #4] | ||
45 | mov r1, #0 | ||
46 | str r1, [r0, #4] | ||
47 | 1: ldr r1, [r0] | ||
48 | cmp r1, #0 | ||
49 | bne 1b | ||
50 | mov r1, #0x74 | ||
51 | str r1, [r0, #8] | ||
52 | mov r1, #2 | ||
53 | str r1, [r0, #0x18] | ||
54 | mov r1, #2 | ||
55 | str r1, [r0, #0x20] | ||
56 | mov r1, #82 | ||
57 | str r1, [r0, #0x28] | ||
58 | mov r1, #100 | ||
59 | str r1, [r0, #0x2c] | ||
60 | mov r1, #0x120 | ||
61 | str r1, [r0, #0x30] | ||
62 | mov r1, #6 | ||
63 | str r1, [r0, #4] | ||
64 | ldr r0, =1f | ||
65 | mov r15, r0 | ||
66 | 1: | ||
67 | #endif /* !DEBUG */ | ||
68 | |||
69 | #ifndef DEBUG | ||
70 | /* Copy exception handler code to address 0 */ | ||
71 | ldr r2, =_vectorsstart | ||
72 | ldr r3, =_vectorsend | ||
73 | ldr r4, =_vectorscopy | ||
74 | 1: | ||
75 | cmp r3, r2 | ||
76 | ldrhi r5, [r4], #4 | ||
77 | strhi r5, [r2], #4 | ||
78 | bhi 1b | ||
79 | #else | ||
80 | ldr r1, =vectors | ||
81 | ldr r0, =irq_handler | ||
82 | str r0, [r1, #24] | ||
83 | ldr r0, =fiq_handler | ||
84 | str r0, [r1, #28] | ||
85 | #endif | ||
86 | |||
87 | #ifndef STUB | ||
88 | /* Zero out IBSS */ | ||
89 | ldr r2, =_iedata | ||
90 | ldr r3, =_iend | ||
91 | mov r4, #0 | ||
92 | 1: | ||
93 | cmp r3, r2 | ||
94 | strhi r4, [r2], #4 | ||
95 | bhi 1b | ||
96 | |||
97 | /* Copy the IRAM */ | ||
98 | ldr r2, =_iramcopy | ||
99 | ldr r3, =_iramstart | ||
100 | ldr r4, =_iramend | ||
101 | 1: | ||
102 | cmp r4, r3 | ||
103 | ldrhi r5, [r2], #4 | ||
104 | strhi r5, [r3], #4 | ||
105 | bhi 1b | ||
106 | #endif /* !STUB */ | ||
107 | #endif /* !BOOTLOADER */ | ||
108 | |||
109 | /* Initialise bss section to zero */ | ||
110 | ldr r2, =_edata | ||
111 | ldr r3, =_end | ||
112 | mov r4, #0 | ||
113 | 1: | ||
114 | cmp r3, r2 | ||
115 | strhi r4, [r2], #4 | ||
116 | bhi 1b | ||
117 | |||
118 | /* Set up stack for IRQ mode */ | ||
119 | msr cpsr_c, #0xd2 | ||
120 | ldr sp, =irq_stack | ||
121 | /* Set up stack for FIQ mode */ | ||
122 | msr cpsr_c, #0xd1 | ||
123 | ldr sp, =fiq_stack | ||
124 | |||
125 | /* Let svc, abort and undefined modes use irq stack */ | ||
126 | msr cpsr_c, #0xd3 | ||
127 | ldr sp =irq_stack | ||
128 | msr cpsr_c, #0xd7 | ||
129 | ldr sp, =irq_stack | ||
130 | msr cpsr_c, #0xdb | ||
131 | ldr sp, =irq_stack | ||
132 | |||
133 | /* Switch to sys mode */ | ||
134 | msr cpsr_c, #0xdf | ||
135 | |||
136 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
137 | ldr sp, =stackend | ||
138 | mov r3, sp | ||
139 | ldr r2, =stackbegin | ||
140 | ldr r4, =0xdeadbeef | ||
141 | 1: | ||
142 | cmp r3, r2 | ||
143 | strhi r4, [r2], #4 | ||
144 | bhi 1b | ||
145 | |||
146 | bl main | ||
147 | /* main() should never return */ | ||
148 | |||
149 | /* Exception handlers. Will be copied to address 0 after memory remapping */ | ||
150 | .section .vectors,"aw" | ||
151 | ldr pc, [pc, #24] | ||
152 | ldr pc, [pc, #24] | ||
153 | ldr pc, [pc, #24] | ||
154 | ldr pc, [pc, #24] | ||
155 | ldr pc, [pc, #24] | ||
156 | ldr pc, [pc, #24] | ||
157 | ldr pc, [pc, #24] | ||
158 | ldr pc, [pc, #24] | ||
159 | |||
160 | /* Exception vectors */ | ||
161 | .global vectors | ||
162 | vectors: | ||
163 | .word start | ||
164 | .word undef_instr_handler | ||
165 | .word software_int_handler | ||
166 | .word prefetch_abort_handler | ||
167 | .word data_abort_handler | ||
168 | .word reserved_handler | ||
169 | .word irq_handler | ||
170 | .word fiq_handler | ||
171 | |||
172 | .text | ||
173 | |||
174 | /* All illegal exceptions call into UIE with exception address as first | ||
175 | parameter. This is calculated differently depending on which exception | ||
176 | we're in. Second parameter is exception number, used for a string lookup | ||
177 | in UIE. | ||
178 | */ | ||
179 | undef_instr_handler: | ||
180 | sub r0, lr, #4 | ||
181 | mov r1, #0 | ||
182 | b UIE | ||
183 | |||
184 | /* We run sys mode most of the time, and should never see a software | ||
185 | exception being thrown. Make it illegal and call UIE. | ||
186 | */ | ||
187 | software_int_handler: | ||
188 | reserved_handler: | ||
189 | sub r0, lr, #4 | ||
190 | mov r1, #4 | ||
191 | b UIE | ||
192 | |||
193 | prefetch_abort_handler: | ||
194 | sub r0, lr, #4 | ||
195 | mov r1, #1 | ||
196 | b UIE | ||
197 | |||
198 | fiq_handler: | ||
199 | @ Branch straight to FIQ handler in pcm_playback.c. This also handles the | ||
200 | @ the correct return sequence. | ||
201 | stmfd sp!, {r0-r7, r12, lr} | ||
202 | bl fiq | ||
203 | ldmfd sp!, {r0-r7, r12, lr} | ||
204 | subs pc, lr, #4 | ||
205 | |||
206 | irq_handler: | ||
207 | #ifndef STUB | ||
208 | stmfd sp!, {r0-r11, r12, lr} | ||
209 | bl irq | ||
210 | ldmfd sp!, {r0-r11, r12, lr} | ||
211 | #endif | ||
212 | subs pc, lr, #4 | ||
213 | |||
214 | #ifdef STUB | ||
215 | UIE: | ||
216 | b UIE | ||
217 | #endif | ||
218 | |||
219 | /* 256 words of IRQ stack */ | ||
220 | .space 256*4 | ||
221 | irq_stack: | ||
222 | |||
223 | /* 256 words of FIQ stack */ | ||
224 | .space 256*4 | ||
225 | fiq_stack: | ||
diff --git a/firmware/target/arm/pnx0101/debug-pnx0101.c b/firmware/target/arm/pnx0101/debug-pnx0101.c deleted file mode 100644 index 8dae2e4925..0000000000 --- a/firmware/target/arm/pnx0101/debug-pnx0101.c +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #include <stdbool.h> | ||
2 | bool dbg_ports() | ||
3 | { | ||
4 | return false; | ||
5 | } | ||
diff --git a/firmware/target/arm/pnx0101/i2c-pnx0101.c b/firmware/target/arm/pnx0101/i2c-pnx0101.c deleted file mode 100644 index eaf1e79500..0000000000 --- a/firmware/target/arm/pnx0101/i2c-pnx0101.c +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | void i2c_init(void) | ||
23 | { | ||
24 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c deleted file mode 100644 index 0f306f9986..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "kernel.h" | ||
25 | #include "thread.h" | ||
26 | #include "adc.h" | ||
27 | |||
28 | static unsigned short adcdata[NUM_ADC_CHANNELS]; | ||
29 | |||
30 | unsigned short adc_read(int channel) | ||
31 | { | ||
32 | return adcdata[channel]; | ||
33 | } | ||
34 | |||
35 | static void adc_tick(void) | ||
36 | { | ||
37 | if (ADCST & 0x10) { | ||
38 | adcdata[0] = ADCCH0 & 0x3ff; | ||
39 | adcdata[1] = ADCCH1 & 0x3ff; | ||
40 | adcdata[2] = ADCCH2 & 0x3ff; | ||
41 | adcdata[3] = ADCCH3 & 0x3ff; | ||
42 | adcdata[4] = ADCCH4 & 0x3ff; | ||
43 | ADCST = 0xa; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | void adc_init(void) | ||
48 | { | ||
49 | ADCR24 = 0xaaaaa; | ||
50 | ADCR28 = 0; | ||
51 | ADCST = 2; | ||
52 | ADCST = 0xa; | ||
53 | |||
54 | while (!(ADCST & 0x10)); | ||
55 | adc_tick(); | ||
56 | |||
57 | tick_add_task(adc_tick); | ||
58 | } | ||
59 | |||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h deleted file mode 100644 index a18aa77c7e..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 5 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | #define ADC_BATTERY 1 | ||
28 | #define ADC_BUTTON_PLAY 2 | ||
29 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
30 | |||
31 | #endif | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c deleted file mode 100644 index 8be7a59de2..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "backlight.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | void backlight_hw_on(void) | ||
28 | { | ||
29 | GPIO3_SET = 1; | ||
30 | } | ||
31 | |||
32 | void backlight_hw_off(void) | ||
33 | { | ||
34 | GPIO3_CLR = 1; | ||
35 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c deleted file mode 100644 index 45f9fae478..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #include <stdlib.h> | ||
24 | #include "config.h" | ||
25 | #include "cpu.h" | ||
26 | #include "system.h" | ||
27 | #include "button.h" | ||
28 | #include "kernel.h" | ||
29 | #include "backlight.h" | ||
30 | #include "adc.h" | ||
31 | |||
32 | |||
33 | void button_init_device(void) | ||
34 | { | ||
35 | |||
36 | } | ||
37 | |||
38 | bool button_hold(void) | ||
39 | { | ||
40 | return (GPIO5_READ & 4) ? false : true; | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * Get button pressed from hardware | ||
45 | */ | ||
46 | int button_read_device(void) | ||
47 | { | ||
48 | int btn = BUTTON_NONE; | ||
49 | int data; | ||
50 | static bool hold_button = false; | ||
51 | bool hold_button_old; | ||
52 | |||
53 | /* normal buttons */ | ||
54 | hold_button_old = hold_button; | ||
55 | hold_button = button_hold(); | ||
56 | |||
57 | if (hold_button != hold_button_old) | ||
58 | backlight_hold_changed(hold_button); | ||
59 | |||
60 | if (!button_hold()) | ||
61 | { | ||
62 | data = adc_read(ADC_BUTTONS); | ||
63 | if (data < 0x35c) | ||
64 | { | ||
65 | if (data < 0x151) | ||
66 | if (data < 0xc7) | ||
67 | if (data < 0x41) | ||
68 | btn = BUTTON_LEFT; | ||
69 | else | ||
70 | btn = BUTTON_RIGHT; | ||
71 | else | ||
72 | btn = BUTTON_SELECT; | ||
73 | else | ||
74 | if (data < 0x268) | ||
75 | if (data < 0x1d7) | ||
76 | btn = BUTTON_UP; | ||
77 | else | ||
78 | btn = BUTTON_DOWN; | ||
79 | else | ||
80 | if (data < 0x2f9) | ||
81 | btn = BUTTON_EQ; | ||
82 | else | ||
83 | btn = BUTTON_MODE; | ||
84 | } | ||
85 | |||
86 | if (adc_read(ADC_BUTTON_PLAY) < 0x64) | ||
87 | btn |= BUTTON_PLAY; | ||
88 | } | ||
89 | return btn; | ||
90 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h deleted file mode 100644 index 6932b8956f..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | /* Custom written for the ifp7xx */ | ||
23 | |||
24 | #ifndef _BUTTON_TARGET_H_ | ||
25 | #define _BUTTON_TARGET_H_ | ||
26 | |||
27 | #define HAS_BUTTON_HOLD | ||
28 | |||
29 | /* iriver IFP7XX specific button codes */ | ||
30 | |||
31 | #define BUTTON_PLAY 0x00000001 | ||
32 | #define BUTTON_SELECT 0x00000002 | ||
33 | |||
34 | #define BUTTON_LEFT 0x00000004 | ||
35 | #define BUTTON_RIGHT 0x00000008 | ||
36 | #define BUTTON_UP 0x00000010 | ||
37 | #define BUTTON_DOWN 0x00000020 | ||
38 | |||
39 | #define BUTTON_MODE 0x00000040 | ||
40 | #define BUTTON_EQ 0x00000080 | ||
41 | |||
42 | #define BUTTON_MAIN (BUTTON_PLAY|BUTTON_SELECT\ | ||
43 | |BUTTON_LEFT|BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN\ | ||
44 | |BUTTON_MODE|BUTTON_EQ) | ||
45 | |||
46 | #define POWEROFF_BUTTON BUTTON_PLAY | ||
47 | #define POWEROFF_COUNT 40 | ||
48 | |||
49 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c deleted file mode 100644 index 1ad604d50c..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c +++ /dev/null | |||
@@ -1,224 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | |||
23 | #include "kernel.h" | ||
24 | #include "lcd.h" | ||
25 | #include "system.h" | ||
26 | |||
27 | /*** definitions ***/ | ||
28 | |||
29 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
30 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
31 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
32 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
33 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
34 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
35 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
36 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
37 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
38 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
39 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
40 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
41 | #define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) | ||
42 | #define LCD_SET_BIAS_TC_OSC ((char)0xA9) | ||
43 | #define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA) | ||
44 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
45 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
46 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
47 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
48 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
49 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
50 | #define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2) | ||
51 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
52 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
53 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
54 | #define LCD_NOP ((char)0xE3) | ||
55 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
56 | |||
57 | /* LCD command codes */ | ||
58 | #define LCD_CNTL_RESET 0xe2 /* Software reset */ | ||
59 | #define LCD_CNTL_POWER 0x2f /* Power control */ | ||
60 | #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ | ||
61 | #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ | ||
62 | #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ | ||
63 | #define LCD_CNTL_DISPON 0xaf /* Display on */ | ||
64 | |||
65 | #define LCD_CNTL_PAGE 0xb0 /* Page address */ | ||
66 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | ||
67 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | ||
68 | |||
69 | /*** driver routines ***/ | ||
70 | |||
71 | void lcd_write_command(int cmd) | ||
72 | { | ||
73 | while ((LCDSTAT & 3) != 3); | ||
74 | LCDCMD = cmd; | ||
75 | } | ||
76 | |||
77 | void lcd_write_data( const unsigned char* data, int count ) | ||
78 | { | ||
79 | int i; | ||
80 | for (i=0; i < count; i++) { | ||
81 | while ((LCDSTAT & 3) != 3); | ||
82 | LCDDATA = data[i]; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | /*** hardware configuration ***/ | ||
87 | |||
88 | int lcd_default_contrast(void) | ||
89 | { | ||
90 | return 45; | ||
91 | } | ||
92 | |||
93 | void lcd_set_contrast(int val) | ||
94 | { | ||
95 | lcd_write_command(LCD_CNTL_CONTRAST); | ||
96 | lcd_write_command(val); | ||
97 | } | ||
98 | |||
99 | void lcd_set_invert_display(bool yesno) | ||
100 | { | ||
101 | if (yesno) | ||
102 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | ||
103 | else | ||
104 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
105 | } | ||
106 | |||
107 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
108 | void lcd_set_flip(bool yesno) | ||
109 | { | ||
110 | if (yesno) | ||
111 | { | ||
112 | lcd_write_command(LCD_SET_SEGMENT_REMAP); | ||
113 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01); | ||
118 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | void lcd_init_device(void) | ||
123 | { | ||
124 | LCDREG10 = 0xf; | ||
125 | LCDREG04 = 0x4084; | ||
126 | |||
127 | /* inits like the original firmware */ | ||
128 | lcd_write_command(LCD_SOFTWARE_RESET); | ||
129 | lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 4); | ||
130 | lcd_write_command(LCD_SET_LCD_BIAS); | ||
131 | lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7); | ||
132 | /* power control register: op-amp=1, regulator=1, booster=1 */ | ||
133 | lcd_write_command(LCD_SET_DISPLAY_ON); | ||
134 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
135 | lcd_set_flip(false); | ||
136 | lcd_write_command(LCD_SET_DISPLAY_START_LINE + 0); | ||
137 | lcd_set_contrast(lcd_default_contrast()); | ||
138 | lcd_write_command(LCD_SET_PAGE_ADDRESS); | ||
139 | lcd_write_command(LCD_SET_LOWER_COLUMN_ADDRESS + 0); | ||
140 | lcd_write_command(LCD_SET_HIGHER_COLUMN_ADDRESS + 0); | ||
141 | |||
142 | lcd_clear_display(); | ||
143 | lcd_update(); | ||
144 | } | ||
145 | |||
146 | /*** Update functions ***/ | ||
147 | |||
148 | /* Performance function that works with an external buffer | ||
149 | note that by and bheight are in 8-pixel units! */ | ||
150 | void lcd_blit_mono(const unsigned char *data, int x, int by, int width, | ||
151 | int bheight, int stride) | ||
152 | { | ||
153 | /* Copy display bitmap to hardware */ | ||
154 | while (bheight--) | ||
155 | { | ||
156 | lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); | ||
157 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4)>>4) & 0xf)); | ||
158 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf)); | ||
159 | |||
160 | lcd_write_data(data, width); | ||
161 | data += stride; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | |||
166 | /* Performance function that works with an external buffer | ||
167 | note that by and bheight are in 8-pixel units! */ | ||
168 | void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, | ||
169 | int x, int by, int width, int bheight, int stride) | ||
170 | { | ||
171 | (void)values; | ||
172 | (void)phases; | ||
173 | (void)x; | ||
174 | (void)by; | ||
175 | (void)width; | ||
176 | (void)bheight; | ||
177 | (void)stride; | ||
178 | } | ||
179 | |||
180 | /* Update the display. | ||
181 | This must be called after all other LCD functions that change the display. */ | ||
182 | void lcd_update(void) ICODE_ATTR; | ||
183 | void lcd_update(void) | ||
184 | { | ||
185 | int y; | ||
186 | |||
187 | /* Copy display bitmap to hardware */ | ||
188 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
189 | { | ||
190 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
191 | lcd_write_command (LCD_CNTL_HIGHCOL); | ||
192 | lcd_write_command (LCD_CNTL_LOWCOL | 4); | ||
193 | |||
194 | lcd_write_data (FBADDR(0, y), LCD_WIDTH); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | /* Update a fraction of the display. */ | ||
199 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
200 | void lcd_update_rect(int x, int y, int width, int height) | ||
201 | { | ||
202 | int ymax; | ||
203 | |||
204 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
205 | ymax = (y + height-1) >> 3; | ||
206 | y >>= 3; | ||
207 | |||
208 | if(x + width > LCD_WIDTH) | ||
209 | width = LCD_WIDTH - x; | ||
210 | if (width <= 0) | ||
211 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
212 | if(ymax >= LCD_FBHEIGHT) | ||
213 | ymax = LCD_FBHEIGHT-1; | ||
214 | |||
215 | /* Copy specified rectange bitmap to hardware */ | ||
216 | for (; y <= ymax; y++) | ||
217 | { | ||
218 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
219 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4) >> 4) & 0xf)); | ||
220 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf)); | ||
221 | |||
222 | lcd_write_data (FBADDR(x,y), width); | ||
223 | } | ||
224 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c deleted file mode 100644 index 1fd9d68028..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include <stdbool.h> | ||
24 | #include "kernel.h" | ||
25 | #include "system.h" | ||
26 | #include "power.h" | ||
27 | #include "logf.h" | ||
28 | #include "usb.h" | ||
29 | |||
30 | #if CONFIG_TUNER | ||
31 | |||
32 | bool tuner_power(bool status) | ||
33 | { | ||
34 | (void)status; | ||
35 | return true; | ||
36 | } | ||
37 | |||
38 | #endif /* #if CONFIG_TUNER */ | ||
39 | |||
40 | #ifndef SIMULATOR | ||
41 | |||
42 | void power_init(void) | ||
43 | { | ||
44 | } | ||
45 | |||
46 | void ide_power_enable(bool on) | ||
47 | { | ||
48 | (void)on; | ||
49 | /* no ide controller */ | ||
50 | } | ||
51 | |||
52 | bool ide_powered(void) | ||
53 | { | ||
54 | return true; /* pretend always powered if not controlable */ | ||
55 | } | ||
56 | |||
57 | void power_off(void) | ||
58 | { | ||
59 | disable_interrupt(IRQ_FIQ_STATUS); | ||
60 | GPIO1_CLR = 1 << 16; | ||
61 | GPIO2_SET = 1; | ||
62 | while(1); | ||
63 | } | ||
64 | |||
65 | #else | ||
66 | |||
67 | void power_off(void) | ||
68 | { | ||
69 | } | ||
70 | |||
71 | void ide_power_enable(bool on) | ||
72 | { | ||
73 | (void)on; | ||
74 | } | ||
75 | |||
76 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c deleted file mode 100644 index 4ce90a4c4f..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "adc.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
28 | { | ||
29 | 1050, 1150 | ||
30 | }; | ||
31 | |||
32 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
33 | { | ||
34 | 1050, 1150 /* FIXME: just copied from above, was missing in powermgmt.c */ | ||
35 | }; | ||
36 | |||
37 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
38 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
39 | { | ||
40 | /* These values are the same as for Ondio divided by 3. */ | ||
41 | /* May need recalibration. */ | ||
42 | { 930, 1080, 1140, 1180, 1210, 1250, 1280, 1320, 1360, 1420, 1580 }, /* alkaline */ | ||
43 | { 1030, 1180, 1210, 1230, 1240, 1250, 1260, 1270, 1280, 1290, 1350 } /* NiMH */ | ||
44 | }; | ||
45 | |||
46 | /* TODO: only roughly correct */ | ||
47 | #define BATTERY_SCALE_FACTOR 3072 | ||
48 | /* full-scale ADC readout (2^10) in millivolt */ | ||
49 | |||
50 | /* Returns battery voltage from ADC [millivolts] */ | ||
51 | int _battery_voltage(void) | ||
52 | { | ||
53 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | ||
54 | } | ||
55 | |||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h deleted file mode 100644 index 9aad4a7b74..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef SYSTEM_TARGET_H | ||
22 | #define SYSTEM_TARGET_H | ||
23 | |||
24 | #include "system-arm.h" | ||
25 | |||
26 | #define CPUFREQ_DEFAULT 12000000 | ||
27 | #define CPUFREQ_NORMAL 48000000 | ||
28 | #define CPUFREQ_MAX 60000000 | ||
29 | |||
30 | typedef void (*interrupt_handler_t)(void); | ||
31 | |||
32 | void irq_set_int_handler(int n, interrupt_handler_t handler); | ||
33 | void irq_enable_int(int n); | ||
34 | void irq_disable_int(int n); | ||
35 | |||
36 | #endif /* SYSTEM_TARGET_H */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c deleted file mode 100644 index 0bfcdf3b1a..0000000000 --- a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "kernel.h" | ||
24 | #include "thread.h" | ||
25 | #include "system.h" | ||
26 | #include "debug.h" | ||
27 | #include "ata.h" | ||
28 | #include "disk.h" | ||
29 | #include "panic.h" | ||
30 | #include "lcd.h" | ||
31 | #include "usb.h" | ||
32 | #include "button.h" | ||
33 | #include "string.h" | ||
34 | |||
35 | void usb_init_device(void) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | int usb_detect(void) | ||
40 | { | ||
41 | /* TODO: Implement USB_ISP1582 */ | ||
42 | return USB_EXTRACTED; | ||
43 | } | ||
44 | |||
45 | void usb_enable(bool on) | ||
46 | { | ||
47 | /* TODO: Implement USB_ISP1582 */ | ||
48 | (void)on; | ||
49 | } | ||
diff --git a/firmware/target/arm/pnx0101/kernel-pnx0101.c b/firmware/target/arm/pnx0101/kernel-pnx0101.c deleted file mode 100644 index db0f1b0d7f..0000000000 --- a/firmware/target/arm/pnx0101/kernel-pnx0101.c +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "system.h" | ||
23 | #include "kernel.h" | ||
24 | |||
25 | void timer_handler(void) | ||
26 | { | ||
27 | /* Run through the list of tick tasks */ | ||
28 | call_tick_tasks(); | ||
29 | |||
30 | TIMER0.clr = 0; | ||
31 | } | ||
32 | |||
33 | void tick_start(unsigned int interval_in_ms) | ||
34 | { | ||
35 | TIMER0.ctrl &= ~0x80; /* Disable the counter */ | ||
36 | TIMER0.ctrl |= 0x40; /* Reload after counting down to zero */ | ||
37 | TIMER0.load = 3000000 * interval_in_ms / 1000; | ||
38 | TIMER0.ctrl &= ~0xc; /* No prescaler */ | ||
39 | TIMER0.clr = 1; /* Clear the interrupt request */ | ||
40 | |||
41 | irq_set_int_handler(IRQ_TIMER0, timer_handler); | ||
42 | irq_enable_int(IRQ_TIMER0); | ||
43 | |||
44 | TIMER0.ctrl |= 0x80; /* Enable the counter */ | ||
45 | } | ||
diff --git a/firmware/target/arm/pnx0101/pcm-pnx0101.c b/firmware/target/arm/pnx0101/pcm-pnx0101.c deleted file mode 100644 index 6099dcb7ef..0000000000 --- a/firmware/target/arm/pnx0101/pcm-pnx0101.c +++ /dev/null | |||
@@ -1,207 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Tomek Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "system.h" | ||
22 | #include "audio.h" | ||
23 | #include "string.h" | ||
24 | #include "pcm-internal.h" | ||
25 | |||
26 | #define DMA_BUF_SAMPLES 0x100 | ||
27 | |||
28 | short __attribute__((section(".dmabuf"))) dma_buf_left[DMA_BUF_SAMPLES]; | ||
29 | short __attribute__((section(".dmabuf"))) dma_buf_right[DMA_BUF_SAMPLES]; | ||
30 | |||
31 | const int16_t* p IBSS_ATTR; | ||
32 | size_t p_size IBSS_ATTR; | ||
33 | |||
34 | void pcm_play_lock(void) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | void pcm_play_unlock(void) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | void pcm_play_dma_start(const void *addr, size_t size) | ||
43 | { | ||
44 | p = addr; | ||
45 | p_size = size; | ||
46 | } | ||
47 | |||
48 | void pcm_play_dma_stop(void) | ||
49 | { | ||
50 | } | ||
51 | |||
52 | static inline void fill_dma_buf(int offset) | ||
53 | { | ||
54 | short *l, *r, *lend; | ||
55 | |||
56 | l = dma_buf_left + offset; | ||
57 | lend = l + DMA_BUF_SAMPLES / 2; | ||
58 | r = dma_buf_right + offset; | ||
59 | |||
60 | if (pcm_playing) | ||
61 | { | ||
62 | bool new_buffer =false; | ||
63 | |||
64 | do | ||
65 | { | ||
66 | int count; | ||
67 | const int16_t *tmp_p; | ||
68 | count = MIN(p_size / 4, (size_t)(lend - l)); | ||
69 | tmp_p = p; | ||
70 | p_size -= count * 4; | ||
71 | |||
72 | if ((int)l & 3) | ||
73 | { | ||
74 | *l++ = *tmp_p++; | ||
75 | *r++ = *tmp_p++; | ||
76 | count--; | ||
77 | } | ||
78 | while (count >= 4) | ||
79 | { | ||
80 | asm("ldmia %0!, {r0, r1, r2, r3}\n\t" | ||
81 | "and r4, r0, %3\n\t" | ||
82 | "orr r4, r4, r1, lsl #16\n\t" | ||
83 | "and r5, r2, %3\n\t" | ||
84 | "orr r5, r5, r3, lsl #16\n\t" | ||
85 | "stmia %1!, {r4, r5}\n\t" | ||
86 | "bic r4, r1, %3\n\t" | ||
87 | "orr r4, r4, r0, lsr #16\n\t" | ||
88 | "bic r5, r3, %3\n\t" | ||
89 | "orr r5, r5, r2, lsr #16\n\t" | ||
90 | "stmia %2!, {r4, r5}" | ||
91 | : "+r" (tmp_p), "+r" (l), "+r" (r) | ||
92 | : "r" (0xffff) | ||
93 | : "r0", "r1", "r2", "r3", "r4", "r5", "memory"); | ||
94 | count -= 4; | ||
95 | } | ||
96 | while (count > 0) | ||
97 | { | ||
98 | *l++ = *tmp_p++; | ||
99 | *r++ = *tmp_p++; | ||
100 | count--; | ||
101 | } | ||
102 | p = tmp_p; | ||
103 | |||
104 | if (new_buffer) | ||
105 | { | ||
106 | new_buffer = false; | ||
107 | pcm_play_dma_status_callback(PCM_DMAST_STARTED); | ||
108 | } | ||
109 | |||
110 | if (l >= lend) | ||
111 | return; | ||
112 | |||
113 | new_buffer = pcm_play_dma_complete_callback(PCM_DMAST_OK, | ||
114 | &p, &p_size); | ||
115 | } | ||
116 | while (p_size); | ||
117 | } | ||
118 | |||
119 | if (l < lend) | ||
120 | { | ||
121 | memset(l, 0, sizeof(short) * (lend - l)); | ||
122 | memset(r, 0, sizeof(short) * (lend - l)); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | static void audio_irq(void) | ||
127 | { | ||
128 | unsigned long st = DMAINTSTAT & ~DMAINTEN; | ||
129 | int i; | ||
130 | for (i = 0; i < 2; i++) | ||
131 | if (st & (1 << i)) | ||
132 | { | ||
133 | fill_dma_buf((i == 1) ? 0 : DMA_BUF_SAMPLES / 2); | ||
134 | DMAINTSTAT = 1 << i; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | unsigned long physical_address(void *p) | ||
139 | { | ||
140 | unsigned long adr = (unsigned long)p; | ||
141 | return (MMUBLOCK((adr >> 21) & 0xf) << 21) | (adr & ((1 << 21) - 1)); | ||
142 | } | ||
143 | |||
144 | void pcm_init(void) | ||
145 | { | ||
146 | int i; | ||
147 | |||
148 | memset(dma_buf_left, 0, sizeof(dma_buf_left)); | ||
149 | memset(dma_buf_right, 0, sizeof(dma_buf_right)); | ||
150 | |||
151 | for (i = 0; i < 8; i++) | ||
152 | { | ||
153 | DMASRC(i) = 0; | ||
154 | DMADEST(i) = 0; | ||
155 | DMALEN(i) = 0x1ffff; | ||
156 | DMAR0C(i) = 0; | ||
157 | DMAR10(i) = 0; | ||
158 | DMAR1C(i) = 0; | ||
159 | } | ||
160 | |||
161 | DMAINTSTAT = 0xc000ffff; | ||
162 | DMAINTEN = 0xc000ffff; | ||
163 | |||
164 | DMASRC(0) = physical_address(dma_buf_left); | ||
165 | DMADEST(0) = 0x80200280; | ||
166 | DMALEN(0) = 0xff; | ||
167 | DMAR1C(0) = 0; | ||
168 | DMAR0C(0) = 0x40408; | ||
169 | |||
170 | DMASRC(1) = physical_address(dma_buf_right); | ||
171 | DMADEST(1) = 0x80200284; | ||
172 | DMALEN(1) = 0xff; | ||
173 | DMAR1C(1) = 0; | ||
174 | DMAR0C(1) = 0x40409; | ||
175 | |||
176 | irq_set_int_handler(0x1b, audio_irq); | ||
177 | irq_enable_int(0x1b); | ||
178 | |||
179 | DMAINTSTAT = 1; | ||
180 | DMAINTSTAT = 2; | ||
181 | DMAINTEN &= ~3; | ||
182 | DMAR10(0) |= 1; | ||
183 | DMAR10(1) |= 1; | ||
184 | } | ||
185 | |||
186 | void pcm_play_dma_postinit(void) | ||
187 | { | ||
188 | audiohw_postinit(); | ||
189 | } | ||
190 | |||
191 | void pcm_dma_apply_settings(void) | ||
192 | { | ||
193 | } | ||
194 | |||
195 | const void * pcm_play_dma_get_peak_buffer(int *count) | ||
196 | { | ||
197 | unsigned long addr = (unsigned long)p; | ||
198 | size_t cnt = p_size; | ||
199 | *count = cnt >> 2; | ||
200 | return (void *)((addr + 2) & ~3); | ||
201 | } | ||
202 | |||
203 | void audiohw_set_volume(int value) | ||
204 | { | ||
205 | int tmp = (60 - value * 4) & 0xff; | ||
206 | CODECVOL = tmp | (tmp << 8); | ||
207 | } | ||
diff --git a/firmware/target/arm/pnx0101/system-pnx0101.c b/firmware/target/arm/pnx0101/system-pnx0101.c deleted file mode 100644 index 63720d11be..0000000000 --- a/firmware/target/arm/pnx0101/system-pnx0101.c +++ /dev/null | |||
@@ -1,317 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include "pnx0101.h" | ||
24 | #include "system.h" | ||
25 | |||
26 | static struct | ||
27 | { | ||
28 | unsigned char freq; | ||
29 | unsigned char sys_mult; | ||
30 | unsigned char sys_div; | ||
31 | } | ||
32 | perf_modes[3] ICONST_ATTR = | ||
33 | { | ||
34 | {12, 4, 4}, | ||
35 | {48, 4, 1}, | ||
36 | {60, 5, 1} | ||
37 | }; | ||
38 | |||
39 | static int performance_mode, bus_divider; | ||
40 | |||
41 | static void cgu_set_sel_stage_input(int clock, int input) | ||
42 | { | ||
43 | int s = CGU.base_ssr[clock]; | ||
44 | if (s & 1) | ||
45 | CGU.base_fs2[clock] = input; | ||
46 | else | ||
47 | CGU.base_fs1[clock] = input; | ||
48 | CGU.base_scr[clock] = (s & 3) ^ 3; | ||
49 | } | ||
50 | |||
51 | static void cgu_reset_sel_stage_clocks(int first_esr, int n_esr, | ||
52 | int first_div, int n_div) | ||
53 | { | ||
54 | int i; | ||
55 | for (i = 0; i < n_esr; i++) | ||
56 | CGU.clk_esr[first_esr + i] = 0; | ||
57 | for (i = 0; i < n_div; i++) | ||
58 | CGU.base_fdc[first_div + i] = 0; | ||
59 | } | ||
60 | |||
61 | static void cgu_configure_div(int div, int n, int m) | ||
62 | { | ||
63 | int msub, madd, div_size, max_n; | ||
64 | unsigned long cfg; | ||
65 | |||
66 | if (n == m) | ||
67 | { | ||
68 | CGU.base_fdc[div] = CGU.base_fdc[div] & ~1; | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | msub = -n; | ||
73 | madd = m - n; | ||
74 | div_size = (div == PNX0101_HIPREC_FDC) ? 10 : 8; | ||
75 | max_n = 1 << div_size; | ||
76 | while ((madd << 1) < max_n && (msub << 1) >= -max_n) | ||
77 | { | ||
78 | madd <<= 1; | ||
79 | msub <<= 1; | ||
80 | } | ||
81 | cfg = (((msub << div_size) | madd) << 3) | 4; | ||
82 | CGU.base_fdc[div] = CGU.base_fdc[div] & ~1; | ||
83 | CGU.base_fdc[div] = cfg | 2; | ||
84 | CGU.base_fdc[div] = cfg; | ||
85 | CGU.base_fdc[div] = cfg | 1; | ||
86 | } | ||
87 | |||
88 | static void cgu_connect_div_to_clock(int rel_div, int esr) | ||
89 | { | ||
90 | CGU.clk_esr[esr] = (rel_div << 1) | 1; | ||
91 | } | ||
92 | |||
93 | static void cgu_enable_clock(int clock) | ||
94 | { | ||
95 | CGU.clk_pcr[clock] |= 1; | ||
96 | } | ||
97 | |||
98 | static void cgu_start_sel_stage_dividers(int bcr) | ||
99 | { | ||
100 | CGU.base_bcr[bcr] = 1; | ||
101 | } | ||
102 | |||
103 | /* Convert a pointer that points to IRAM (0x4xxxx) to a pointer that | ||
104 | points to the uncached page (0x0xxxx) that is also mapped to IRAM. */ | ||
105 | static inline void *noncached(void *p) | ||
106 | { | ||
107 | return (void *)(((unsigned long)p) & 0xffff); | ||
108 | } | ||
109 | |||
110 | /* To avoid SRAM accesses while changing memory controller settings we | ||
111 | run this routine from uncached copy of IRAM. All times are in CPU | ||
112 | cycles. At CPU frequencies lower than 60 MHz we could use faster | ||
113 | settings, but since DMA may access SRAM at any time, changing | ||
114 | memory timings together with CPU frequency would be tricky. */ | ||
115 | static void do_set_mem_timings(void) ICODE_ATTR; | ||
116 | static void do_set_mem_timings(void) | ||
117 | { | ||
118 | int old_irq = disable_irq_save(); | ||
119 | while ((EMC.status & 3) != 0); | ||
120 | EMC.control = 5; | ||
121 | EMCSTATIC0.waitrd = 6; | ||
122 | EMCSTATIC0.waitwr = 5; | ||
123 | EMCSTATIC1.waitrd = 5; | ||
124 | EMCSTATIC1.waitwr = 4; /* OF uses 5 here */ | ||
125 | EMCSTATIC2.waitrd = 4; | ||
126 | EMCSTATIC2.waitwr = 3; | ||
127 | EMCSTATIC0.waitoen = 1; | ||
128 | EMCSTATIC1.waitoen = 1; | ||
129 | EMCSTATIC2.waitoen = 1; | ||
130 | /* Enable write buffers for SRAM. */ | ||
131 | #ifndef DEBUG | ||
132 | EMCSTATIC1.config = 0x80081; | ||
133 | #endif | ||
134 | EMC.control = 1; | ||
135 | restore_irq(old_irq); | ||
136 | } | ||
137 | |||
138 | static void emc_set_mem_timings(void) | ||
139 | { | ||
140 | void (*f)(void) = noncached(do_set_mem_timings); | ||
141 | (*f)(); | ||
142 | } | ||
143 | |||
144 | static void cgu_set_sys_mult(int i) | ||
145 | { | ||
146 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS, PNX0101_MAIN_CLOCK_FAST); | ||
147 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3, PNX0101_MAIN_CLOCK_FAST); | ||
148 | |||
149 | PLL.lppdn = 1; | ||
150 | PLL.lpfin = 1; | ||
151 | PLL.lpmbyp = 0; | ||
152 | PLL.lpdbyp = 0; | ||
153 | PLL.lppsel = 1; | ||
154 | PLL.lpmsel = i - 1; | ||
155 | PLL.lppdn = 0; | ||
156 | while (!PLL.lplock); | ||
157 | |||
158 | cgu_configure_div(PNX0101_FIRST_DIV_SYS + 1, 1, (i == 5) ? 15 : 12); | ||
159 | cgu_connect_div_to_clock(1, 0x11); | ||
160 | cgu_enable_clock(0x11); | ||
161 | cgu_start_sel_stage_dividers(PNX0101_BCR_SYS); | ||
162 | |||
163 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS, | ||
164 | PNX0101_MAIN_CLOCK_MAIN_PLL); | ||
165 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3, | ||
166 | PNX0101_MAIN_CLOCK_MAIN_PLL); | ||
167 | } | ||
168 | |||
169 | static void pnx0101_set_performance_mode(int mode) | ||
170 | { | ||
171 | int old = performance_mode; | ||
172 | if (perf_modes[old].sys_mult != perf_modes[mode].sys_mult) | ||
173 | cgu_set_sys_mult(perf_modes[mode].sys_mult); | ||
174 | if (perf_modes[old].sys_div != perf_modes[mode].sys_div) | ||
175 | cgu_configure_div(bus_divider, 1, perf_modes[mode].sys_div); | ||
176 | performance_mode = mode; | ||
177 | } | ||
178 | |||
179 | static void pnx0101_init_clocks(void) | ||
180 | { | ||
181 | bus_divider = PNX0101_FIRST_DIV_SYS + (CGU.clk_esr[0] >> 1); | ||
182 | performance_mode = 0; | ||
183 | emc_set_mem_timings(); | ||
184 | pnx0101_set_performance_mode(2); | ||
185 | |||
186 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB1, | ||
187 | PNX0101_MAIN_CLOCK_FAST); | ||
188 | cgu_reset_sel_stage_clocks(PNX0101_FIRST_ESR_APB1, PNX0101_N_ESR_APB1, | ||
189 | PNX0101_FIRST_DIV_APB1, PNX0101_N_DIV_APB1); | ||
190 | cgu_configure_div(PNX0101_FIRST_DIV_APB1, 1, 4); | ||
191 | cgu_connect_div_to_clock(0, PNX0101_ESR_APB1); | ||
192 | cgu_connect_div_to_clock(0, PNX0101_ESR_T0); | ||
193 | cgu_connect_div_to_clock(0, PNX0101_ESR_T1); | ||
194 | cgu_connect_div_to_clock(0, PNX0101_ESR_I2C); | ||
195 | cgu_enable_clock(PNX0101_CLOCK_APB1); | ||
196 | cgu_enable_clock(PNX0101_CLOCK_T0); | ||
197 | cgu_enable_clock(PNX0101_CLOCK_T1); | ||
198 | cgu_enable_clock(PNX0101_CLOCK_I2C); | ||
199 | } | ||
200 | |||
201 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
202 | void set_cpu_frequency(long frequency) | ||
203 | { | ||
204 | switch (frequency) | ||
205 | { | ||
206 | case CPUFREQ_MAX: | ||
207 | pnx0101_set_performance_mode(2); | ||
208 | cpu_frequency = CPUFREQ_MAX; | ||
209 | break; | ||
210 | case CPUFREQ_NORMAL: | ||
211 | pnx0101_set_performance_mode(1); | ||
212 | cpu_frequency = CPUFREQ_NORMAL; | ||
213 | break; | ||
214 | case CPUFREQ_DEFAULT: | ||
215 | default: | ||
216 | pnx0101_set_performance_mode(0); | ||
217 | cpu_frequency = CPUFREQ_DEFAULT; | ||
218 | break; | ||
219 | } | ||
220 | |||
221 | } | ||
222 | #endif | ||
223 | |||
224 | interrupt_handler_t interrupt_vector[0x1d] __attribute__ ((section(".idata"))); | ||
225 | |||
226 | #define IRQ_READ(reg, dest) \ | ||
227 | do { unsigned long v2; \ | ||
228 | do { \ | ||
229 | dest = (reg); \ | ||
230 | v2 = (reg); \ | ||
231 | } while ((dest != v2)); \ | ||
232 | } while (0); | ||
233 | |||
234 | #define IRQ_WRITE_WAIT(reg, val, cond) \ | ||
235 | do { unsigned long v, v2; \ | ||
236 | do { \ | ||
237 | (reg) = (val); \ | ||
238 | v = (reg); \ | ||
239 | v2 = (reg); \ | ||
240 | } while ((v != v2) || !(cond)); \ | ||
241 | } while (0); | ||
242 | |||
243 | static void undefined_int(void) | ||
244 | { | ||
245 | } | ||
246 | |||
247 | void irq(void) | ||
248 | { | ||
249 | unsigned long n; | ||
250 | IRQ_READ(INTVECTOR[0], n) | ||
251 | (*(interrupt_vector[n >> 3]))(); | ||
252 | } | ||
253 | |||
254 | void fiq(void) | ||
255 | { | ||
256 | } | ||
257 | |||
258 | void irq_enable_int(int n) | ||
259 | { | ||
260 | IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE | INTREQ_ENABLE, v & 0x10000); | ||
261 | } | ||
262 | |||
263 | void irq_disable_int(int n) | ||
264 | { | ||
265 | IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE, (v & 0x10000) == 0); | ||
266 | } | ||
267 | |||
268 | void irq_set_int_handler(int n, interrupt_handler_t handler) | ||
269 | { | ||
270 | interrupt_vector[n] = handler; | ||
271 | } | ||
272 | |||
273 | void system_init(void) | ||
274 | { | ||
275 | int i; | ||
276 | |||
277 | /* turn off watchdog */ | ||
278 | (*(volatile unsigned long *)0x80002804) = 0; | ||
279 | |||
280 | /* | ||
281 | IRQ_WRITE_WAIT(INTVECTOR[0], 0, v == 0); | ||
282 | IRQ_WRITE_WAIT(INTVECTOR[1], 0, v == 0); | ||
283 | IRQ_WRITE_WAIT(INTPRIOMASK[0], 0, v == 0); | ||
284 | IRQ_WRITE_WAIT(INTPRIOMASK[1], 0, v == 0); | ||
285 | */ | ||
286 | |||
287 | for (i = 1; i <= 0x1c; i++) | ||
288 | { | ||
289 | IRQ_WRITE_WAIT(INTREQ[i], | ||
290 | INTREQ_WEPRIO | INTREQ_WETARGET | | ||
291 | INTREQ_WEENABLE | INTREQ_WEACTVLO | 1, | ||
292 | (v & 0x3010f) == 1); | ||
293 | IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEENABLE, (v & 0x10000) == 0); | ||
294 | IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEPRIO | 1, (v & 0xf) == 1); | ||
295 | interrupt_vector[i] = undefined_int; | ||
296 | } | ||
297 | interrupt_vector[0] = undefined_int; | ||
298 | pnx0101_init_clocks(); | ||
299 | } | ||
300 | |||
301 | |||
302 | void system_reboot(void) | ||
303 | { | ||
304 | (*(volatile unsigned long *)0x80002804) = 1; | ||
305 | while (1); | ||
306 | } | ||
307 | |||
308 | void system_exception_wait(void) | ||
309 | { | ||
310 | while (1); | ||
311 | } | ||
312 | |||
313 | int system_memory_guard(int newmode) | ||
314 | { | ||
315 | (void)newmode; | ||
316 | return 0; | ||
317 | } | ||
diff --git a/firmware/target/arm/pnx0101/timer-pnx0101.c b/firmware/target/arm/pnx0101/timer-pnx0101.c deleted file mode 100644 index 1ec1d2871f..0000000000 --- a/firmware/target/arm/pnx0101/timer-pnx0101.c +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Tomasz Malesinski | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "timer.h" | ||
24 | |||
25 | static long cycles_new = 0; | ||
26 | |||
27 | void TIMER1_ISR(void) | ||
28 | { | ||
29 | if (cycles_new > 0) | ||
30 | { | ||
31 | TIMER1.load = cycles_new - 1; | ||
32 | cycles_new = 0; | ||
33 | } | ||
34 | if (pfn_timer != NULL) | ||
35 | { | ||
36 | cycles_new = -1; | ||
37 | /* "lock" the variable, in case timer_set_period() | ||
38 | * is called within pfn_timer() */ | ||
39 | pfn_timer(); | ||
40 | cycles_new = 0; | ||
41 | } | ||
42 | TIMER1.clr = 1; /* clear the interrupt */ | ||
43 | } | ||
44 | |||
45 | bool timer_set(long cycles, bool start) | ||
46 | { | ||
47 | if (start) | ||
48 | { | ||
49 | if (pfn_unregister != NULL) | ||
50 | { | ||
51 | pfn_unregister(); | ||
52 | pfn_unregister = NULL; | ||
53 | } | ||
54 | TIMER1.ctrl &= ~0x80; /* disable the counter */ | ||
55 | TIMER1.ctrl |= 0x40; /* reload after counting down to zero */ | ||
56 | TIMER1.ctrl &= ~0xc; /* no prescaler */ | ||
57 | TIMER1.clr = 1; /* clear an interrupt event */ | ||
58 | } | ||
59 | if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */ | ||
60 | { /* enable timer */ | ||
61 | TIMER1.load = cycles - 1; | ||
62 | TIMER1.ctrl |= 0x80; /* enable the counter */ | ||
63 | } | ||
64 | else | ||
65 | cycles_new = cycles; | ||
66 | |||
67 | return true; | ||
68 | } | ||
69 | |||
70 | bool timer_start(void) | ||
71 | { | ||
72 | irq_set_int_handler(IRQ_TIMER1, TIMER1_ISR); | ||
73 | irq_enable_int(IRQ_TIMER1); | ||
74 | return true; | ||
75 | } | ||
76 | |||
77 | void timer_stop(void) | ||
78 | { | ||
79 | TIMER1.ctrl &= ~0x80; /* disable timer 1 */ | ||
80 | irq_disable_int(IRQ_TIMER1); | ||
81 | } | ||
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h index 97562ef933..5b4030bd37 100644 --- a/firmware/target/hosted/sdl/sim-ui-defines.h +++ b/firmware/target/hosted/sdl/sim-ui-defines.h | |||
@@ -203,13 +203,6 @@ | |||
203 | #define UI_LCD_POSX 42 /* x position of lcd */ | 203 | #define UI_LCD_POSX 42 /* x position of lcd */ |
204 | #define UI_LCD_POSY 35 /* y position of lcd */ | 204 | #define UI_LCD_POSY 35 /* y position of lcd */ |
205 | 205 | ||
206 | #elif defined(IRIVER_IFP7XX) | ||
207 | #define UI_TITLE "iriver iFP7xx" | ||
208 | #define UI_WIDTH 425 /* width of GUI window */ | ||
209 | #define UI_HEIGHT 183 /* height of GUI window */ | ||
210 | #define UI_LCD_POSX 115 /* x position of lcd */ | ||
211 | #define UI_LCD_POSY 54 /* y position of lcd */ | ||
212 | |||
213 | #elif defined(MROBE_100) | 206 | #elif defined(MROBE_100) |
214 | #define UI_TITLE "Olympus M:Robe 100" | 207 | #define UI_TITLE "Olympus M:Robe 100" |
215 | #define UI_WIDTH 247 /* width of GUI window */ | 208 | #define UI_WIDTH 247 /* width of GUI window */ |