1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Bertrik Sikken 2009-07-29 20:42:02 +00:00
parent e30f1e83c4
commit 2fb73842a9
11 changed files with 1141 additions and 0 deletions

View file

@ -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

306
bootloader/samsung_yps3.c Normal file
View file

@ -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 <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#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<duration;i++);
}
// forward declaration
static int rds_decode(int line, struct si4700_dbg_info *nfo);
static int count = 0;
static void timer_callback(void)
{
count++;
}
void main(void)
{
char mystring[64];
int line, col;
unsigned char read_data[16];
int i;
struct si4700_dbg_info si4700_info;
line = 1;
// enable all peripherals
PWRCON = 0;
// disable all interrupts
INTMSK = 0;
// start with all GPIOs as input
PCON0 = 0;
PCON1 = 0;
PCON2 = 0;
PCON3 = 0;
PCON4 = 0;
PCON5 = 0;
PCON6 = 0;
PCON7 = 0;
system_init();
kernel_init();
asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
lcd_init();
lcd_clear_display();
lcd_bitmap(rockboxlogo, 0, 160, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
lcd_update();
power_init();
i2c_init();
fmradio_i2c_init();
adc_init();
_backlight_init();
timer_register(1, NULL, 3 * TIMER_FREQ, timer_callback);
// LED outputs
PCON3 = (PCON3 & ~(0x0000FF00)) | 0x00001100;
PDAT3 |= (1 << 2) | (1 << 3);
// FM power
si4700_init();
tuner_power(true);
si4700_set(RADIO_SLEEP, 0);
si4700_set(RADIO_MUTE, 0);
si4700_set(RADIO_FREQUENCY, 100700000);
lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---");
while (true)
{
line = 1;
#if 1 /* enable to see GPIOs */
snprintf(mystring, 64, "%02X %02X %02X %02X %02X %02X %02X %02X", PDAT0, PDAT1, PDAT2, PDAT3, PDAT4, PDAT5, PDAT6, PDAT7);
lcd_puts(0, line++, mystring);
#endif
#if 1 /* enable this to see info about the RTC */
rtc_read_datetime(read_data);
snprintf(mystring, 64, "RTC:");
for (i = 0; i < 7; i++) {
snprintf(mystring + 2 * i + 4, 64, "%02X", read_data[i]);
}
lcd_puts(0, line++, mystring);
#endif
#if 0 /* enable this so see info about the codec */
memset(read_data, 0, sizeof(read_data));
for (i = 0; i < 1; i++) {
i2c_read(0x34, i, 2, read_data);
data = read_data[0] << 8 | read_data[1];
snprintf(mystring + 4 * i, 64, "%04X", data);
}
lcd_puts(0, line++, mystring);
#endif
#if 1 /* enable this to see radio debug info */
si4700_dbg_info(&si4700_info);
col = snprintf(mystring, 64, "FM: ");
for (i = 0; i < 16; i++) {
col += snprintf(mystring + col, 64, "%04X ", si4700_info.regs[i]);
if (((i + 1) % 4) == 0) {
lcd_puts(0, line++, mystring);
col = 4;
}
}
line = rds_decode(line, &si4700_info);
#endif
#if 1 /* enable this to see ADC info */
snprintf(mystring, 64, "%04X %04X %04X %04X", adc_read(0), adc_read(1), adc_read(2), adc_read(3));
lcd_puts(0, line++, mystring);
snprintf(mystring, 64, "ADC:USB %4d mV BAT %4d mV",
(adc_read(0) * 6000) >> 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;
}

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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_ */

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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 */

24
tools/configure vendored
View file

@ -815,6 +815,7 @@ cat <<EOF
140) YH-820 150) Elio TPJ-1022 ==Lyre project==
141) YH-920 130) Lyre proto 1
142) YH-925
143) YP-S3
EOF
buildfor=`input`;
@ -2275,6 +2276,29 @@ fi
t_model="yh925"
;;
143|yps3)
target_id=60
modelname="yps3"
target="-DSAMSUNG_YPS3"
memory=16 # always
arm940tbecc
tool="cp"
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
output="rockbox.yps3"
appextra="recorder:gui"
plugins="no" #FIXME
swcodec="yes"
toolset=$genericbitmaptools
boottool="cp"
bootoutput="rockboot.ebn"
# architecture, manufacturer and model for the target-tree build
t_cpu="arm"
t_manufacturer="s5l8700"
t_model="yps3"
;;
*)
echo "Please select a supported target platform!"
exit 7