summaryrefslogtreecommitdiffstats
path: root/firmware/target/coldfire/iriver
diff options
context:
space:
mode:
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 */