blob: 5dbeadf73258584b08b2a6ce13878e9894844c36 [file] [log] [blame]
Jens Arnold769fcbd2008-03-12 20:35:42 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Jens Arnold769fcbd2008-03-12 20:35:42 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "cpu.h"
24#include <stdbool.h>
25#include "kernel.h"
Jens Arnold8e664912008-03-19 00:34:56 +000026#include "lcd.h"
Jens Arnold769fcbd2008-03-12 20:35:42 +000027#include "power.h"
Jens Arnold8e664912008-03-19 00:34:56 +000028#include "system.h"
Jens Arnold769fcbd2008-03-12 20:35:42 +000029
30#ifndef SIMULATOR
31
32void power_init(void)
33{
34 /* Set KEEPACT */
35 or_l(0x00040000, &GPIO_OUT);
36 or_l(0x00040000, &GPIO_ENABLE);
37 or_l(0x00040000, &GPIO_FUNCTION);
38
39 /* Charger detect */
40 and_l(~0x00000020, &GPIO1_ENABLE);
41 or_l(0x00000020, &GPIO1_FUNCTION);
Jens Arnolded3ff1b2008-03-17 23:47:38 +000042
Jens Arnoldd7009702008-03-18 00:17:21 +000043#ifndef BOOTLOADER
Jens Arnoldc6b6bad2008-03-17 00:19:23 +000044 /* FIXME: Just disable the multi-colour LED for now. */
45 and_l(~0x00000210, &GPIO1_OUT);
46 and_l(~0x00008000, &GPIO_OUT);
Jens Arnoldd7009702008-03-18 00:17:21 +000047#endif
Jens Arnold769fcbd2008-03-12 20:35:42 +000048}
49
50bool charger_inserted(void)
51{
52 return (GPIO1_READ & 0x00000020) == 0;
53}
54
55void ide_power_enable(bool on)
56{
57 if (on)
58 {
59 or_l(0x00800000, &GPIO_OUT);
60 }
61 else
62 {
63 and_l(~0x00800000, &GPIO_OUT);
64 }
65}
66
67bool ide_powered(void)
68{
Jens Arnolded3ff1b2008-03-17 23:47:38 +000069 return (GPIO_OUT & 0x00800000) != 0;
Jens Arnold769fcbd2008-03-12 20:35:42 +000070}
71
72void power_off(void)
73{
74 lcd_poweroff();
75 set_irq_level(DISABLE_INTERRUPTS);
76 and_l(~0x00040000, &GPIO_OUT); /* Set KEEPACT low */
77 asm("halt");
78}
79
80#endif /* SIMULATOR */
Jens Arnold8a6291d2008-03-14 08:54:54 +000081
82bool tuner_power(bool status)
83{
84 (void)status;
85 return true;
86}