blob: a066e55a054867e2f511027a7cbcc3d0ec1ef2ef [file] [log] [blame]
Jens Arnold41cd44c2008-01-12 00:59:18 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Jens Arnold41cd44c2008-01-12 00:59:18 +000016 *
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
25#if CONFIG_CPU == PP5002
26 .section .icode,"ax",%progbits
27#else
28 .text
29#endif
30 .align 2
31
32
33 .global lcd_write_data
34 .type lcd_write_data,%function
35
36lcd_write_data:
Jens Arnold567105b2008-03-28 18:56:50 +000037 str lr, [sp, #-4]!
38 ldr lr, =LCD1_BASE
Jens Arnold41cd44c2008-01-12 00:59:18 +000039
40.loop:
Jens Arnold567105b2008-03-28 18:56:50 +000041 ldrb r2, [r0], #1
Jens Arnold41cd44c2008-01-12 00:59:18 +000042
43#ifdef IPOD_MINI2G
Jens Arnold567105b2008-03-28 18:56:50 +000044 ldrb r3, [r0], #1
45 orr r2, r3, r2, lsl #8
46 orr r2, r2, #0x760000
Jens Arnold41cd44c2008-01-12 00:59:18 +0000471:
Jens Arnold567105b2008-03-28 18:56:50 +000048 ldr r3, [lr]
49 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +000050 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +000051 str r2, [lr, #0x08]
Jens Arnold41cd44c2008-01-12 00:59:18 +000052#else
531:
Jens Arnold567105b2008-03-28 18:56:50 +000054 ldr r3, [lr]
55 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +000056 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +000057 str r2, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +000058
Jens Arnold567105b2008-03-28 18:56:50 +000059 ldrb r2, [r0], #1
Jens Arnold41cd44c2008-01-12 00:59:18 +0000601:
Jens Arnold567105b2008-03-28 18:56:50 +000061 ldr r3, [lr]
62 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +000063 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +000064 str r2, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +000065#endif
66
67 subs r1, r1, #1
68 bne .loop
69
Jens Arnold567105b2008-03-28 18:56:50 +000070 ldr pc, [sp], #4
Jens Arnold28cd26c2008-01-13 13:58:18 +000071 .size lcd_write_data,.-lcd_write_data
Jens Arnold41cd44c2008-01-12 00:59:18 +000072
73
74#ifdef IPOD_MINI2G
75
76 .global lcd_write_data_shifted
77 .type lcd_write_data_shifted,%function
78
79lcd_write_data_shifted:
Jens Arnold567105b2008-03-28 18:56:50 +000080 stmfd sp!, {r4, r5, lr}
81 ldr lr, =LCD1_BASE
82 mov r5, #0x760000
83 ldrb r2, [r0], #1
Jens Arnold41cd44c2008-01-12 00:59:18 +000084
85.sloop:
Jens Arnold567105b2008-03-28 18:56:50 +000086 ldrb r3, [r0], #1
87 orr r2, r3, r2, lsl #8
88 ldrb r3, [r0], #1
89 orr r2, r3, r2, lsl #8
90 mov r4, r2, lsl #12
91 orr r4, r5, r4, lsr #16
Jens Arnold41cd44c2008-01-12 00:59:18 +0000921:
Jens Arnold567105b2008-03-28 18:56:50 +000093 ldr r3, [lr]
94 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +000095 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +000096 str r4, [lr, #0x08]
Jens Arnold41cd44c2008-01-12 00:59:18 +000097
98 subs r1, r1, #1
99 bne .sloop
100
Jens Arnold567105b2008-03-28 18:56:50 +0000101 ldmfd sp!, {r4, r5, pc}
Jens Arnold28cd26c2008-01-13 13:58:18 +0000102 .size lcd_write_data_shifted,.-lcd_write_data_shifted
Jens Arnold41cd44c2008-01-12 00:59:18 +0000103
104#elif defined IPOD_MINI
105
106 .global lcd_write_data_shifted
107 .type lcd_write_data_shifted,%function
108
109lcd_write_data_shifted:
Jens Arnold567105b2008-03-28 18:56:50 +0000110 stmfd sp!, {r4, lr}
111 ldr lr, =LCD1_BASE
112 ldrb r2, [r0], #1
Jens Arnold41cd44c2008-01-12 00:59:18 +0000113
114.sloop:
Jens Arnold567105b2008-03-28 18:56:50 +0000115 ldrb r3, [r0], #1
116 orr r2, r3, r2, lsl #8
117 mov r4, r2, lsr #4
Jens Arnold41cd44c2008-01-12 00:59:18 +00001181:
Jens Arnold567105b2008-03-28 18:56:50 +0000119 ldr r3, [lr]
120 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000121 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +0000122 str r4, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000123
Jens Arnold567105b2008-03-28 18:56:50 +0000124 ldrb r3, [r0], #1
125 orr r2, r3, r2, lsl #8
126 mov r4, r2, lsr #4
Jens Arnold41cd44c2008-01-12 00:59:18 +00001271:
Jens Arnold567105b2008-03-28 18:56:50 +0000128 ldr r3, [lr]
129 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000130 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +0000131 str r4, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000132
133 subs r1, r1, #1
134 bne .sloop
135
Jens Arnold567105b2008-03-28 18:56:50 +0000136 ldmfd sp!, {r4, pc}
Jens Arnold28cd26c2008-01-13 13:58:18 +0000137 .size lcd_write_data_shifted,.-lcd_write_data_shifted
138
Jens Arnold41cd44c2008-01-12 00:59:18 +0000139#endif
140
141 .global lcd_mono_data
142 .type lcd_mono_data,%function
143
144lcd_mono_data:
Jens Arnold567105b2008-03-28 18:56:50 +0000145 stmfd sp!, {r4, r5, lr}
146 ldr lr, =LCD1_BASE
147 adr r5, .dibits
Jens Arnold41cd44c2008-01-12 00:59:18 +0000148
149.mloop:
Jens Arnold567105b2008-03-28 18:56:50 +0000150 ldrb r2, [r0], #1
151 mov r3, r2, lsr #4
152 ldrb r4, [r5, r3]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000153
154#ifdef IPOD_MINI2G
Jens Arnold567105b2008-03-28 18:56:50 +0000155 and r3, r2, #0x0f
156 ldrb r3, [r5, r3]
157 orr r4, r3, r4, lsl #8
158 orr r4, r4, #0x760000
Jens Arnold41cd44c2008-01-12 00:59:18 +00001591:
Jens Arnold567105b2008-03-28 18:56:50 +0000160 ldr r3, [lr]
161 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000162 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +0000163 str r4, [lr, #0x08]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000164#else
1651:
Jens Arnold567105b2008-03-28 18:56:50 +0000166 ldr r3, [lr]
167 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000168 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +0000169 str r4, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000170
Jens Arnold567105b2008-03-28 18:56:50 +0000171 and r3, r2, #0x0f
172 ldrb r4, [r5, r3]
Jens Arnold41cd44c2008-01-12 00:59:18 +00001731:
Jens Arnold567105b2008-03-28 18:56:50 +0000174 ldr r3, [lr]
175 tst r3, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000176 bne 1b
Jens Arnold567105b2008-03-28 18:56:50 +0000177 str r4, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000178#endif
179
180 subs r1, r1, #1
181 bne .mloop
182
Jens Arnold567105b2008-03-28 18:56:50 +0000183 ldmfd sp!, {r4, r5, pc}
Jens Arnold41cd44c2008-01-12 00:59:18 +0000184
185.dibits:
186 .byte 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F
187 .byte 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF
188
Jens Arnold28cd26c2008-01-13 13:58:18 +0000189 .size lcd_mono_data,.-lcd_mono_data
190
Jens Arnold41cd44c2008-01-12 00:59:18 +0000191
192 .global lcd_grey_data
193 .type lcd_grey_data,%function
194
195/* A high performance function to write grey phase data to the display,
196 * one or multiple pixels.
197 *
198 * Arguments:
199 * r0 - pixel value data address
200 * r1 - pixel phase data address
201 * r2 - pixel block count
202 *
203 * Register usage:
204 * r3/r4 - current block of phases
205 * r5/r6 - current block of values
206 * r7 - lcd data accumulator
207 * r8 - phase signs mask
Jens Arnold567105b2008-03-28 18:56:50 +0000208 * lr - lcd bridge address
Jens Arnold41cd44c2008-01-12 00:59:18 +0000209 */
210
211lcd_grey_data:
Jens Arnold567105b2008-03-28 18:56:50 +0000212 stmfd sp!, {r4-r8, lr}
Jens Arnold41cd44c2008-01-12 00:59:18 +0000213 mov r8, #0x80
214 orr r8, r8, r8, lsl #8
215 orr r8, r8, r8, lsl #16
Jens Arnold567105b2008-03-28 18:56:50 +0000216 ldr lr, =LCD1_BASE
Jens Arnold41cd44c2008-01-12 00:59:18 +0000217
218.greyloop:
219 ldmia r1, {r3-r4} /* Fetch 8 pixel phases */
220 ldmia r0!, {r5-r6} /* Fetch 8 pixel values */
221
222#ifdef IPOD_MINI2G /* Serial bridge mode */
223 mov r7, #0x760000
224 tst r3, #0x80
225 orreq r7, r7, #0xc000
226 tst r3, #0x8000
227 orreq r7, r7, #0x3000
228 tst r3, #0x800000
229 orreq r7, r7, #0x0c00
230 tst r3, #0x80000000
231 orreq r7, r7, #0x0300
232 bic r3, r3, r8
233 add r3, r3, r5
234#else /* Parallel bridge mode */
235 mov r7, #0
236 tst r3, #0x80
237 orreq r7, r7, #0xc0
238 tst r3, #0x8000
239 orreq r7, r7, #0x30
240 tst r3, #0x800000
241 orreq r7, r7, #0x0c
242 tst r3, #0x80000000
243 orreq r7, r7, #0x03
244 bic r3, r3, r8
245 add r3, r3, r5
246
2471:
Jens Arnold567105b2008-03-28 18:56:50 +0000248 ldr r5, [lr]
Jens Arnold28cd26c2008-01-13 13:58:18 +0000249 tst r5, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000250 bne 1b
251
Jens Arnold567105b2008-03-28 18:56:50 +0000252 str r7, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000253 mov r7, #0
254#endif
255
256 tst r4, #0x80
257 orreq r7, r7, #0xc0
258 tst r4, #0x8000
259 orreq r7, r7, #0x30
260 tst r4, #0x800000
261 orreq r7, r7, #0x0c
262 tst r4, #0x80000000
263 orreq r7, r7, #0x03
264 bic r4, r4, r8
265 add r4, r4, r6
266
267 stmia r1!, {r3-r4}
268
2691:
Jens Arnold567105b2008-03-28 18:56:50 +0000270 ldr r5, [lr]
Jens Arnold28cd26c2008-01-13 13:58:18 +0000271 tst r5, #LCD1_BUSY_MASK
Jens Arnold41cd44c2008-01-12 00:59:18 +0000272 bne 1b
273#ifdef IPOD_MINI2G
Jens Arnold567105b2008-03-28 18:56:50 +0000274 str r7, [lr, #0x08]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000275#else
Jens Arnold567105b2008-03-28 18:56:50 +0000276 str r7, [lr, #0x10]
Jens Arnold41cd44c2008-01-12 00:59:18 +0000277#endif
278
279 subs r2, r2, #1
280 bne .greyloop
281
Jens Arnold567105b2008-03-28 18:56:50 +0000282 ldmfd sp!, {r4-r8, pc}
Jens Arnold28cd26c2008-01-13 13:58:18 +0000283 .size lcd_grey_data,.-lcd_grey_data
Jens Arnold41cd44c2008-01-12 00:59:18 +0000284