diff options
author | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-10-28 11:08:10 +0000 |
commit | 28f6ae49ec1b1d3464add2941eb015bab56f8016 (patch) | |
tree | 6d4cddba129663340cf2f30212a516acdd16a4eb /firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c | |
parent | d3e101bd1184e5c1f474ff0978f65ac7e8e2dbfb (diff) | |
download | rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.tar.gz rockbox-28f6ae49ec1b1d3464add2941eb015bab56f8016.zip |
Initial work on a port to the Logik DAX 1GB MP3/DAB player. The bootloader build compiles and runs (but only displays some debugging info), and the LCD and ADC drivers are working. Two different bootloader builds are possible: 1) The default build is just a test application for uploading to the device via tcctool; 2) Adding -DTCCBOOT to EXTRA_DEFINES in the build directory Makefile will compile the bootloader so that it can be appended to the end of the original firmware and installed on the device, dual-booting. This commit also includes some work by Hein-Pieter van Braam on a port to the iAudio 7, but that doesn't build yet. A large part of these ports will be generic to all TCC77x devices - see the TelechipsInfo wiki page for some other devices with this CPU. NOTE: Compiling these builds requires an arm-elf-gcc with armv5 support - the current version of rockboxdev.sh compiles such a gcc.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15339 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c')
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c new file mode 100644 index 0000000000..973d4cb333 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c | |||
@@ -0,0 +1,253 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | |||
21 | #include "hwcompat.h" | ||
22 | #include "kernel.h" | ||
23 | #include "lcd.h" | ||
24 | #include "system.h" | ||
25 | #include "cpu.h" | ||
26 | |||
27 | /*** definitions ***/ | ||
28 | |||
29 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
30 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
31 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
32 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
33 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
34 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
35 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
36 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
37 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
38 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
39 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
40 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
41 | #define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) | ||
42 | #define LCD_SET_BIAS_TC_OSC ((char)0xA9) | ||
43 | #define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA) | ||
44 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
45 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
46 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
47 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
48 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
49 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
50 | #define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2) | ||
51 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
52 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
53 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
54 | #define LCD_NOP ((char)0xE3) | ||
55 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
56 | |||
57 | /* LCD command codes */ | ||
58 | #define LCD_CNTL_RESET 0xe2 /* Software reset */ | ||
59 | #define LCD_CNTL_POWER 0x2f /* Power control */ | ||
60 | #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ | ||
61 | #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ | ||
62 | #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ | ||
63 | #define LCD_CNTL_DISPON 0xaf /* Display on */ | ||
64 | |||
65 | #define LCD_CNTL_PAGE 0xb0 /* Page address */ | ||
66 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | ||
67 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | ||
68 | |||
69 | /* TCC77x specific defines */ | ||
70 | #define LCD_BASE 0x50000000 | ||
71 | #define LCD_CMD *(volatile unsigned char*)(LCD_BASE) | ||
72 | #define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1) | ||
73 | |||
74 | void lcd_write_command(int byte) | ||
75 | { | ||
76 | LCD_CMD = byte; | ||
77 | |||
78 | asm volatile ( | ||
79 | "nop \n\t" | ||
80 | "nop \n\t" | ||
81 | "nop \n\t" | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
86 | { | ||
87 | while (count--) | ||
88 | { | ||
89 | LCD_DATA = *(p_bytes++); | ||
90 | |||
91 | asm volatile ( | ||
92 | "nop \n\t" | ||
93 | "nop \n\t" | ||
94 | "nop \n\t" | ||
95 | ); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | /* End of TCC77x specific defines */ | ||
100 | |||
101 | |||
102 | /** globals **/ | ||
103 | |||
104 | static int xoffset; /* needed for flip */ | ||
105 | |||
106 | /*** hardware configuration ***/ | ||
107 | |||
108 | int lcd_default_contrast(void) | ||
109 | { | ||
110 | return 0x1f; | ||
111 | } | ||
112 | |||
113 | void lcd_set_contrast(int val) | ||
114 | { | ||
115 | lcd_write_command(LCD_CNTL_CONTRAST); | ||
116 | lcd_write_command(val); | ||
117 | } | ||
118 | |||
119 | void lcd_set_invert_display(bool yesno) | ||
120 | { | ||
121 | if (yesno) | ||
122 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | ||
123 | else | ||
124 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
125 | } | ||
126 | |||
127 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
128 | void lcd_set_flip(bool yesno) | ||
129 | { | ||
130 | /* TODO: flip mode isn't working. The commands in the else part of | ||
131 | this function are how the original firmware inits the LCD */ | ||
132 | |||
133 | if (yesno) | ||
134 | { | ||
135 | lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01); | ||
136 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION); | ||
137 | xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 128 we have */ | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | lcd_write_command(LCD_SET_SEGMENT_REMAP); | ||
142 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08); | ||
143 | xoffset = 0; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | |||
148 | /* LCD init */ | ||
149 | void lcd_init_device(void) | ||
150 | { | ||
151 | uint32_t bus_width; | ||
152 | |||
153 | /* Telechips init the same as the original firmware */ | ||
154 | CSCFG1 &= 0xc3ffc000; | ||
155 | CSCFG1 |= 0x3400101a; | ||
156 | CSCFG1 |= (1 << 21); | ||
157 | CSCFG1 &= ~(1 << 21); | ||
158 | |||
159 | bus_width = ((MCFG >> 11) & 0x3) ^ 3; | ||
160 | |||
161 | CSCFG1 = (bus_width << 28) | | ||
162 | (3 << 26) | /* MTYPE = 3 */ | ||
163 | ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */ | ||
164 | (1 << 20) | /* Unknown */ | ||
165 | (3 << 11) | /* Setup time = 3 cycles */ | ||
166 | (3 << 3) | /* Pulse width = 3+1 cycles */ | ||
167 | (1 << 0); /* Hold time = 1 cycle */ | ||
168 | |||
169 | /* SSD1815 inits like the original firmware */ | ||
170 | lcd_write_command(LCD_SET_DISPLAY_OFF); | ||
171 | lcd_set_flip(false); | ||
172 | lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5); | ||
173 | lcd_set_contrast(lcd_default_contrast()); | ||
174 | lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7); | ||
175 | /* power control register: op-amp=1, regulator=1, booster=1 */ | ||
176 | lcd_write_command(LCD_SET_BIAS_TC_OSC); | ||
177 | |||
178 | /* 0xc2 = 110 000 10: Osc. Freq 110 - ??? | ||
179 | TC value 000 - "-0.01%/C (TC0, POR)" | ||
180 | Bias ratio 10 - "1/9, 1/7 (POR)" | ||
181 | */ | ||
182 | lcd_write_command(0xc2); | ||
183 | lcd_write_command(LCD_SET_DISPLAY_ON); | ||
184 | |||
185 | lcd_clear_display(); | ||
186 | lcd_update(); | ||
187 | } | ||
188 | |||
189 | /*** Update functions ***/ | ||
190 | |||
191 | /* Performance function that works with an external buffer | ||
192 | note that by and bheight are in 8-pixel units! */ | ||
193 | void lcd_blit(const unsigned char* data, int x, int by, int width, | ||
194 | int bheight, int stride) | ||
195 | { | ||
196 | /* Copy display bitmap to hardware */ | ||
197 | while (bheight--) | ||
198 | { | ||
199 | lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); | ||
200 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf)); | ||
201 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
202 | |||
203 | lcd_write_data(data, width); | ||
204 | data += stride; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | |||
209 | /* Update the display. | ||
210 | This must be called after all other LCD functions that change the display. */ | ||
211 | void lcd_update(void) ICODE_ATTR; | ||
212 | void lcd_update(void) | ||
213 | { | ||
214 | int y; | ||
215 | |||
216 | /* Copy display bitmap to hardware */ | ||
217 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
218 | { | ||
219 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
220 | lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf)); | ||
221 | lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf)); | ||
222 | |||
223 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /* Update a fraction of the display. */ | ||
228 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
229 | void lcd_update_rect(int x, int y, int width, int height) | ||
230 | { | ||
231 | int ymax; | ||
232 | |||
233 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
234 | ymax = (y + height-1) >> 3; | ||
235 | y >>= 3; | ||
236 | |||
237 | if(x + width > LCD_WIDTH) | ||
238 | width = LCD_WIDTH - x; | ||
239 | if (width <= 0) | ||
240 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
241 | if(ymax >= LCD_FBHEIGHT) | ||
242 | ymax = LCD_FBHEIGHT-1; | ||
243 | |||
244 | /* Copy specified rectange bitmap to hardware */ | ||
245 | for (; y <= ymax; y++) | ||
246 | { | ||
247 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
248 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf)); | ||
249 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf)); | ||
250 | |||
251 | lcd_write_data (&lcd_framebuffer[y][x], width); | ||
252 | } | ||
253 | } | ||