From 2fb73842a9b51e554a3a14feb0b4c0814c82ebec Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Wed, 29 Jul 2009 20:42:02 +0000 Subject: 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 --- bootloader/SOURCES | 2 + bootloader/samsung_yps3.c | 306 +++++++++++++++++++ firmware/SOURCES | 18 ++ firmware/export/config-yps3.h | 183 +++++++++++ firmware/export/config.h | 3 + firmware/target/arm/s5l8700/yps3/backlight-yps3.c | 78 +++++ firmware/target/arm/s5l8700/yps3/button-target.h | 50 +++ .../target/arm/s5l8700/yps3/fmradio-i2c-yps3.c | 46 +++ firmware/target/arm/s5l8700/yps3/lcd-yps3.c | 336 +++++++++++++++++++++ firmware/target/arm/s5l8700/yps3/power-yps3.c | 95 ++++++ tools/configure | 24 ++ 11 files changed, 1141 insertions(+) create mode 100644 bootloader/samsung_yps3.c create mode 100644 firmware/export/config-yps3.h create mode 100644 firmware/target/arm/s5l8700/yps3/backlight-yps3.c create mode 100644 firmware/target/arm/s5l8700/yps3/button-target.h create mode 100644 firmware/target/arm/s5l8700/yps3/fmradio-i2c-yps3.c create mode 100644 firmware/target/arm/s5l8700/yps3/lcd-yps3.c create mode 100644 firmware/target/arm/s5l8700/yps3/power-yps3.c 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 meizu_m6sp.c #elif defined(MEIZU_M3) meizu_m3.c +#elif defined(SAMSUNG_YPS3) +samsung_yps3.c #elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777) ondavx747.c 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 @@ +/*************************************************************************** + * __________ __ ___. + * 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 +#include +#include +#include + +#include "config.h" + +#include "inttypes.h" +#include "cpu.h" +#include "system.h" +#include "lcd.h" +#include "kernel.h" +#include "thread.h" +#include "backlight.h" +#include "backlight-target.h" +#include "button.h" +#include "panic.h" +#include "power.h" +#include "common.h" +#include "usb.h" +#include "bitmaps/rockboxlogo.h" + +#include "adc.h" +#include "adc-target.h" + +#include "timer.h" + +#include "i2c-s5l8700.h" +#include "dma-target.h" +#include "pcm.h" +#include "audiohw.h" +#include "rtc.h" +#include "tuner.h" +#include "si4700.h" +#include "fmradio_i2c.h" + +char version[] = APPSVERSION; +#define LONG_DELAY 200000 +#define SHORT_DELAY 50000 +#define PAUSE_DELAY 50000 + +static inline void delay(unsigned int duration) +{ + volatile unsigned int i; + for(i=0;i> 10, (adc_read(2) * 4650) >> 10); + lcd_puts(0, line++, mystring); +#endif + +#if 1 /* enable this so see USB info */ + snprintf(mystring, 64, "CLK %08X CLK2 %08X", CLKCON, CLKCON2); + lcd_puts(0, line++, mystring); + + snprintf(mystring, 64, "%04X %04X %04X %04X", PHYCTRL, PHYPWR, URSTCON, UCLKCON); + lcd_puts(0, line++, mystring); + + snprintf(mystring, 64, "SCR %04X SSR %04X EIR %04X", SCR, SSR, EIR); + lcd_puts(0, line++, mystring); + + snprintf(mystring, 64, "FAR %04X FNR %04X EP0 %04X", FAR, FNR, EP0SR); + lcd_puts(0, line++, mystring); +#endif + +#if 1 /* enable to see timer/counter info */ + snprintf(mystring, 64, "TIMER: %08X", count); + lcd_puts(0, line++, mystring); + snprintf(mystring, 64, "current_tick: %08X", current_tick); + lcd_puts(0, line++, mystring); + snprintf(mystring, 64, "TIMER %04X %04X %04X", TDCON, TDPRE, TDDATA0); + lcd_puts(0, line++, mystring); +#endif + +#if 1 /* enable this to control backlight brightness with the hold switch */ + if (PDAT4 & (1 << 3)) { + _backlight_set_brightness(10); + PDAT3 &= ~(1 << 4); + } + else { + _backlight_set_brightness(15); + PDAT3 |= (1 << 4); + } +#endif + + lcd_update(); + } +} + + +static int rds_decode(int line, struct si4700_dbg_info *nfo) +{ + unsigned short rdsdata[4]; + unsigned int pi, group, tp, pty, segment, abflag; + static unsigned int af1 = 0, af2 = 0; + static unsigned int day = 0, hour = 0, minute = 0; + static unsigned int abflag_prev = -1; + static char mystring[64]; + + /* big RDS arrays */ + static char ps[9]; + static char rt[65]; + + rdsdata[0] = nfo->regs[12]; + rdsdata[1] = nfo->regs[13]; + rdsdata[2] = nfo->regs[14]; + rdsdata[3] = nfo->regs[15]; + + pi = rdsdata[0]; + group = (rdsdata[1] >> 11) & 0x1F; + tp = (rdsdata[1] >> 10) & 1; + pty = (rdsdata[1] >> 5) & 0x1F; + + switch (group) { + + case 0: /* group 0A: basic info */ + af1 = (rdsdata[2] >> 8) & 0xFF; + af2 = (rdsdata[2] >> 0) & 0xFF; + /* fall through */ + case 1: /* group 0B: basic info */ + segment = rdsdata[1] & 3; + ps[segment * 2 + 0] = (rdsdata[3] >> 8) & 0xFF; + ps[segment * 2 + 1] = (rdsdata[3] >> 0) & 0xFF; + break; + + case 2: /* group 1A: programme item */ + case 3: /* group 1B: programme item */ + day = (rdsdata[3] >> 11) & 0x1F; + hour = (rdsdata[3] >> 6) & 0x1F; + minute = (rdsdata[3] >> 0) & 0x3F; + break; + + case 4: /* group 2A: radio text */ + segment = rdsdata[1] & 0xF; + abflag = (rdsdata[1] >> 4) & 1; + if (abflag != abflag_prev) { + memset(rt, '.', 64); + abflag_prev = abflag; + } + rt[segment * 4 + 0] = (rdsdata[2] >> 8) & 0xFF; + rt[segment * 4 + 1] = (rdsdata[2] >> 0) & 0xFF; + rt[segment * 4 + 2] = (rdsdata[3] >> 8) & 0xFF; + rt[segment * 4 + 3] = (rdsdata[3] >> 0) & 0xFF; + break; + + case 5: /* group 2B: radio text */ + segment = rdsdata[1] & 0xF; + abflag = (rdsdata[1] >> 4) & 1; + if (abflag != abflag_prev) { + memset(rt, '.', 64); + abflag_prev = abflag; + } + rt[segment * 2 + 0] = (rdsdata[3] >> 8) & 0xFF; + rt[segment * 2 + 1] = (rdsdata[3] >> 0) & 0xFF; + break; + + default: + break; + } + + snprintf(mystring, 64, "PI:%04X,TP:%d,PTY:%2d,AF:%02X/%02X", pi, tp, pty, af1, af2); + lcd_puts(0, line++, mystring); + snprintf(mystring, 64, "PS:%s,ITEM:%02d-%02d:%02d", ps, day, hour, minute); + lcd_puts(0, line++, mystring); + snprintf(mystring, 64, "RT:%s", rt); + lcd_puts(0, line++, mystring); + + return line; +} + + 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 + +#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 + +#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 +#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 */ + diff --git a/tools/configure b/tools/configure index b23d40ed50..36c74105a3 100755 --- a/tools/configure +++ b/tools/configure @@ -815,6 +815,7 @@ cat <