diff options
author | Mark Arigo <markarigo@gmail.com> | 2008-05-21 03:55:17 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2008-05-21 03:55:17 +0000 |
commit | b4275d4941e464c851ae3f5fe33c80f56ea365e5 (patch) | |
tree | 6f82b4e9cc490bf759dc4e1c64b4416d3b2d4879 /firmware/target/arm/philips/sa9200/power-sa9200.c | |
parent | 4c99f9a74964c4a44ca27a216f302bdc79b23121 (diff) | |
download | rockbox-b4275d4941e464c851ae3f5fe33c80f56ea365e5.tar.gz rockbox-b4275d4941e464c851ae3f5fe33c80f56ea365e5.zip |
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
Diffstat (limited to 'firmware/target/arm/philips/sa9200/power-sa9200.c')
-rw-r--r-- | firmware/target/arm/philips/sa9200/power-sa9200.c | 136 |
1 files changed, 136 insertions, 0 deletions
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 | |||
28 | void power_init(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | void 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 | |||
54 | bool 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 | |||
65 | void ide_power_enable(bool on) | ||
66 | { | ||
67 | (void)on; | ||
68 | } | ||
69 | |||
70 | #if CONFIG_TUNER | ||
71 | |||
72 | /** Tuner **/ | ||
73 | static bool powered = false; | ||
74 | |||
75 | bool 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 */ | ||