summaryrefslogtreecommitdiffstats
path: root/firmware/target
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
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')
-rw-r--r--firmware/target/arm/archos/av300/power-av300.c31
-rw-r--r--firmware/target/arm/as3525/power-as3525.c13
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.c37
-rw-r--r--firmware/target/arm/ipod/power-ipod.c20
-rw-r--r--firmware/target/arm/iriver/h10/power-h10.c6
-rw-r--r--firmware/target/arm/olympus/mrobe-100/power-mr100.c7
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/power-hdd1630.c4
-rw-r--r--firmware/target/arm/philips/sa9200/power-sa9200.c10
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c48
-rw-r--r--firmware/target/arm/sandisk/power-c200_e200.c24
-rw-r--r--firmware/target/arm/tatung/tpj1022/power-tpj1022.c6
-rw-r--r--firmware/target/arm/tcc77x/c100/power-c100.c21
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c5
-rw-r--r--firmware/target/arm/tcc77x/logikdax/power-logikdax.c25
-rw-r--r--firmware/target/arm/tcc77x/m200/power-m200.c25
-rw-r--r--firmware/target/arm/tcc780x/cowond2/power-cowond2.c30
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c25
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c30
-rw-r--r--firmware/target/coldfire/iaudio/m3/power-m3.c11
-rw-r--r--firmware/target/coldfire/iaudio/m5/power-m5.c11
-rw-r--r--firmware/target/coldfire/iaudio/x5/power-x5.c11
-rw-r--r--firmware/target/coldfire/iriver/h100/power-h100.c21
-rw-r--r--firmware/target/coldfire/iriver/h300/power-h300.c53
-rw-r--r--firmware/target/sh/archos/fm_v2/power-fm_v2.c15
-rw-r--r--firmware/target/sh/archos/player/power-player.c5
-rw-r--r--firmware/target/sh/archos/recorder/power-recorder.c5
26 files changed, 177 insertions, 322 deletions
diff --git a/firmware/target/arm/archos/av300/power-av300.c b/firmware/target/arm/archos/av300/power-av300.c
index 5aa757d3e6..013fd04691 100644
--- a/firmware/target/arm/archos/av300/power-av300.c
+++ b/firmware/target/arm/archos/av300/power-av300.c
@@ -32,16 +32,14 @@
#include "system.h"
#include "power.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Charger detect */
}
-bool charger_inserted(void)
-{
- return false;
+unsigned int power_input_status(void)
+{
+ return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
@@ -61,29 +59,6 @@ void power_off(void)
{
}
-#else
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
-
bool tuner_power(bool status)
{
(void)status;
diff --git a/firmware/target/arm/as3525/power-as3525.c b/firmware/target/arm/as3525/power-as3525.c
index a61cb59c12..07867546c2 100644
--- a/firmware/target/arm/as3525/power-as3525.c
+++ b/firmware/target/arm/as3525/power-as3525.c
@@ -18,7 +18,6 @@
* KIND, either express or implied.
*
****************************************************************************/
-
#include <stdbool.h>
#include "config.h"
#include "ascodec-target.h"
@@ -40,14 +39,14 @@ void power_init(void)
}
#if CONFIG_CHARGING
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- if(ascodec_read(AS3514_IRQ_ENRD0) & (1<<5))
- return true;
- else
- return false;
+ return (ascodec_read(AS3514_IRQ_ENRD0) & (1<<5)) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
+
+ /* TODO: Handle USB and other sources properly */
}
-#endif
+#endif /* CONFIG_CHARGING */
void ide_power_enable(bool on)
{
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
index 9d9cc6bcb6..62f9982dd5 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
@@ -27,8 +27,6 @@
#include "avic-imx31.h"
#include "mc13783.h"
-#ifndef SIMULATOR
-
static bool charger_detect = false;
/* This is called from the mc13783 interrupt thread */
@@ -38,9 +36,17 @@ void charger_detect_event(void)
mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_CHGDETS;
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return charger_detect;
+ unsigned int status = POWER_INPUT_NONE;
+
+ if ((GPIO3_DR & (1 << 20)) != 0)
+ status |= POWER_INPUT_BATTERY;
+
+ if (charger_detect)
+ status |= POWER_INPUT_MAIN_CHARGER;
+
+ return status;
}
/* Returns true if the unit is charging the batteries. */
@@ -90,26 +96,3 @@ void power_init(void)
mc13783_enable_event(MC13783_CHGDET_EVENT);
}
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
-
diff --git a/firmware/target/arm/ipod/power-ipod.c b/firmware/target/arm/ipod/power-ipod.c
index af1ac9fc87..cb93fe398f 100644
--- a/firmware/target/arm/ipod/power-ipod.c
+++ b/firmware/target/arm/ipod/power-ipod.c
@@ -43,18 +43,28 @@ void power_init(void)
}
#if CONFIG_CHARGING
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
-#if defined(IPOD_VIDEO)
- return (GPIOL_INPUT_VAL & 0x08)?false:true;
+ unsigned int status = POWER_INPUT_NONE;
+
+#if defined(IPOD_NANO) || defined(IPOD_VIDEO)
+ if ((GPIOL_INPUT_VAL & 0x08) == 0)
+ status = POWER_INPUT_MAIN_CHARGER;
+
+ if ((GPIOL_INPUT_VAL & 0x10) != 0)
+ status |= POWER_INPUT_USB_CHARGER;
+ /* */
#elif defined(IPOD_4G) || defined(IPOD_COLOR) \
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
/* C2 is firewire power */
- return (GPIOC_INPUT_VAL & 0x04)?false:true;
+ if ((GPIOC_INPUT_VAL & 0x04) == 0)
+ status = POWER_INPUT_MAIN_CHARGER;
+ /* */
#else
/* This needs filling in for other ipods. */
- return false;
#endif
+
+ return status;
}
/* Returns true if the unit is charging the batteries. */
diff --git a/firmware/target/arm/iriver/h10/power-h10.c b/firmware/target/arm/iriver/h10/power-h10.c
index dd09387889..deca3258e2 100644
--- a/firmware/target/arm/iriver/h10/power-h10.c
+++ b/firmware/target/arm/iriver/h10/power-h10.c
@@ -52,9 +52,11 @@ void power_init(void)
{
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return (GPIOF_INPUT_VAL & 0x08)?true:false;
+ /* No separate source for USB and charges from USB on its own */
+ return (GPIOF_INPUT_VAL & 0x08) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/olympus/mrobe-100/power-mr100.c b/firmware/target/arm/olympus/mrobe-100/power-mr100.c
index 1ff15c57bf..c3eb96b03c 100644
--- a/firmware/target/arm/olympus/mrobe-100/power-mr100.c
+++ b/firmware/target/arm/olympus/mrobe-100/power-mr100.c
@@ -41,9 +41,10 @@ void power_init(void)
GPIOB_OUTPUT_EN |= 0x80;
}
-bool charger_inserted(void)
-{
- return (GPIOL_INPUT_VAL & 0x24) ? true : false ;
+unsigned int power_input_status(void)
+{
+ return (GPIOL_INPUT_VAL & 0x24) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/hdd1630/power-hdd1630.c
index 91193bae35..ade2536154 100755
--- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/power-hdd1630.c
@@ -37,9 +37,9 @@ void power_init(void)
{
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return false ;
+ return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/philips/sa9200/power-sa9200.c b/firmware/target/arm/philips/sa9200/power-sa9200.c
index 44df437577..654beee064 100644
--- a/firmware/target/arm/philips/sa9200/power-sa9200.c
+++ b/firmware/target/arm/philips/sa9200/power-sa9200.c
@@ -54,15 +54,9 @@ void power_off(void)
}
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
-#ifdef SANSA_E200
- if(GPIOB_INPUT_VAL & 0x10)
-#else /* SANSA_C200 */
- if(GPIOH_INPUT_VAL & 0x2)
-#endif
- return true;
- return false;
+ return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
index c1c0595262..ad9098dd8a 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
@@ -27,8 +27,7 @@
#include "pcf50606.h"
#include "backlight.h"
#include "backlight-target.h"
-
-#ifndef SIMULATOR
+#include "usb.h"
void power_init(void)
{
@@ -39,13 +38,28 @@ void power_init(void)
/* Charger detect */
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return (GPFDAT & (1 << 4)) ? false : true;
+ unsigned int status = POWER_INPUT_NONE;
+
+ /* Is the battery switch ON? */
+ if ((GPGDAT & (1 << 9)) == 0)
+ status |= POWER_INPUT_BATTERY;
+
+ /* Main or cradle power available? */
+ if ((GPFDAT & (1 << 4)) == 0)
+ status |= POWER_INPUT_MAIN_CHARGER;
+
+ /* Is the USB cable inserted? */
+ if (usb_detect() == USB_INSERTED)
+ status |= POWER_INPUT_USB_CHARGER;
+
+ return status;
}
/* Returns true if the unit is charging the batteries. */
-bool charging_state(void) {
+bool charging_state(void)
+{
return (GPGDAT & (1 << 8)) ? false : true;
}
@@ -87,27 +101,3 @@ void power_off(void)
reboot_point();
}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
-
diff --git a/firmware/target/arm/sandisk/power-c200_e200.c b/firmware/target/arm/sandisk/power-c200_e200.c
index d6319f44bb..cc9d16f466 100644
--- a/firmware/target/arm/sandisk/power-c200_e200.c
+++ b/firmware/target/arm/sandisk/power-c200_e200.c
@@ -26,6 +26,7 @@
#include "tuner.h"
#include "as3514.h"
#include "power.h"
+#include "usb.h"
void power_init(void)
{
@@ -53,15 +54,24 @@ void power_off(void)
}
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
-#ifdef SANSA_E200
- if(GPIOB_INPUT_VAL & 0x10)
-#else /* SANSA_C200 */
- if(GPIOH_INPUT_VAL & 0x2)
+ unsigned int status = POWER_INPUT_NONE;
+
+#if defined(SANSA_E200)
+ #define _charger_present() (GPIOB_INPUT_VAL & 0x10)
+#elif defined(SANSA_C200)
+ #define _charger_present() (GPIOH_INPUT_VAL & 0x2)
+#else
+ #define _charger_present() 0
#endif
- return true;
- return false;
+
+ if (_charger_present())
+ status = POWER_INPUT_MAIN_CHARGER;
+
+ /* No separate source for USB */
+
+ return status;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/tatung/tpj1022/power-tpj1022.c b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c
index f16d3c9cc2..abf5790702 100644
--- a/firmware/target/arm/tatung/tpj1022/power-tpj1022.c
+++ b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c
@@ -41,9 +41,9 @@ void power_init(void)
{
}
-bool charger_inserted(void)
-{
- return false;
+unsigned int power_input_status(void)
+{
+ return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/arm/tcc77x/c100/power-c100.c b/firmware/target/arm/tcc77x/c100/power-c100.c
index 77574ccc87..e84ff1c852 100644
--- a/firmware/target/arm/tcc77x/c100/power-c100.c
+++ b/firmware/target/arm/tcc77x/c100/power-c100.c
@@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
}
@@ -43,22 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
index ce7175ef55..0501ba272c 100644
--- a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
+++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c
@@ -141,7 +141,8 @@ bool tuner_power(bool status)
#endif /* CONFIG_TUNER */
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return (GPIOA & 0x1) ? true : false;
+ return (GPIOA & 0x1) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
index 82eb8dce02..e84ff1c852 100644
--- a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
+++ b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
@@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
}
@@ -43,26 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tcc77x/m200/power-m200.c b/firmware/target/arm/tcc77x/m200/power-m200.c
index 82eb8dce02..e84ff1c852 100644
--- a/firmware/target/arm/tcc77x/m200/power-m200.c
+++ b/firmware/target/arm/tcc77x/m200/power-m200.c
@@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
}
@@ -43,26 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
index 9eb0871c6e..d3f6a1ce16 100644
--- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
@@ -26,8 +26,6 @@
#include "button-target.h"
#include "tuner.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
@@ -93,9 +91,10 @@ void EXT3(void)
#endif
#if CONFIG_CHARGING
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return (GPIOC & (1<<26)) ? false:true;
+ return ((GPIOC & (1<<26)) == 0) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
#endif
@@ -147,26 +146,3 @@ bool tuner_power(bool status)
}
#endif /* CONFIG_TUNER */
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c
index a76e827bec..9c0f9c3cb7 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/power-creativezvm.c
@@ -28,8 +28,6 @@
#include "backlight.h"
#include "backlight-target.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Initialize IDE power pin */
@@ -37,34 +35,17 @@ void power_init(void)
/* Charger detect */
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return false;
+ return POWER_INPUT_NONE;
}
/* Returns true if the unit is charging the batteries. */
-bool charging_state(void) {
- return false;
-}
-
-void power_off(void)
-{
-}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
+bool charging_state(void)
{
return false;
}
-void charger_enable(bool on)
-{
- (void)on;
-}
-
void power_off(void)
{
}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
index 7f4a3b31de..8e8531e4ff 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
@@ -29,8 +29,6 @@
#include "backlight.h"
#include "backlight-target.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Initialize IDE power pin */
@@ -40,9 +38,9 @@ void power_init(void)
/* Charger detect */
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
- return false;
+ return POWER_INPUT_NONE;
}
/* Returns true if the unit is charging the batteries. */
@@ -71,27 +69,3 @@ void power_off(void)
/* Hard shutdown */
IO_GIO_BITSET1|=1<<10;
}
-
-#else /* SIMULATOR */
-
-bool charger_inserted(void)
-{
- return false;
-}
-
-void charger_enable(bool on)
-{
- (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
- (void)on;
-}
-
-#endif /* SIMULATOR */
-
diff --git a/firmware/target/coldfire/iaudio/m3/power-m3.c b/firmware/target/coldfire/iaudio/m3/power-m3.c
index 5dbeadf732..4c446e54d0 100644
--- a/firmware/target/coldfire/iaudio/m3/power-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/power-m3.c
@@ -27,8 +27,6 @@
#include "power.h"
#include "system.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Set KEEPACT */
@@ -47,9 +45,10 @@ void power_init(void)
#endif
}
-bool charger_inserted(void)
-{
- return (GPIO1_READ & 0x00000020) == 0;
+unsigned int power_input_status(void)
+{
+ return ((GPIO1_READ & 0x00000020) == 0) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
@@ -77,8 +76,6 @@ void power_off(void)
asm("halt");
}
-#endif /* SIMULATOR */
-
bool tuner_power(bool status)
{
(void)status;
diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c
index 987ce0f3c5..8bb36c663d 100644
--- a/firmware/target/coldfire/iaudio/m5/power-m5.c
+++ b/firmware/target/coldfire/iaudio/m5/power-m5.c
@@ -27,8 +27,6 @@
#include "pcf50606.h"
#include "lcd-remote-target.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Charger detect */
@@ -38,9 +36,10 @@ void power_init(void)
pcf50606_init();
}
-bool charger_inserted(void)
-{
- return (GPIO1_READ & 0x01000000) != 0;
+unsigned int power_input_status(void)
+{
+ return (GPIO1_READ & 0x01000000) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
@@ -66,5 +65,3 @@ void power_off(void)
and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */
asm("halt");
}
-
-#endif /* SIMULATOR */
diff --git a/firmware/target/coldfire/iaudio/x5/power-x5.c b/firmware/target/coldfire/iaudio/x5/power-x5.c
index 22f56961bf..4feb9c15d0 100644
--- a/firmware/target/coldfire/iaudio/x5/power-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/power-x5.c
@@ -27,8 +27,6 @@
#include "pcf50606.h"
#include "lcd-remote-target.h"
-#ifndef SIMULATOR
-
void power_init(void)
{
/* Charger detect */
@@ -38,9 +36,10 @@ void power_init(void)
pcf50606_init();
}
-bool charger_inserted(void)
-{
- return (GPIO1_READ & 0x01000000) != 0;
+unsigned int power_input_status(void)
+{
+ return (GPIO1_READ & 0x01000000) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
@@ -67,8 +66,6 @@ void power_off(void)
asm("halt");
}
-#endif /* SIMULATOR */
-
bool tuner_power(bool status)
{
(void)status;
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 */
diff --git a/firmware/target/sh/archos/fm_v2/power-fm_v2.c b/firmware/target/sh/archos/fm_v2/power-fm_v2.c
index 32b5c95da9..24bccf6eb2 100644
--- a/firmware/target/sh/archos/fm_v2/power-fm_v2.c
+++ b/firmware/target/sh/archos/fm_v2/power-fm_v2.c
@@ -28,7 +28,6 @@
#include "usb.h"
#if CONFIG_TUNER
-
bool tuner_power(bool status)
{
(void)status;
@@ -44,10 +43,20 @@ void power_init(void)
or_b(0x20, &PBDRL); /* hold power */
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
+ unsigned int status = POWER_INPUT_NONE;
+
/* FM or V2 can also charge from the USB port */
- return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF);
+ if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF)
+ status = POWER_INPUT_MAIN_CHARGER;
+
+#ifdef HAVE_USB_POWER
+ if (usb_detect() == USB_INSERTED)
+ status |= POWER_INPUT_USB_CHARGER;
+#endif
+
+ return status;
}
/* Returns true if the unit is charging the batteries. */
diff --git a/firmware/target/sh/archos/player/power-player.c b/firmware/target/sh/archos/player/power-player.c
index 59b87f69a5..857ba25e50 100644
--- a/firmware/target/sh/archos/player/power-player.c
+++ b/firmware/target/sh/archos/player/power-player.c
@@ -31,10 +31,11 @@ void power_init(void)
{
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
/* Player */
- return (PADR & 1) == 0;
+ return ((PADR & 1) == 0) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
diff --git a/firmware/target/sh/archos/recorder/power-recorder.c b/firmware/target/sh/archos/recorder/power-recorder.c
index b0a7ad1786..d90c029890 100644
--- a/firmware/target/sh/archos/recorder/power-recorder.c
+++ b/firmware/target/sh/archos/recorder/power-recorder.c
@@ -36,10 +36,11 @@ void power_init(void)
charger_enable(false); /* Default to charger OFF */
}
-bool charger_inserted(void)
+unsigned int power_input_status(void)
{
/* Recorder */
- return adc_read(ADC_EXT_POWER) > 0x100;
+ return (adc_read(ADC_EXT_POWER) > 0x100) ?
+ POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void charger_enable(bool on)