summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-07-29 20:42:02 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-07-29 20:42:02 +0000
commit2fb73842a9b51e554a3a14feb0b4c0814c82ebec (patch)
tree25a93a7b725a5a2f6fa59929f7952fd8ccd7fcb0
parente30f1e83c495727d2ecd108c225499c79e467ca8 (diff)
downloadrockbox-2fb73842a9b51e554a3a14feb0b4c0814c82ebec.tar.gz
rockbox-2fb73842a9b51e554a3a14feb0b4c0814c82ebec.zip
Start of a Rockbox port to the Samsung YP-S3.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22085 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/SOURCES2
-rw-r--r--bootloader/samsung_yps3.c306
-rw-r--r--firmware/SOURCES18
-rw-r--r--firmware/export/config-yps3.h183
-rw-r--r--firmware/export/config.h3
-rw-r--r--firmware/target/arm/s5l8700/yps3/backlight-yps3.c78
-rw-r--r--firmware/target/arm/s5l8700/yps3/button-target.h50
-rw-r--r--firmware/target/arm/s5l8700/yps3/fmradio-i2c-yps3.c46
-rw-r--r--firmware/target/arm/s5l8700/yps3/lcd-yps3.c336
-rw-r--r--firmware/target/arm/s5l8700/yps3/power-yps3.c95
-rwxr-xr-xtools/configure24
11 files changed, 1141 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
42meizu_m6sp.c 42meizu_m6sp.c
43#elif defined(MEIZU_M3) 43#elif defined(MEIZU_M3)
44meizu_m3.c 44meizu_m3.c
45#elif defined(SAMSUNG_YPS3)
46samsung_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)
46ondavx747.c 48ondavx747.c
47show_logo.c 49show_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
58char version[] = APPSVERSION;
59#define LONG_DELAY 200000
60#define SHORT_DELAY 50000
61#define PAUSE_DELAY 50000
62
63static inline void delay(unsigned int duration)
64{
65 volatile unsigned int i;
66 for(i=0;i<duration;i++);
67}
68
69// forward declaration
70static int rds_decode(int line, struct si4700_dbg_info *nfo);
71
72static int count = 0;
73
74static void timer_callback(void)
75{
76 count++;
77}
78
79void 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
226static 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
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 46c1f58cb3..b60bb29a4a 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -204,6 +204,9 @@ drivers/tuner/lv24020lp.c
204drivers/fmradio.c 204drivers/fmradio.c
205drivers/tuner/s1a0903x01.c 205drivers/tuner/s1a0903x01.c
206#endif /* (CONFIG_TUNER & S1A0903X01) */ 206#endif /* (CONFIG_TUNER & S1A0903X01) */
207#if (CONFIG_TUNER & TEA5760)
208drivers/tuner/tea5760uk.c
209#endif
207#if (CONFIG_TUNER & TEA5767) 210#if (CONFIG_TUNER & TEA5767)
208drivers/tuner/tea5767.c 211drivers/tuner/tea5767.c
209#endif /* (CONFIG_TUNER & TEA5767) */ 212#endif /* (CONFIG_TUNER & TEA5767) */
@@ -1406,3 +1409,18 @@ target/arm/samsung/yh925/lcd-as-yh925.S
1406target/arm/samsung/yh925/powermgmt-yh925.c 1409target/arm/samsung/yh925/powermgmt-yh925.c
1407#endif /* SIMULATOR */ 1410#endif /* SIMULATOR */
1408#endif /* SAMSUNG_YH925 */ 1411#endif /* SAMSUNG_YH925 */
1412
1413#ifdef SAMSUNG_YPS3
1414/* TODO: currently including all files for the bootloader DFU test program */
1415drivers/generic_i2c.c
1416drivers/mcs3080.c
1417target/arm/s5l8700/adc-s5l8700.c
1418target/arm/s5l8700/i2c-s5l8700.c
1419target/arm/s5l8700/kernel-s5l8700.c
1420target/arm/s5l8700/timer-s5l8700.c
1421target/arm/s5l8700/yps3/lcd-yps3.c
1422target/arm/s5l8700/yps3/fmradio-i2c-yps3.c
1423target/arm/s5l8700/yps3/backlight-yps3.c
1424target/arm/s5l8700/yps3/power-yps3.c
1425#endif /* SAMSUNG_YPS3 */
1426
diff --git a/firmware/export/config-yps3.h b/firmware/export/config-yps3.h
new file mode 100644
index 0000000000..2685f0228a
--- /dev/null
+++ b/firmware/export/config-yps3.h
@@ -0,0 +1,183 @@
1/*
2 * This config file is for Samsung YP-S3
3 */
4
5#define TARGET_TREE /* this target is using the target tree system */
6
7/* For Rolo and boot loader */
8#define MODEL_NUMBER 53
9
10#define MODEL_NAME "Samsumg YP-S3"
11
12/* define this if you have recording possibility */
13//#define HAVE_RECORDING
14
15/* Define bitmask of input sources - recordable bitmask can be defined
16 explicitly if different */
17#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
18
19/* define the bitmask of hardware sample rates */
20#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
21
22/* define the bitmask of recording sample rates */
23#define REC_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
24
25/* define this if you have a bitmap LCD display */
26#define HAVE_LCD_BITMAP
27
28/* define this if you can flip your LCD */
29//#define HAVE_LCD_FLIP
30
31/* define this if you have a colour LCD */
32#define HAVE_LCD_COLOR
33
34/* define this if you want album art for this target */
35#define HAVE_ALBUMART
36
37/* define this to enable bitmap scaling */
38#define HAVE_BMP_SCALING
39
40/* define this to enable JPEG decoding */
41#define HAVE_JPEG
42
43/* define this if you can invert the colours on your LCD */
44//#define HAVE_LCD_INVERT
45
46/* define this if you have access to the quickscreen */
47#define HAVE_QUICKSCREEN
48
49/* define this if you have access to the pitchscreen */
50#define HAVE_PITCHSCREEN
51
52/* define this if you would like tagcache to build on this target */
53#define HAVE_TAGCACHE
54
55/* define this if you have a flash memory storage */
56#define HAVE_FLASH_STORAGE
57
58#define CONFIG_STORAGE STORAGE_NAND
59
60#define CONFIG_NAND NAND_SAMSUNG
61
62/* LCD dimensions */
63#define LCD_WIDTH 176
64#define LCD_HEIGHT 220
65#define LCD_DEPTH 16 /* pseudo 262.144 colors */
66#define LCD_PIXELFORMAT RGB565 /* rgb565 */
67
68/* Define this if your LCD can be enabled/disabled */
69//#define HAVE_LCD_ENABLE
70
71/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
72 should be defined as well. */
73//#define HAVE_LCD_SLEEP
74
75#define CONFIG_KEYPAD MEIZU_M3_PAD
76
77//#define AB_REPEAT_ENABLE 1
78//#define ACTION_WPSAB_SINGLE ACTION_WPS_BROWSE
79
80/* Define this if you do software codec */
81#define CONFIG_CODEC SWCODEC
82
83/* define this if you have a real-time clock */
84#define CONFIG_RTC RTC_S35390A
85
86/* Define the type of audio codec */
87//#define HAVE_WM....
88
89/* Define this for LCD backlight available */
90#define HAVE_BACKLIGHT
91#define HAVE_BACKLIGHT_BRIGHTNESS
92
93/* Define this if you have a software controlled poweroff */
94#define HAVE_SW_POWEROFF
95
96/* The number of bytes reserved for loadable codecs */
97#define CODEC_SIZE 0x100000
98
99/* The number of bytes reserved for loadable plugins */
100#define PLUGIN_BUFFER_SIZE 0x80000
101
102/* FM Tuner */
103#define CONFIG_TUNER SI4700
104#define CONFIG_TUNER_XTAL 32768
105
106/* assume no tone controls, so we use the software ones */
107#define HAVE_SW_TONE_CONTROLS
108
109#define BATTERY_CAPACITY_DEFAULT 580 /* default battery capacity */
110#define BATTERY_CAPACITY_MIN 580 /* min. capacity selectable */
111#define BATTERY_CAPACITY_MAX 580 /* max. capacity selectable */
112#define BATTERY_CAPACITY_INC 0 /* capacity increment */
113#define BATTERY_TYPES_COUNT 1 /* only one type */
114
115/* Hardware controlled charging, software can monitor plug and charge state */
116#define CONFIG_CHARGING CHARGING_MONITOR
117
118#ifndef SIMULATOR
119
120/* Define this if your LCD can set contrast */
121//#define HAVE_LCD_CONTRAST
122
123/* We have a Samsung S5L8700 */
124#define CONFIG_CPU S5L8700
125
126/* We use the S5L8700 i2c interface */
127#define CONFIG_I2C I2C_S5L8700
128
129/* define this if the hardware can be powered off while charging */
130//#define HAVE_POWEROFF_WHILE_CHARGING
131
132/* The size of the flash ROM */
133#define FLASH_SIZE 0x400000
134
135/* Define this to the CPU frequency */
136#define CPU_FREQ 200000000
137
138/* Define this if you have ATA power-off control */
139//#define HAVE_ATA_POWER_OFF
140
141/* Virtual LED (icon) */
142#define CONFIG_LED LED_VIRTUAL
143
144/* Offset ( in the firmware file's header ) to the file CRC */
145#define FIRMWARE_OFFSET_FILE_CRC 0
146
147/* Offset ( in the firmware file's header ) to the real data */
148#define FIRMWARE_OFFSET_FILE_DATA 8
149
150/* USB */
151//#define HAVE_USBSTACK
152#define USE_ROCKBOX_USB
153#define USB_VENDOR_ID 0x04E8
154#define USB_PRODUCT_ID 0x5090
155
156/* Define this if you have adjustable CPU frequency */
157#define HAVE_ADJUSTABLE_CPU_FREQ
158
159#define BOOTFILE_EXT "yps3"
160#define BOOTFILE "rockbox." BOOTFILE_EXT
161#define BOOTDIR "/.rockbox"
162
163//#define BOOTLOADER_ENTRYPOINT 0x001F0000
164//#define FLASH_ENTRYPOINT 0x00001000
165//#define FLASH_MAGIC 0xfbfbfbf1
166
167#endif /* SIMULATOR */
168
169/* Define this for FM radio input available */
170#define HAVE_FMRADIO_IN
171
172/** Port-specific settings **/
173
174/* Main LCD contrast range and defaults */
175#define MIN_CONTRAST_SETTING 1
176#define MAX_CONTRAST_SETTING 30
177#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */
178
179/* Main LCD backlight brightness range and defaults */
180#define MIN_BRIGHTNESS_SETTING 0
181#define MAX_BRIGHTNESS_SETTING 15
182#define DEFAULT_BRIGHTNESS_SETTING 10
183
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 092e02f458..0082f3ab31 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -113,6 +113,7 @@
113#define LYRE_PROTO1_PAD 37 113#define LYRE_PROTO1_PAD 37
114#define SAMSUNG_YH_PAD 38 114#define SAMSUNG_YH_PAD 38
115#define ONDAVX777_PAD 39 115#define ONDAVX777_PAD 39
116#define SAMSUNG_YPS3_PAD 40
116 117
117/* CONFIG_REMOTE_KEYPAD */ 118/* CONFIG_REMOTE_KEYPAD */
118#define H100_REMOTE 1 119#define H100_REMOTE 1
@@ -381,6 +382,8 @@ Lyre prototype 1*/
381#include "config-yh920.h" 382#include "config-yh920.h"
382#elif defined(SAMSUNG_YH925) 383#elif defined(SAMSUNG_YH925)
383#include "config-yh925.h" 384#include "config-yh925.h"
385#elif defined(SAMSUNG_YPS3)
386#include "config-yps3.h"
384#else 387#else
385/* no known platform */ 388/* no known platform */
386#endif 389#endif
diff --git a/firmware/target/arm/s5l8700/yps3/backlight-yps3.c b/firmware/target/arm/s5l8700/yps3/backlight-yps3.c
new file mode 100644
index 0000000000..0a9cf3cc9a
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/backlight-yps3.c
@@ -0,0 +1,78 @@
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#include <stdbool.h>
22
23#include "config.h"
24#include "backlight.h"
25#include "backlight-target.h"
26#include "system.h"
27
28/*
29 Backlight driver using the PWM mode of a hardware timer.
30
31 The PWM duty cycle depends exponentially on the configured brightness
32 level. This makes the brightness curve more linear to the human eye.
33 */
34
35void _backlight_set_brightness(int brightness)
36{
37 /* pwm = (sqrt(2)**x)-1, where brightness level x = 0..16 */
38 static const unsigned char logtable[] =
39 {0, 1, 2, 3, 5, 7, 10, 15, 22, 31, 44, 63, 90, 127, 180, 255};
40
41 /* set PWM width */
42 TADATA0 = 255 - logtable[brightness];
43}
44
45void _backlight_on(void)
46{
47 _backlight_set_brightness(backlight_brightness);
48}
49
50void _backlight_off(void)
51{
52 _backlight_set_brightness(MIN_BRIGHTNESS_SETTING);
53}
54
55bool _backlight_init(void)
56{
57 /* enable backlight pin as timer output */
58 PCON0 = ((PCON0 & ~(3 << 0)) | (2 << 0));
59
60 /* enable timer clock */
61 PWRCON &= ~(1 << 4);
62
63 /* configure timer */
64 TACMD = (1 << 1); /* TC_CLR */
65 TACON = (0 << 13) | /* TC_INT1_EN */
66 (0 << 12) | /* TC_INT0_EN */
67 (0 << 11) | /* TC_START */
68 (3 << 8) | /* TC_CS = PCLK / 64 */
69 (1 << 4); /* TC_MODE_SEL = PWM mode */
70 TADATA1 = 255; /* set PWM period */
71 TAPRE = 20; /* prescaler */
72 TACMD = (1 << 0); /* TC_EN */
73
74 _backlight_on();
75
76 return true;
77}
78
diff --git a/firmware/target/arm/s5l8700/yps3/button-target.h b/firmware/target/arm/s5l8700/yps3/button-target.h
new file mode 100644
index 0000000000..86e8488857
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/button-target.h
@@ -0,0 +1,50 @@
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#ifndef _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_
23
24#include <stdbool.h>
25
26#define HAS_BUTTON_HOLD
27
28bool button_hold(void);
29void button_init_device(void);
30int button_read_device(void);
31
32#define BUTTON_BACK 0x00000001
33#define BUTTON_MENU 0x00000002
34#define BUTTON_UP 0x00000004
35#define BUTTON_DOWN 0x00000008
36#define BUTTON_LEFT 0x00000010
37#define BUTTON_RIGHT 0x00000020
38#define BUTTON_SELECT 0x00000040
39#define BUTTON_POWER 0x00000080
40
41#define BUTTON_MAIN (BUTTON_BACK|BUTTON_MENU|BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|\
42 BUTTON_RIGHT|BUTTON_SELECT)
43
44#define BUTTON_REMOTE 0
45
46#define POWEROFF_BUTTON BUTTON_POWER
47#define POWEROFF_COUNT 10
48
49#endif /* _BUTTON_TARGET_H_ */
50
diff --git a/firmware/target/arm/s5l8700/yps3/fmradio-i2c-yps3.c b/firmware/target/arm/s5l8700/yps3/fmradio-i2c-yps3.c
new file mode 100644
index 0000000000..29261b8265
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/fmradio-i2c-yps3.c
@@ -0,0 +1,46 @@
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/*
23 FM radio i2c interface, allows the radio driver to talk to the tuner chip.
24
25 */
26
27#include "config.h"
28
29#include "i2c-s5l8700.h"
30#include "fmradio_i2c.h"
31
32void fmradio_i2c_init(void)
33{
34 /* nothing to do */
35}
36
37int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
38{
39 return i2c_write(address, -1, count, buf);
40}
41
42int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
43{
44 return i2c_read(address, -1, count, buf);
45}
46
diff --git a/firmware/target/arm/s5l8700/yps3/lcd-yps3.c b/firmware/target/arm/s5l8700/yps3/lcd-yps3.c
new file mode 100644
index 0000000000..6093eb3054
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/lcd-yps3.c
@@ -0,0 +1,336 @@
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 "config.h"
23
24#include "s5l8700.h"
25#include "lcd.h"
26
27/* LCD driver for the Samsung YP-S3
28
29 It appears that this player can contain two display types.
30 Detection of the display type is done by looking at the level of pin P0.4.
31 Currently only display "type 2" has been implemented and tested.
32
33 This driver could use DMA to do the screen updates, but currently writes
34 the data to the LCD using the processor instead.
35*/
36
37
38static int lcd_type = 0;
39
40
41static void lcd_delay(int delay)
42{
43 volatile int i;
44 for (i = 0; i < delay; i++);
45}
46
47static void lcd_reset_delay(void)
48{
49 lcd_delay(10000);
50}
51
52static void lcd_reset(void)
53{
54 LCD_CON = 0xDB8;
55 LCD_PHTIME = 0x22;
56 LCD_RST_TIME = 0x7FFF;
57
58 lcd_reset_delay();
59 LCD_DRV_RST = 0;
60 lcd_reset_delay();
61 LCD_DRV_RST = 1;
62 lcd_reset_delay();
63 LCD_DRV_RST = 0;
64 lcd_reset_delay();
65 LCD_DRV_RST = 1;
66
67 LCD_INTCON = 0;
68}
69
70static void lcd_wcmd(unsigned int cmd)
71{
72 while ((LCD_STATUS & 0x10) != 0);
73 LCD_WCMD = cmd;
74}
75
76static void lcd_wdata(unsigned int data)
77{
78 while ((LCD_STATUS & 0x10) != 0);
79 LCD_WDATA = data;
80}
81
82static void lcd_wcmd_data(unsigned int cmd, unsigned int data)
83{
84 lcd_wcmd(cmd);
85 lcd_wdata(data);
86}
87
88void lcd_init1(void)
89{
90 lcd_wcmd(0x11);
91 lcd_delay(10000);
92
93 lcd_wcmd(0xF0);
94 lcd_wdata(0x5A);
95
96 lcd_wcmd(0xC0);
97 lcd_wdata(0x05);
98 lcd_wdata(0x01);
99
100 lcd_wcmd(0xC1);
101 lcd_wdata(0x04);
102
103 lcd_wcmd(0xC5);
104 lcd_wdata(0xB0);
105
106 lcd_wcmd(0xC6);
107 lcd_wdata(0x0);
108
109 lcd_wcmd(0xB1);
110 lcd_wdata(0x02);
111 lcd_wdata(0x0E);
112 lcd_wdata(0x00);
113
114 lcd_wcmd(0xF2);
115 lcd_wdata(0x01);
116
117 lcd_wcmd(0xE0);
118 lcd_wdata(0x09);
119 lcd_wdata(0x00);
120 lcd_wdata(0x06);
121 lcd_wdata(0x2E);
122 lcd_wdata(0x2B);
123 lcd_wdata(0x0B);
124 lcd_wdata(0x1A);
125 lcd_wdata(0x02);
126 lcd_wdata(0x06);
127 lcd_wdata(0x0C);
128 lcd_wdata(0x0D);
129 lcd_wdata(0x00);
130 lcd_wdata(0x05);
131 lcd_wdata(0x02);
132 lcd_wdata(0x05);
133
134 lcd_wcmd(0xE1);
135 lcd_wdata(0x06);
136 lcd_wdata(0x23);
137 lcd_wdata(0x25);
138 lcd_wdata(0x0F);
139 lcd_wdata(0x0A);
140 lcd_wdata(0x04);
141 lcd_wdata(0x02);
142 lcd_wdata(0x1A);
143 lcd_wdata(0x05);
144 lcd_wdata(0x03);
145 lcd_wdata(0x06);
146 lcd_wdata(0x01);
147 lcd_wdata(0x0C);
148 lcd_wdata(0x0B);
149 lcd_wdata(0x05);
150 lcd_wdata(0x05);
151
152 lcd_wcmd(0x3A);
153 lcd_wdata(0x05);
154
155 lcd_wcmd(0x29);
156
157 lcd_wcmd(0x2C);
158}
159
160void lcd_init2(void)
161{
162 lcd_wcmd_data(0x00, 0x0001);
163 lcd_delay(50000);
164
165 lcd_wcmd_data(0x07, 0x0000);
166 lcd_wcmd_data(0x12, 0x0000);
167 lcd_delay(10000);
168
169 lcd_wcmd(0);
170 lcd_wcmd(0);
171 lcd_wcmd(0);
172 lcd_wcmd(0);
173
174 lcd_wcmd_data(0xA4, 0x0001);
175 lcd_delay(10000);
176
177 lcd_wcmd_data(0x70, 0x1B00);
178 lcd_wcmd_data(0x08, 0x030A);
179 lcd_wcmd_data(0x30, 0x0000);
180 lcd_wcmd_data(0x31, 0x0305);
181 lcd_wcmd_data(0x32, 0x0304);
182 lcd_wcmd_data(0x33, 0x0107);
183 lcd_wcmd_data(0x34, 0x0304);
184
185 lcd_wcmd_data(0x35, 0x0204);
186 lcd_wcmd_data(0x36, 0x0707);
187 lcd_wcmd_data(0x37, 0x0701);
188 lcd_wcmd_data(0x38, 0x1B08);
189 lcd_wcmd_data(0x39, 0x030F);
190 lcd_wcmd_data(0x3A, 0x0E0E);
191
192 lcd_wcmd_data(0x07, 0x0001);
193 lcd_delay(50000);
194
195 lcd_wcmd_data(0x18, 0x0001);
196 lcd_wcmd_data(0x10, 0x12B0);
197 lcd_wcmd_data(0x11, 0x0001);
198
199 lcd_wcmd_data(0x12, 0x0114);
200 lcd_wcmd_data(0x13, 0x8D0F);
201 lcd_wcmd_data(0x12, 0x0134);
202 lcd_delay(1000);
203 lcd_wcmd_data(0x01, 0x0100);
204 lcd_wcmd_data(0x02, 0x0700);
205 lcd_wcmd_data(0x03, 0x5030);
206
207 lcd_wcmd_data(0x04, 0x0000);
208 lcd_wcmd_data(0x09, 0x0000);
209 lcd_wcmd_data(0x0C, 0x0000);
210 lcd_wcmd_data(0x0F, 0x0000);
211
212 lcd_wcmd_data(0x14, 0x8000);
213 lcd_wcmd_data(0x20, 0x0000);
214 lcd_wcmd_data(0x21, 0x0000);
215 lcd_wcmd_data(0x71, 0x0001);
216 lcd_wcmd_data(0x7A, 0x0000);
217 lcd_wcmd_data(0x90, 0x0000);
218 lcd_wcmd_data(0x91, 0x0100);
219 lcd_wcmd_data(0x92, 0x0000);
220 lcd_wcmd_data(0x98, 0x0001);
221 lcd_wcmd_data(0x99, 0x030C);
222 lcd_wcmd_data(0x9A, 0x030C);
223
224 lcd_delay(50000);
225 lcd_wcmd_data(0x07, 0x0001);
226 lcd_delay(30000);
227 lcd_wcmd_data(0x07, 0x0021);
228
229 lcd_wcmd_data(0x12, 0x1134);
230 lcd_delay(10000);
231
232 lcd_wcmd_data(0x07, 0x0233);
233 lcd_delay(30000);
234}
235
236
237void lcd_set_window1(int x, int y, int width, int height)
238{
239 (void)x;
240 (void)width;
241
242 lcd_wcmd(0x2A);
243 lcd_wdata(0);
244 lcd_wdata(y);
245 lcd_wdata(0);
246
247 lcd_wcmd(0x2B);
248 lcd_wdata(0);
249 lcd_wdata(y + height - 1);
250 lcd_wdata(0);
251}
252
253void lcd_set_window2(int x, int y, int width, int height)
254{
255 lcd_wcmd_data(0x50, x);
256 lcd_wcmd_data(0x51, x + width - 1);
257 lcd_wcmd_data(0x52, y);
258 lcd_wcmd_data(0x53, y + height - 1);
259}
260
261
262static void lcd_set_position1(int x, int y)
263{
264 (void)x;
265 (void)y;
266}
267
268static void lcd_set_position2(int x, int y)
269{
270 lcd_wcmd_data(0x20, x);
271 lcd_wcmd_data(0x21, y);
272 lcd_wcmd(0x22);
273}
274
275void lcd_init_device(void)
276{
277 /* enable LCD clock */
278 PWRCON &= ~(1 << 18);
279
280 /* configure LCD pins */
281 PCON0 &= ~(3 << 8);
282 PCON7 = (PCON7 & ~(0x000000FF)) | 0x00000033;
283 PCON_ASRAM = 2;
284
285 lcd_reset();
286
287 /* detect LCD type on P0.4 */
288 lcd_type = (PDAT0 & (1 << 4)) ? 1 : 2;
289
290 /* initialise display */
291 if (lcd_type == 1) {
292 lcd_init1();
293 } else {
294 lcd_init2();
295 }
296}
297
298void lcd_update_rect(int x, int y, int width, int height)
299{
300 fb_data* p;
301 int h, w;
302
303 if (lcd_type == 1) {
304 /* TODO implement and test */
305 lcd_set_window1(x, y, width, height);
306 lcd_set_position1(x, y);
307
308 for (h = 0; h < height; h++) {
309 p = &lcd_framebuffer[y][0];
310 for (w = 0; w < LCD_WIDTH; w++) {
311 while (LCD_STATUS & 0x10);
312 LCD_WDATA = *p++;
313 }
314 y++;
315 }
316 }
317 else {
318 lcd_set_window2(x, y, width, height);
319 lcd_set_position2(x, y);
320
321 for (h = 0; h < height; h++) {
322 p = &lcd_framebuffer[y][x];
323 for (w = 0; w < width; w++) {
324 while (LCD_STATUS & 0x10);
325 LCD_WDATA = *p++;
326 }
327 y++;
328 }
329 }
330}
331
332void lcd_update(void)
333{
334 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
335}
336
diff --git a/firmware/target/arm/s5l8700/yps3/power-yps3.c b/firmware/target/arm/s5l8700/yps3/power-yps3.c
new file mode 100644
index 0000000000..784a5a9629
--- /dev/null
+++ b/firmware/target/arm/s5l8700/yps3/power-yps3.c
@@ -0,0 +1,95 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 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#include <stdbool.h>
22#include "config.h"
23#include "s5l8700.h"
24#include "power.h"
25
26/* Power handling for the S5L8700 based Samsung YP-S3
27
28 Pins involved in with power management:
29 * P1.1: USB power detect
30 * P4.7: tuner power/enable
31 * P5.2: unknown output
32 * P5.3: unknown output, related to charging (perhaps charge current?)
33 * P5.4: charge status input (only valid if charger enabled)
34 * P5.6: charger enable
35*/
36
37void power_off(void)
38{
39 /* don't know how to do this yet */
40}
41
42void power_init(void)
43{
44 /* configure pin P1.1 as input for USB power detect */
45 PCON1 = (PCON1 & ~0x000000F0) | 0x00000000;
46
47 /* enable tuner power pin on P4.7 and turn power off */
48 PCON4 = (PCON4 & ~0xF0000000) | 0x10000000;
49 PDAT4 &= ~(1 << 7);
50
51 /* configure pins P5.2 / P5.3 / P5.6 as output, P5.4 as input */
52 PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100;
53 PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6));
54}
55
56#if CONFIG_CHARGING
57unsigned int power_input_status(void)
58{
59 /* check USB power on P1.1 */
60 if (PDAT1 & (1 << 1)) {
61 return POWER_INPUT_USB;
62 }
63
64 return POWER_INPUT_NONE;
65}
66
67bool charging_state(void)
68{
69 if (PDAT5 & (1 << 6)) {
70 /* charger is enabled, check if charging is busy */
71 return (PDAT5 & (1 << 4));
72 }
73 return false;
74}
75#endif /* CONFIG_CHARGING */
76
77#if CONFIG_TUNER
78bool tuner_power(bool status)
79{
80 if (status) {
81 PDAT4 |= (1 << 7);
82 }
83 else {
84 PDAT4 &= ~(1 << 7);
85 }
86 /* TODO what should we return here? */
87 return status;
88}
89
90bool tuner_powered(void)
91{
92 return (PDAT4 & (1 << 7));
93}
94#endif /* CONFIG_TUNER */
95
diff --git a/tools/configure b/tools/configure
index b23d40ed50..36c74105a3 100755
--- a/tools/configure
+++ b/tools/configure
@@ -815,6 +815,7 @@ cat <<EOF
815 140) YH-820 150) Elio TPJ-1022 ==Lyre project== 815 140) YH-820 150) Elio TPJ-1022 ==Lyre project==
816 141) YH-920 130) Lyre proto 1 816 141) YH-920 130) Lyre proto 1
817 142) YH-925 817 142) YH-925
818 143) YP-S3
818EOF 819EOF
819 820
820 buildfor=`input`; 821 buildfor=`input`;
@@ -2275,6 +2276,29 @@ fi
2275 t_model="yh925" 2276 t_model="yh925"
2276 ;; 2277 ;;
2277 2278
2279 143|yps3)
2280 target_id=60
2281 modelname="yps3"
2282 target="-DSAMSUNG_YPS3"
2283 memory=16 # always
2284 arm940tbecc
2285 tool="cp"
2286 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
2287 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
2288 output="rockbox.yps3"
2289 appextra="recorder:gui"
2290 plugins="no" #FIXME
2291 swcodec="yes"
2292 toolset=$genericbitmaptools
2293 boottool="cp"
2294 bootoutput="rockboot.ebn"
2295 # architecture, manufacturer and model for the target-tree build
2296 t_cpu="arm"
2297 t_manufacturer="s5l8700"
2298 t_model="yps3"
2299 ;;
2300
2301
2278 *) 2302 *)
2279 echo "Please select a supported target platform!" 2303 echo "Please select a supported target platform!"
2280 exit 7 2304 exit 7