diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-30 08:56:06 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-30 08:56:06 +0000 |
commit | 139f9f28e9179a881c0bdd5c6bed6790591a07cb (patch) | |
tree | 21920a9ca8bf5e9123ff230c6aa3ec5e9b7acb1b /firmware/target/coldfire/iriver/h300/power-h300.c | |
parent | 145ec81d2f879482fbfe192dcf39350f36bda3d7 (diff) | |
download | rockbox-139f9f28e9179a881c0bdd5c6bed6790591a07cb.tar.gz rockbox-139f9f28e9179a881c0bdd5c6bed6790591a07cb.zip |
move the iriver h1x0/h3x0 targets to the target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11392 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/power-h300.c')
-rw-r--r-- | firmware/target/coldfire/iriver/h300/power-h300.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iriver/h300/power-h300.c b/firmware/target/coldfire/iriver/h300/power-h300.c new file mode 100644 index 0000000000..7c95aaf200 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/power-h300.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
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 <stdbool.h> | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "power.h" | ||
25 | #include "pcf50606.h" | ||
26 | |||
27 | |||
28 | #ifdef CONFIG_TUNER | ||
29 | |||
30 | static bool powered = false; | ||
31 | |||
32 | bool radio_powered(void) | ||
33 | { | ||
34 | return powered; | ||
35 | } | ||
36 | |||
37 | bool radio_power(bool status) | ||
38 | { | ||
39 | bool old_status = powered; | ||
40 | powered = status; | ||
41 | return old_status; | ||
42 | } | ||
43 | |||
44 | #endif /* #ifdef CONFIG_TUNER */ | ||
45 | |||
46 | #ifndef SIMULATOR | ||
47 | |||
48 | void power_init(void) | ||
49 | { | ||
50 | or_l(0x00080000, &GPIO1_OUT); | ||
51 | or_l(0x00080000, &GPIO1_ENABLE); | ||
52 | or_l(0x00080000, &GPIO1_FUNCTION); | ||
53 | |||
54 | #ifndef BOOTLOADER | ||
55 | /* The boot loader controls the power */ | ||
56 | ide_power_enable(true); | ||
57 | #endif | ||
58 | or_l(0x80000000, &GPIO_ENABLE); | ||
59 | or_l(0x80000000, &GPIO_FUNCTION); | ||
60 | pcf50606_init(); | ||
61 | } | ||
62 | |||
63 | |||
64 | #ifdef CONFIG_CHARGING | ||
65 | bool charger_inserted(void) | ||
66 | { | ||
67 | return (GPIO1_READ & 0x00400000)?true:false; | ||
68 | } | ||
69 | #endif /* CONFIG_CHARGING */ | ||
70 | |||
71 | /* Returns true if the unit is charging the batteries. */ | ||
72 | bool charging_state(void) { | ||
73 | return (GPIO_READ & 0x00800000)?true:false; | ||
74 | } | ||
75 | |||
76 | |||
77 | void ide_power_enable(bool on) | ||
78 | { | ||
79 | if(on) | ||
80 | and_l(~0x80000000, &GPIO_OUT); | ||
81 | else | ||
82 | or_l(0x80000000, &GPIO_OUT); | ||
83 | } | ||
84 | |||
85 | |||
86 | bool ide_powered(void) | ||
87 | { | ||
88 | return (GPIO_OUT & 0x80000000)?false:true; | ||
89 | } | ||
90 | |||
91 | |||
92 | void power_off(void) | ||
93 | { | ||
94 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
95 | and_l(~0x00080000, &GPIO1_OUT); | ||
96 | asm("halt"); | ||
97 | while(1) | ||
98 | yield(); | ||
99 | } | ||
100 | |||
101 | #endif /* SIMULATOR */ | ||