From b4275d4941e464c851ae3f5fe33c80f56ea365e5 Mon Sep 17 00:00:00 2001 From: Mark Arigo Date: Wed, 21 May 2008 03:55:17 +0000 Subject: Philips GoGear SA9200 port. Working bootloader and normal builds, including sound. No touchpad now, buttons limited to using vol+/vol-/power for up/down/select. Rockbox USB is enabled since the OF is MTP only...read the warnings on the PortalPlayerUsb wiki page. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17591 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/ata-sd-pp.c | 2 +- firmware/target/arm/i2c-pp.c | 2 +- firmware/target/arm/philips/app.lds | 198 ++++++++++++++++++++ firmware/target/arm/philips/boot.lds | 65 +++++++ firmware/target/arm/philips/sa9200/adc-target.h | 43 +++++ .../target/arm/philips/sa9200/backlight-sa9200.c | 75 ++++++++ .../target/arm/philips/sa9200/backlight-target.h | 30 +++ firmware/target/arm/philips/sa9200/button-sa9200.c | 72 ++++++++ firmware/target/arm/philips/sa9200/button-target.h | 53 ++++++ firmware/target/arm/philips/sa9200/lcd-sa9200.c | 205 +++++++++++++++++++++ firmware/target/arm/philips/sa9200/power-sa9200.c | 136 ++++++++++++++ .../target/arm/philips/sa9200/powermgmt-sa9200.c | 58 ++++++ firmware/target/arm/system-pp502x.c | 6 +- firmware/target/arm/usb-fw-pp502x.c | 5 + 14 files changed, 945 insertions(+), 5 deletions(-) create mode 100644 firmware/target/arm/philips/app.lds create mode 100644 firmware/target/arm/philips/boot.lds create mode 100644 firmware/target/arm/philips/sa9200/adc-target.h create mode 100644 firmware/target/arm/philips/sa9200/backlight-sa9200.c create mode 100644 firmware/target/arm/philips/sa9200/backlight-target.h create mode 100755 firmware/target/arm/philips/sa9200/button-sa9200.c create mode 100755 firmware/target/arm/philips/sa9200/button-target.h create mode 100755 firmware/target/arm/philips/sa9200/lcd-sa9200.c create mode 100644 firmware/target/arm/philips/sa9200/power-sa9200.c create mode 100644 firmware/target/arm/philips/sa9200/powermgmt-sa9200.c (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index e4ab922f24..797a9f8e36 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c @@ -526,7 +526,7 @@ static int sd_select_bank(unsigned char bank) static void sd_card_mux(int card_no) { /* Set the current card mux */ -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(PHILIPS_SA9200) if (card_no == 0) { GPO32_VAL |= 0x4; diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c index 5799d7c37f..7dbd223ddf 100644 --- a/firmware/target/arm/i2c-pp.c +++ b/firmware/target/arm/i2c-pp.c @@ -209,7 +209,7 @@ void i2c_init(void) outl(0x0, 0x600060a4); outl(0x80 | (0 << 8), 0x600060a4); #elif CONFIG_I2C == I2C_PP5024 -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(PHILIPS_SA9200) /* Sansa OF sets this to 0x20 first, communicates with the AS3514 then sets it to 0x23 - this still works fine though */ outl(0x0, 0x600060a4); diff --git a/firmware/target/arm/philips/app.lds b/firmware/target/arm/philips/app.lds new file mode 100644 index 0000000000..d7159e8e1e --- /dev/null +++ b/firmware/target/arm/philips/app.lds @@ -0,0 +1,198 @@ +#include "config.h" + +ENTRY(start) + +OUTPUT_FORMAT(elf32-littlearm) +OUTPUT_ARCH(arm) +STARTUP(target/arm/crt0-pp.o) + +#define PLUGINSIZE PLUGIN_BUFFER_SIZE +#define CODECSIZE CODEC_SIZE + +#ifdef DEBUG +#define STUBOFFSET 0x10000 +#else +#define STUBOFFSET 0 +#endif + +#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE + +#define DRAMORIG 0x00000000 + STUBOFFSET +#define IRAMORIG 0x40000000 +#define IRAMSIZE 0xc000 + +#ifdef CPU_PP502x +#define NOCACHE_BASE 0x10000000 +#else +#define NOCACHE_BASE 0x28000000 +#endif + +#define CACHEALIGN_SIZE 16 + +/* End of the audio buffer, where the codec buffer starts */ +#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) + +/* Where the codec buffer ends, and the plugin buffer starts */ +#define ENDADDR (ENDAUDIOADDR + CODECSIZE) + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE +} + +SECTIONS +{ + .text : + { + loadaddress = .; + _loadaddress = .; + . = ALIGN(0x200); + *(.init.text) + *(.text*) + *(.glue_7) + *(.glue_7t) + . = ALIGN(0x4); + } > DRAM + + .rodata : + { + *(.rodata) /* problems without this, dunno why */ + *(.rodata*) + *(.rodata.str1.1) + *(.rodata.str1.4) + . = ALIGN(0x4); + + /* Pseudo-allocate the copies of the data sections */ + _datacopy = .; + } > DRAM + + /* TRICK ALERT! For RAM execution, we put the .data section at the + same load address as the copy. Thus, we don't waste extra RAM + when we don't actually need the copy. */ + .data : AT ( _datacopy ) + { + _datastart = .; + *(.data*) + . = ALIGN(0x4); + _dataend = .; + } > DRAM + +#if NOCACHE_BASE != 0 + /* .ncdata section is placed at uncached physical alias address and is + * loaded at the proper cached virtual address - no copying is + * performed in the init code */ + .ncdata . + NOCACHE_BASE : + { + . = ALIGN(CACHEALIGN_SIZE); + *(.ncdata*) + . = ALIGN(CACHEALIGN_SIZE); + } AT> DRAM +#endif + + /DISCARD/ : + { + *(.eh_frame) + } + + .vectors 0x0 : + { + _vectorsstart = .; + *(.vectors); + _vectorsend = .; + } AT> DRAM + + _vectorscopy = LOADADDR(.vectors); + + .ibss IRAMORIG (NOLOAD) : + { + _iedata = .; + *(.qharray) + *(.ibss) + . = ALIGN(0x4); + _iend = .; + } > IRAM + + .iram _iend : + { + _iramstart = .; + *(.icode) + *(.irodata) + *(.idata) + . = ALIGN(0x4); + _iramend = .; + } > IRAM AT> DRAM + + _iramcopy = LOADADDR(.iram); + + .idle_stacks (NOLOAD) : + { + *(.idle_stacks) +#if NUM_CORES > 1 + cpu_idlestackbegin = .; + . += IDLE_STACK_SIZE; + cpu_idlestackend = .; +#endif + cop_idlestackbegin = .; + . += IDLE_STACK_SIZE; + cop_idlestackend = .; + } > IRAM + + .stack (NOLOAD) : + { + *(.stack) + stackbegin = .; + . += 0x2000; + stackend = .; + } > IRAM + + /* .bss and .ncbss are treated as a single section to use one init loop to + * zero it - note "_edata" and "_end" */ + .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\ + SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) : + { + _edata = .; + *(.bss*) + *(COMMON) + . = ALIGN(0x4); + } > DRAM + +#if NOCACHE_BASE != 0 + .ncbss . + NOCACHE_BASE (NOLOAD): + { + . = ALIGN(CACHEALIGN_SIZE); + *(.ncbss*) + . = ALIGN(CACHEALIGN_SIZE); + } AT> DRAM +#endif + + /* This will be aligned by preceding alignments */ + .endaddr . - NOCACHE_BASE (NOLOAD) : + { + _end = .; + } > DRAM + + .audiobuf (NOLOAD) : + { + _audiobuffer = .; + audiobuffer = .; + } > DRAM + + .audiobufend ENDAUDIOADDR (NOLOAD) : + { + audiobufend = .; + _audiobufend = .; + } > DRAM + + .codec ENDAUDIOADDR (NOLOAD) : + { + codecbuf = .; + _codecbuf = .; + } + + .plugin ENDADDR (NOLOAD) : + { + _pluginbuf = .; + pluginbuf = .; + } +} diff --git a/firmware/target/arm/philips/boot.lds b/firmware/target/arm/philips/boot.lds new file mode 100644 index 0000000000..d115aa5949 --- /dev/null +++ b/firmware/target/arm/philips/boot.lds @@ -0,0 +1,65 @@ +#include "config.h" + +ENTRY(start) +OUTPUT_FORMAT(elf32-littlearm) +OUTPUT_ARCH(arm) +STARTUP(target/arm/crt0-pp-bl.o) + +#define DRAMSIZE (MEMORYSIZE * 0x100000) + +#define DRAMORIG 0x10000000 +#ifndef IRAMORIG +#define IRAMORIG 0x40000000 +#endif +#define IRAMSIZE 0x20000 +#define FLASHORIG 0x001f0000 +#define FLASHSIZE 2M + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE +} + +SECTIONS +{ + . = IRAMORIG; + + .text : { + *(.init.text) + *(.text*) + *(.glue_7) + *(.glue_7t) + } > IRAM + + .data : { + *(.icode) + *(.irodata) + *(.idata) + *(.data*) + *(.ncdata*) + *(.rodata*) + _dataend = . ; + } > IRAM + + .stack : { + *(.stack) + _stackbegin = .; + stackbegin = .; + . += 0x2000; + _stackend = .; + stackend = .; + } > IRAM + + /* The bss section is too large for IRAM - we just move it 16MB into the + DRAM */ + + . = DRAMORIG; + .bss . + (16*1024*1024) : { + _edata = .; + *(.bss*); + *(.ibss); + *(.ncbss*); + _end = .; + } > DRAM +} diff --git a/firmware/target/arm/philips/sa9200/adc-target.h b/firmware/target/arm/philips/sa9200/adc-target.h new file mode 100644 index 0000000000..56efdf7574 --- /dev/null +++ b/firmware/target/arm/philips/sa9200/adc-target.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Barry Wardell + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +/* ADC channels */ +#define NUM_ADC_CHANNELS 13 + +#define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */ +#define ADC_RTCSUP 1 /* RTC backup battery voltage */ +#define ADC_UVDD 2 /* USB host voltage */ +#define ADC_CHG_IN 3 /* Charger input voltage */ +#define ADC_CVDD 4 /* Charger pump output voltage */ +#define ADC_BATTEMP 5 /* Battery charging temperature */ +#define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control + or external voltage measurement */ +#define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control + or external voltage measurement */ +#define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */ +#define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */ +#define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */ +#define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */ +#define ADC_VBAT 12 /* Single cell battery voltage */ + +#define ADC_UNREG_POWER ADC_BVDD /* For compatibility */ + +#endif diff --git a/firmware/target/arm/philips/sa9200/backlight-sa9200.c b/firmware/target/arm/philips/sa9200/backlight-sa9200.c new file mode 100644 index 0000000000..aaec8cf007 --- /dev/null +++ b/firmware/target/arm/philips/sa9200/backlight-sa9200.c @@ -0,0 +1,75 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Barry Wardell + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "backlight-target.h" +#include "system.h" +#include "lcd.h" +#include "backlight.h" +#include "i2c-pp.h" +#include "as3514.h" + +static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; + +void _backlight_set_brightness(int brightness) +{ + backlight_brightness = brightness; + + if (brightness > 0) + _backlight_on(); + else + _backlight_off(); +} + +void _backlight_on(void) +{ +#ifdef HAVE_LCD_SLEEP + backlight_lcd_sleep_countdown(false); /* stop counter */ +#endif +#ifdef HAVE_LCD_ENABLE + lcd_enable(true); /* power on lcd + visible display */ +#endif + pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness); +} + +void _backlight_off(void) +{ + pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0); +#ifdef HAVE_LCD_ENABLE + lcd_enable(false); /* power off visible display */ +#endif +#ifdef HAVE_LCD_SLEEP + backlight_lcd_sleep_countdown(true); /* start countdown */ +#endif +} + +void _buttonlight_on(void) +{ + GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x80); +#ifdef SANSA_C200 + GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */ +#endif +} + +void _buttonlight_off(void) +{ + GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x80); +#ifdef SANSA_C200 + GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */ +#endif +} diff --git a/firmware/target/arm/philips/sa9200/backlight-target.h b/firmware/target/arm/philips/sa9200/backlight-target.h new file mode 100644 index 0000000000..01573b8403 --- /dev/null +++ b/firmware/target/arm/philips/sa9200/backlight-target.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Barry Wardell + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +#define _backlight_init() true +void _backlight_on(void); +void _backlight_off(void); +void _backlight_set_brightness(int brightness); +int __backlight_is_on(void); + +void _buttonlight_on(void); +void _buttonlight_off(void); +#endif diff --git a/firmware/target/arm/philips/sa9200/button-sa9200.c b/firmware/target/arm/philips/sa9200/button-sa9200.c new file mode 100755 index 0000000000..dc9f3466c2 --- /dev/null +++ b/firmware/target/arm/philips/sa9200/button-sa9200.c @@ -0,0 +1,72 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "system.h" +#include "button.h" +#include "backlight.h" + +void button_init_device(void) +{ + /* TODO...for now, hardware initialisation is done by the c200 bootloader */ +} + +bool button_hold(void) +{ + return !(GPIOL_INPUT_VAL & 0x40); +} + +/* + * Get button pressed from hardware + */ +int button_read_device(void) +{ + int btn = BUTTON_NONE; + static bool hold_button = false; + bool hold_button_old; + + /* Hold */ + hold_button_old = hold_button; + hold_button = button_hold(); + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) + backlight_hold_changed(hold_button); +#endif + + /* device buttons */ + if (!hold_button) + { +#if 0 + if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER; + if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP; + if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; +#endif + /* A hack until the touchpad works */ + if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT; + if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_UP; + if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN; + } + + return btn; +} + +bool headphones_inserted(void) +{ + return (GPIOB_INPUT_VAL & 0x10) ? false : true; +} diff --git a/firmware/target/arm/philips/sa9200/button-target.h b/firmware/target/arm/philips/sa9200/button-target.h new file mode 100755 index 0000000000..1cd6e52097 --- /dev/null +++ b/firmware/target/arm/philips/sa9200/button-target.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2007 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * 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 +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(void); + +/* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_SELECT 0x00000002 +#define BUTTON_MENU 0x00000004 +#define BUTTON_LEFT 0x00000008 +#define BUTTON_RIGHT 0x00000010 +#define BUTTON_REW 0x00000020 +#define BUTTON_FFWD 0x00000040 +#define BUTTON_UP 0x00000080 +#define BUTTON_DOWN 0x00000100 +#define BUTTON_VOL_UP 0x00000200 +#define BUTTON_VOL_DOWN 0x00000400 + +#define BUTTON_MAIN 0x00000fff + +/* No Remote control */ +#define BUTTON_REMOTE 0 + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/philips/sa9200/lcd-sa9200.c b/firmware/target/arm/philips/sa9200/lcd-sa9200.c new file mode 100755 index 0000000000..b06dcd952b --- /dev/null +++ b/firmware/target/arm/philips/sa9200/lcd-sa9200.c @@ -0,0 +1,205 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "lcd.h" +#include "kernel.h" +#include "system.h" + +/* Display status */ +static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; + +/* wait for LCD */ +static inline void lcd_wait_write(void) +{ + while (LCD1_CONTROL & LCD1_BUSY_MASK); +} + +/* send LCD data */ +static void lcd_send_data(unsigned data) +{ + lcd_wait_write(); + LCD1_DATA = data >> 8; + lcd_wait_write(); + LCD1_DATA = data & 0xff; +} + +/* send LCD command */ +static void lcd_send_command(unsigned cmd) +{ + lcd_wait_write(); + LCD1_CMD = cmd >> 8; + lcd_wait_write(); + LCD1_CMD = cmd & 0xff; +} + +static void lcd_write_reg(unsigned reg, unsigned data) +{ + lcd_send_command(reg); + lcd_send_data(data); +} + +void lcd_init_device(void) +{ +#if 0 + /* This is the init done by the OF bootloader. + Re-initializing the lcd causes it to flash + a white screen, so for now disable this. */ + DEV_INIT1 &= ~0x3000; + DEV_INIT1 = DEV_INIT1; + DEV_INIT2 &= ~0x400; + + LCD1_CONTROL = 0x4680; + udelay(1500); + LCD1_CONTROL = 0x4684; + + outl(1, 0x70003018); + + LCD1_CONTROL &= ~0x200; + LCD1_CONTROL &= ~0x800; + LCD1_CONTROL &= ~0x400; + udelay(30000); + + LCD1_CONTROL |= 0x1; + + lcd_write_reg(0x0000, 0x0001); + udelay(50000); + + lcd_write_reg(0x0011, 0x171f); + lcd_write_reg(0x0012, 0x0001); + lcd_write_reg(0x0013, 0x08cd); + lcd_write_reg(0x0014, 0x0416); + lcd_write_reg(0x0010, 0x1208); + udelay(50000); + + lcd_write_reg(0x0013, 0x081C); + udelay(200000); + + lcd_write_reg(0x0001, 0x0a0c); + lcd_write_reg(0x0002, 0x0200); + lcd_write_reg(0x0003, 0x1030); + lcd_write_reg(0x0007, 0x0005); + lcd_write_reg(0x0008, 0x030a); + lcd_write_reg(0x000b, 0x0000); + lcd_write_reg(0x000c, 0x0000); + lcd_write_reg(0x0030, 0x0000); + lcd_write_reg(0x0031, 0x0204); + lcd_write_reg(0x0032, 0x0001); + lcd_write_reg(0x0033, 0x0600); + lcd_write_reg(0x0034, 0x0607); + lcd_write_reg(0x0035, 0x0305); + lcd_write_reg(0x0036, 0x0707); + lcd_write_reg(0x0037, 0x0006); + lcd_write_reg(0x0038, 0x0400); + lcd_write_reg(0x0040, 0x0000); + lcd_write_reg(0x0042, 0x9f00); + lcd_write_reg(0x0043, 0x0000); + lcd_write_reg(0x0044, 0x7f00); + lcd_write_reg(0x0045, 0x9f00); + lcd_write_reg(0x00a8, 0x0125); + lcd_write_reg(0x00a9, 0x0014); + lcd_write_reg(0x00a7, 0x0022); + + lcd_write_reg(0x0007, 0x0021); + udelay(40000); + lcd_write_reg(0x0007, 0x0023); + udelay(40000); + lcd_write_reg(0x0007, 0x1037); + + lcd_write_reg(0x0021, 0x0000); +#endif +} + +/*** hardware configuration ***/ +#if 0 +int lcd_default_contrast(void) +{ + return DEFAULT_CONTRAST_SETTING; +} +#endif + +void lcd_set_contrast(int val) +{ + (void)val; +} + +void lcd_set_invert_display(bool yesno) +{ + (void)yesno; +} + +/* turn the display upside down (call lcd_update() afterwards) */ +void lcd_set_flip(bool yesno) +{ + (void)yesno; +} + +void lcd_yuv_set_options(unsigned options) +{ + lcd_yuv_options = options; +} + +/* Performance function to blit a YUV bitmap directly to the LCD */ +void lcd_blit_yuv(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + (void)src; + (void)src_x; + (void)src_y; + (void)stride; + (void)x; + (void)y; + (void)width; + (void)height; +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + const fb_data *addr; + + if (x + width >= LCD_WIDTH) + width = LCD_WIDTH - x; + if (y + height >= LCD_HEIGHT) + height = LCD_HEIGHT - y; + + if ((width <= 0) || (height <= 0)) + return; /* Nothing left to do. */ + + addr = &lcd_framebuffer[y][x]; + + do { + lcd_write_reg(0x0021, ((y++ & 0xff) << 8) | (x & 0xff)); + lcd_send_command(0x0022); + + int w = width; + do { + lcd_send_data(*addr++); + } while (--w > 0); + addr += LCD_WIDTH - width; + } while (--height > 0); +} diff --git a/firmware/target/arm/philips/sa9200/power-sa9200.c b/firmware/target/arm/philips/sa9200/power-sa9200.c new file mode 100644 index 0000000000..8c8214a7ce --- /dev/null +++ b/firmware/target/arm/philips/sa9200/power-sa9200.c @@ -0,0 +1,136 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Daniel Ankers + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "system.h" +#include "cpu.h" +#include "i2c-pp.h" +#include "tuner.h" +#include "as3514.h" +#include "power.h" + +void power_init(void) +{ +} + +void power_off(void) +{ + char byte; + + /* Send shutdown command to PMU */ + byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM); + byte &= ~0x1; + pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte); + + /* Stop interrupts on both cores */ + disable_interrupt(IRQ_FIQ_STATUS); + COP_INT_CLR = -1; + CPU_INT_CLR = -1; + + /* Halt everything and wait for device to power off */ + while (1) + { + COP_CTL = 0x40000000; + CPU_CTL = 0x40000000; + } +} + +bool charger_inserted(void) +{ +#ifdef SANSA_E200 + if(GPIOB_INPUT_VAL & 0x10) +#else /* SANSA_C200 */ + if(GPIOH_INPUT_VAL & 0x2) +#endif + return true; + return false; +} + +void ide_power_enable(bool on) +{ + (void)on; +} + +#if CONFIG_TUNER + +/** Tuner **/ +static bool powered = false; + +bool tuner_power(bool status) +{ + bool old_status; + lv24020lp_lock(); + + old_status = powered; + + if (status != old_status) + { + if (status) + { + /* init mystery amplification device */ +#if defined(SANSA_E200) + GPO32_ENABLE |= 0x1; +#else /* SANSA_C200 */ + DEV_INIT2 &= ~0x800; +#endif + udelay(5); + + /* When power up, host should initialize the 3-wire bus + in host read mode: */ + + /* 1. Set direction of the DATA-line to input-mode. */ + GPIOH_OUTPUT_EN &= ~(1 << 5); + GPIOH_ENABLE |= (1 << 5); + + /* 2. Drive NR_W low */ + GPIOH_OUTPUT_VAL &= ~(1 << 3); + GPIOH_OUTPUT_EN |= (1 << 3); + GPIOH_ENABLE |= (1 << 3); + + /* 3. Drive CLOCK high */ + GPIOH_OUTPUT_VAL |= (1 << 4); + GPIOH_OUTPUT_EN |= (1 << 4); + GPIOH_ENABLE |= (1 << 4); + + lv24020lp_power(true); + } + else + { + lv24020lp_power(false); + + /* set all as inputs */ + GPIOH_OUTPUT_EN &= ~((1 << 5) | (1 << 3) | (1 << 4)); + GPIOH_ENABLE &= ~((1 << 3) | (1 << 4)); + + /* turn off mystery amplification device */ +#if defined (SANSA_E200) + GPO32_ENABLE &= ~0x1; +#else + DEV_INIT2 |= 0x800; +#endif + } + + powered = status; + } + + lv24020lp_unlock(); + return old_status; +} + +#endif /* CONFIG_TUNER */ diff --git a/firmware/target/arm/philips/sa9200/powermgmt-sa9200.c b/firmware/target/arm/philips/sa9200/powermgmt-sa9200.c new file mode 100644 index 0000000000..9bb70263be --- /dev/null +++ b/firmware/target/arm/philips/sa9200/powermgmt-sa9200.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese + * Revisions copyright (C) 2005 by Gerald Van Baren + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "adc.h" +#include "powermgmt.h" + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 3400 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 3300 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* Sansa Li Ion 750mAH, took from battery benchs */ + { 3300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160 }, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = +{ + /* Sansa Li Ion 750mAH FIXME */ + 3300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160 +}; + +/* ADC should read 0x3ff=5.12V */ +#define BATTERY_SCALE_FACTOR 5125 +/* full-scale ADC readout (2^10) in millivolt */ + +/* Returns battery voltage from ADC [millivolts] */ +unsigned int battery_adc_voltage(void) +{ + return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; +} + diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 4e3f2c0cf0..f74b0484ab 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -374,7 +374,7 @@ void system_init(void) /* to be done */ #endif -#if !defined(SANSA_E200) && !defined(SANSA_C200) +#if !defined(SANSA_E200) && !defined(SANSA_C200) && !defined(PHILIPS_SA9200) /* Remap the flash ROM on CPU, keep hidden from COP: * 0x00000000-0x3fffffff = 0x20000000-0x23ffffff */ MMAP1_LOGICAL = 0x20003c00; @@ -405,7 +405,7 @@ void system_init(void) GPIOK_INT_EN = 0; GPIOL_INT_EN = 0; -#if defined(SANSA_E200) || defined(SANSA_C200) +#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) /* outl(0x00000000, 0x6000b000); */ outl(inl(0x6000a000) | 0x80000000, 0x6000a000); /* Init DMA controller? */ #endif @@ -433,7 +433,7 @@ void system_init(void) void system_reboot(void) { /* Reboot */ -#if defined(SANSA_E200) || defined(SANSA_C200) +#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) CACHE_CTL &= ~CACHE_CTL_VECT_REMAP; /* Magic used by the c200 OF: 0x23066000 diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index 18ef3d234e..eae78886f4 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c @@ -121,6 +121,11 @@ static bool usb_pin_detect(void) /* GPIO L bit 2 is usb detect */ if (GPIOL_INPUT_VAL & 0x4) retval = true; + +#elif defined(PHILIPS_SA9200) + /* GPIO F bit 7 is usb detect */ + if (!(GPIOF_INPUT_VAL & 0x80)) + retval = true; #endif return retval; -- cgit v1.2.3