diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-05-25 21:10:45 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-05-25 21:10:45 +0000 |
commit | 758bb3bc628705ff8e5c677b3b2d87720c726c13 (patch) | |
tree | d78cbf984e4bc613b0b76fcf4a5f090ab1d774b8 /firmware/target/arm/samsung/yh920 | |
parent | d2ea7db6f55cbb121870ecd41d4d80581354b799 (diff) | |
download | rockbox-758bb3bc628705ff8e5c677b3b2d87720c726c13.tar.gz rockbox-758bb3bc628705ff8e5c677b3b2d87720c726c13.zip |
3 new ports: Samsung YH-820, YH-920, and YH-925. Mostly functional. Audio working on 820 & 925 (untested on the 920). No battery readings. No recording. No plugins. Keymap needs work.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21083 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/samsung/yh920')
-rw-r--r-- | firmware/target/arm/samsung/yh920/backlight-yh920.c | 47 | ||||
-rw-r--r-- | firmware/target/arm/samsung/yh920/lcd-yh920.c | 294 | ||||
-rw-r--r-- | firmware/target/arm/samsung/yh920/powermgmt-yh920.c | 59 |
3 files changed, 400 insertions, 0 deletions
diff --git a/firmware/target/arm/samsung/yh920/backlight-yh920.c b/firmware/target/arm/samsung/yh920/backlight-yh920.c new file mode 100644 index 0000000000..5e2cf81e08 --- /dev/null +++ b/firmware/target/arm/samsung/yh920/backlight-yh920.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "backlight.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | void _backlight_on(void) | ||
28 | { | ||
29 | #ifdef HAVE_LCD_SLEEP | ||
30 | backlight_lcd_sleep_countdown(false); /* stop counter */ | ||
31 | #endif | ||
32 | #ifdef HAVE_LCD_ENABLE | ||
33 | lcd_enable(true); /* power on lcd + visible display */ | ||
34 | #endif | ||
35 | GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x2); | ||
36 | } | ||
37 | |||
38 | void _backlight_off(void) | ||
39 | { | ||
40 | GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x2); | ||
41 | #ifdef HAVE_LCD_ENABLE | ||
42 | lcd_enable(false); /* power off visible display */ | ||
43 | #endif | ||
44 | #ifdef HAVE_LCD_SLEEP | ||
45 | backlight_lcd_sleep_countdown(true); /* start countdown */ | ||
46 | #endif | ||
47 | } | ||
diff --git a/firmware/target/arm/samsung/yh920/lcd-yh920.c b/firmware/target/arm/samsung/yh920/lcd-yh920.c new file mode 100644 index 0000000000..6c1528b630 --- /dev/null +++ b/firmware/target/arm/samsung/yh920/lcd-yh920.c | |||
@@ -0,0 +1,294 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2004 by Linus Nielsen Feltzing | ||
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 "system.h" | ||
24 | #include "kernel.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | /*** definitions ***/ | ||
28 | |||
29 | /* LCD command codes */ | ||
30 | #define LCD_CNTL_POWER_CONTROL 0x25 | ||
31 | #define LCD_CNTL_VOLTAGE_SELECT 0x2b | ||
32 | #define LCD_CNTL_LINE_INVERT_DRIVE 0x36 | ||
33 | #define LCD_CNTL_GRAY_SCALE_PATTERN 0x39 | ||
34 | #define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e | ||
35 | #define LCD_CNTL_OSC_FREQUENCY 0x5f | ||
36 | #define LCD_CNTL_ON_OFF 0xae | ||
37 | #define LCD_CNTL_OSC_ON_OFF 0xaa | ||
38 | #define LCD_CNTL_OFF_MODE 0xbe | ||
39 | #define LCD_CNTL_REVERSE 0xa6 | ||
40 | #define LCD_CNTL_ALL_LIGHTING 0xa4 | ||
41 | #define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4 | ||
42 | #define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0 | ||
43 | #define LCD_CNTL_NLINE_ON_OFF 0xe4 | ||
44 | #define LCD_CNTL_DISPLAY_MODE 0x66 | ||
45 | #define LCD_CNTL_DUTY_SET 0x6d | ||
46 | #define LCD_CNTL_ELECTRONIC_VOLUME 0x81 | ||
47 | #define LCD_CNTL_DATA_INPUT_DIR 0x84 | ||
48 | #define LCD_CNTL_DISPLAY_START_LINE 0x8a | ||
49 | #define LCD_CNTL_AREA_SCROLL 0x10 | ||
50 | |||
51 | #define LCD_CNTL_PAGE 0xb1 | ||
52 | #define LCD_CNTL_COLUMN 0x13 | ||
53 | #define LCD_CNTL_DATA_WRITE 0x1d | ||
54 | |||
55 | /* lcd commands */ | ||
56 | static void lcd_send_data(unsigned byte) | ||
57 | { | ||
58 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
59 | LCD1_DATA = byte; | ||
60 | } | ||
61 | |||
62 | static void lcd_send_cmd(unsigned byte) | ||
63 | { | ||
64 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
65 | LCD1_CMD = byte; | ||
66 | } | ||
67 | |||
68 | static void lcd_write_reg(unsigned cmd, unsigned data) | ||
69 | { | ||
70 | lcd_send_cmd(cmd); | ||
71 | lcd_send_data(data); | ||
72 | } | ||
73 | |||
74 | static void lcd_write_reg_ex(unsigned cmd, unsigned data0, unsigned data1) | ||
75 | { | ||
76 | lcd_send_cmd(cmd); | ||
77 | lcd_send_data(data0); | ||
78 | lcd_send_data(data1); | ||
79 | } | ||
80 | |||
81 | /*** hardware configuration ***/ | ||
82 | int lcd_default_contrast(void) | ||
83 | { | ||
84 | return DEFAULT_CONTRAST_SETTING; | ||
85 | } | ||
86 | |||
87 | void lcd_set_contrast(int val) | ||
88 | { | ||
89 | /* Keep val in acceptable hw range */ | ||
90 | if (val < 0) | ||
91 | val = 0; | ||
92 | else if (val > 127) | ||
93 | val = 127; | ||
94 | |||
95 | lcd_write_reg_ex(LCD_CNTL_ELECTRONIC_VOLUME, val, -1); | ||
96 | } | ||
97 | |||
98 | void lcd_set_invert_display(bool yesno) | ||
99 | { | ||
100 | lcd_send_cmd(LCD_CNTL_REVERSE | (yesno?1:0)); | ||
101 | } | ||
102 | |||
103 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
104 | void lcd_set_flip(bool yesno) | ||
105 | { | ||
106 | if (yesno) | ||
107 | { | ||
108 | lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 1); | ||
109 | lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); | ||
110 | lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x20, 0); | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); | ||
115 | lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 1); | ||
116 | lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x20, 1); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | void lcd_init_device(void) | ||
121 | { | ||
122 | #if 0 | ||
123 | /* This is the init sequence from the yh820 OF bootloader */ | ||
124 | unsigned long tmp; | ||
125 | |||
126 | DEV_INIT2 |= 0x400; | ||
127 | |||
128 | DEV_INIT1 &= ~0x3000; | ||
129 | tmp = DEV_INIT1; | ||
130 | DEV_INIT1 = tmp; | ||
131 | DEV_INIT2 &= ~0x400; | ||
132 | |||
133 | LCD1_CONTROL &= ~0x4; | ||
134 | udelay(15); | ||
135 | LCD1_CONTROL |= 0x4; | ||
136 | |||
137 | LCD1_CONTROL = 0x680; | ||
138 | LCD1_CONTROL = 0x684; | ||
139 | |||
140 | LCD1_CONTROL |= 0x1; | ||
141 | |||
142 | lcd_send_cmd(LCD_CNTL_RESET); | ||
143 | lcd_send_cmd(LCD_CNTL_DISCHARGE_ON_OFF | 0); | ||
144 | lcd_send_cmd(LCD_CNTL_ON_OFF | 0); /* LCD OFF */ | ||
145 | lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); /* Normal */ | ||
146 | lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal */ | ||
147 | lcd_send_cmd(LCD_CNTL_REVERSE | 0); /* Reverse OFF */ | ||
148 | lcd_send_cmd(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */ | ||
149 | lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x1f, 0x00); | ||
150 | lcd_send_cmd(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */ | ||
151 | lcd_write_reg(LCD_CNTL_VOLTAGE_SELECT, 0x03); | ||
152 | lcd_write_reg(LCD_CNTL_ELECTRONIC_VOLUME, 0x40); | ||
153 | lcd_write_reg(LCD_CNTL_TEMP_GRADIENT_SELECT, 0x00); | ||
154 | lcd_write_reg(LCD_CNTL_LINE_INVERT_DRIVE, 0x1f); | ||
155 | lcd_send_cmd(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */ | ||
156 | lcd_write_reg(LCD_CNTL_OSC_FREQUENCY, 0x00); | ||
157 | lcd_send_cmd(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */ | ||
158 | lcd_write_reg(LCD_CNTL_STEPUP_CK_FREQ, 0x03); | ||
159 | lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1c); | ||
160 | lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1e); | ||
161 | lcd_write_reg(LCD_CNTL_DISPLAY_START_LINE, 0x00); | ||
162 | lcd_send_cmd(LCD_CNTL_DATA_INPUT_DIR | 0); /* Column mode */ | ||
163 | lcd_send_cmd(LCD_CNTL_DISPLAY_MODE, 0); /* Greyscale mode */ | ||
164 | lcd_write_reg(LCD_CNTL_GRAY_SCALE_PATTERN, 0x52); | ||
165 | lcd_send_cmd(LCD_CNTL_PARTIAL_DISPLAY_ON_OFF | 0); | ||
166 | lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1f); | ||
167 | lcd_send_cmd(LCD_CNTL_ON_OFF | 1); /* LCD ON */ | ||
168 | #endif | ||
169 | } | ||
170 | |||
171 | /*** update functions ***/ | ||
172 | |||
173 | /* Performance function that works with an external buffer | ||
174 | note that by and bheight are in 8-pixel units! */ | ||
175 | void lcd_blit_mono(const unsigned char *data, int x, int by, int width, | ||
176 | int bheight, int stride) | ||
177 | { | ||
178 | (void)data; | ||
179 | (void)x; | ||
180 | (void)by; | ||
181 | (void)width; | ||
182 | (void)bheight; | ||
183 | (void)stride; | ||
184 | |||
185 | #if 0 | ||
186 | /* This is from the h100 lcd code, perhaps we can adapt */ | ||
187 | const unsigned char *src, *src_end; | ||
188 | unsigned char *dst_u, *dst_l; | ||
189 | static unsigned char upper[LCD_WIDTH] IBSS_ATTR; | ||
190 | static unsigned char lower[LCD_WIDTH] IBSS_ATTR; | ||
191 | unsigned int byte; | ||
192 | |||
193 | by *= 2; | ||
194 | |||
195 | while (bheight--) | ||
196 | { | ||
197 | src = data; | ||
198 | src_end = data + width; | ||
199 | dst_u = upper; | ||
200 | dst_l = lower; | ||
201 | do | ||
202 | { | ||
203 | byte = *src++; | ||
204 | *dst_u++ = lcd_dibits[byte & 0x0F]; | ||
205 | byte >>= 4; | ||
206 | *dst_l++ = lcd_dibits[byte & 0x0F]; | ||
207 | } | ||
208 | while (src < src_end); | ||
209 | |||
210 | lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1); | ||
211 | lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1); | ||
212 | lcd_send_cmd(LCD_CNTL_DATA_WRITE); | ||
213 | lcd_write_data(upper, width); | ||
214 | |||
215 | lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1); | ||
216 | lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1); | ||
217 | lcd_send_cmd(LCD_CNTL_DATA_WRITE); | ||
218 | lcd_write_data(lower, width); | ||
219 | |||
220 | data += stride; | ||
221 | } | ||
222 | #endif | ||
223 | } | ||
224 | |||
225 | /* Helper function for lcd_grey_phase_blit(). */ | ||
226 | /* void lcd_grey_data(unsigned char *values, unsigned char *phases, int count); */ | ||
227 | |||
228 | /* Performance function that works with an external buffer | ||
229 | note that by and bheight are in 4-pixel units! */ | ||
230 | void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, | ||
231 | int x, int by, int width, int bheight, int stride) | ||
232 | { | ||
233 | (void)values; | ||
234 | (void)phases; | ||
235 | (void)x; | ||
236 | (void)by; | ||
237 | (void)width; | ||
238 | (void)bheight; | ||
239 | (void)stride; | ||
240 | |||
241 | #if 0 | ||
242 | /* This is from the h100 lcd code, perhaps we can adapt */ | ||
243 | stride <<= 2; /* 4 pixels per block */ | ||
244 | while (bheight--) | ||
245 | { | ||
246 | lcd_write_reg_ex(LCD_CNTL_PAGE, by++, -1); | ||
247 | lcd_write_reg_ex(LCD_CNTL_COLUMN, x, -1); | ||
248 | lcd_send_cmd(LCD_CNTL_DATA_WRITE); | ||
249 | lcd_grey_data(values, phases, width); | ||
250 | values += stride; | ||
251 | phases += stride; | ||
252 | } | ||
253 | #endif | ||
254 | } | ||
255 | |||
256 | /* Update a fraction of the display. */ | ||
257 | /* void lcd_update_rect(int, int, int, int) ICODE_ATTR; */ | ||
258 | void lcd_update_rect(int x0, int y, int width, int height) | ||
259 | { | ||
260 | const fb_data *addr; | ||
261 | int ymax; | ||
262 | int x = x0; | ||
263 | |||
264 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
265 | ymax = (y + height-1) >> 2; | ||
266 | y >>= 2; | ||
267 | |||
268 | if(x + width > LCD_WIDTH) | ||
269 | width = LCD_WIDTH - x; | ||
270 | if (width <= 0) | ||
271 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
272 | if(ymax >= LCD_FBHEIGHT) | ||
273 | ymax = LCD_FBHEIGHT-1; | ||
274 | |||
275 | /* Copy specified rectange bitmap to hardware */ | ||
276 | for (; y <= ymax; y++) | ||
277 | { | ||
278 | lcd_write_reg(LCD_CNTL_PAGE, y); | ||
279 | lcd_write_reg(LCD_CNTL_COLUMN, x0); | ||
280 | |||
281 | addr = &lcd_framebuffer[y][x0]; | ||
282 | |||
283 | lcd_send_cmd(LCD_CNTL_DATA_WRITE); | ||
284 | for (x = x0; x < width; x++) | ||
285 | lcd_send_data(*addr++); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /* Update the display. | ||
290 | This must be called after all other LCD functions that change the display. */ | ||
291 | void lcd_update(void) | ||
292 | { | ||
293 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
294 | } | ||
diff --git a/firmware/target/arm/samsung/yh920/powermgmt-yh920.c b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c new file mode 100644 index 0000000000..6d7e3487aa --- /dev/null +++ b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "adc.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | /* TODO: Not yet calibrated */ | ||
28 | |||
29 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
30 | { | ||
31 | 3733 | ||
32 | }; | ||
33 | |||
34 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
35 | { | ||
36 | 3627 | ||
37 | }; | ||
38 | |||
39 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
40 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
41 | { | ||
42 | { 3733, 3772, 3821, 3840, 3869, 3917, 3985, 4034, 4072, 4140, 4198 } | ||
43 | }; | ||
44 | |||
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
46 | const unsigned short percent_to_volt_charge[11] = | ||
47 | { | ||
48 | 3956, 3995, 4024, 4043, 4063, 4082, 4111, 4140, 4179, 4218, 4266 | ||
49 | }; | ||
50 | |||
51 | #define BATTERY_SCALE_FACTOR 4650 | ||
52 | /* full-scale ADC readout (2^10) in millivolt */ | ||
53 | |||
54 | /* Returns battery voltage from ADC [millivolts] */ | ||
55 | unsigned int battery_adc_voltage(void) | ||
56 | { | ||
57 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | ||
58 | return 4100; | ||
59 | } | ||