summaryrefslogtreecommitdiffstats
path: root/firmware/target/coldfire/iriver
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-03 19:54:25 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-03 19:54:25 +0000
commit58eb784a5d1f0ac800e656d5dfa3a1bff8fb2657 (patch)
tree084c7b7c5d374fbfef2f8cddb3673a3b2a26a7df /firmware/target/coldfire/iriver
parent0d0cc039f88ced4f6db5c4468b19913f52cd08c8 (diff)
downloadrockbox-58eb784a5d1f0ac800e656d5dfa3a1bff8fb2657.tar.gz
rockbox-58eb784a5d1f0ac800e656d5dfa3a1bff8fb2657.tar.bz2
rockbox-58eb784a5d1f0ac800e656d5dfa3a1bff8fb2657.zip
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
Diffstat (limited to 'firmware/target/coldfire/iriver')
-rw-r--r--firmware/target/coldfire/iriver/h100/power-h100.c21
-rw-r--r--firmware/target/coldfire/iriver/h300/power-h300.c53
2 files changed, 51 insertions, 23 deletions
diff --git a/firmware/target/coldfire/iriver/h100/power-h100.c b/firmware/target/coldfire/iriver/h100/power-h100.c
index 6eb403732d..2717e42f4a 100644
--- a/firmware/target/coldfire/iriver/h100/power-h100.c
+++ b/firmware/target/coldfire/iriver/h100/power-h100.c
@@ -26,19 +26,14 @@
#include "power.h"
#include "spdif.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,14 +51,16 @@ void power_init(void)
#endif
}
-
-bool charger_inserted(void)
-{
- return (GPIO1_READ & 0x00400000)?true:false;
+unsigned int power_input_status(void)
+{
+ return (GPIO1_READ & 0x00400000) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
+
/* Returns true if the unit is charging the batteries. */
-bool charging_state(void) {
- return charger_inserted();
+bool charging_state(void)
+{
+ return (power_input_status() & POWER_INPUT_CHARGER) != 0;
}
#ifdef HAVE_SPDIF_POWER
@@ -119,5 +116,3 @@ void power_off(void)
asm("halt");
while(1);
}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/coldfire/iriver/h300/power-h300.c b/firmware/target/coldfire/iriver/h300/power-h300.c
index ea66625794..400dc02526 100644
--- a/firmware/target/coldfire/iriver/h300/power-h300.c
+++ b/firmware/target/coldfire/iriver/h300/power-h300.c
@@ -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 */