M:Robe 500: Move all remote specific code into a common file for reuse on other playe...
[kugel-rb.git] / firmware / target / arm / tms320dm320 / mrobe-500 / power-mr500.c
blob1b90ccca786d5023d3dc0b90b920197bffbcca7b
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Karl Kurbjun
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include "cpu.h"
24 #include <stdbool.h>
25 #include "kernel.h"
26 #include "system.h"
27 #include "power.h"
28 #include "lcd.h"
29 #include "pcf50606.h"
30 #include "backlight.h"
31 #include "backlight-target.h"
32 #include "lcd-remote-target.h"
34 void power_init(void)
36 /* Initialize IDE power pin */
37 /* set GIO17 (ATA power) on and output */
38 ide_power_enable(true);
39 IO_GIO_DIR1&=~(1<<1);
40 /* Charger detect */
43 unsigned int power_input_status(void)
45 /* Charger is active low */
46 if(!(IO_GIO_BITSET1&(1<<9)))
48 return POWER_INPUT_MAIN_CHARGER;
50 return POWER_INPUT_NONE;
53 /* Returns true if the unit is charging the batteries. */
54 bool charging_state(void)
56 return false;
59 void ide_power_enable(bool on)
61 if (on)
62 IO_GIO_BITCLR1=(1<<1);
63 else
64 IO_GIO_BITSET1=(1<<1);
67 bool ide_powered(void)
69 return !(IO_GIO_BITSET1&(1<<1));
72 void power_off(void)
74 /* turn off backlight and wait for 1 second */
75 _backlight_off();
76 lcd_remote_sleep();
77 lcd_sleep();
78 sleep(HZ);
79 /* Hard shutdown */
80 IO_GIO_DIR1&=~(1<<10);
81 IO_GIO_BITSET1|=1<<10;