diff options
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/SOURCES | 2 | ||||
-rw-r--r-- | bootloader/samsung_yps3.c | 306 |
2 files changed, 308 insertions, 0 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 42f3f577cf..f297f18fba 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -42,6 +42,8 @@ meizu_m6sl.c | |||
42 | meizu_m6sp.c | 42 | meizu_m6sp.c |
43 | #elif defined(MEIZU_M3) | 43 | #elif defined(MEIZU_M3) |
44 | meizu_m3.c | 44 | meizu_m3.c |
45 | #elif defined(SAMSUNG_YPS3) | ||
46 | samsung_yps3.c | ||
45 | #elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777) | 47 | #elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777) |
46 | ondavx747.c | 48 | ondavx747.c |
47 | show_logo.c | 49 | show_logo.c |
diff --git a/bootloader/samsung_yps3.c b/bootloader/samsung_yps3.c new file mode 100644 index 0000000000..ba9f2d70e5 --- /dev/null +++ b/bootloader/samsung_yps3.c | |||
@@ -0,0 +1,306 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
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 | |||
22 | #include <stdlib.h> | ||
23 | #include <stdio.h> | ||
24 | #include <stdarg.h> | ||
25 | #include <string.h> | ||
26 | |||
27 | #include "config.h" | ||
28 | |||
29 | #include "inttypes.h" | ||
30 | #include "cpu.h" | ||
31 | #include "system.h" | ||
32 | #include "lcd.h" | ||
33 | #include "kernel.h" | ||
34 | #include "thread.h" | ||
35 | #include "backlight.h" | ||
36 | #include "backlight-target.h" | ||
37 | #include "button.h" | ||
38 | #include "panic.h" | ||
39 | #include "power.h" | ||
40 | #include "common.h" | ||
41 | #include "usb.h" | ||
42 | #include "bitmaps/rockboxlogo.h" | ||
43 | |||
44 | #include "adc.h" | ||
45 | #include "adc-target.h" | ||
46 | |||
47 | #include "timer.h" | ||
48 | |||
49 | #include "i2c-s5l8700.h" | ||
50 | #include "dma-target.h" | ||
51 | #include "pcm.h" | ||
52 | #include "audiohw.h" | ||
53 | #include "rtc.h" | ||
54 | #include "tuner.h" | ||
55 | #include "si4700.h" | ||
56 | #include "fmradio_i2c.h" | ||
57 | |||
58 | char version[] = APPSVERSION; | ||
59 | #define LONG_DELAY 200000 | ||
60 | #define SHORT_DELAY 50000 | ||
61 | #define PAUSE_DELAY 50000 | ||
62 | |||
63 | static inline void delay(unsigned int duration) | ||
64 | { | ||
65 | volatile unsigned int i; | ||
66 | for(i=0;i<duration;i++); | ||
67 | } | ||
68 | |||
69 | // forward declaration | ||
70 | static int rds_decode(int line, struct si4700_dbg_info *nfo); | ||
71 | |||
72 | static int count = 0; | ||
73 | |||
74 | static void timer_callback(void) | ||
75 | { | ||
76 | count++; | ||
77 | } | ||
78 | |||
79 | void main(void) | ||
80 | { | ||
81 | char mystring[64]; | ||
82 | int line, col; | ||
83 | unsigned char read_data[16]; | ||
84 | int i; | ||
85 | struct si4700_dbg_info si4700_info; | ||
86 | |||
87 | line = 1; | ||
88 | |||
89 | // enable all peripherals | ||
90 | PWRCON = 0; | ||
91 | |||
92 | // disable all interrupts | ||
93 | INTMSK = 0; | ||
94 | |||
95 | // start with all GPIOs as input | ||
96 | PCON0 = 0; | ||
97 | PCON1 = 0; | ||
98 | PCON2 = 0; | ||
99 | PCON3 = 0; | ||
100 | PCON4 = 0; | ||
101 | PCON5 = 0; | ||
102 | PCON6 = 0; | ||
103 | PCON7 = 0; | ||
104 | |||
105 | system_init(); | ||
106 | kernel_init(); | ||
107 | |||
108 | asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts | ||
109 | |||
110 | lcd_init(); | ||
111 | |||
112 | lcd_clear_display(); | ||
113 | lcd_bitmap(rockboxlogo, 0, 160, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); | ||
114 | lcd_update(); | ||
115 | |||
116 | power_init(); | ||
117 | |||
118 | i2c_init(); | ||
119 | fmradio_i2c_init(); | ||
120 | adc_init(); | ||
121 | _backlight_init(); | ||
122 | |||
123 | timer_register(1, NULL, 3 * TIMER_FREQ, timer_callback); | ||
124 | |||
125 | // LED outputs | ||
126 | PCON3 = (PCON3 & ~(0x0000FF00)) | 0x00001100; | ||
127 | PDAT3 |= (1 << 2) | (1 << 3); | ||
128 | |||
129 | // FM power | ||
130 | si4700_init(); | ||
131 | tuner_power(true); | ||
132 | si4700_set(RADIO_SLEEP, 0); | ||
133 | si4700_set(RADIO_MUTE, 0); | ||
134 | si4700_set(RADIO_FREQUENCY, 100700000); | ||
135 | |||
136 | lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---"); | ||
137 | |||
138 | while (true) | ||
139 | { | ||
140 | line = 1; | ||
141 | |||
142 | #if 1 /* enable to see GPIOs */ | ||
143 | snprintf(mystring, 64, "%02X %02X %02X %02X %02X %02X %02X %02X", PDAT0, PDAT1, PDAT2, PDAT3, PDAT4, PDAT5, PDAT6, PDAT7); | ||
144 | lcd_puts(0, line++, mystring); | ||
145 | #endif | ||
146 | |||
147 | #if 1 /* enable this to see info about the RTC */ | ||
148 | rtc_read_datetime(read_data); | ||
149 | snprintf(mystring, 64, "RTC:"); | ||
150 | for (i = 0; i < 7; i++) { | ||
151 | snprintf(mystring + 2 * i + 4, 64, "%02X", read_data[i]); | ||
152 | } | ||
153 | lcd_puts(0, line++, mystring); | ||
154 | #endif | ||
155 | |||
156 | #if 0 /* enable this so see info about the codec */ | ||
157 | memset(read_data, 0, sizeof(read_data)); | ||
158 | for (i = 0; i < 1; i++) { | ||
159 | i2c_read(0x34, i, 2, read_data); | ||
160 | data = read_data[0] << 8 | read_data[1]; | ||
161 | snprintf(mystring + 4 * i, 64, "%04X", data); | ||
162 | } | ||
163 | lcd_puts(0, line++, mystring); | ||
164 | #endif | ||
165 | |||
166 | #if 1 /* enable this to see radio debug info */ | ||
167 | si4700_dbg_info(&si4700_info); | ||
168 | col = snprintf(mystring, 64, "FM: "); | ||
169 | for (i = 0; i < 16; i++) { | ||
170 | col += snprintf(mystring + col, 64, "%04X ", si4700_info.regs[i]); | ||
171 | if (((i + 1) % 4) == 0) { | ||
172 | lcd_puts(0, line++, mystring); | ||
173 | col = 4; | ||
174 | } | ||
175 | } | ||
176 | line = rds_decode(line, &si4700_info); | ||
177 | #endif | ||
178 | |||
179 | #if 1 /* enable this to see ADC info */ | ||
180 | snprintf(mystring, 64, "%04X %04X %04X %04X", adc_read(0), adc_read(1), adc_read(2), adc_read(3)); | ||
181 | lcd_puts(0, line++, mystring); | ||
182 | snprintf(mystring, 64, "ADC:USB %4d mV BAT %4d mV", | ||
183 | (adc_read(0) * 6000) >> 10, (adc_read(2) * 4650) >> 10); | ||
184 | lcd_puts(0, line++, mystring); | ||
185 | #endif | ||
186 | |||
187 | #if 1 /* enable this so see USB info */ | ||
188 | snprintf(mystring, 64, "CLK %08X CLK2 %08X", CLKCON, CLKCON2); | ||
189 | lcd_puts(0, line++, mystring); | ||
190 | |||
191 | snprintf(mystring, 64, "%04X %04X %04X %04X", PHYCTRL, PHYPWR, URSTCON, UCLKCON); | ||
192 | lcd_puts(0, line++, mystring); | ||
193 | |||
194 | snprintf(mystring, 64, "SCR %04X SSR %04X EIR %04X", SCR, SSR, EIR); | ||
195 | lcd_puts(0, line++, mystring); | ||
196 | |||
197 | snprintf(mystring, 64, "FAR %04X FNR %04X EP0 %04X", FAR, FNR, EP0SR); | ||
198 | lcd_puts(0, line++, mystring); | ||
199 | #endif | ||
200 | |||
201 | #if 1 /* enable to see timer/counter info */ | ||
202 | snprintf(mystring, 64, "TIMER: %08X", count); | ||
203 | lcd_puts(0, line++, mystring); | ||
204 | snprintf(mystring, 64, "current_tick: %08X", current_tick); | ||
205 | lcd_puts(0, line++, mystring); | ||
206 | snprintf(mystring, 64, "TIMER %04X %04X %04X", TDCON, TDPRE, TDDATA0); | ||
207 | lcd_puts(0, line++, mystring); | ||
208 | #endif | ||
209 | |||
210 | #if 1 /* enable this to control backlight brightness with the hold switch */ | ||
211 | if (PDAT4 & (1 << 3)) { | ||
212 | _backlight_set_brightness(10); | ||
213 | PDAT3 &= ~(1 << 4); | ||
214 | } | ||
215 | else { | ||
216 | _backlight_set_brightness(15); | ||
217 | PDAT3 |= (1 << 4); | ||
218 | } | ||
219 | #endif | ||
220 | |||
221 | lcd_update(); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | |||
226 | static int rds_decode(int line, struct si4700_dbg_info *nfo) | ||
227 | { | ||
228 | unsigned short rdsdata[4]; | ||
229 | unsigned int pi, group, tp, pty, segment, abflag; | ||
230 | static unsigned int af1 = 0, af2 = 0; | ||
231 | static unsigned int day = 0, hour = 0, minute = 0; | ||
232 | static unsigned int abflag_prev = -1; | ||
233 | static char mystring[64]; | ||
234 | |||
235 | /* big RDS arrays */ | ||
236 | static char ps[9]; | ||
237 | static char rt[65]; | ||
238 | |||
239 | rdsdata[0] = nfo->regs[12]; | ||
240 | rdsdata[1] = nfo->regs[13]; | ||
241 | rdsdata[2] = nfo->regs[14]; | ||
242 | rdsdata[3] = nfo->regs[15]; | ||
243 | |||
244 | pi = rdsdata[0]; | ||
245 | group = (rdsdata[1] >> 11) & 0x1F; | ||
246 | tp = (rdsdata[1] >> 10) & 1; | ||
247 | pty = (rdsdata[1] >> 5) & 0x1F; | ||
248 | |||
249 | switch (group) { | ||
250 | |||
251 | case 0: /* group 0A: basic info */ | ||
252 | af1 = (rdsdata[2] >> 8) & 0xFF; | ||
253 | af2 = (rdsdata[2] >> 0) & 0xFF; | ||
254 | /* fall through */ | ||
255 | case 1: /* group 0B: basic info */ | ||
256 | segment = rdsdata[1] & 3; | ||
257 | ps[segment * 2 + 0] = (rdsdata[3] >> 8) & 0xFF; | ||
258 | ps[segment * 2 + 1] = (rdsdata[3] >> 0) & 0xFF; | ||
259 | break; | ||
260 | |||
261 | case 2: /* group 1A: programme item */ | ||
262 | case 3: /* group 1B: programme item */ | ||
263 | day = (rdsdata[3] >> 11) & 0x1F; | ||
264 | hour = (rdsdata[3] >> 6) & 0x1F; | ||
265 | minute = (rdsdata[3] >> 0) & 0x3F; | ||
266 | break; | ||
267 | |||
268 | case 4: /* group 2A: radio text */ | ||
269 | segment = rdsdata[1] & 0xF; | ||
270 | abflag = (rdsdata[1] >> 4) & 1; | ||
271 | if (abflag != abflag_prev) { | ||
272 | memset(rt, '.', 64); | ||
273 | abflag_prev = abflag; | ||
274 | } | ||
275 | rt[segment * 4 + 0] = (rdsdata[2] >> 8) & 0xFF; | ||
276 | rt[segment * 4 + 1] = (rdsdata[2] >> 0) & 0xFF; | ||
277 | rt[segment * 4 + 2] = (rdsdata[3] >> 8) & 0xFF; | ||
278 | rt[segment * 4 + 3] = (rdsdata[3] >> 0) & 0xFF; | ||
279 | break; | ||
280 | |||
281 | case 5: /* group 2B: radio text */ | ||
282 | segment = rdsdata[1] & 0xF; | ||
283 | abflag = (rdsdata[1] >> 4) & 1; | ||
284 | if (abflag != abflag_prev) { | ||
285 | memset(rt, '.', 64); | ||
286 | abflag_prev = abflag; | ||
287 | } | ||
288 | rt[segment * 2 + 0] = (rdsdata[3] >> 8) & 0xFF; | ||
289 | rt[segment * 2 + 1] = (rdsdata[3] >> 0) & 0xFF; | ||
290 | break; | ||
291 | |||
292 | default: | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | snprintf(mystring, 64, "PI:%04X,TP:%d,PTY:%2d,AF:%02X/%02X", pi, tp, pty, af1, af2); | ||
297 | lcd_puts(0, line++, mystring); | ||
298 | snprintf(mystring, 64, "PS:%s,ITEM:%02d-%02d:%02d", ps, day, hour, minute); | ||
299 | lcd_puts(0, line++, mystring); | ||
300 | snprintf(mystring, 64, "RT:%s", rt); | ||
301 | lcd_puts(0, line++, mystring); | ||
302 | |||
303 | return line; | ||
304 | } | ||
305 | |||
306 | |||