Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Jens Arnold |
| 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. |
Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +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 "kernel.h" |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 26 | #include "lcd.h" |
Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +0000 | [diff] [blame] | 27 | #include "power.h" |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 28 | #include "system.h" |
Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +0000 | [diff] [blame] | 29 | |
| 30 | #ifndef SIMULATOR |
| 31 | |
| 32 | void 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 Arnold | ed3ff1b | 2008-03-17 23:47:38 +0000 | [diff] [blame] | 42 | |
Jens Arnold | d700970 | 2008-03-18 00:17:21 +0000 | [diff] [blame] | 43 | #ifndef BOOTLOADER |
Jens Arnold | c6b6bad | 2008-03-17 00:19:23 +0000 | [diff] [blame] | 44 | /* FIXME: Just disable the multi-colour LED for now. */ |
| 45 | and_l(~0x00000210, &GPIO1_OUT); |
| 46 | and_l(~0x00008000, &GPIO_OUT); |
Jens Arnold | d700970 | 2008-03-18 00:17:21 +0000 | [diff] [blame] | 47 | #endif |
Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | bool charger_inserted(void) |
| 51 | { |
| 52 | return (GPIO1_READ & 0x00000020) == 0; |
| 53 | } |
| 54 | |
| 55 | void 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 | |
| 67 | bool ide_powered(void) |
| 68 | { |
Jens Arnold | ed3ff1b | 2008-03-17 23:47:38 +0000 | [diff] [blame] | 69 | return (GPIO_OUT & 0x00800000) != 0; |
Jens Arnold | 769fcbd | 2008-03-12 20:35:42 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | void 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 Arnold | 8a6291d | 2008-03-14 08:54:54 +0000 | [diff] [blame] | 81 | |
| 82 | bool tuner_power(bool status) |
| 83 | { |
| 84 | (void)status; |
| 85 | return true; |
| 86 | } |