Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Jens Arnold |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 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 | |
| 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 | |
| 36 | lcd_write_data: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 37 | str lr, [sp, #-4]! |
| 38 | ldr lr, =LCD1_BASE |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 39 | |
| 40 | .loop: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 41 | ldrb r2, [r0], #1 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 42 | |
| 43 | #ifdef IPOD_MINI2G |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 44 | ldrb r3, [r0], #1 |
| 45 | orr r2, r3, r2, lsl #8 |
| 46 | orr r2, r2, #0x760000 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 47 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 48 | ldr r3, [lr] |
| 49 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 50 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 51 | str r2, [lr, #0x08] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 52 | #else |
| 53 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 54 | ldr r3, [lr] |
| 55 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 56 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 57 | str r2, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 58 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 59 | ldrb r2, [r0], #1 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 60 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 61 | ldr r3, [lr] |
| 62 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 63 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 64 | str r2, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 65 | #endif |
| 66 | |
| 67 | subs r1, r1, #1 |
| 68 | bne .loop |
| 69 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 70 | ldr pc, [sp], #4 |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 71 | .size lcd_write_data,.-lcd_write_data |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | #ifdef IPOD_MINI2G |
| 75 | |
| 76 | .global lcd_write_data_shifted |
| 77 | .type lcd_write_data_shifted,%function |
| 78 | |
| 79 | lcd_write_data_shifted: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 80 | stmfd sp!, {r4, r5, lr} |
| 81 | ldr lr, =LCD1_BASE |
| 82 | mov r5, #0x760000 |
| 83 | ldrb r2, [r0], #1 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 84 | |
| 85 | .sloop: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 86 | 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 Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 92 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 93 | ldr r3, [lr] |
| 94 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 95 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 96 | str r4, [lr, #0x08] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 97 | |
| 98 | subs r1, r1, #1 |
| 99 | bne .sloop |
| 100 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 101 | ldmfd sp!, {r4, r5, pc} |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 102 | .size lcd_write_data_shifted,.-lcd_write_data_shifted |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 103 | |
| 104 | #elif defined IPOD_MINI |
| 105 | |
| 106 | .global lcd_write_data_shifted |
| 107 | .type lcd_write_data_shifted,%function |
| 108 | |
| 109 | lcd_write_data_shifted: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 110 | stmfd sp!, {r4, lr} |
| 111 | ldr lr, =LCD1_BASE |
| 112 | ldrb r2, [r0], #1 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 113 | |
| 114 | .sloop: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 115 | ldrb r3, [r0], #1 |
| 116 | orr r2, r3, r2, lsl #8 |
| 117 | mov r4, r2, lsr #4 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 118 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 119 | ldr r3, [lr] |
| 120 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 121 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 122 | str r4, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 123 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 124 | ldrb r3, [r0], #1 |
| 125 | orr r2, r3, r2, lsl #8 |
| 126 | mov r4, r2, lsr #4 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 127 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 128 | ldr r3, [lr] |
| 129 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 130 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 131 | str r4, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 132 | |
| 133 | subs r1, r1, #1 |
| 134 | bne .sloop |
| 135 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 136 | ldmfd sp!, {r4, pc} |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 137 | .size lcd_write_data_shifted,.-lcd_write_data_shifted |
| 138 | |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 139 | #endif |
| 140 | |
| 141 | .global lcd_mono_data |
| 142 | .type lcd_mono_data,%function |
| 143 | |
| 144 | lcd_mono_data: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 145 | stmfd sp!, {r4, r5, lr} |
| 146 | ldr lr, =LCD1_BASE |
| 147 | adr r5, .dibits |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 148 | |
| 149 | .mloop: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 150 | ldrb r2, [r0], #1 |
| 151 | mov r3, r2, lsr #4 |
| 152 | ldrb r4, [r5, r3] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 153 | |
| 154 | #ifdef IPOD_MINI2G |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 155 | and r3, r2, #0x0f |
| 156 | ldrb r3, [r5, r3] |
| 157 | orr r4, r3, r4, lsl #8 |
| 158 | orr r4, r4, #0x760000 |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 159 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 160 | ldr r3, [lr] |
| 161 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 162 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 163 | str r4, [lr, #0x08] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 164 | #else |
| 165 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 166 | ldr r3, [lr] |
| 167 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 168 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 169 | str r4, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 170 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 171 | and r3, r2, #0x0f |
| 172 | ldrb r4, [r5, r3] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 173 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 174 | ldr r3, [lr] |
| 175 | tst r3, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 176 | bne 1b |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 177 | str r4, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 178 | #endif |
| 179 | |
| 180 | subs r1, r1, #1 |
| 181 | bne .mloop |
| 182 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 183 | ldmfd sp!, {r4, r5, pc} |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 184 | |
| 185 | .dibits: |
| 186 | .byte 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F |
| 187 | .byte 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF |
| 188 | |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 189 | .size lcd_mono_data,.-lcd_mono_data |
| 190 | |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 191 | |
| 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 Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 208 | * lr - lcd bridge address |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 209 | */ |
| 210 | |
| 211 | lcd_grey_data: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 212 | stmfd sp!, {r4-r8, lr} |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 213 | mov r8, #0x80 |
| 214 | orr r8, r8, r8, lsl #8 |
| 215 | orr r8, r8, r8, lsl #16 |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 216 | ldr lr, =LCD1_BASE |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 217 | |
| 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 | |
| 247 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 248 | ldr r5, [lr] |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 249 | tst r5, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 250 | bne 1b |
| 251 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 252 | str r7, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 253 | 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 | |
| 269 | 1: |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 270 | ldr r5, [lr] |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 271 | tst r5, #LCD1_BUSY_MASK |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 272 | bne 1b |
| 273 | #ifdef IPOD_MINI2G |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 274 | str r7, [lr, #0x08] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 275 | #else |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 276 | str r7, [lr, #0x10] |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 277 | #endif |
| 278 | |
| 279 | subs r2, r2, #1 |
| 280 | bne .greyloop |
| 281 | |
Jens Arnold | 567105b | 2008-03-28 18:56:50 +0000 | [diff] [blame] | 282 | ldmfd sp!, {r4-r8, pc} |
Jens Arnold | 28cd26c | 2008-01-13 13:58:18 +0000 | [diff] [blame] | 283 | .size lcd_grey_data,.-lcd_grey_data |
Jens Arnold | 41cd44c | 2008-01-12 00:59:18 +0000 | [diff] [blame] | 284 | |