2008-01-09 07:24:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-01-09 07:24:43 +00:00
|
|
|
*
|
|
|
|
* 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 "kernel.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "logf.h"
|
|
|
|
#include "usb.h"
|
2009-07-26 14:26:14 +00:00
|
|
|
#include "lcd-remote-target.h"
|
2008-01-09 07:24:43 +00:00
|
|
|
|
|
|
|
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;
|
2009-08-14 21:11:08 +00:00
|
|
|
|
|
|
|
/* IDE power */
|
|
|
|
GPIOC_ENABLE |= 0x8;
|
|
|
|
GPIOC_OUTPUT_VAL &= ~0x8;
|
|
|
|
GPIOC_OUTPUT_EN |= 0x8;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 19:54:25 +00:00
|
|
|
unsigned int power_input_status(void)
|
|
|
|
{
|
|
|
|
return (GPIOL_INPUT_VAL & 0x24) ?
|
|
|
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ide_power_enable(bool on)
|
|
|
|
{
|
2009-08-14 21:11:08 +00:00
|
|
|
if(on)
|
|
|
|
{
|
|
|
|
GPIO_CLEAR_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
|
|
|
|
DEV_EN |= DEV_IDE0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEV_EN &= ~DEV_IDE0;
|
|
|
|
GPIO_SET_BITWISE(GPIOC_OUTPUT_VAL, 0x08);
|
|
|
|
}
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ide_powered(void)
|
|
|
|
{
|
2009-08-14 21:11:08 +00:00
|
|
|
return ((GPIOC_INPUT_VAL & 0x8) == 0);
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void power_off(void)
|
|
|
|
{
|
2009-07-26 14:26:14 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
lcd_remote_off();
|
|
|
|
#endif
|
|
|
|
|
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 */
|
2008-06-03 05:08:24 +00:00
|
|
|
CPU_INT_DIS = -1;
|
|
|
|
COP_INT_DIS = -1;
|
2008-02-03 00:04:02 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
GPIOB_OUTPUT_VAL |= 0x80;
|
2008-01-09 07:24:43 +00:00
|
|
|
}
|