Also fix Debug->View partitions when SECTOR_SIZE!=512
[kugel-rb.git] / firmware / target / arm / ipod / lcd-as-gray.S
blobb6878a1a78ffa944a652696f8069d1c000e939cd
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2008 by Jens Arnold
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  ****************************************************************************/
22 #include "config.h"
23 #include "cpu.h"
25 #if CONFIG_CPU == PP5002
26     .section    .icode,"ax",%progbits
27 #else
28     .text
29 #endif
30     .align      2
33     .global     lcd_write_data
34     .type       lcd_write_data,%function
36 lcd_write_data:
37     ldr     r12, =LCD1_BASE
39 .loop:
40     ldrb    r2, [r0], #1
42 #ifdef IPOD_MINI2G
43     ldrb    r3, [r0], #1
44     orr     r2, r3, r2, lsl #8
45     orr     r2, r2, #0x760000
47     ldr     r3, [r12]
48     tst     r3, #LCD1_BUSY_MASK
49     bne     1b
50     str     r2, [r12, #0x08]
51 #else
53     ldr     r3, [r12]
54     tst     r3, #LCD1_BUSY_MASK
55     bne     1b
56     str     r2, [r12, #0x10]
58     ldrb    r2, [r0], #1
60     ldr     r3, [r12]
61     tst     r3, #LCD1_BUSY_MASK
62     bne     1b
63     str     r2, [r12, #0x10]
64 #endif
66     subs    r1, r1, #1
67     bne     .loop
69     bx      lr
70     .size   lcd_write_data,.-lcd_write_data
71     
73 #ifdef IPOD_MINI2G
75     .global     lcd_write_data_shifted
76     .type       lcd_write_data_shifted,%function
77     
78 lcd_write_data_shifted:
79     stmfd   sp!, {r4, lr}
80     ldr     lr, =LCD1_BASE
81     mov     r12, #0x760000
82     ldrb    r2, [r0], #1
84 .sloop:
85     ldrb    r3, [r0], #1
86     orr     r2, r3, r2, lsl #8
87     ldrb    r3, [r0], #1
88     orr     r2, r3, r2, lsl #8
89     mov     r4, r2, lsl #12
90     orr     r4, r12, r4, lsr #16
92     ldr     r3, [lr]
93     tst     r3, #LCD1_BUSY_MASK
94     bne     1b
95     str     r4, [lr, #0x08]
97     subs    r1, r1, #1
98     bne     .sloop
100     ldmfd   sp!, {r4, pc}
101     .size   lcd_write_data_shifted,.-lcd_write_data_shifted
102     
103 #elif defined IPOD_MINI
105     .global     lcd_write_data_shifted
106     .type       lcd_write_data_shifted,%function
107     
108 lcd_write_data_shifted:
109     str     lr, [sp, #-4]!
110     ldr     lr, =LCD1_BASE
111     ldrb    r2, [r0], #1
113 .sloop:
114     ldrb    r3, [r0], #1
115     orr     r2, r3, r2, lsl #8
116     mov     r12, r2, lsr #4
118     ldr     r3, [lr]
119     tst     r3, #LCD1_BUSY_MASK
120     bne     1b
121     str     r12, [lr, #0x10]
123     ldrb    r3, [r0], #1
124     orr     r2, r3, r2, lsl #8
125     mov     r12, r2, lsr #4
127     ldr     r3, [lr]
128     tst     r3, #LCD1_BUSY_MASK
129     bne     1b
130     str     r12, [lr, #0x10]
132     subs    r1, r1, #1
133     bne     .sloop
135     ldr     pc, [sp], #4
136     .size   lcd_write_data_shifted,.-lcd_write_data_shifted
138 #endif
140     .global     lcd_mono_data
141     .type       lcd_mono_data,%function
142     
143 lcd_mono_data:
144     stmfd   sp!, {r4, lr}
145     ldr     lr, =LCD1_BASE
146     adr     r12, .dibits
148 .mloop:
149     ldrb    r2, [r0], #1
150     mov     r3, r2, lsr #4
151     ldrb    r4, [r12, r3]
153 #ifdef IPOD_MINI2G
154     and     r3, r2, #0x0f
155     ldrb    r3, [r12, r3]
156     orr     r4, r3, r4, lsl #8
157     orr     r4, r4, #0x760000
159     ldr     r3, [lr]
160     tst     r3, #LCD1_BUSY_MASK
161     bne     1b
162     str     r4, [lr, #0x08]
163 #else
165     ldr     r3, [lr]
166     tst     r3, #LCD1_BUSY_MASK
167     bne     1b
168     str     r4, [lr, #0x10]
170     and     r3, r2, #0x0f
171     ldrb    r4, [r12, r3]
173     ldr     r3, [lr]
174     tst     r3, #LCD1_BUSY_MASK
175     bne     1b
176     str     r4, [lr, #0x10]
177 #endif
179     subs    r1, r1, #1
180     bne     .mloop
182     ldmfd   sp!, {r4, pc}
184 .dibits:
185     .byte   0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F
186     .byte   0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF
188     .size   lcd_mono_data,.-lcd_mono_data
191     .global     lcd_grey_data
192     .type       lcd_grey_data,%function
194 /* A high performance function to write grey phase data to the display,
195  * one or multiple pixels.
197  * Arguments:
198  *   r0 - pixel value data address
199  *   r1 - pixel phase data address
200  *   r2 - pixel block count
202  * Register usage:
203  *   r3/r4 - current block of phases
204  *   r5/r6 - current block of values
205  *   r7  - lcd data accumulator
206  *   r12 - phase signs mask
207  *   lr  - lcd bridge address
208  */
210 lcd_grey_data:
211     stmfd   sp!, {r4-r7, lr}
212     mov     r12, #0x80
213     orr     r12, r12, r12, lsl #8
214     orr     r12, r12, r12, lsl #16
215     ldr     lr, =LCD1_BASE
217 .greyloop:
218     ldmia   r1, {r3-r4}         /* Fetch 8 pixel phases */
219     ldmia   r0!, {r5-r6}        /* Fetch 8 pixel values */
221 #ifdef IPOD_MINI2G              /* Serial bridge mode */
222     mov     r7, #0x760000
223     tst     r3, #0x80
224     orreq   r7, r7, #0xc000
225     tst     r3, #0x8000
226     orreq   r7, r7, #0x3000
227     tst     r3, #0x800000
228     orreq   r7, r7, #0x0c00
229     tst     r3, #0x80000000
230     orreq   r7, r7, #0x0300
231     bic     r3, r3, r12
232     add     r3, r3, r5
233 #else                           /* Parallel bridge mode */
234     mov     r7, #0
235     tst     r3, #0x80
236     orreq   r7, r7, #0xc0
237     tst     r3, #0x8000
238     orreq   r7, r7, #0x30
239     tst     r3, #0x800000
240     orreq   r7, r7, #0x0c
241     tst     r3, #0x80000000
242     orreq   r7, r7, #0x03
243     bic     r3, r3, r12
244     add     r3, r3, r5
247     ldr     r5, [lr]
248     tst     r5, #LCD1_BUSY_MASK
249     bne     1b
251     str     r7, [lr, #0x10]
252     mov     r7, #0
253 #endif
255     tst     r4, #0x80
256     orreq   r7, r7, #0xc0
257     tst     r4, #0x8000
258     orreq   r7, r7, #0x30
259     tst     r4, #0x800000
260     orreq   r7, r7, #0x0c
261     tst     r4, #0x80000000
262     orreq   r7, r7, #0x03
263     bic     r4, r4, r12
264     add     r4, r4, r6
266     stmia   r1!, {r3-r4}
269     ldr     r5, [lr]
270     tst     r5, #LCD1_BUSY_MASK
271     bne     1b
272 #ifdef IPOD_MINI2G
273     str     r7, [lr, #0x08]
274 #else
275     str     r7, [lr, #0x10]
276 #endif
278     subs    r2, r2, #1
279     bne     .greyloop
281     ldmfd   sp!, {r4-r7, pc}
282     .size   lcd_grey_data,.-lcd_grey_data