2007-09-20 04:46:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-09-22 15:43:38 +00:00
|
|
|
* $Id$
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Karl Kurbjun
|
|
|
|
*
|
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.
|
2007-09-20 04:46:41 +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"
|
2009-04-01 03:21:18 +00:00
|
|
|
#include "lcd.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
#include "pcf50606.h"
|
|
|
|
#include "backlight.h"
|
|
|
|
#include "backlight-target.h"
|
2009-04-11 17:00:51 +00:00
|
|
|
#include "lcd-remote-target.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
|
|
|
|
void power_init(void)
|
|
|
|
{
|
2009-12-15 01:02:39 +00:00
|
|
|
ide_power_enable(true); /* Power up the drive */
|
|
|
|
|
|
|
|
/* Power down pin */
|
|
|
|
IO_GIO_BITCLR1 = 1<<10; /* Make sure it is not active */
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 19:54:25 +00:00
|
|
|
unsigned int power_input_status(void)
|
2007-09-20 04:46:41 +00:00
|
|
|
{
|
2010-01-03 10:19:43 +00:00
|
|
|
/* Charger is active low */
|
|
|
|
if(!(IO_GIO_BITSET1&(1<<9)))
|
|
|
|
{
|
|
|
|
return POWER_INPUT_MAIN_CHARGER;
|
|
|
|
}
|
2008-12-03 19:54:25 +00:00
|
|
|
return POWER_INPUT_NONE;
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns true if the unit is charging the batteries. */
|
2009-03-24 16:40:31 +00:00
|
|
|
bool charging_state(void)
|
|
|
|
{
|
2007-09-20 04:46:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ide_power_enable(bool on)
|
|
|
|
{
|
|
|
|
if (on)
|
2011-02-06 20:46:37 +00:00
|
|
|
{
|
2009-10-11 06:58:43 +00:00
|
|
|
IO_GIO_BITCLR1 = (1<<1);
|
2011-02-06 20:46:37 +00:00
|
|
|
}
|
2007-09-20 04:46:41 +00:00
|
|
|
else
|
2011-02-06 20:46:37 +00:00
|
|
|
{
|
2009-10-11 06:58:43 +00:00
|
|
|
IO_GIO_BITSET1 = (1<<1);
|
2011-02-06 20:46:37 +00:00
|
|
|
}
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ide_powered(void)
|
|
|
|
{
|
2007-09-25 01:44:57 +00:00
|
|
|
return !(IO_GIO_BITSET1&(1<<1));
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void power_off(void)
|
|
|
|
{
|
|
|
|
/* turn off backlight and wait for 1 second */
|
2015-01-08 23:22:40 +00:00
|
|
|
backlight_hw_off();
|
2009-05-15 13:43:30 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD)
|
2009-04-11 07:23:56 +00:00
|
|
|
lcd_remote_sleep();
|
2009-05-15 13:43:30 +00:00
|
|
|
#endif
|
2009-04-01 03:21:18 +00:00
|
|
|
lcd_sleep();
|
2007-09-20 04:46:41 +00:00
|
|
|
sleep(HZ);
|
2007-09-25 01:44:57 +00:00
|
|
|
/* Hard shutdown */
|
2009-10-11 06:58:43 +00:00
|
|
|
IO_GIO_BITSET1 = 1<<10;
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|