diff options
Diffstat (limited to 'firmware/target/arm/tcc77x/logikdax')
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/adc-target.h | 26 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/backlight-target.h | 38 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/button-target.h | 70 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c | 253 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/power-logikdax.c | 66 |
5 files changed, 453 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/logikdax/adc-target.h b/firmware/target/arm/tcc77x/logikdax/adc-target.h new file mode 100644 index 0000000000..cfc8117a99 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/adc-target.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 | #ifndef _ADC_TARGET_H_ | ||
20 | #define _ADC_TARGET_H_ | ||
21 | |||
22 | #define NUM_ADC_CHANNELS 8 | ||
23 | |||
24 | #define ADC_BUTTONS 0 | ||
25 | |||
26 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h new file mode 100644 index 0000000000..4714f22aa3 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/backlight-target.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 | #ifndef BACKLIGHT_TARGET_H | ||
20 | #define BACKLIGHT_TARGET_H | ||
21 | |||
22 | #include "tcc77x.h" | ||
23 | |||
24 | #define __backlight_init() true | ||
25 | |||
26 | static inline void __backlight_on(void) | ||
27 | { | ||
28 | /* Enable backlight */ | ||
29 | GPIOD |= 0x10; | ||
30 | } | ||
31 | |||
32 | static inline void __backlight_off(void) | ||
33 | { | ||
34 | /* Disable backlight */ | ||
35 | GPIOD &= ~0x10; | ||
36 | } | ||
37 | |||
38 | #endif | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h new file mode 100644 index 0000000000..2925a423b6 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/button-target.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
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 | |||
20 | #ifndef _BUTTON_TARGET_H_ | ||
21 | #define _BUTTON_TARGET_H_ | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | /* | ||
27 | |||
28 | Results of button testing: | ||
29 | |||
30 | HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released) | ||
31 | POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released) | ||
32 | |||
33 | ADC[0]: (approx values) | ||
34 | |||
35 | RIGHT - 0x37 | ||
36 | LEFT - 0x7f | ||
37 | JOYSTICK PRESS - 0xc7 | ||
38 | UP - 0x11e | ||
39 | DOWN - 0x184 | ||
40 | MODE - 0x1f0/0x1ff | ||
41 | PRESET - 0x268/0x269 | ||
42 | TIMESHIFT - 0x2dd | ||
43 | |||
44 | Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384 | ||
45 | |||
46 | */ | ||
47 | |||
48 | |||
49 | void button_init_device(void); | ||
50 | int button_read_device(void); | ||
51 | |||
52 | /* Main unit's buttons */ | ||
53 | #define BUTTON_POWERPLAY 0x00000001 | ||
54 | #define BUTTON_MODE 0x00000002 | ||
55 | #define BUTTON_HOLD 0x00000004 | ||
56 | #define BUTTON_REC 0x00000008 | ||
57 | #define BUTTON_PRESET 0x00000010 | ||
58 | #define BUTTON_LEFT 0x00000020 | ||
59 | #define BUTTON_RIGHT 0x00000040 | ||
60 | #define BUTTON_UP 0x00000080 | ||
61 | #define BUTTON_DOWN 0x00000100 | ||
62 | #define BUTTON_SELECT 0x00000200 | ||
63 | |||
64 | #define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\ | ||
65 | |BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\ | ||
66 | |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT) | ||
67 | |||
68 | #define BUTTON_REMOTE 0 | ||
69 | |||
70 | #endif /* _BUTTON_TARGET_H_ */ | ||
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 | } | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c new file mode 100644 index 0000000000..df2ee10d6b --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Dave Chapman | ||
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 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | |||
26 | #ifndef SIMULATOR | ||
27 | |||
28 | void power_init(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | void ide_power_enable(bool on) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | bool ide_powered(void) | ||
37 | { | ||
38 | return true; | ||
39 | } | ||
40 | |||
41 | void power_off(void) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | #else /* SIMULATOR */ | ||
46 | |||
47 | bool charger_inserted(void) | ||
48 | { | ||
49 | return false; | ||
50 | } | ||
51 | |||
52 | void charger_enable(bool on) | ||
53 | { | ||
54 | (void)on; | ||
55 | } | ||
56 | |||
57 | void power_off(void) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | void ide_power_enable(bool on) | ||
62 | { | ||
63 | (void)on; | ||
64 | } | ||
65 | |||
66 | #endif /* SIMULATOR */ | ||