2008-01-09 07:24:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "adc.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "logf.h"
|
|
|
|
#include "usb.h"
|
|
|
|
|
|
|
|
#if CONFIG_CHARGING == CHARGING_CONTROL
|
|
|
|
bool charger_enabled;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void power_init(void)
|
|
|
|
{
|
2008-03-07 16:05:22 +00:00
|
|
|
/* Enable power-off bit */
|
|
|
|
GPIOB_ENABLE |= 0x80;
|
|
|
|
GPIOB_OUTPUT_VAL &= ~0x80;
|
|
|
|
GPIOB_OUTPUT_EN |= 0x80;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool charger_inserted(void)
|
|
|
|
{
|
2008-01-12 20:36:45 +00:00
|
|
|
return (GPIOL_INPUT_VAL & 0x24) ? true : false ;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ide_power_enable(bool on)
|
|
|
|
{
|
|
|
|
(void)on;
|
2008-01-11 21:48:01 +00:00
|
|
|
/* We do nothing */
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ide_powered(void)
|
|
|
|
{
|
2008-01-11 21:48:01 +00:00
|
|
|
/* pretend we are always powered - we don't turn it off */
|
2008-01-09 07:24:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void power_off(void)
|
|
|
|
{
|
2008-02-03 00:04:02 +00:00
|
|
|
/* Disable interrupts on this core */
|
2008-03-31 06:00:23 +00:00
|
|
|
disable_interrupt(IRQ_FIQ_STATUS);
|
2008-02-03 00:04:02 +00:00
|
|
|
|
|
|
|
/* Mask them on both cores */
|
|
|
|
CPU_INT_CLR = -1;
|
|
|
|
COP_INT_CLR = -1;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
GPIOB_OUTPUT_VAL |= 0x80;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|