diff options
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r-- | firmware/target/arm/tcc77x/lcd-ssd1815.c | 256 |
1 files changed, 0 insertions, 256 deletions
diff --git a/firmware/target/arm/tcc77x/lcd-ssd1815.c b/firmware/target/arm/tcc77x/lcd-ssd1815.c deleted file mode 100644 index b41c8d26ef..0000000000 --- a/firmware/target/arm/tcc77x/lcd-ssd1815.c +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
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 | #include "config.h" | ||
22 | |||
23 | #include "hwcompat.h" | ||
24 | #include "kernel.h" | ||
25 | #include "lcd.h" | ||
26 | #include "system.h" | ||
27 | #include "cpu.h" | ||
28 | |||
29 | /*** definitions ***/ | ||
30 | |||
31 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
32 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
33 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
34 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
35 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
36 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
37 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
38 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
39 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
40 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
41 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
42 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
43 | #define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) | ||
44 | #define LCD_SET_BIAS_TC_OSC ((char)0xA9) | ||
45 | #define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA) | ||
46 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
47 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
48 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
49 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
50 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
51 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
52 | #define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2) | ||
53 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
54 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
55 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
56 | #define LCD_NOP ((char)0xE3) | ||
57 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
58 | |||
59 | /* LCD command codes */ | ||
60 | #define LCD_CNTL_RESET 0xe2 /* Software reset */ | ||
61 | #define LCD_CNTL_POWER 0x2f /* Power control */ | ||
62 | #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ | ||
63 | #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ | ||
64 | #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ | ||
65 | #define LCD_CNTL_DISPON 0xaf /* Display on */ | ||
66 | |||
67 | #define LCD_CNTL_PAGE 0xb0 /* Page address */ | ||
68 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | ||
69 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | ||
70 | |||
71 | /* TCC77x specific defines */ | ||
72 | #define LCD_BASE 0x50000000 | ||
73 | #define LCD_CMD *(volatile unsigned char*)(LCD_BASE) | ||
74 | #define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1) | ||
75 | |||
76 | void lcd_write_command(int byte) | ||
77 | { | ||
78 | LCD_CMD = byte; | ||
79 | |||
80 | asm volatile ( | ||
81 | "nop \n\t" | ||
82 | "nop \n\t" | ||
83 | "nop \n\t" | ||
84 | ); | ||
85 | } | ||
86 | |||
87 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
88 | { | ||
89 | while (count--) | ||
90 | { | ||
91 | LCD_DATA = *(p_bytes++); | ||
92 | |||
93 | asm volatile ( | ||
94 | "nop \n\t" | ||
95 | "nop \n\t" | ||
96 | "nop \n\t" | ||
97 | ); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | /* End of TCC77x specific defines */ | ||
102 | |||
103 | |||
104 | /** globals **/ | ||
105 | |||
106 | static int xoffset; /* needed for flip */ | ||
107 | |||
108 | /*** hardware configuration ***/ | ||
109 | |||
110 | int lcd_default_contrast(void) | ||
111 | { | ||
112 | return 0x1f; | ||
113 | } | ||
114 | |||
115 | void lcd_set_contrast(int val) | ||
116 | { | ||
117 | lcd_write_command(LCD_CNTL_CONTRAST); | ||
118 | lcd_write_command(val); | ||
119 | } | ||
120 | |||
121 | void lcd_set_invert_display(bool yesno) | ||
122 | { | ||
123 | if (yesno) | ||
124 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | ||
125 | else | ||
126 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
127 | } | ||
128 | |||
129 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
130 | void lcd_set_flip(bool yesno) | ||
131 | { | ||
132 | (void)yesno; | ||
133 | /* TODO */ | ||
134 | } | ||
135 | |||
136 | |||
137 | /* LCD init */ | ||
138 | void lcd_init_device(void) | ||
139 | { | ||
140 | uint32_t bus_width; | ||
141 | |||
142 | /* Telechips init the same as the original firmware */ | ||
143 | CSCFG1 &= 0xc3ffc000; | ||
144 | CSCFG1 |= 0x3400101a; | ||
145 | CSCFG1 |= (1 << 21); | ||
146 | CSCFG1 &= ~(1 << 21); | ||
147 | |||
148 | bus_width = ((MCFG >> 11) & 0x3) ^ 3; | ||
149 | |||
150 | CSCFG1 = (bus_width << 28) | | ||
151 | (3 << 26) | /* MTYPE = 3 */ | ||
152 | ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */ | ||
153 | (1 << 20) | /* Unknown */ | ||
154 | (3 << 11) | /* Setup time = 3 cycles */ | ||
155 | (3 << 3) | /* Pulse width = 3+1 cycles */ | ||
156 | (1 << 0); /* Hold time = 1 cycle */ | ||
157 | |||
158 | /* SSD1815 inits like the original firmware */ | ||
159 | lcd_write_command(LCD_SET_DISPLAY_OFF); | ||
160 | lcd_set_flip(false); | ||
161 | lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5); | ||
162 | lcd_set_contrast(lcd_default_contrast()); | ||
163 | lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7); | ||
164 | /* power control register: op-amp=1, regulator=1, booster=1 */ | ||
165 | lcd_write_command(LCD_SET_BIAS_TC_OSC); | ||
166 | |||
167 | /* 0xc2 = 110 000 10: Osc. Freq 110 - ??? | ||
168 | TC value 000 - "-0.01%/C (TC0, POR)" | ||
169 | Bias ratio 10 - "1/9, 1/7 (POR)" | ||
170 | */ | ||
171 | lcd_write_command(0xc2); | ||
172 | lcd_write_command(LCD_SET_DISPLAY_ON); | ||
173 | |||
174 | lcd_clear_display(); | ||
175 | lcd_update(); | ||
176 | } | ||
177 | |||
178 | /*** Update functions ***/ | ||
179 | |||
180 | /* Performance function that works with an external buffer | ||
181 | note that by and bheight are in 8-pixel units! */ | ||
182 | void lcd_blit_mono(const unsigned char *data, int x, int by, int width, | ||
183 | int bheight, int stride) | ||
184 | { | ||
185 | /* Copy display bitmap to hardware */ | ||
186 | while (bheight--) | ||
187 | { | ||
188 | lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); | ||
189 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf)); | ||
190 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
191 | |||
192 | lcd_write_data(data, width); | ||
193 | data += stride; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | |||
198 | /* Performance function that works with an external buffer | ||
199 | note that by and bheight are in 8-pixel units! */ | ||
200 | void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, | ||
201 | int x, int by, int width, int bheight, int stride) | ||
202 | { | ||
203 | (void)values; | ||
204 | (void)phases; | ||
205 | (void)x; | ||
206 | (void)by; | ||
207 | (void)width; | ||
208 | (void)bheight; | ||
209 | (void)stride; | ||
210 | } | ||
211 | |||
212 | /* Update the display. | ||
213 | This must be called after all other LCD functions that change the display. */ | ||
214 | void lcd_update(void) ICODE_ATTR; | ||
215 | void lcd_update(void) | ||
216 | { | ||
217 | int y; | ||
218 | |||
219 | /* Copy display bitmap to hardware */ | ||
220 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
221 | { | ||
222 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
223 | lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf)); | ||
224 | lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf)); | ||
225 | |||
226 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /* Update a fraction of the display. */ | ||
231 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
232 | void lcd_update_rect(int x, int y, int width, int height) | ||
233 | { | ||
234 | int ymax; | ||
235 | |||
236 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
237 | ymax = (y + height-1) >> 3; | ||
238 | y >>= 3; | ||
239 | |||
240 | if(x + width > LCD_WIDTH) | ||
241 | width = LCD_WIDTH - x; | ||
242 | if (width <= 0) | ||
243 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
244 | if(ymax >= LCD_FBHEIGHT) | ||
245 | ymax = LCD_FBHEIGHT-1; | ||
246 | |||
247 | /* Copy specified rectange bitmap to hardware */ | ||
248 | for (; y <= ymax; y++) | ||
249 | { | ||
250 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
251 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf)); | ||
252 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
253 | |||
254 | lcd_write_data (&lcd_framebuffer[y][x], width); | ||
255 | } | ||
256 | } | ||