summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES16
-rw-r--r--firmware/drivers/audio/as3514.c6
-rw-r--r--firmware/export/as3514.h2
-rwxr-xr-xfirmware/export/config-sa9200.h167
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/export/usb.h3
-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
20 files changed, 1140 insertions, 8 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 0d7261632d..bbdd0bc5a2 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -118,7 +118,7 @@ drivers/ata_flash.c
118drivers/ata.c 118drivers/ata.c
119#endif /* HAVE_MMC */ 119#endif /* HAVE_MMC */
120drivers/fat.c 120drivers/fat.c
121#ifdef HAVE_HOTSWAP 121#if defined(HAVE_HOTSWAP) || defined(HAVE_ATA_SD)
122hotswap.c 122hotswap.c
123#endif 123#endif
124#endif /* SIMULATOR */ 124#endif /* SIMULATOR */
@@ -467,6 +467,20 @@ target/arm/sandisk/audio-c200_e200.c
467#endif /* SIMULATOR */ 467#endif /* SIMULATOR */
468#endif /* SANSA_C200 */ 468#endif /* SANSA_C200 */
469 469
470#ifdef PHILIPS_SA9200
471#ifndef SIMULATOR
472target/arm/ata-sd-pp.c
473target/arm/philips/sa9200/lcd-sa9200.c
474target/arm/adc-as3514.c
475target/arm/philips/sa9200/backlight-sa9200.c
476target/arm/usb-fw-pp502x.c
477target/arm/philips/sa9200/button-sa9200.c
478target/arm/philips/sa9200/power-sa9200.c
479target/arm/philips/sa9200/powermgmt-sa9200.c
480target/arm/i2s-pp.c
481#endif /* SIMULATOR */
482#endif /* PHILIPS_SA9200 */
483
470#ifdef IAUDIO_X5 484#ifdef IAUDIO_X5
471#ifndef SIMULATOR 485#ifndef SIMULATOR
472target/coldfire/ata-as-coldfire.S 486target/coldfire/ata-as-coldfire.S
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c
index e1f325c3fe..b801375846 100644
--- a/firmware/drivers/audio/as3514.c
+++ b/firmware/drivers/audio/as3514.c
@@ -37,9 +37,11 @@ const struct sound_settings_info audiohw_settings[] = {
37 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, 37 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
38 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 38 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
39 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 39 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
40#if defined(HAVE_RECORDING)
40 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 39, 23}, 41 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 39, 23},
41 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23}, 42 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23},
42 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23}, 43 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23},
44#endif
43}; 45};
44 46
45/* Shadow registers */ 47/* Shadow registers */
@@ -112,11 +114,13 @@ int sound_val2phys(int setting, int value)
112 114
113 switch(setting) 115 switch(setting)
114 { 116 {
117#if defined(HAVE_RECORDING)
115 case SOUND_LEFT_GAIN: 118 case SOUND_LEFT_GAIN:
116 case SOUND_RIGHT_GAIN: 119 case SOUND_RIGHT_GAIN:
117 case SOUND_MIC_GAIN: 120 case SOUND_MIC_GAIN:
118 result = (value - 23) * 15; 121 result = (value - 23) * 15;
119 break; 122 break;
123#endif
120 124
121 default: 125 default:
122 result = value; 126 result = value;
@@ -292,6 +296,7 @@ void audiohw_set_sample_rate(int sampling_control)
292 (void)sampling_control; 296 (void)sampling_control;
293} 297}
294 298
299#if defined(HAVE_RECORDING)
295void audiohw_enable_recording(bool source_mic) 300void audiohw_enable_recording(bool source_mic)
296{ 301{
297 if (source_mic) { 302 if (source_mic) {
@@ -417,3 +422,4 @@ void audiohw_set_monitor(bool enable)
417 /* Sync mixer volume */ 422 /* Sync mixer volume */
418 audiohw_set_master_vol(as3514.vol_l, as3514.vol_r); 423 audiohw_set_master_vol(as3514.vol_l, as3514.vol_r);
419} 424}
425#endif /* HAVE_RECORDING */
diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h
index f6f759b75c..6edb5878f3 100644
--- a/firmware/export/as3514.h
+++ b/firmware/export/as3514.h
@@ -77,7 +77,7 @@ extern void audiohw_set_sample_rate(int sampling_control);
77#define VOLUME_MIN -735 77#define VOLUME_MIN -735
78#define VOLUME_MAX 60 78#define VOLUME_MAX 60
79 79
80#if defined(SANSA_E200) || defined(SANSA_C200) 80#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
81#define AS3514_I2C_ADDR 0x46 81#define AS3514_I2C_ADDR 0x46
82#endif 82#endif
83 83
diff --git a/firmware/export/config-sa9200.h b/firmware/export/config-sa9200.h
new file mode 100755
index 0000000000..9cdfe6bba7
--- /dev/null
+++ b/firmware/export/config-sa9200.h
@@ -0,0 +1,167 @@
1/*
2 * This config file is for the Philips GoGear SA9200
3 */
4#define TARGET_TREE /* this target is using the target tree system */
5
6/* For Rolo and boot loader */
7#define MODEL_NUMBER 26
8#define MODEL_NAME "Philips GoGear SA200"
9
10#define HW_SAMPR_CAPS (SAMPR_CAP_44)
11
12/* define this if you have a bitmap LCD display */
13#define HAVE_LCD_BITMAP
14
15/* define this if you have a colour LCD */
16#define HAVE_LCD_COLOR
17
18/* define this if you want album art for this target */
19#define HAVE_ALBUMART
20
21/* define this if you have a light associated with the buttons */
22#define HAVE_BUTTON_LIGHT
23
24/* define this if you have access to the quickscreen */
25#define HAVE_QUICKSCREEN
26
27/* define this if you have access to the pitchscreen */
28#define HAVE_PITCHSCREEN
29
30/* define this if you would like tagcache to build on this target */
31#define HAVE_TAGCACHE
32
33/* LCD dimensions */
34#define LCD_WIDTH 128
35#define LCD_HEIGHT 160
36#define LCD_DEPTH 16 /* 65536 colours */
37#define LCD_PIXELFORMAT RGB565 /* rgb565 */
38
39/* define this if you have LCD enable function */
40/* #define HAVE_LCD_ENABLE */
41
42/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
43 should be defined as well. */
44/* #define HAVE_LCD_SLEEP */
45
46/* define this if you can flip your LCD */
47/* #define HAVE_LCD_FLIP */
48
49/* define this if you can invert the colours on your LCD */
50/* #define HAVE_LCD_INVERT */
51
52/* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */
53
54#define CONFIG_KEYPAD PHILIPS_SA9200_PAD
55
56/* Define this if you do software codec */
57#define CONFIG_CODEC SWCODEC
58
59/* There is no hardware tone control */
60#define HAVE_SW_TONE_CONTROLS
61
62/* The PP5024 has a built-in AustriaMicrosystems AS3514 */
63#define HAVE_AS3514
64
65/* define this if you have a real-time clock */
66#ifndef BOOTLOADER
67#define CONFIG_RTC RTC_AS3514
68#endif
69
70/* Define this if you have a software controlled poweroff */
71#define HAVE_SW_POWEROFF
72
73/* Some Sansa E200s seem to be FAT16 formatted */
74#define HAVE_FAT16SUPPORT
75
76/* The number of bytes reserved for loadable codecs */
77#define CODEC_SIZE 0x80000
78
79/* The number of bytes reserved for loadable plugins */
80#define PLUGIN_BUFFER_SIZE 0x80000
81
82#define AB_REPEAT_ENABLE 1
83
84/* Define this for LCD backlight available */
85#define HAVE_BACKLIGHT
86#define HAVE_BACKLIGHT_BRIGHTNESS
87
88/* Main LCD backlight brightness range and defaults */
89#define MIN_BRIGHTNESS_SETTING 1
90#define MAX_BRIGHTNESS_SETTING 12
91#define DEFAULT_BRIGHTNESS_SETTING 6
92
93/* define this if you have a flash memory storage */
94#define HAVE_FLASH_STORAGE
95
96/* define this if the flash memory uses the SecureDigital Memory Card protocol */
97#define HAVE_ATA_SD
98
99#define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */
100#define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */
101#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */
102#define BATTERY_CAPACITY_INC 0 /* capacity increment */
103#define BATTERY_TYPES_COUNT 1 /* only one type */
104
105/* Hardware controlled charging? FIXME */
106#define CONFIG_CHARGING CHARGING_SIMPLE
107
108/* define this if the unit can be powered or charged via USB */
109#define HAVE_USB_POWER
110
111/** Non-simulator section **/
112#ifndef SIMULATOR
113
114/* Define this if you have a PortalPlayer PP5024 */
115#define CONFIG_CPU PP5024
116
117/* Define this if you want to use the PP5024 i2c interface */
118#define CONFIG_I2C I2C_PP5024
119
120/* define this if the hardware can be powered off while charging */
121/* Sansa can't be powered off while charging */
122/* #define HAVE_POWEROFF_WHILE_CHARGING */
123
124/* The start address index for ROM builds */
125#define ROM_START 0x00000000
126
127/* Define this to the CPU frequency */
128#define CPU_FREQ 75000000
129
130/* Type of LCD TODO: hopefully the same as the x5 but check this*/
131#define CONFIG_LCD LCD_SA9200
132
133/* #define USB_IPODSTYLE */
134
135/* USB On-the-go */
136#define CONFIG_USBOTG USBOTG_ARC
137
138/* enable these for the experimental usb stack */
139#define HAVE_USBSTACK
140#define USB_VENDOR_ID 0x0471
141#define USB_PRODUCT_ID 0x014f
142
143/* WARNING! Enable Rockbox USB mass storage. */
144#ifndef BOOTLOADER
145#define USE_ROCKBOX_USB
146#endif
147
148/* Virtual LED (icon) */
149#define CONFIG_LED LED_VIRTUAL
150
151/* Define this if you have adjustable CPU frequency */
152#define HAVE_ADJUSTABLE_CPU_FREQ
153
154#define MI4_FORMAT
155#define BOOTFILE_EXT "mi4"
156#define BOOTFILE "rockbox." BOOTFILE_EXT
157#define BOOTDIR "/.rockbox"
158
159/* These values are unused, but need to be defined */
160#define FIRMWARE_OFFSET_FILE_CRC 0x0
161#define FIRMWARE_OFFSET_FILE_DATA 0x8
162
163#define ICODE_ATTR_TREMOR_NOT_MDCT
164
165#define INCLUDE_TIMEOUT_API
166
167#endif /* SIMULATOR */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 51c79abccf..c200355872 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -82,6 +82,7 @@
82#define CREATIVEZVM_PAD 24 82#define CREATIVEZVM_PAD 24
83#define SANSA_M200_PAD 25 83#define SANSA_M200_PAD 25
84#define CREATIVEZV_PAD 26 84#define CREATIVEZV_PAD 26
85#define PHILIPS_SA9200_PAD 27
85 86
86/* CONFIG_REMOTE_KEYPAD */ 87/* CONFIG_REMOTE_KEYPAD */
87#define H100_REMOTE 1 88#define H100_REMOTE 1
@@ -120,6 +121,7 @@
120#define LCD_CREATIVEZVM 22 /* as used by Creative Zen Vision:M */ 121#define LCD_CREATIVEZVM 22 /* as used by Creative Zen Vision:M */
121#define LCD_TL0350A 23 /* as used by the iAudio M3 remote, treated as main LCD */ 122#define LCD_TL0350A 23 /* as used by the iAudio M3 remote, treated as main LCD */
122#define LCD_COWOND2 24 /* as used by Cowon D2 - LTV250QV, TCC7801 driver */ 123#define LCD_COWOND2 24 /* as used by Cowon D2 - LTV250QV, TCC7801 driver */
124#define LCD_SA9200 25 /* as used by the Philips SA9200 */
123 125
124/* LCD_PIXELFORMAT */ 126/* LCD_PIXELFORMAT */
125#define HORIZONTAL_PACKING 1 127#define HORIZONTAL_PACKING 1
@@ -258,6 +260,8 @@
258#include "config-creativezvm60gb.h" 260#include "config-creativezvm60gb.h"
259#elif defined(CREATIVE_ZV) 261#elif defined(CREATIVE_ZV)
260#include "config-creativezv.h" 262#include "config-creativezv.h"
263#elif defined(PHILIPS_SA9200)
264#include "config-sa9200.h"
261#else 265#else
262/* no known platform */ 266/* no known platform */
263#endif 267#endif
diff --git a/firmware/export/usb.h b/firmware/export/usb.h
index ff1f55cd35..0590f702c5 100644
--- a/firmware/export/usb.h
+++ b/firmware/export/usb.h
@@ -60,7 +60,8 @@ enum {
60#define USBPOWER_BUTTON BUTTON_RIGHT 60#define USBPOWER_BUTTON BUTTON_RIGHT
61#define USBPOWER_BTN_IGNORE BUTTON_POWER 61#define USBPOWER_BTN_IGNORE BUTTON_POWER
62#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ 62#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
63 (CONFIG_KEYPAD == SANSA_C200_PAD) 63 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
64 (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
64#define USBPOWER_BUTTON BUTTON_SELECT 65#define USBPOWER_BUTTON BUTTON_SELECT
65#define USBPOWER_BTN_IGNORE BUTTON_POWER 66#define USBPOWER_BTN_IGNORE BUTTON_POWER
66#endif 67#endif
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;