summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/SOURCES26
-rwxr-xr-xfirmware/target/sh/archos/lcd-as-archos-bitmap.S211
-rwxr-xr-xfirmware/target/sh/archos/player/lcd-as-player.S (renamed from firmware/drivers/lcd.S)100
3 files changed, 246 insertions, 91 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 2b3e632ed7..1a43eab0a9 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -213,7 +213,6 @@ bitswap.S
213crt0.S 213crt0.S
214descramble.S 214descramble.S
215drivers/i2c.c 215drivers/i2c.c
216drivers/lcd.S
217target/sh/crt0.S 216target/sh/crt0.S
218target/sh/memcpy-sh.S 217target/sh/memcpy-sh.S
219target/sh/memmove-sh.S 218target/sh/memmove-sh.S
@@ -246,7 +245,6 @@ target/coldfire/i2c-coldfire.c
246common/memcpy.c 245common/memcpy.c
247common/memmove.c 246common/memmove.c
248common/strlen.c 247common/strlen.c
249drivers/lcd.S
250#ifndef SIMULATOR 248#ifndef SIMULATOR
251target/arm/memset-arm.S 249target/arm/memset-arm.S
252target/arm/memset16-arm.S 250target/arm/memset16-arm.S
@@ -280,6 +278,30 @@ drivers/i2c.c
280 278
281#endif /* defined(CPU_*) */ 279#endif /* defined(CPU_*) */
282 280
281#ifdef ARCHOS_PLAYER
282#ifndef SIMULATOR
283target/sh/archos/player/lcd-as-player.S
284#endif /* SIMULATOR */
285#endif /* ARCHOS_PLAYER */
286
287#ifdef ARCHOS_RECORDER
288#ifndef SIMULATOR
289target/sh/archos/lcd-as-archos-bitmap.S
290#endif /* SIMULATOR */
291#endif /* ARCHOS_RECORDER */
292
293#if defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2)
294#ifndef SIMULATOR
295target/sh/archos/lcd-as-archos-bitmap.S
296#endif /* SIMULATOR */
297#endif /* ARCHOS_FMRECORDER || ARCHOS_RECORDERV2 */
298
299#if defined(ARCHOS_ONDIOFM) || defined(ARCHOS_ONDIOSP)
300#ifndef SIMULATOR
301target/sh/archos/lcd-as-archos-bitmap.S
302#endif /* SIMULATOR */
303#endif /* ARCHOS_ONDIOFM || ARCHOS_ONDIOFM */
304
283#ifdef SANSA_E200 305#ifdef SANSA_E200
284#ifndef SIMULATOR 306#ifndef SIMULATOR
285target/arm/wmcodec-pp.c 307target/arm/wmcodec-pp.c
diff --git a/firmware/target/sh/archos/lcd-as-archos-bitmap.S b/firmware/target/sh/archos/lcd-as-archos-bitmap.S
new file mode 100755
index 0000000000..bef231c3c7
--- /dev/null
+++ b/firmware/target/sh/archos/lcd-as-archos-bitmap.S
@@ -0,0 +1,211 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Jens Arnold
11 * Based on the work of Alan Korr and Jörg Hohensohn
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "cpu.h"
23
24#define LCDR (PBDR_ADDR+1)
25
26#define LCD_SD 1 /* PB0 = 1 --- 0001 */
27#define LCD_SC 2 /* PB1 = 1 --- 0010 */
28#define LCD_DS 4 /* PB2 = 1 --- 0100 */
29#define LCD_CS 8 /* PB3 = 1 --- 1000 */
30
31/*
32 * About /CS,DS,SC,SD
33 * ------------------
34 *
35 * LCD on JBP and JBR uses a SPI protocol to receive orders (SDA and SCK lines)
36 *
37 * - /CS -> Chip Selection line :
38 * 0 : LCD chipset is activated.
39 * - DS -> Data Selection line, latched at the rising edge
40 * of the 8th serial clock (*) :
41 * 0 : instruction register,
42 * 1 : data register;
43 * - SC -> Serial Clock line (SDA).
44 * - SD -> Serial Data line (SCK), latched at the rising edge
45 * of each serial clock (*).
46 *
47 * _ _
48 * /CS \ /
49 * \______________________________________________________/
50 * _____ ____ ____ ____ ____ ____ ____ ____ ____ _____
51 * SD \/ D7 \/ D6 \/ D5 \/ D4 \/ D3 \/ D2 \/ D1 \/ D0 \/
52 * _____/\____/\____/\____/\____/\____/\____/\____/\____/\_____
53 *
54 * _____ _ _ _ _ _ _ _ ________
55 * SC \ * \ * \ * \ * \ * \ * \ * \ *
56 * \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
57 * _ _________________________________________________________
58 * DS \/
59 * _/\_________________________________________________________
60 *
61 */
62
63 .section .icode,"ax",@progbits
64
65 .align 2
66 .global _lcd_write_command
67 .type _lcd_write_command,@function
68
69/* Write a command byte to the lcd controller
70 *
71 * Arguments:
72 * r4 - data byte (int)
73 *
74 * Register usage:
75 * r0 - scratch
76 * r1 - data byte (copied)
77 * r2 - precalculated port value (CS, DS and SC low, SD high),
78 * negated (neg)!
79 * r3 - lcd port address
80 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
81 */
82
83_lcd_write_command:
84 mov.l .lcdr,r3 /* put lcd data port address in r3 */
85 mov r4,r1 /* copy data byte to r1 */
86 mov #1,r5 /* set byte count to 1 (!) */
87
88 /* This code will fail if an interrupt changes the contents of PBDRL.
89 * If so, we must disable the interrupt here. */
90
91 mov.b @r3,r0 /* r0 = PBDRL */
92 or #(LCD_SD),r0 /* r0 |= LCD_SD */
93 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
94
95 bra .single_transfer /* jump into the transfer loop */
96 neg r0,r2 /* r2 = 0 - r0 */
97
98
99 .align 2
100 .global _lcd_write_data
101 .type _lcd_write_data,@function
102
103
104/* A high performance function to write data to the display,
105 * one or multiple bytes.
106 *
107 * Arguments:
108 * r4 - data address
109 * r5 - byte count
110 *
111 * Register usage:
112 * r0 - scratch
113 * r1 - current data byte
114 * r2 - precalculated port value (CS and SC low, DS and SD high),
115 * negated (neg)!
116 * r3 - lcd port address
117 */
118
119_lcd_write_data:
120 mov.l .lcdr,r3 /* put lcd data port address in r3 */
121 nop /* align here */
122
123 /* This code will fail if an interrupt changes the contents of PBDRL.
124 * If so, we must disable the interrupt here. If disabling interrupts
125 * for a long time (~9200 clks = ~830 µs for transferring 112 bytes on
126 * recorders)is undesirable, the loop has to be rewritten to
127 * disable/precalculate/transfer/enable for each iteration. However,
128 * this would significantly decrease performance. */
129
130 mov.b @r3,r0 /* r0 = PBDRL */
131 or #(LCD_DS|LCD_SD),r0 /* r0 |= LCD_DS|LCD_SD */
132 and #(~(LCD_CS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_SC) */
133 neg r0,r2 /* r2 = 0 - r0 */
134
135 /* loop exploits that SD is on bit 0 for recorders and Ondios */
136
137 .align 2
138.multi_transfer:
139 mov.b @r4+,r1 /* load data byte from memory */
140 nop
141
142.single_transfer:
143 shll16 r1 /* shift data to most significant byte */
144 shll8 r1
145 not r1,r1 /* and invert for use with negc */
146
147 shll r1 /* shift the MSB into carry */
148 negc r2,r0 /* carry to SD, SC low */
149 shll r1 /* next shift here for alignment */
150 mov.b r0,@r3 /* set data to port */
151 or #(LCD_SC),r0 /* rise SC (independent of SD level) */
152 mov.b r0,@r3 /* set to port */
153
154 negc r2,r0
155 mov.b r0,@r3
156 or #(LCD_SC),r0
157 mov.b r0,@r3
158
159 shll r1
160 negc r2,r0
161 shll r1
162 mov.b r0,@r3
163 or #(LCD_SC),r0
164 mov.b r0,@r3
165
166 negc r2,r0
167 mov.b r0,@r3
168 or #(LCD_SC),r0
169 mov.b r0,@r3
170
171 shll r1
172 negc r2,r0
173 shll r1
174 mov.b r0,@r3
175 or #(LCD_SC),r0
176 mov.b r0,@r3
177
178 negc r2,r0
179 mov.b r0,@r3
180 or #(LCD_SC),r0
181 mov.b r0,@r3
182
183 shll r1
184 negc r2,r0
185 shll r1
186 mov.b r0,@r3
187 or #(LCD_SC),r0
188 mov.b r0,@r3
189
190 negc r2,r0
191 mov.b r0,@r3
192 or #(LCD_SC),r0
193 mov.b r0,@r3
194
195 add #-1,r5 /* decrease byte count */
196 tst r5,r5 /* r5 == 0 ? */
197 bf .multi_transfer /* no: next iteration */
198
199 or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC),r0 /* restore port */
200 rts
201 mov.b r0,@r3
202
203 /* This is the place to reenable the interrupts, if we have disabled
204 * them. See above. */
205
206 .align 2
207.lcdr:
208 .long LCDR
209
210.end:
211 .size _lcd_write_command,.end-_lcd_write_command
diff --git a/firmware/drivers/lcd.S b/firmware/target/sh/archos/player/lcd-as-player.S
index ed0bc8d15b..7a6324865f 100755
--- a/firmware/drivers/lcd.S
+++ b/firmware/target/sh/archos/player/lcd-as-player.S
@@ -21,21 +21,12 @@
21#include "config.h" 21#include "config.h"
22#include "cpu.h" 22#include "cpu.h"
23 23
24#if CONFIG_CPU == SH7034
25#define LCDR (PBDR_ADDR+1) 24#define LCDR (PBDR_ADDR+1)
26 25
27#ifdef HAVE_LCD_CHARCELLS
28#define LCD_DS 1 /* PB0 = 1 --- 0001 --- LCD-DS */ 26#define LCD_DS 1 /* PB0 = 1 --- 0001 --- LCD-DS */
29#define LCD_CS 2 /* PB1 = 1 --- 0010 --- /LCD-CS */ 27#define LCD_CS 2 /* PB1 = 1 --- 0010 --- /LCD-CS */
30#define LCD_SD 4 /* PB2 = 1 --- 0100 --- LCD-SD */ 28#define LCD_SD 4 /* PB2 = 1 --- 0100 --- LCD-SD */
31#define LCD_SC 8 /* PB3 = 1 --- 1000 --- LCD-SC */ 29#define LCD_SC 8 /* PB3 = 1 --- 1000 --- LCD-SC */
32#else
33#define LCD_SD 1 /* PB0 = 1 --- 0001 */
34#define LCD_SC 2 /* PB1 = 1 --- 0010 */
35#define LCD_RS 4 /* PB2 = 1 --- 0100 */
36#define LCD_CS 8 /* PB3 = 1 --- 1000 */
37#define LCD_DS LCD_RS
38#endif
39 30
40/* 31/*
41 * About /CS,DS,SC,SD 32 * About /CS,DS,SC,SD
@@ -83,8 +74,7 @@
83 * Register usage: 74 * Register usage:
84 * r0 - scratch 75 * r0 - scratch
85 * r1 - data byte (copied) 76 * r1 - data byte (copied)
86 * r2 - precalculated port value (CS, DS and SC low, SD high), 77 * r2 - precalculated port value (CS, DS and SC low, SD high)
87 * negated (neg)!
88 * r3 - lcd port address 78 * r3 - lcd port address
89 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data) 79 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
90 */ 80 */
@@ -102,7 +92,7 @@ _lcd_write_command:
102 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */ 92 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
103 93
104 bra .single_transfer /* jump into the transfer loop */ 94 bra .single_transfer /* jump into the transfer loop */
105 neg r0,r2 /* r2 = 0 - r0 */ 95 mov r0,r2
106 96
107 97
108 .align 2 98 .align 2
@@ -139,10 +129,7 @@ _lcd_write_data:
139 mov.b @r3,r0 /* r0 = PBDRL */ 129 mov.b @r3,r0 /* r0 = PBDRL */
140 or #(LCD_DS|LCD_SD),r0 /* r0 |= LCD_DS|LCD_SD */ 130 or #(LCD_DS|LCD_SD),r0 /* r0 |= LCD_DS|LCD_SD */
141 and #(~(LCD_CS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_SC) */ 131 and #(~(LCD_CS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_SC) */
142 neg r0,r2 /* r2 = 0 - r0 */ 132 mov r0,r2
143
144#ifdef HAVE_LCD_CHARCELLS
145/* optimized player version, also works for recorders */
146 133
147 .align 2 134 .align 2
148.multi_transfer: 135.multi_transfer:
@@ -153,8 +140,7 @@ _lcd_write_data:
153 shll8 r1 140 shll8 r1
154 141
155 shll r1 /* shift the msb into carry */ 142 shll r1 /* shift the msb into carry */
156 neg r2,r0 /* copy negated precalculated port value */ 143 mov r2,r0 /* copy precalculated port value */
157 /* uses neg here for compatibility with recorder version */
158 bt 1f /* data bit = 1? */ 144 bt 1f /* data bit = 1? */
159 and #(~LCD_SD),r0 /* no: r0 &= ~LCD_SD */ 145 and #(~LCD_SD),r0 /* no: r0 &= ~LCD_SD */
160 1: 146 1:
@@ -163,7 +149,7 @@ _lcd_write_data:
163 or #(LCD_SC),r0 /* rise SC (independent of SD level) */ 149 or #(LCD_SC),r0 /* rise SC (independent of SD level) */
164 mov.b r0,@r3 /* set to port */ 150 mov.b r0,@r3 /* set to port */
165 151
166 neg r2,r0 152 mov r2,r0
167 bt 1f 153 bt 1f
168 and #(~LCD_SD),r0 154 and #(~LCD_SD),r0
169 1: 155 1:
@@ -172,7 +158,7 @@ _lcd_write_data:
172 mov.b r0,@r3 158 mov.b r0,@r3
173 159
174 shll r1 160 shll r1
175 neg r2,r0 161 mov r2,r0
176 bt 1f 162 bt 1f
177 and #(~LCD_SD),r0 163 and #(~LCD_SD),r0
178 1: 164 1:
@@ -181,7 +167,7 @@ _lcd_write_data:
181 or #(LCD_SC),r0 167 or #(LCD_SC),r0
182 mov.b r0,@r3 168 mov.b r0,@r3
183 169
184 neg r2,r0 170 mov r2,r0
185 bt 1f 171 bt 1f
186 and #(~LCD_SD),r0 172 and #(~LCD_SD),r0
187 1: 173 1:
@@ -190,7 +176,7 @@ _lcd_write_data:
190 mov.b r0,@r3 176 mov.b r0,@r3
191 177
192 shll r1 178 shll r1
193 neg r2,r0 179 mov r2,r0
194 bt 1f 180 bt 1f
195 and #(~LCD_SD),r0 181 and #(~LCD_SD),r0
196 1: 182 1:
@@ -199,7 +185,7 @@ _lcd_write_data:
199 or #(LCD_SC),r0 185 or #(LCD_SC),r0
200 mov.b r0,@r3 186 mov.b r0,@r3
201 187
202 neg r2,r0 188 mov r2,r0
203 bt 1f 189 bt 1f
204 and #(~LCD_SD),r0 190 and #(~LCD_SD),r0
205 1: 191 1:
@@ -208,7 +194,7 @@ _lcd_write_data:
208 mov.b r0,@r3 194 mov.b r0,@r3
209 195
210 shll r1 196 shll r1
211 neg r2,r0 197 mov r2,r0
212 bt 1f 198 bt 1f
213 and #(~LCD_SD),r0 199 and #(~LCD_SD),r0
214 1: 200 1:
@@ -217,7 +203,7 @@ _lcd_write_data:
217 or #(LCD_SC),r0 203 or #(LCD_SC),r0
218 mov.b r0,@r3 204 mov.b r0,@r3
219 205
220 neg r2,r0 206 mov r2,r0
221 bt 1f 207 bt 1f
222 and #(~LCD_SD),r0 208 and #(~LCD_SD),r0
223 1: 209 1:
@@ -225,69 +211,6 @@ _lcd_write_data:
225 or #(LCD_SC),r0 211 or #(LCD_SC),r0
226 mov.b r0,@r3 212 mov.b r0,@r3
227 213
228#else /* HAVE_LCD_CHARCELLS */
229/* further optimized version, exploits that SD is on bit 0 for recorders */
230
231 .align 2
232.multi_transfer:
233 mov.b @r4+,r1 /* load data byte from memory */
234 nop
235
236.single_transfer:
237 shll16 r1 /* shift data to most significant byte */
238 shll8 r1
239 not r1,r1 /* and invert for use with negc */
240
241 shll r1 /* shift the MSB into carry */
242 negc r2,r0 /* carry to SD, SC low */
243 shll r1 /* next shift here for alignment */
244 mov.b r0,@r3 /* set data to port */
245 or #(LCD_SC),r0 /* rise SC (independent of SD level) */
246 mov.b r0,@r3 /* set to port */
247
248 negc r2,r0
249 mov.b r0,@r3
250 or #(LCD_SC),r0
251 mov.b r0,@r3
252
253 shll r1
254 negc r2,r0
255 shll r1
256 mov.b r0,@r3
257 or #(LCD_SC),r0
258 mov.b r0,@r3
259
260 negc r2,r0
261 mov.b r0,@r3
262 or #(LCD_SC),r0
263 mov.b r0,@r3
264
265 shll r1
266 negc r2,r0
267 shll r1
268 mov.b r0,@r3
269 or #(LCD_SC),r0
270 mov.b r0,@r3
271
272 negc r2,r0
273 mov.b r0,@r3
274 or #(LCD_SC),r0
275 mov.b r0,@r3
276
277 shll r1
278 negc r2,r0
279 shll r1
280 mov.b r0,@r3
281 or #(LCD_SC),r0
282 mov.b r0,@r3
283
284 negc r2,r0
285 mov.b r0,@r3
286 or #(LCD_SC),r0
287 mov.b r0,@r3
288
289#endif /* HAVE_LCD_CHARCELLS */
290
291 add #-1,r5 /* decrease byte count */ 214 add #-1,r5 /* decrease byte count */
292 tst r5,r5 /* r5 == 0 ? */ 215 tst r5,r5 /* r5 == 0 ? */
293 bf .multi_transfer /* no: next iteration */ 216 bf .multi_transfer /* no: next iteration */
@@ -305,4 +228,3 @@ _lcd_write_data:
305 228
306.end: 229.end:
307 .size _lcd_write_command,.end-_lcd_write_command 230 .size _lcd_write_command,.end-_lcd_write_command
308#endif