summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iriver/h300/power-h300.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/power-h300.c')
-rw-r--r--firmware/target/coldfire/iriver/h300/power-h300.c101
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
30static bool powered = false;
31
32bool radio_powered(void)
33{
34 return powered;
35}
36
37bool 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
48void 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
65bool 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. */
72bool charging_state(void) {
73 return (GPIO_READ & 0x00800000)?true:false;
74}
75
76
77void 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
86bool ide_powered(void)
87{
88 return (GPIO_OUT & 0x80000000)?false:true;
89}
90
91
92void 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 */