Straighten out some powermanagement stuff. Give target complete control over how power inputs are sensed. Clean SIMULATOR stuff out of target files. Get rid of USB charging option on targets that don't support it or don't implement it yet. Menu string remains to avoid language incompatibility but should be removed on next cleanup for targets not using it (notice in english.lang). global_settings becomes incompatible for some builds and so plugin API version is incremented.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19315 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-12-03 19:54:25 +00:00
parent 0d0cc039f8
commit 58eb784a5d
41 changed files with 284 additions and 403 deletions

View file

@ -25,20 +25,18 @@
#include "system.h"
#include "power.h"
#include "pcf50606.h"
#include "usb.h"
#include "logf.h"
#if CONFIG_TUNER
bool tuner_power(bool status)
{
(void)status;
return true;
}
#endif /* #if CONFIG_TUNER */
#ifndef SIMULATOR
void power_init(void)
{
or_l(0x00080000, &GPIO1_OUT);
@ -56,17 +54,54 @@ void power_init(void)
#if CONFIG_CHARGING
bool charger_inserted(void)
{
return (GPIO1_READ & 0x00400000)?true:false;
unsigned int power_input_status(void)
{
unsigned int status = POWER_INPUT_NONE;
if (GPIO1_READ & 0x00400000)
status |= POWER_INPUT_MAIN_CHARGER;
#ifdef HAVE_USB_POWER
if (usb_detect() == USB_INSERTED && pcf50606_usb_charging_enabled())
status |= POWER_INPUT_USB_CHARGER;
/* CHECK: Can the device be powered from USB w/o charging it? */
#endif
return status;
}
#ifdef HAVE_USB_POWER
bool usb_charging_enable(bool on)
{
bool rc = false;
int irqlevel;
logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
irqlevel = disable_irq_save();
pcf50606_set_usb_charging(on);
rc = on;
restore_irq(irqlevel);
return rc;
}
#endif /* HAVE_USB_POWER */
#endif /* CONFIG_CHARGING */
/* Returns true if the unit is charging the batteries. */
bool charging_state(void) {
bool charging_state(void)
{
return (GPIO_READ & 0x00800000)?true:false;
}
bool usb_charging_enabled(void)
{
bool rc = false;
/* TODO: read the state of the GPOOD2 register...
* (this also means to set the irq level here) */
rc = pcf50606_usb_charging_enabled();
logf("usb charging %s", rc ? "enabled" : "disabled" );
return rc;
}
void ide_power_enable(bool on)
{
@ -90,5 +125,3 @@ void power_off(void)
asm("halt");
while(1);
}
#endif /* SIMULATOR */