diff options
author | Dave Chapman <dave@dchapman.com> | 2008-09-06 17:50:59 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2008-09-06 17:50:59 +0000 |
commit | d462a64a918117991e11dade2d7fa3a28196e07a (patch) | |
tree | 0a6f5ed8777b18bb1641fbb3608f10374901706c /firmware/target/arm/tcc77x/iaudio7/ata2501.c | |
parent | b87715f670f04c9adbe358c32a385c6771d99a81 (diff) | |
download | rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip |
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7/ata2501.c')
-rw-r--r-- | firmware/target/arm/tcc77x/iaudio7/ata2501.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c new file mode 100644 index 0000000000..fa165d9d0d --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 Vitja Makarov | ||
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 "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "button.h" | ||
25 | |||
26 | #include "ata2501.h" | ||
27 | |||
28 | #define STB (1<<5) | ||
29 | #define SDATA (1<<4) | ||
30 | #define RESET (1<<6) | ||
31 | #define SIFMD (1<<7) | ||
32 | #define STB_DELAY 200 | ||
33 | |||
34 | #define udelay _udelay | ||
35 | |||
36 | /* do we really need it? */ | ||
37 | static void _udelay(int cycles) | ||
38 | { | ||
39 | cycles /= 8; | ||
40 | while (cycles--) { | ||
41 | asm("nop;nop;"); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | TODO: sensitivity using GPIOS | ||
47 | */ | ||
48 | void ata2501_init(void) | ||
49 | { | ||
50 | GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9)); | ||
51 | GPIOD_DIR &= ~(SDATA); | ||
52 | |||
53 | GPIOD &= ~RESET; | ||
54 | udelay(1000); | ||
55 | |||
56 | GPIOD |= RESET; | ||
57 | |||
58 | GPIOD &= ~STB; | ||
59 | |||
60 | #if 1 | ||
61 | GPIOD &= ~((1 << 9) | (1 << 8)); | ||
62 | GPIOD |= ((1 << 8) | SIFMD) | (1 << 9); | ||
63 | #else | ||
64 | GPIOD |= ((1 << 9) | (1 << 8)); | ||
65 | GPIOD &= ~(SIFMD); | ||
66 | #endif | ||
67 | } | ||
68 | |||
69 | unsigned short ata2501_read(void) | ||
70 | { | ||
71 | unsigned short ret = 0; | ||
72 | int i; | ||
73 | |||
74 | for (i = 0; i < 12; i++) { | ||
75 | GPIOD |= STB; | ||
76 | udelay(50); | ||
77 | |||
78 | ret <<= 1; | ||
79 | if (GPIOD & SDATA) | ||
80 | ret |= 1; | ||
81 | udelay(50); | ||
82 | GPIOD &= ~STB; | ||
83 | udelay(100); | ||
84 | } | ||
85 | |||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | #define ATA2501_TEST | ||
90 | #ifdef ATA2501_TEST | ||
91 | #include "lcd.h" | ||
92 | #include "sprintf.h" | ||
93 | |||
94 | static | ||
95 | void bits(char *str, unsigned short val) | ||
96 | { | ||
97 | int i; | ||
98 | |||
99 | for (i = 0; i < 12; i++) | ||
100 | str[i] = (val & (1 << i)) ? '1' : '0'; | ||
101 | str[i] = 0; | ||
102 | } | ||
103 | |||
104 | void ata2501_test(void) | ||
105 | { | ||
106 | char buf[100]; | ||
107 | ata2501_init(); | ||
108 | |||
109 | while (1) { | ||
110 | unsigned short data; | ||
111 | int i, line = 0; | ||
112 | |||
113 | data = ata2501_read(); | ||
114 | lcd_clear_display(); | ||
115 | lcd_puts(0, line++, "ATA2501 test"); | ||
116 | |||
117 | bits(buf, data); | ||
118 | lcd_puts(0, line++, buf); | ||
119 | |||
120 | lcd_update(); | ||
121 | udelay(2000); | ||
122 | } | ||
123 | } | ||
124 | #endif | ||