Do core interrupt masking in a less general fashion and save some instructions to...
[kugel-rb.git] / firmware / target / coldfire / iriver / h300 / power-h300.c
bloba06763e5551902bcfb554ab475ee47337a16eab6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
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"
28 #if CONFIG_TUNER
30 bool tuner_power(bool status)
32 (void)status;
33 return true;
36 #endif /* #if CONFIG_TUNER */
38 #ifndef SIMULATOR
40 void power_init(void)
42 or_l(0x00080000, &GPIO1_OUT);
43 or_l(0x00080000, &GPIO1_ENABLE);
44 or_l(0x00080000, &GPIO1_FUNCTION);
46 #ifndef BOOTLOADER
47 /* The boot loader controls the power */
48 ide_power_enable(true);
49 #endif
50 or_l(0x80000000, &GPIO_ENABLE);
51 or_l(0x80000000, &GPIO_FUNCTION);
52 pcf50606_init();
56 #if CONFIG_CHARGING
57 bool charger_inserted(void)
59 return (GPIO1_READ & 0x00400000)?true:false;
61 #endif /* CONFIG_CHARGING */
63 /* Returns true if the unit is charging the batteries. */
64 bool charging_state(void) {
65 return (GPIO_READ & 0x00800000)?true:false;
69 void ide_power_enable(bool on)
71 if(on)
72 and_l(~0x80000000, &GPIO_OUT);
73 else
74 or_l(0x80000000, &GPIO_OUT);
78 bool ide_powered(void)
80 return (GPIO_OUT & 0x80000000)?false:true;
84 void power_off(void)
86 set_irq_level(DISABLE_INTERRUPTS);
87 and_l(~0x00080000, &GPIO1_OUT);
88 asm("halt");
89 while(1);
92 #endif /* SIMULATOR */