summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/ata-sd-pp.c2
-rw-r--r--firmware/target/arm/i2c-pp.c2
-rw-r--r--firmware/target/arm/philips/app.lds198
-rw-r--r--firmware/target/arm/philips/boot.lds65
-rw-r--r--firmware/target/arm/philips/sa9200/adc-target.h43
-rw-r--r--firmware/target/arm/philips/sa9200/backlight-sa9200.c75
-rw-r--r--firmware/target/arm/philips/sa9200/backlight-target.h30
-rwxr-xr-xfirmware/target/arm/philips/sa9200/button-sa9200.c72
-rwxr-xr-xfirmware/target/arm/philips/sa9200/button-target.h53
-rwxr-xr-xfirmware/target/arm/philips/sa9200/lcd-sa9200.c205
-rw-r--r--firmware/target/arm/philips/sa9200/power-sa9200.c136
-rw-r--r--firmware/target/arm/philips/sa9200/powermgmt-sa9200.c58
-rw-r--r--firmware/target/arm/system-pp502x.c6
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c5
14 files changed, 945 insertions, 5 deletions
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)
526static void sd_card_mux(int card_no) 526static void sd_card_mux(int card_no)
527{ 527{
528/* Set the current card mux */ 528/* Set the current card mux */
529#ifdef SANSA_E200 529#if defined(SANSA_E200) || defined(PHILIPS_SA9200)
530 if (card_no == 0) 530 if (card_no == 0)
531 { 531 {
532 GPO32_VAL |= 0x4; 532 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)
209 outl(0x0, 0x600060a4); 209 outl(0x0, 0x600060a4);
210 outl(0x80 | (0 << 8), 0x600060a4); 210 outl(0x80 | (0 << 8), 0x600060a4);
211#elif CONFIG_I2C == I2C_PP5024 211#elif CONFIG_I2C == I2C_PP5024
212#ifdef SANSA_E200 212#if defined(SANSA_E200) || defined(PHILIPS_SA9200)
213 /* Sansa OF sets this to 0x20 first, communicates with the AS3514 213 /* Sansa OF sets this to 0x20 first, communicates with the AS3514
214 then sets it to 0x23 - this still works fine though */ 214 then sets it to 0x23 - this still works fine though */
215 outl(0x0, 0x600060a4); 215 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 @@
1#include "config.h"
2
3ENTRY(start)
4
5OUTPUT_FORMAT(elf32-littlearm)
6OUTPUT_ARCH(arm)
7STARTUP(target/arm/crt0-pp.o)
8
9#define PLUGINSIZE PLUGIN_BUFFER_SIZE
10#define CODECSIZE CODEC_SIZE
11
12#ifdef DEBUG
13#define STUBOFFSET 0x10000
14#else
15#define STUBOFFSET 0
16#endif
17
18#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
19
20#define DRAMORIG 0x00000000 + STUBOFFSET
21#define IRAMORIG 0x40000000
22#define IRAMSIZE 0xc000
23
24#ifdef CPU_PP502x
25#define NOCACHE_BASE 0x10000000
26#else
27#define NOCACHE_BASE 0x28000000
28#endif
29
30#define CACHEALIGN_SIZE 16
31
32/* End of the audio buffer, where the codec buffer starts */
33#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
34
35/* Where the codec buffer ends, and the plugin buffer starts */
36#define ENDADDR (ENDAUDIOADDR + CODECSIZE)
37
38MEMORY
39{
40 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
41 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
42}
43
44SECTIONS
45{
46 .text :
47 {
48 loadaddress = .;
49 _loadaddress = .;
50 . = ALIGN(0x200);
51 *(.init.text)
52 *(.text*)
53 *(.glue_7)
54 *(.glue_7t)
55 . = ALIGN(0x4);
56 } > DRAM
57
58 .rodata :
59 {
60 *(.rodata) /* problems without this, dunno why */
61 *(.rodata*)
62 *(.rodata.str1.1)
63 *(.rodata.str1.4)
64 . = ALIGN(0x4);
65
66 /* Pseudo-allocate the copies of the data sections */
67 _datacopy = .;
68 } > DRAM
69
70 /* TRICK ALERT! For RAM execution, we put the .data section at the
71 same load address as the copy. Thus, we don't waste extra RAM
72 when we don't actually need the copy. */
73 .data : AT ( _datacopy )
74 {
75 _datastart = .;
76 *(.data*)
77 . = ALIGN(0x4);
78 _dataend = .;
79 } > DRAM
80
81#if NOCACHE_BASE != 0
82 /* .ncdata section is placed at uncached physical alias address and is
83 * loaded at the proper cached virtual address - no copying is
84 * performed in the init code */
85 .ncdata . + NOCACHE_BASE :
86 {
87 . = ALIGN(CACHEALIGN_SIZE);
88 *(.ncdata*)
89 . = ALIGN(CACHEALIGN_SIZE);
90 } AT> DRAM
91#endif
92
93 /DISCARD/ :
94 {
95 *(.eh_frame)
96 }
97
98 .vectors 0x0 :
99 {
100 _vectorsstart = .;
101 *(.vectors);
102 _vectorsend = .;
103 } AT> DRAM
104
105 _vectorscopy = LOADADDR(.vectors);
106
107 .ibss IRAMORIG (NOLOAD) :
108 {
109 _iedata = .;
110 *(.qharray)
111 *(.ibss)
112 . = ALIGN(0x4);
113 _iend = .;
114 } > IRAM
115
116 .iram _iend :
117 {
118 _iramstart = .;
119 *(.icode)
120 *(.irodata)
121 *(.idata)
122 . = ALIGN(0x4);
123 _iramend = .;
124 } > IRAM AT> DRAM
125
126 _iramcopy = LOADADDR(.iram);
127
128 .idle_stacks (NOLOAD) :
129 {
130 *(.idle_stacks)
131#if NUM_CORES > 1
132 cpu_idlestackbegin = .;
133 . += IDLE_STACK_SIZE;
134 cpu_idlestackend = .;
135#endif
136 cop_idlestackbegin = .;
137 . += IDLE_STACK_SIZE;
138 cop_idlestackend = .;
139 } > IRAM
140
141 .stack (NOLOAD) :
142 {
143 *(.stack)
144 stackbegin = .;
145 . += 0x2000;
146 stackend = .;
147 } > IRAM
148
149 /* .bss and .ncbss are treated as a single section to use one init loop to
150 * zero it - note "_edata" and "_end" */
151 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\
152 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
153 {
154 _edata = .;
155 *(.bss*)
156 *(COMMON)
157 . = ALIGN(0x4);
158 } > DRAM
159
160#if NOCACHE_BASE != 0
161 .ncbss . + NOCACHE_BASE (NOLOAD):
162 {
163 . = ALIGN(CACHEALIGN_SIZE);
164 *(.ncbss*)
165 . = ALIGN(CACHEALIGN_SIZE);
166 } AT> DRAM
167#endif
168
169 /* This will be aligned by preceding alignments */
170 .endaddr . - NOCACHE_BASE (NOLOAD) :
171 {
172 _end = .;
173 } > DRAM
174
175 .audiobuf (NOLOAD) :
176 {
177 _audiobuffer = .;
178 audiobuffer = .;
179 } > DRAM
180
181 .audiobufend ENDAUDIOADDR (NOLOAD) :
182 {
183 audiobufend = .;
184 _audiobufend = .;
185 } > DRAM
186
187 .codec ENDAUDIOADDR (NOLOAD) :
188 {
189 codecbuf = .;
190 _codecbuf = .;
191 }
192
193 .plugin ENDADDR (NOLOAD) :
194 {
195 _pluginbuf = .;
196 pluginbuf = .;
197 }
198}
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 @@
1#include "config.h"
2
3ENTRY(start)
4OUTPUT_FORMAT(elf32-littlearm)
5OUTPUT_ARCH(arm)
6STARTUP(target/arm/crt0-pp-bl.o)
7
8#define DRAMSIZE (MEMORYSIZE * 0x100000)
9
10#define DRAMORIG 0x10000000
11#ifndef IRAMORIG
12#define IRAMORIG 0x40000000
13#endif
14#define IRAMSIZE 0x20000
15#define FLASHORIG 0x001f0000
16#define FLASHSIZE 2M
17
18MEMORY
19{
20 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
21 IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
22}
23
24SECTIONS
25{
26 . = IRAMORIG;
27
28 .text : {
29 *(.init.text)
30 *(.text*)
31 *(.glue_7)
32 *(.glue_7t)
33 } > IRAM
34
35 .data : {
36 *(.icode)
37 *(.irodata)
38 *(.idata)
39 *(.data*)
40 *(.ncdata*)
41 *(.rodata*)
42 _dataend = . ;
43 } > IRAM
44
45 .stack : {
46 *(.stack)
47 _stackbegin = .;
48 stackbegin = .;
49 . += 0x2000;
50 _stackend = .;
51 stackend = .;
52 } > IRAM
53
54 /* The bss section is too large for IRAM - we just move it 16MB into the
55 DRAM */
56
57 . = DRAMORIG;
58 .bss . + (16*1024*1024) : {
59 _edata = .;
60 *(.bss*);
61 *(.ibss);
62 *(.ncbss*);
63 _end = .;
64 } > DRAM
65}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _ADC_TARGET_H_
20#define _ADC_TARGET_H_
21
22/* ADC channels */
23#define NUM_ADC_CHANNELS 13
24
25#define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
26#define ADC_RTCSUP 1 /* RTC backup battery voltage */
27#define ADC_UVDD 2 /* USB host voltage */
28#define ADC_CHG_IN 3 /* Charger input voltage */
29#define ADC_CVDD 4 /* Charger pump output voltage */
30#define ADC_BATTEMP 5 /* Battery charging temperature */
31#define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
32 or external voltage measurement */
33#define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
34 or external voltage measurement */
35#define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
36#define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
37#define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
38#define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
39#define ADC_VBAT 12 /* Single cell battery voltage */
40
41#define ADC_UNREG_POWER ADC_BVDD /* For compatibility */
42
43#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "backlight-target.h"
21#include "system.h"
22#include "lcd.h"
23#include "backlight.h"
24#include "i2c-pp.h"
25#include "as3514.h"
26
27static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
28
29void _backlight_set_brightness(int brightness)
30{
31 backlight_brightness = brightness;
32
33 if (brightness > 0)
34 _backlight_on();
35 else
36 _backlight_off();
37}
38
39void _backlight_on(void)
40{
41#ifdef HAVE_LCD_SLEEP
42 backlight_lcd_sleep_countdown(false); /* stop counter */
43#endif
44#ifdef HAVE_LCD_ENABLE
45 lcd_enable(true); /* power on lcd + visible display */
46#endif
47 pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness);
48}
49
50void _backlight_off(void)
51{
52 pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0);
53#ifdef HAVE_LCD_ENABLE
54 lcd_enable(false); /* power off visible display */
55#endif
56#ifdef HAVE_LCD_SLEEP
57 backlight_lcd_sleep_countdown(true); /* start countdown */
58#endif
59}
60
61void _buttonlight_on(void)
62{
63 GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x80);
64#ifdef SANSA_C200
65 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */
66#endif
67}
68
69void _buttonlight_off(void)
70{
71 GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x80);
72#ifdef SANSA_C200
73 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */
74#endif
75}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H
21
22#define _backlight_init() true
23void _backlight_on(void);
24void _backlight_off(void);
25void _backlight_set_brightness(int brightness);
26int __backlight_is_on(void);
27
28void _buttonlight_on(void);
29void _buttonlight_off(void);
30#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Mark Arigo
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "system.h"
21#include "button.h"
22#include "backlight.h"
23
24void button_init_device(void)
25{
26 /* TODO...for now, hardware initialisation is done by the c200 bootloader */
27}
28
29bool button_hold(void)
30{
31 return !(GPIOL_INPUT_VAL & 0x40);
32}
33
34/*
35 * Get button pressed from hardware
36 */
37int button_read_device(void)
38{
39 int btn = BUTTON_NONE;
40 static bool hold_button = false;
41 bool hold_button_old;
42
43 /* Hold */
44 hold_button_old = hold_button;
45 hold_button = button_hold();
46
47#ifndef BOOTLOADER
48 if (hold_button != hold_button_old)
49 backlight_hold_changed(hold_button);
50#endif
51
52 /* device buttons */
53 if (!hold_button)
54 {
55#if 0
56 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER;
57 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP;
58 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN;
59#endif
60 /* A hack until the touchpad works */
61 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT;
62 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_UP;
63 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN;
64 }
65
66 return btn;
67}
68
69bool headphones_inserted(void)
70{
71 return (GPIOB_INPUT_VAL & 0x10) ? false : true;
72}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
9 *
10 * Copyright (C) 2007 by Mark Arigo
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_BUTTON_HOLD
27
28bool button_hold(void);
29void button_init_device(void);
30int button_read_device(void);
31
32/* Main unit's buttons */
33#define BUTTON_POWER 0x00000001
34#define BUTTON_SELECT 0x00000002
35#define BUTTON_MENU 0x00000004
36#define BUTTON_LEFT 0x00000008
37#define BUTTON_RIGHT 0x00000010
38#define BUTTON_REW 0x00000020
39#define BUTTON_FFWD 0x00000040
40#define BUTTON_UP 0x00000080
41#define BUTTON_DOWN 0x00000100
42#define BUTTON_VOL_UP 0x00000200
43#define BUTTON_VOL_DOWN 0x00000400
44
45#define BUTTON_MAIN 0x00000fff
46
47/* No Remote control */
48#define BUTTON_REMOTE 0
49
50#define POWEROFF_BUTTON BUTTON_POWER
51#define POWEROFF_COUNT 10
52
53#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Mark Arigo
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include "lcd.h"
22#include "kernel.h"
23#include "system.h"
24
25/* Display status */
26static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
27
28/* wait for LCD */
29static inline void lcd_wait_write(void)
30{
31 while (LCD1_CONTROL & LCD1_BUSY_MASK);
32}
33
34/* send LCD data */
35static void lcd_send_data(unsigned data)
36{
37 lcd_wait_write();
38 LCD1_DATA = data >> 8;
39 lcd_wait_write();
40 LCD1_DATA = data & 0xff;
41}
42
43/* send LCD command */
44static void lcd_send_command(unsigned cmd)
45{
46 lcd_wait_write();
47 LCD1_CMD = cmd >> 8;
48 lcd_wait_write();
49 LCD1_CMD = cmd & 0xff;
50}
51
52static void lcd_write_reg(unsigned reg, unsigned data)
53{
54 lcd_send_command(reg);
55 lcd_send_data(data);
56}
57
58void lcd_init_device(void)
59{
60#if 0
61 /* This is the init done by the OF bootloader.
62 Re-initializing the lcd causes it to flash
63 a white screen, so for now disable this. */
64 DEV_INIT1 &= ~0x3000;
65 DEV_INIT1 = DEV_INIT1;
66 DEV_INIT2 &= ~0x400;
67
68 LCD1_CONTROL = 0x4680;
69 udelay(1500);
70 LCD1_CONTROL = 0x4684;
71
72 outl(1, 0x70003018);
73
74 LCD1_CONTROL &= ~0x200;
75 LCD1_CONTROL &= ~0x800;
76 LCD1_CONTROL &= ~0x400;
77 udelay(30000);
78
79 LCD1_CONTROL |= 0x1;
80
81 lcd_write_reg(0x0000, 0x0001);
82 udelay(50000);
83
84 lcd_write_reg(0x0011, 0x171f);
85 lcd_write_reg(0x0012, 0x0001);
86 lcd_write_reg(0x0013, 0x08cd);
87 lcd_write_reg(0x0014, 0x0416);
88 lcd_write_reg(0x0010, 0x1208);
89 udelay(50000);
90
91 lcd_write_reg(0x0013, 0x081C);
92 udelay(200000);
93
94 lcd_write_reg(0x0001, 0x0a0c);
95 lcd_write_reg(0x0002, 0x0200);
96 lcd_write_reg(0x0003, 0x1030);
97 lcd_write_reg(0x0007, 0x0005);
98 lcd_write_reg(0x0008, 0x030a);
99 lcd_write_reg(0x000b, 0x0000);
100 lcd_write_reg(0x000c, 0x0000);
101 lcd_write_reg(0x0030, 0x0000);
102 lcd_write_reg(0x0031, 0x0204);
103 lcd_write_reg(0x0032, 0x0001);
104 lcd_write_reg(0x0033, 0x0600);
105 lcd_write_reg(0x0034, 0x0607);
106 lcd_write_reg(0x0035, 0x0305);
107 lcd_write_reg(0x0036, 0x0707);
108 lcd_write_reg(0x0037, 0x0006);
109 lcd_write_reg(0x0038, 0x0400);
110 lcd_write_reg(0x0040, 0x0000);
111 lcd_write_reg(0x0042, 0x9f00);
112 lcd_write_reg(0x0043, 0x0000);
113 lcd_write_reg(0x0044, 0x7f00);
114 lcd_write_reg(0x0045, 0x9f00);
115 lcd_write_reg(0x00a8, 0x0125);
116 lcd_write_reg(0x00a9, 0x0014);
117 lcd_write_reg(0x00a7, 0x0022);
118
119 lcd_write_reg(0x0007, 0x0021);
120 udelay(40000);
121 lcd_write_reg(0x0007, 0x0023);
122 udelay(40000);
123 lcd_write_reg(0x0007, 0x1037);
124
125 lcd_write_reg(0x0021, 0x0000);
126#endif
127}
128
129/*** hardware configuration ***/
130#if 0
131int lcd_default_contrast(void)
132{
133 return DEFAULT_CONTRAST_SETTING;
134}
135#endif
136
137void lcd_set_contrast(int val)
138{
139 (void)val;
140}
141
142void lcd_set_invert_display(bool yesno)
143{
144 (void)yesno;
145}
146
147/* turn the display upside down (call lcd_update() afterwards) */
148void lcd_set_flip(bool yesno)
149{
150 (void)yesno;
151}
152
153void lcd_yuv_set_options(unsigned options)
154{
155 lcd_yuv_options = options;
156}
157
158/* Performance function to blit a YUV bitmap directly to the LCD */
159void lcd_blit_yuv(unsigned char * const src[3],
160 int src_x, int src_y, int stride,
161 int x, int y, int width, int height)
162{
163 (void)src;
164 (void)src_x;
165 (void)src_y;
166 (void)stride;
167 (void)x;
168 (void)y;
169 (void)width;
170 (void)height;
171}
172
173/* Update the display.
174 This must be called after all other LCD functions that change the display. */
175void lcd_update(void)
176{
177 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
178}
179
180/* Update a fraction of the display. */
181void lcd_update_rect(int x, int y, int width, int height)
182{
183 const fb_data *addr;
184
185 if (x + width >= LCD_WIDTH)
186 width = LCD_WIDTH - x;
187 if (y + height >= LCD_HEIGHT)
188 height = LCD_HEIGHT - y;
189
190 if ((width <= 0) || (height <= 0))
191 return; /* Nothing left to do. */
192
193 addr = &lcd_framebuffer[y][x];
194
195 do {
196 lcd_write_reg(0x0021, ((y++ & 0xff) << 8) | (x & 0xff));
197 lcd_send_command(0x0022);
198
199 int w = width;
200 do {
201 lcd_send_data(*addr++);
202 } while (--w > 0);
203 addr += LCD_WIDTH - width;
204 } while (--height > 0);
205}
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Daniel Ankers
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stdbool.h>
21#include "system.h"
22#include "cpu.h"
23#include "i2c-pp.h"
24#include "tuner.h"
25#include "as3514.h"
26#include "power.h"
27
28void power_init(void)
29{
30}
31
32void power_off(void)
33{
34 char byte;
35
36 /* Send shutdown command to PMU */
37 byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM);
38 byte &= ~0x1;
39 pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte);
40
41 /* Stop interrupts on both cores */
42 disable_interrupt(IRQ_FIQ_STATUS);
43 COP_INT_CLR = -1;
44 CPU_INT_CLR = -1;
45
46 /* Halt everything and wait for device to power off */
47 while (1)
48 {
49 COP_CTL = 0x40000000;
50 CPU_CTL = 0x40000000;
51 }
52}
53
54bool charger_inserted(void)
55{
56#ifdef SANSA_E200
57 if(GPIOB_INPUT_VAL & 0x10)
58#else /* SANSA_C200 */
59 if(GPIOH_INPUT_VAL & 0x2)
60#endif
61 return true;
62 return false;
63}
64
65void ide_power_enable(bool on)
66{
67 (void)on;
68}
69
70#if CONFIG_TUNER
71
72/** Tuner **/
73static bool powered = false;
74
75bool tuner_power(bool status)
76{
77 bool old_status;
78 lv24020lp_lock();
79
80 old_status = powered;
81
82 if (status != old_status)
83 {
84 if (status)
85 {
86 /* init mystery amplification device */
87#if defined(SANSA_E200)
88 GPO32_ENABLE |= 0x1;
89#else /* SANSA_C200 */
90 DEV_INIT2 &= ~0x800;
91#endif
92 udelay(5);
93
94 /* When power up, host should initialize the 3-wire bus
95 in host read mode: */
96
97 /* 1. Set direction of the DATA-line to input-mode. */
98 GPIOH_OUTPUT_EN &= ~(1 << 5);
99 GPIOH_ENABLE |= (1 << 5);
100
101 /* 2. Drive NR_W low */
102 GPIOH_OUTPUT_VAL &= ~(1 << 3);
103 GPIOH_OUTPUT_EN |= (1 << 3);
104 GPIOH_ENABLE |= (1 << 3);
105
106 /* 3. Drive CLOCK high */
107 GPIOH_OUTPUT_VAL |= (1 << 4);
108 GPIOH_OUTPUT_EN |= (1 << 4);
109 GPIOH_ENABLE |= (1 << 4);
110
111 lv24020lp_power(true);
112 }
113 else
114 {
115 lv24020lp_power(false);
116
117 /* set all as inputs */
118 GPIOH_OUTPUT_EN &= ~((1 << 5) | (1 << 3) | (1 << 4));
119 GPIOH_ENABLE &= ~((1 << 3) | (1 << 4));
120
121 /* turn off mystery amplification device */
122#if defined (SANSA_E200)
123 GPO32_ENABLE &= ~0x1;
124#else
125 DEV_INIT2 |= 0x800;
126#endif
127 }
128
129 powered = status;
130 }
131
132 lv24020lp_unlock();
133 return old_status;
134}
135
136#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 * Revisions copyright (C) 2005 by Gerald Van Baren
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "adc.h"
23#include "powermgmt.h"
24
25const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
26{
27 3400
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3300
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* Sansa Li Ion 750mAH, took from battery benchs */
39 { 3300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160 },
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* Sansa Li Ion 750mAH FIXME */
46 3300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160
47};
48
49/* ADC should read 0x3ff=5.12V */
50#define BATTERY_SCALE_FACTOR 5125
51/* full-scale ADC readout (2^10) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
57}
58
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)
374 /* to be done */ 374 /* to be done */
375#endif 375#endif
376 376
377#if !defined(SANSA_E200) && !defined(SANSA_C200) 377#if !defined(SANSA_E200) && !defined(SANSA_C200) && !defined(PHILIPS_SA9200)
378 /* Remap the flash ROM on CPU, keep hidden from COP: 378 /* Remap the flash ROM on CPU, keep hidden from COP:
379 * 0x00000000-0x3fffffff = 0x20000000-0x23ffffff */ 379 * 0x00000000-0x3fffffff = 0x20000000-0x23ffffff */
380 MMAP1_LOGICAL = 0x20003c00; 380 MMAP1_LOGICAL = 0x20003c00;
@@ -405,7 +405,7 @@ void system_init(void)
405 GPIOK_INT_EN = 0; 405 GPIOK_INT_EN = 0;
406 GPIOL_INT_EN = 0; 406 GPIOL_INT_EN = 0;
407 407
408#if defined(SANSA_E200) || defined(SANSA_C200) 408#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
409 /* outl(0x00000000, 0x6000b000); */ 409 /* outl(0x00000000, 0x6000b000); */
410 outl(inl(0x6000a000) | 0x80000000, 0x6000a000); /* Init DMA controller? */ 410 outl(inl(0x6000a000) | 0x80000000, 0x6000a000); /* Init DMA controller? */
411#endif 411#endif
@@ -433,7 +433,7 @@ void system_init(void)
433void system_reboot(void) 433void system_reboot(void)
434{ 434{
435 /* Reboot */ 435 /* Reboot */
436#if defined(SANSA_E200) || defined(SANSA_C200) 436#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
437 CACHE_CTL &= ~CACHE_CTL_VECT_REMAP; 437 CACHE_CTL &= ~CACHE_CTL_VECT_REMAP;
438 438
439 /* Magic used by the c200 OF: 0x23066000 439 /* 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)
121 /* GPIO L bit 2 is usb detect */ 121 /* GPIO L bit 2 is usb detect */
122 if (GPIOL_INPUT_VAL & 0x4) 122 if (GPIOL_INPUT_VAL & 0x4)
123 retval = true; 123 retval = true;
124
125#elif defined(PHILIPS_SA9200)
126 /* GPIO F bit 7 is usb detect */
127 if (!(GPIOF_INPUT_VAL & 0x80))
128 retval = true;
124#endif 129#endif
125 130
126 return retval; 131 return retval;