Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2006 by Barry Wardell |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 16 | * |
| 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 |
| 33 | bool charger_enabled; |
| 34 | #endif |
| 35 | |
| 36 | void power_init(void) |
| 37 | { |
Mark Arigo | 89dc21a | 2008-03-07 16:05:22 +0000 | [diff] [blame] | 38 | /* Enable power-off bit */ |
| 39 | GPIOB_ENABLE |= 0x80; |
| 40 | GPIOB_OUTPUT_VAL &= ~0x80; |
| 41 | GPIOB_OUTPUT_EN |= 0x80; |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | bool charger_inserted(void) |
| 45 | { |
Robert Kukla | a615aab | 2008-01-12 20:36:45 +0000 | [diff] [blame] | 46 | return (GPIOL_INPUT_VAL & 0x24) ? true : false ; |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void ide_power_enable(bool on) |
| 50 | { |
| 51 | (void)on; |
Robert Kukla | 7d961d3 | 2008-01-11 21:48:01 +0000 | [diff] [blame] | 52 | /* We do nothing */ |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | |
| 56 | bool ide_powered(void) |
| 57 | { |
Robert Kukla | 7d961d3 | 2008-01-11 21:48:01 +0000 | [diff] [blame] | 58 | /* pretend we are always powered - we don't turn it off */ |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 59 | return true; |
| 60 | } |
| 61 | |
| 62 | void power_off(void) |
| 63 | { |
Mark Arigo | 06daa03 | 2008-02-03 00:04:02 +0000 | [diff] [blame] | 64 | /* Disable interrupts on this core */ |
Michael Sevakis | 75f2d44 | 2008-03-31 06:00:23 +0000 | [diff] [blame] | 65 | disable_interrupt(IRQ_FIQ_STATUS); |
Mark Arigo | 06daa03 | 2008-02-03 00:04:02 +0000 | [diff] [blame] | 66 | |
| 67 | /* Mask them on both cores */ |
Michael Sevakis | 191320c | 2008-06-03 05:08:24 +0000 | [diff] [blame] | 68 | CPU_INT_DIS = -1; |
| 69 | COP_INT_DIS = -1; |
Mark Arigo | 06daa03 | 2008-02-03 00:04:02 +0000 | [diff] [blame] | 70 | |
| 71 | while (1) |
| 72 | GPIOB_OUTPUT_VAL |= 0x80; |
Mark Arigo | e66ddd7 | 2008-01-09 07:24:43 +0000 | [diff] [blame] | 73 | } |