blob: 1ff15c57bf5698f2a286b485e6fe1b8376c5dbb7 [file] [log] [blame]
Mark Arigoe66ddd72008-01-09 07:24:43 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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.
Mark Arigoe66ddd72008-01-09 07:24:43 +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 "adc.h"
26#include "kernel.h"
27#include "system.h"
28#include "power.h"
29#include "logf.h"
30#include "usb.h"
31
32#if CONFIG_CHARGING == CHARGING_CONTROL
33bool charger_enabled;
34#endif
35
36void power_init(void)
37{
Mark Arigo89dc21a2008-03-07 16:05:22 +000038 /* Enable power-off bit */
39 GPIOB_ENABLE |= 0x80;
40 GPIOB_OUTPUT_VAL &= ~0x80;
41 GPIOB_OUTPUT_EN |= 0x80;
Mark Arigoe66ddd72008-01-09 07:24:43 +000042}
43
44bool charger_inserted(void)
45{
Robert Kuklaa615aab2008-01-12 20:36:45 +000046 return (GPIOL_INPUT_VAL & 0x24) ? true : false ;
Mark Arigoe66ddd72008-01-09 07:24:43 +000047}
48
49void ide_power_enable(bool on)
50{
51 (void)on;
Robert Kukla7d961d32008-01-11 21:48:01 +000052 /* We do nothing */
Mark Arigoe66ddd72008-01-09 07:24:43 +000053}
54
55
56bool ide_powered(void)
57{
Robert Kukla7d961d32008-01-11 21:48:01 +000058 /* pretend we are always powered - we don't turn it off */
Mark Arigoe66ddd72008-01-09 07:24:43 +000059 return true;
60}
61
62void power_off(void)
63{
Mark Arigo06daa032008-02-03 00:04:02 +000064 /* Disable interrupts on this core */
Michael Sevakis75f2d442008-03-31 06:00:23 +000065 disable_interrupt(IRQ_FIQ_STATUS);
Mark Arigo06daa032008-02-03 00:04:02 +000066
67 /* Mask them on both cores */
Michael Sevakis191320c2008-06-03 05:08:24 +000068 CPU_INT_DIS = -1;
69 COP_INT_DIS = -1;
Mark Arigo06daa032008-02-03 00:04:02 +000070
71 while (1)
72 GPIOB_OUTPUT_VAL |= 0x80;
Mark Arigoe66ddd72008-01-09 07:24:43 +000073}