summaryrefslogtreecommitdiffstats
path: root/firmware
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 /firmware
parente30f1e83c495727d2ecd108c225499c79e467ca8 (diff)
downloadrockbox-2fb73842a9b51e554a3a14feb0b4c0814c82ebec.tar.gz
rockbox-2fb73842a9b51e554a3a14feb0b4c0814c82ebec.tar.bz2
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
Diffstat (limited to 'firmware')
-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
8 files changed, 809 insertions, 0 deletions
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
drivers/fmradio.c
drivers/tuner/s1a0903x01.c
#endif /* (CONFIG_TUNER & S1A0903X01) */
+#if (CONFIG_TUNER & TEA5760)
+drivers/tuner/tea5760uk.c
+#endif
#if (CONFIG_TUNER & TEA5767)
drivers/tuner/tea5767.c
#endif /* (CONFIG_TUNER & TEA5767) */
@@ -1406,3 +1409,18 @@ target/arm/samsung/yh925/lcd-as-yh925.S
target/arm/samsung/yh925/powermgmt-yh925.c
#endif /* SIMULATOR */
#endif /* SAMSUNG_YH925 */
+
+#ifdef SAMSUNG_YPS3
+/* TODO: currently including all files for the bootloader DFU test program */
+drivers/generic_i2c.c
+drivers/mcs3080.c
+target/arm/s5l8700/adc-s5l8700.c
+target/arm/s5l8700/i2c-s5l8700.c
+target/arm/s5l8700/kernel-s5l8700.c
+target/arm/s5l8700/timer-s5l8700.c
+target/arm/s5l8700/yps3/lcd-yps3.c
+target/arm/s5l8700/yps3/fmradio-i2c-yps3.c
+target/arm/s5l8700/yps3/backlight-yps3.c
+target/arm/s5l8700/yps3/power-yps3.c
+#endif /* SAMSUNG_YPS3 */
+
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 @@
+/*
+ * This config file is for Samsung YP-S3
+ */
+
+#define TARGET_TREE /* this target is using the target tree system */
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 53
+
+#define MODEL_NAME "Samsumg YP-S3"
+
+/* define this if you have recording possibility */
+//#define HAVE_RECORDING
+
+/* Define bitmask of input sources - recordable bitmask can be defined
+ explicitly if different */
+#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
+
+/* define the bitmask of hardware sample rates */
+#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
+
+/* define the bitmask of recording sample rates */
+#define REC_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+
+/* define this if you can flip your LCD */
+//#define HAVE_LCD_FLIP
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+/* define this if you want album art for this target */
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* define this if you can invert the colours on your LCD */
+//#define HAVE_LCD_INVERT
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you have access to the pitchscreen */
+#define HAVE_PITCHSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+/* define this if you have a flash memory storage */
+#define HAVE_FLASH_STORAGE
+
+#define CONFIG_STORAGE STORAGE_NAND
+
+#define CONFIG_NAND NAND_SAMSUNG
+
+/* LCD dimensions */
+#define LCD_WIDTH 176
+#define LCD_HEIGHT 220
+#define LCD_DEPTH 16 /* pseudo 262.144 colors */
+#define LCD_PIXELFORMAT RGB565 /* rgb565 */
+
+/* Define this if your LCD can be enabled/disabled */
+//#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+ should be defined as well. */
+//#define HAVE_LCD_SLEEP
+
+#define CONFIG_KEYPAD MEIZU_M3_PAD
+
+//#define AB_REPEAT_ENABLE 1
+//#define ACTION_WPSAB_SINGLE ACTION_WPS_BROWSE
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* define this if you have a real-time clock */
+#define CONFIG_RTC RTC_S35390A
+
+/* Define the type of audio codec */
+//#define HAVE_WM....
+
+/* Define this for LCD backlight available */
+#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x100000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x80000
+
+/* FM Tuner */
+#define CONFIG_TUNER SI4700
+#define CONFIG_TUNER_XTAL 32768
+
+/* assume no tone controls, so we use the software ones */
+#define HAVE_SW_TONE_CONTROLS
+
+#define BATTERY_CAPACITY_DEFAULT 580 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 580 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 580 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0 /* capacity increment */
+#define BATTERY_TYPES_COUNT 1 /* only one type */
+
+/* Hardware controlled charging, software can monitor plug and charge state */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+#ifndef SIMULATOR
+
+/* Define this if your LCD can set contrast */
+//#define HAVE_LCD_CONTRAST
+
+/* We have a Samsung S5L8700 */
+#define CONFIG_CPU S5L8700
+
+/* We use the S5L8700 i2c interface */
+#define CONFIG_I2C I2C_S5L8700
+
+/* define this if the hardware can be powered off while charging */
+//#define HAVE_POWEROFF_WHILE_CHARGING
+
+/* The size of the flash ROM */
+#define FLASH_SIZE 0x400000
+
+/* Define this to the CPU frequency */
+#define CPU_FREQ 200000000
+
+/* Define this if you have ATA power-off control */
+//#define HAVE_ATA_POWER_OFF
+
+/* Virtual LED (icon) */
+#define CONFIG_LED LED_VIRTUAL
+
+/* Offset ( in the firmware file's header ) to the file CRC */
+#define FIRMWARE_OFFSET_FILE_CRC 0
+
+/* Offset ( in the firmware file's header ) to the real data */
+#define FIRMWARE_OFFSET_FILE_DATA 8
+
+/* USB */
+//#define HAVE_USBSTACK
+#define USE_ROCKBOX_USB
+#define USB_VENDOR_ID 0x04E8
+#define USB_PRODUCT_ID 0x5090
+
+/* Define this if you have adjustable CPU frequency */
+#define HAVE_ADJUSTABLE_CPU_FREQ
+
+#define BOOTFILE_EXT "yps3"
+#define BOOTFILE "rockbox." BOOTFILE_EXT
+#define BOOTDIR "/.rockbox"
+
+//#define BOOTLOADER_ENTRYPOINT 0x001F0000
+//#define FLASH_ENTRYPOINT 0x00001000
+//#define FLASH_MAGIC 0xfbfbfbf1
+
+#endif /* SIMULATOR */
+
+/* Define this for FM radio input available */
+#define HAVE_FMRADIO_IN
+
+/** Port-specific settings **/
+
+/* Main LCD contrast range and defaults */
+#define MIN_CONTRAST_SETTING 1
+#define MAX_CONTRAST_SETTING 30
+#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 0
+#define MAX_BRIGHTNESS_SETTING 15
+#define DEFAULT_BRIGHTNESS_SETTING 10
+
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 @@
#define LYRE_PROTO1_PAD 37
#define SAMSUNG_YH_PAD 38
#define ONDAVX777_PAD 39
+#define SAMSUNG_YPS3_PAD 40
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@@ -381,6 +382,8 @@ Lyre prototype 1*/
#include "config-yh920.h"
#elif defined(SAMSUNG_YH925)
#include "config-yh925.h"
+#elif defined(SAMSUNG_YPS3)
+#include "config-yps3.h"
#else
/* no known platform */
#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <stdbool.h>
+
+#include "config.h"
+#include "backlight.h"
+#include "backlight-target.h"
+#include "system.h"
+
+/*
+ Backlight driver using the PWM mode of a hardware timer.
+
+ The PWM duty cycle depends exponentially on the configured brightness
+ level. This makes the brightness curve more linear to the human eye.
+ */
+
+void _backlight_set_brightness(int brightness)
+{
+ /* pwm = (sqrt(2)**x)-1, where brightness level x = 0..16 */
+ static const unsigned char logtable[] =
+ {0, 1, 2, 3, 5, 7, 10, 15, 22, 31, 44, 63, 90, 127, 180, 255};
+
+ /* set PWM width */
+ TADATA0 = 255 - logtable[brightness];
+}
+
+void _backlight_on(void)
+{
+ _backlight_set_brightness(backlight_brightness);
+}
+
+void _backlight_off(void)
+{
+ _backlight_set_brightness(MIN_BRIGHTNESS_SETTING);
+}
+
+bool _backlight_init(void)
+{
+ /* enable backlight pin as timer output */
+ PCON0 = ((PCON0 & ~(3 << 0)) | (2 << 0));
+
+ /* enable timer clock */
+ PWRCON &= ~(1 << 4);
+
+ /* configure timer */
+ TACMD = (1 << 1); /* TC_CLR */
+ TACON = (0 << 13) | /* TC_INT1_EN */
+ (0 << 12) | /* TC_INT0_EN */
+ (0 << 11) | /* TC_START */
+ (3 << 8) | /* TC_CS = PCLK / 64 */
+ (1 << 4); /* TC_MODE_SEL = PWM mode */
+ TADATA1 = 255; /* set PWM period */
+ TAPRE = 20; /* prescaler */
+ TACMD = (1 << 0); /* TC_EN */
+
+ _backlight_on();
+
+ return true;
+}
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+#include <stdbool.h>
+
+#define HAS_BUTTON_HOLD
+
+bool button_hold(void);
+void button_init_device(void);
+int button_read_device(void);
+
+#define BUTTON_BACK 0x00000001
+#define BUTTON_MENU 0x00000002
+#define BUTTON_UP 0x00000004
+#define BUTTON_DOWN 0x00000008
+#define BUTTON_LEFT 0x00000010
+#define BUTTON_RIGHT 0x00000020
+#define BUTTON_SELECT 0x00000040
+#define BUTTON_POWER 0x00000080
+
+#define BUTTON_MAIN (BUTTON_BACK|BUTTON_MENU|BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|\
+ BUTTON_RIGHT|BUTTON_SELECT)
+
+#define BUTTON_REMOTE 0
+
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
+
+#endif /* _BUTTON_TARGET_H_ */
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/*
+ FM radio i2c interface, allows the radio driver to talk to the tuner chip.
+
+ */
+
+#include "config.h"
+
+#include "i2c-s5l8700.h"
+#include "fmradio_i2c.h"
+
+void fmradio_i2c_init(void)
+{
+ /* nothing to do */
+}
+
+int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
+{
+ return i2c_write(address, -1, count, buf);
+}
+
+int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
+{
+ return i2c_read(address, -1, count, buf);
+}
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+
+#include "s5l8700.h"
+#include "lcd.h"
+
+/* LCD driver for the Samsung YP-S3
+
+ It appears that this player can contain two display types.
+ Detection of the display type is done by looking at the level of pin P0.4.
+ Currently only display "type 2" has been implemented and tested.
+
+ This driver could use DMA to do the screen updates, but currently writes
+ the data to the LCD using the processor instead.
+*/
+
+
+static int lcd_type = 0;
+
+
+static void lcd_delay(int delay)
+{
+ volatile int i;
+ for (i = 0; i < delay; i++);
+}
+
+static void lcd_reset_delay(void)
+{
+ lcd_delay(10000);
+}
+
+static void lcd_reset(void)
+{
+ LCD_CON = 0xDB8;
+ LCD_PHTIME = 0x22;
+ LCD_RST_TIME = 0x7FFF;
+
+ lcd_reset_delay();
+ LCD_DRV_RST = 0;
+ lcd_reset_delay();
+ LCD_DRV_RST = 1;
+ lcd_reset_delay();
+ LCD_DRV_RST = 0;
+ lcd_reset_delay();
+ LCD_DRV_RST = 1;
+
+ LCD_INTCON = 0;
+}
+
+static void lcd_wcmd(unsigned int cmd)
+{
+ while ((LCD_STATUS & 0x10) != 0);
+ LCD_WCMD = cmd;
+}
+
+static void lcd_wdata(unsigned int data)
+{
+ while ((LCD_STATUS & 0x10) != 0);
+ LCD_WDATA = data;
+}
+
+static void lcd_wcmd_data(unsigned int cmd, unsigned int data)
+{
+ lcd_wcmd(cmd);
+ lcd_wdata(data);
+}
+
+void lcd_init1(void)
+{
+ lcd_wcmd(0x11);
+ lcd_delay(10000);
+
+ lcd_wcmd(0xF0);
+ lcd_wdata(0x5A);
+
+ lcd_wcmd(0xC0);
+ lcd_wdata(0x05);
+ lcd_wdata(0x01);
+
+ lcd_wcmd(0xC1);
+ lcd_wdata(0x04);
+
+ lcd_wcmd(0xC5);
+ lcd_wdata(0xB0);
+
+ lcd_wcmd(0xC6);
+ lcd_wdata(0x0);
+
+ lcd_wcmd(0xB1);
+ lcd_wdata(0x02);
+ lcd_wdata(0x0E);
+ lcd_wdata(0x00);
+
+ lcd_wcmd(0xF2);
+ lcd_wdata(0x01);
+
+ lcd_wcmd(0xE0);
+ lcd_wdata(0x09);
+ lcd_wdata(0x00);
+ lcd_wdata(0x06);
+ lcd_wdata(0x2E);
+ lcd_wdata(0x2B);
+ lcd_wdata(0x0B);
+ lcd_wdata(0x1A);
+ lcd_wdata(0x02);
+ lcd_wdata(0x06);
+ lcd_wdata(0x0C);
+ lcd_wdata(0x0D);
+ lcd_wdata(0x00);
+ lcd_wdata(0x05);
+ lcd_wdata(0x02);
+ lcd_wdata(0x05);
+
+ lcd_wcmd(0xE1);
+ lcd_wdata(0x06);
+ lcd_wdata(0x23);
+ lcd_wdata(0x25);
+ lcd_wdata(0x0F);
+ lcd_wdata(0x0A);
+ lcd_wdata(0x04);
+ lcd_wdata(0x02);
+ lcd_wdata(0x1A);
+ lcd_wdata(0x05);
+ lcd_wdata(0x03);
+ lcd_wdata(0x06);
+ lcd_wdata(0x01);
+ lcd_wdata(0x0C);
+ lcd_wdata(0x0B);
+ lcd_wdata(0x05);
+ lcd_wdata(0x05);
+
+ lcd_wcmd(0x3A);
+ lcd_wdata(0x05);
+
+ lcd_wcmd(0x29);
+
+ lcd_wcmd(0x2C);
+}
+
+void lcd_init2(void)
+{
+ lcd_wcmd_data(0x00, 0x0001);
+ lcd_delay(50000);
+
+ lcd_wcmd_data(0x07, 0x0000);
+ lcd_wcmd_data(0x12, 0x0000);
+ lcd_delay(10000);
+
+ lcd_wcmd(0);
+ lcd_wcmd(0);
+ lcd_wcmd(0);
+ lcd_wcmd(0);
+
+ lcd_wcmd_data(0xA4, 0x0001);
+ lcd_delay(10000);
+
+ lcd_wcmd_data(0x70, 0x1B00);
+ lcd_wcmd_data(0x08, 0x030A);
+ lcd_wcmd_data(0x30, 0x0000);
+ lcd_wcmd_data(0x31, 0x0305);
+ lcd_wcmd_data(0x32, 0x0304);
+ lcd_wcmd_data(0x33, 0x0107);
+ lcd_wcmd_data(0x34, 0x0304);
+
+ lcd_wcmd_data(0x35, 0x0204);
+ lcd_wcmd_data(0x36, 0x0707);
+ lcd_wcmd_data(0x37, 0x0701);
+ lcd_wcmd_data(0x38, 0x1B08);
+ lcd_wcmd_data(0x39, 0x030F);
+ lcd_wcmd_data(0x3A, 0x0E0E);
+
+ lcd_wcmd_data(0x07, 0x0001);
+ lcd_delay(50000);
+
+ lcd_wcmd_data(0x18, 0x0001);
+ lcd_wcmd_data(0x10, 0x12B0);
+ lcd_wcmd_data(0x11, 0x0001);
+
+ lcd_wcmd_data(0x12, 0x0114);
+ lcd_wcmd_data(0x13, 0x8D0F);
+ lcd_wcmd_data(0x12, 0x0134);
+ lcd_delay(1000);
+ lcd_wcmd_data(0x01, 0x0100);
+ lcd_wcmd_data(0x02, 0x0700);
+ lcd_wcmd_data(0x03, 0x5030);
+
+ lcd_wcmd_data(0x04, 0x0000);
+ lcd_wcmd_data(0x09, 0x0000);
+ lcd_wcmd_data(0x0C, 0x0000);
+ lcd_wcmd_data(0x0F, 0x0000);
+
+ lcd_wcmd_data(0x14, 0x8000);
+ lcd_wcmd_data(0x20, 0x0000);
+ lcd_wcmd_data(0x21, 0x0000);
+ lcd_wcmd_data(0x71, 0x0001);
+ lcd_wcmd_data(0x7A, 0x0000);
+ lcd_wcmd_data(0x90, 0x0000);
+ lcd_wcmd_data(0x91, 0x0100);
+ lcd_wcmd_data(0x92, 0x0000);
+ lcd_wcmd_data(0x98, 0x0001);
+ lcd_wcmd_data(0x99, 0x030C);
+ lcd_wcmd_data(0x9A, 0x030C);
+
+ lcd_delay(50000);
+ lcd_wcmd_data(0x07, 0x0001);
+ lcd_delay(30000);
+ lcd_wcmd_data(0x07, 0x0021);
+
+ lcd_wcmd_data(0x12, 0x1134);
+ lcd_delay(10000);
+
+ lcd_wcmd_data(0x07, 0x0233);
+ lcd_delay(30000);
+}
+
+
+void lcd_set_window1(int x, int y, int width, int height)
+{
+ (void)x;
+ (void)width;
+
+ lcd_wcmd(0x2A);
+ lcd_wdata(0);
+ lcd_wdata(y);
+ lcd_wdata(0);
+
+ lcd_wcmd(0x2B);
+ lcd_wdata(0);
+ lcd_wdata(y + height - 1);
+ lcd_wdata(0);
+}
+
+void lcd_set_window2(int x, int y, int width, int height)
+{
+ lcd_wcmd_data(0x50, x);
+ lcd_wcmd_data(0x51, x + width - 1);
+ lcd_wcmd_data(0x52, y);
+ lcd_wcmd_data(0x53, y + height - 1);
+}
+
+
+static void lcd_set_position1(int x, int y)
+{
+ (void)x;
+ (void)y;
+}
+
+static void lcd_set_position2(int x, int y)
+{
+ lcd_wcmd_data(0x20, x);
+ lcd_wcmd_data(0x21, y);
+ lcd_wcmd(0x22);
+}
+
+void lcd_init_device(void)
+{
+ /* enable LCD clock */
+ PWRCON &= ~(1 << 18);
+
+ /* configure LCD pins */
+ PCON0 &= ~(3 << 8);
+ PCON7 = (PCON7 & ~(0x000000FF)) | 0x00000033;
+ PCON_ASRAM = 2;
+
+ lcd_reset();
+
+ /* detect LCD type on P0.4 */
+ lcd_type = (PDAT0 & (1 << 4)) ? 1 : 2;
+
+ /* initialise display */
+ if (lcd_type == 1) {
+ lcd_init1();
+ } else {
+ lcd_init2();
+ }
+}
+
+void lcd_update_rect(int x, int y, int width, int height)
+{
+ fb_data* p;
+ int h, w;
+
+ if (lcd_type == 1) {
+ /* TODO implement and test */
+ lcd_set_window1(x, y, width, height);
+ lcd_set_position1(x, y);
+
+ for (h = 0; h < height; h++) {
+ p = &lcd_framebuffer[y][0];
+ for (w = 0; w < LCD_WIDTH; w++) {
+ while (LCD_STATUS & 0x10);
+ LCD_WDATA = *p++;
+ }
+ y++;
+ }
+ }
+ else {
+ lcd_set_window2(x, y, width, height);
+ lcd_set_position2(x, y);
+
+ for (h = 0; h < height; h++) {
+ p = &lcd_framebuffer[y][x];
+ for (w = 0; w < width; w++) {
+ while (LCD_STATUS & 0x10);
+ LCD_WDATA = *p++;
+ }
+ y++;
+ }
+ }
+}
+
+void lcd_update(void)
+{
+ lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
+}
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright © 2009 Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <stdbool.h>
+#include "config.h"
+#include "s5l8700.h"
+#include "power.h"
+
+/* Power handling for the S5L8700 based Samsung YP-S3
+
+ Pins involved in with power management:
+ * P1.1: USB power detect
+ * P4.7: tuner power/enable
+ * P5.2: unknown output
+ * P5.3: unknown output, related to charging (perhaps charge current?)
+ * P5.4: charge status input (only valid if charger enabled)
+ * P5.6: charger enable
+*/
+
+void power_off(void)
+{
+ /* don't know how to do this yet */
+}
+
+void power_init(void)
+{
+ /* configure pin P1.1 as input for USB power detect */
+ PCON1 = (PCON1 & ~0x000000F0) | 0x00000000;
+
+ /* enable tuner power pin on P4.7 and turn power off */
+ PCON4 = (PCON4 & ~0xF0000000) | 0x10000000;
+ PDAT4 &= ~(1 << 7);
+
+ /* configure pins P5.2 / P5.3 / P5.6 as output, P5.4 as input */
+ PCON5 = (PCON5 & ~0x0F0FFF00) | 0x01001100;
+ PDAT5 &= ~((1 << 2) | (1 << 3) | (1 << 6));
+}
+
+#if CONFIG_CHARGING
+unsigned int power_input_status(void)
+{
+ /* check USB power on P1.1 */
+ if (PDAT1 & (1 << 1)) {
+ return POWER_INPUT_USB;
+ }
+
+ return POWER_INPUT_NONE;
+}
+
+bool charging_state(void)
+{
+ if (PDAT5 & (1 << 6)) {
+ /* charger is enabled, check if charging is busy */
+ return (PDAT5 & (1 << 4));
+ }
+ return false;
+}
+#endif /* CONFIG_CHARGING */
+
+#if CONFIG_TUNER
+bool tuner_power(bool status)
+{
+ if (status) {
+ PDAT4 |= (1 << 7);
+ }
+ else {
+ PDAT4 &= ~(1 << 7);
+ }
+ /* TODO what should we return here? */
+ return status;
+}
+
+bool tuner_powered(void)
+{
+ return (PDAT4 & (1 << 7));
+}
+#endif /* CONFIG_TUNER */
+