summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c12
-rw-r--r--firmware/export/config-gigabeat-s.h5
-rw-r--r--firmware/export/config-gigabeat.h4
-rw-r--r--firmware/export/config-h300.h4
-rw-r--r--firmware/export/power.h51
-rw-r--r--firmware/powermgmt.c24
-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
-rw-r--r--firmware/usb.c37
33 files changed, 260 insertions, 376 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 1208973944..07cc9532be 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -488,11 +488,7 @@ static void backlight_update_state(void)
488 else 488 else
489#endif 489#endif
490#if CONFIG_CHARGING 490#if CONFIG_CHARGING
491 if (charger_inserted() 491 if (power_input_present())
492#ifdef HAVE_USB_POWER
493 || usb_powered()
494#endif
495 )
496 backlight_timeout = backlight_timeout_plugged; 492 backlight_timeout = backlight_timeout_plugged;
497 else 493 else
498#endif 494#endif
@@ -532,11 +528,7 @@ static void remote_backlight_update_state(void)
532 else 528 else
533#endif 529#endif
534#if CONFIG_CHARGING 530#if CONFIG_CHARGING
535 if (charger_inserted() 531 if (power_input_present())
536#ifdef HAVE_USB_POWER
537 || usb_powered()
538#endif
539 )
540 remote_backlight_timeout = remote_backlight_timeout_plugged; 532 remote_backlight_timeout = remote_backlight_timeout_plugged;
541 else 533 else
542#endif 534#endif
diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h
index 8ddca5ca6d..f0e9e92a04 100644
--- a/firmware/export/config-gigabeat-s.h
+++ b/firmware/export/config-gigabeat-s.h
@@ -134,6 +134,11 @@
134 134
135/* define this if the unit can be powered or charged via USB */ 135/* define this if the unit can be powered or charged via USB */
136//#define HAVE_USB_POWER /* Disable for now */ 136//#define HAVE_USB_POWER /* Disable for now */
137//#define HAVE_USB_CHARGING_ENABLE
138
139/* define this if the unit has a battery switch or battery can be removed
140 * when running */
141#define HAVE_BATTERY_SWITCH
137 142
138/* USB On-the-go */ 143/* USB On-the-go */
139#define CONFIG_USBOTG USBOTG_ARC 144#define CONFIG_USBOTG USBOTG_ARC
diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h
index 0c5462400b..313bdadcdd 100644
--- a/firmware/export/config-gigabeat.h
+++ b/firmware/export/config-gigabeat.h
@@ -114,6 +114,10 @@
114/* define this if the unit can be powered or charged via USB */ 114/* define this if the unit can be powered or charged via USB */
115#define HAVE_USB_POWER 115#define HAVE_USB_POWER
116 116
117/* define this if the unit has a battery switch or battery can be removed
118 * when running */
119#define HAVE_BATTERY_SWITCH
120
117#ifndef SIMULATOR 121#ifndef SIMULATOR
118 122
119/* The LCD on a Gigabeat is 240x320 - it is portrait */ 123/* The LCD on a Gigabeat is 240x320 - it is portrait */
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 680ca91245..fa0046ac03 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -112,6 +112,10 @@
112/* define this if the unit can be powered or charged via USB */ 112/* define this if the unit can be powered or charged via USB */
113#define HAVE_USB_POWER 113#define HAVE_USB_POWER
114 114
115/* define this if the unit can have USB charging disabled by user -
116 * if USB/MAIN power is discernable and hardware doesn't compel charging */
117#define HAVE_USB_CHARGING_ENABLE
118
115#ifndef SIMULATOR 119#ifndef SIMULATOR
116 120
117/* define this if the backlight thread is used for fade, not for sim, needs 121/* define this if the backlight thread is used for fade, not for sim, needs
diff --git a/firmware/export/power.h b/firmware/export/power.h
index f74e6fe0c2..747887921d 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -27,8 +27,57 @@ void charger_enable(bool on);
27#endif 27#endif
28 28
29#if CONFIG_CHARGING 29#if CONFIG_CHARGING
30bool charger_inserted(void); 30enum power_input_flags {
31 /* No external power source? Default. */
32 POWER_INPUT_NONE = 0x00,
33
34 /* Main power source is available (AC?), the default other than
35 * battery if for instance USB and others cannot be distinguished or
36 * USB is the only possibility. */
37 POWER_INPUT_MAIN = 0x01,
38
39 /* USB power source is available (and is discernable from MAIN). */
40 POWER_INPUT_USB = 0x02,
41
42 /* Something is plugged. */
43 POWER_INPUT = 0x0f,
44
45 /* POWER_INPUT_*_CHARGER of course implies presence of the respective
46 * power source. */
47
48 /* Battery not included in CHARGER (it can't charge itself) */
49
50 /* Charging is possible on main. */
51 POWER_INPUT_MAIN_CHARGER = 0x10 | POWER_INPUT_MAIN,
52
53 /* Charging is possible on USB. */
54 POWER_INPUT_USB_CHARGER = 0x20 | POWER_INPUT_USB,
55
56 /* Charging is possible from something. */
57 POWER_INPUT_CHARGER = 0xf0,
58
59#ifdef HAVE_BATTERY_SWITCH
60 /* Battery is powering device or is available to power device. It
61 * could also be used if the battery is hot-swappable to indicate if
62 * it is present ("switch" as verb vs. noun). */
63 POWER_INPUT_BATTERY = 0x100,
31#endif 64#endif
65};
66
67/* Returns detailed power input status information from device. */
68unsigned int power_input_status(void);
69
70/* Shortcuts */
71/* Returns true if any power source that is connected is capable of
72 * charging the batteries.
73 * > (power_input_status() & POWER_INPUT_CHARGER) != 0 */
74bool charger_inserted(void);
75
76/* Returns true if any power input is connected - charging-capable
77 * or not.
78 * > (power_input_status() & POWER_INPUT) != 0 */
79bool power_input_present(void);
80#endif /* CONFIG_CHARGING */
32 81
33void power_off(void); 82void power_off(void);
34void ide_power_enable(bool on); 83void ide_power_enable(bool on);
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 6f0c37b3c7..899e103d59 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -935,6 +935,23 @@ static inline void charging_algorithm_close(void)
935} 935}
936#endif /* CONFIG_CHARGING == CHARGING_CONTROL */ 936#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
937 937
938#if CONFIG_CHARGING
939/* Shortcut function calls - compatibility, simplicity. */
940
941/* Returns true if any power input is capable of charging. */
942bool charger_inserted(void)
943{
944 return power_input_status() & POWER_INPUT_CHARGER;
945}
946
947/* Returns true if any power input is connected - charging-capable
948 * or not. */
949bool power_input_present(void)
950{
951 return power_input_status() & POWER_INPUT;
952}
953#endif /* CONFIG_CHARGING */
954
938/* 955/*
939 * This function is called to do the relativly long sleep waits from within the 956 * This function is called to do the relativly long sleep waits from within the
940 * main power_thread loop while at the same time servicing any other periodic 957 * main power_thread loop while at the same time servicing any other periodic
@@ -957,12 +974,7 @@ static void power_thread_sleep(int ticks)
957 * loop (including the subroutines), and end up back here where we 974 * loop (including the subroutines), and end up back here where we
958 * transition to the appropriate steady state charger on/off state. 975 * transition to the appropriate steady state charger on/off state.
959 */ 976 */
960 if(charger_inserted() 977 if(power_input_status() & POWER_INPUT_CHARGER) {
961#ifdef HAVE_USB_POWER /* USB powered or USB inserted both provide power */
962 || usb_powered()
963 || (usb_inserted() && usb_charging_enabled())
964#endif
965 ) {
966 switch(charger_input_state) { 978 switch(charger_input_state) {
967 case NO_CHARGER: 979 case NO_CHARGER:
968 case CHARGER_UNPLUGGED: 980 case CHARGER_UNPLUGGED:
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 @@
32#include "system.h" 32#include "system.h"
33#include "power.h" 33#include "power.h"
34 34
35#ifndef SIMULATOR
36
37void power_init(void) 35void power_init(void)
38{ 36{
39 /* Charger detect */ 37 /* Charger detect */
40} 38}
41 39
42bool charger_inserted(void) 40unsigned int power_input_status(void)
43{ 41{
44 return false; 42 return POWER_INPUT_NONE;
45} 43}
46 44
47void ide_power_enable(bool on) 45void ide_power_enable(bool on)
@@ -61,29 +59,6 @@ void power_off(void)
61{ 59{
62} 60}
63 61
64#else
65
66bool charger_inserted(void)
67{
68 return false;
69}
70
71void charger_enable(bool on)
72{
73 (void)on;
74}
75
76void power_off(void)
77{
78}
79
80void ide_power_enable(bool on)
81{
82 (void)on;
83}
84
85#endif /* SIMULATOR */
86
87bool tuner_power(bool status) 62bool tuner_power(bool status)
88{ 63{
89 (void)status; 64 (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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21
22#include <stdbool.h> 21#include <stdbool.h>
23#include "config.h" 22#include "config.h"
24#include "ascodec-target.h" 23#include "ascodec-target.h"
@@ -40,14 +39,14 @@ void power_init(void)
40} 39}
41 40
42#if CONFIG_CHARGING 41#if CONFIG_CHARGING
43bool charger_inserted(void) 42unsigned int power_input_status(void)
44{ 43{
45 if(ascodec_read(AS3514_IRQ_ENRD0) & (1<<5)) 44 return (ascodec_read(AS3514_IRQ_ENRD0) & (1<<5)) ?
46 return true; 45 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
47 else 46
48 return false; 47 /* TODO: Handle USB and other sources properly */
49} 48}
50#endif 49#endif /* CONFIG_CHARGING */
51 50
52void ide_power_enable(bool on) 51void ide_power_enable(bool on)
53{ 52{
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 @@
27#include "avic-imx31.h" 27#include "avic-imx31.h"
28#include "mc13783.h" 28#include "mc13783.h"
29 29
30#ifndef SIMULATOR
31
32static bool charger_detect = false; 30static bool charger_detect = false;
33 31
34/* This is called from the mc13783 interrupt thread */ 32/* This is called from the mc13783 interrupt thread */
@@ -38,9 +36,17 @@ void charger_detect_event(void)
38 mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_CHGDETS; 36 mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_CHGDETS;
39} 37}
40 38
41bool charger_inserted(void) 39unsigned int power_input_status(void)
42{ 40{
43 return charger_detect; 41 unsigned int status = POWER_INPUT_NONE;
42
43 if ((GPIO3_DR & (1 << 20)) != 0)
44 status |= POWER_INPUT_BATTERY;
45
46 if (charger_detect)
47 status |= POWER_INPUT_MAIN_CHARGER;
48
49 return status;
44} 50}
45 51
46/* Returns true if the unit is charging the batteries. */ 52/* Returns true if the unit is charging the batteries. */
@@ -90,26 +96,3 @@ void power_init(void)
90 mc13783_enable_event(MC13783_CHGDET_EVENT); 96 mc13783_enable_event(MC13783_CHGDET_EVENT);
91} 97}
92 98
93#else /* SIMULATOR */
94
95bool charger_inserted(void)
96{
97 return false;
98}
99
100void charger_enable(bool on)
101{
102 (void)on;
103}
104
105void power_off(void)
106{
107}
108
109void ide_power_enable(bool on)
110{
111 (void)on;
112}
113
114#endif /* SIMULATOR */
115
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)
43} 43}
44 44
45#if CONFIG_CHARGING 45#if CONFIG_CHARGING
46bool charger_inserted(void) 46unsigned int power_input_status(void)
47{ 47{
48#if defined(IPOD_VIDEO) 48 unsigned int status = POWER_INPUT_NONE;
49 return (GPIOL_INPUT_VAL & 0x08)?false:true; 49
50#if defined(IPOD_NANO) || defined(IPOD_VIDEO)
51 if ((GPIOL_INPUT_VAL & 0x08) == 0)
52 status = POWER_INPUT_MAIN_CHARGER;
53
54 if ((GPIOL_INPUT_VAL & 0x10) != 0)
55 status |= POWER_INPUT_USB_CHARGER;
56 /* */
50#elif defined(IPOD_4G) || defined(IPOD_COLOR) \ 57#elif defined(IPOD_4G) || defined(IPOD_COLOR) \
51 || defined(IPOD_MINI) || defined(IPOD_MINI2G) 58 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
52 /* C2 is firewire power */ 59 /* C2 is firewire power */
53 return (GPIOC_INPUT_VAL & 0x04)?false:true; 60 if ((GPIOC_INPUT_VAL & 0x04) == 0)
61 status = POWER_INPUT_MAIN_CHARGER;
62 /* */
54#else 63#else
55 /* This needs filling in for other ipods. */ 64 /* This needs filling in for other ipods. */
56 return false;
57#endif 65#endif
66
67 return status;
58} 68}
59 69
60/* Returns true if the unit is charging the batteries. */ 70/* 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)
52{ 52{
53} 53}
54 54
55bool charger_inserted(void) 55unsigned int power_input_status(void)
56{ 56{
57 return (GPIOF_INPUT_VAL & 0x08)?true:false; 57 /* No separate source for USB and charges from USB on its own */
58 return (GPIOF_INPUT_VAL & 0x08) ?
59 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
58} 60}
59 61
60void ide_power_enable(bool on) 62void 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)
41 GPIOB_OUTPUT_EN |= 0x80; 41 GPIOB_OUTPUT_EN |= 0x80;
42} 42}
43 43
44bool charger_inserted(void) 44unsigned int power_input_status(void)
45{ 45{
46 return (GPIOL_INPUT_VAL & 0x24) ? true : false ; 46 return (GPIOL_INPUT_VAL & 0x24) ?
47 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
47} 48}
48 49
49void ide_power_enable(bool on) 50void 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)
37{ 37{
38} 38}
39 39
40bool charger_inserted(void) 40unsigned int power_input_status(void)
41{ 41{
42 return false ; 42 return POWER_INPUT_NONE;
43} 43}
44 44
45void ide_power_enable(bool on) 45void 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)
54 } 54 }
55} 55}
56 56
57bool charger_inserted(void) 57unsigned int power_input_status(void)
58{ 58{
59#ifdef SANSA_E200 59 return POWER_INPUT_NONE;
60 if(GPIOB_INPUT_VAL & 0x10)
61#else /* SANSA_C200 */
62 if(GPIOH_INPUT_VAL & 0x2)
63#endif
64 return true;
65 return false;
66} 60}
67 61
68void ide_power_enable(bool on) 62void 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 @@
27#include "pcf50606.h" 27#include "pcf50606.h"
28#include "backlight.h" 28#include "backlight.h"
29#include "backlight-target.h" 29#include "backlight-target.h"
30 30#include "usb.h"
31#ifndef SIMULATOR
32 31
33void power_init(void) 32void power_init(void)
34{ 33{
@@ -39,13 +38,28 @@ void power_init(void)
39 /* Charger detect */ 38 /* Charger detect */
40} 39}
41 40
42bool charger_inserted(void) 41unsigned int power_input_status(void)
43{ 42{
44 return (GPFDAT & (1 << 4)) ? false : true; 43 unsigned int status = POWER_INPUT_NONE;
44
45 /* Is the battery switch ON? */
46 if ((GPGDAT & (1 << 9)) == 0)
47 status |= POWER_INPUT_BATTERY;
48
49 /* Main or cradle power available? */
50 if ((GPFDAT & (1 << 4)) == 0)
51 status |= POWER_INPUT_MAIN_CHARGER;
52
53 /* Is the USB cable inserted? */
54 if (usb_detect() == USB_INSERTED)
55 status |= POWER_INPUT_USB_CHARGER;
56
57 return status;
45} 58}
46 59
47/* Returns true if the unit is charging the batteries. */ 60/* Returns true if the unit is charging the batteries. */
48bool charging_state(void) { 61bool charging_state(void)
62{
49 return (GPGDAT & (1 << 8)) ? false : true; 63 return (GPGDAT & (1 << 8)) ? false : true;
50} 64}
51 65
@@ -87,27 +101,3 @@ void power_off(void)
87 101
88 reboot_point(); 102 reboot_point();
89} 103}
90
91#else /* SIMULATOR */
92
93bool charger_inserted(void)
94{
95 return false;
96}
97
98void charger_enable(bool on)
99{
100 (void)on;
101}
102
103void power_off(void)
104{
105}
106
107void ide_power_enable(bool on)
108{
109 (void)on;
110}
111
112#endif /* SIMULATOR */
113
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 @@
26#include "tuner.h" 26#include "tuner.h"
27#include "as3514.h" 27#include "as3514.h"
28#include "power.h" 28#include "power.h"
29#include "usb.h"
29 30
30void power_init(void) 31void power_init(void)
31{ 32{
@@ -53,15 +54,24 @@ void power_off(void)
53 } 54 }
54} 55}
55 56
56bool charger_inserted(void) 57unsigned int power_input_status(void)
57{ 58{
58#ifdef SANSA_E200 59 unsigned int status = POWER_INPUT_NONE;
59 if(GPIOB_INPUT_VAL & 0x10) 60
60#else /* SANSA_C200 */ 61#if defined(SANSA_E200)
61 if(GPIOH_INPUT_VAL & 0x2) 62 #define _charger_present() (GPIOB_INPUT_VAL & 0x10)
63#elif defined(SANSA_C200)
64 #define _charger_present() (GPIOH_INPUT_VAL & 0x2)
65#else
66 #define _charger_present() 0
62#endif 67#endif
63 return true; 68
64 return false; 69 if (_charger_present())
70 status = POWER_INPUT_MAIN_CHARGER;
71
72 /* No separate source for USB */
73
74 return status;
65} 75}
66 76
67void ide_power_enable(bool on) 77void 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)
41{ 41{
42} 42}
43 43
44bool charger_inserted(void) 44unsigned int power_input_status(void)
45{ 45{
46 return false; 46 return POWER_INPUT_NONE;
47} 47}
48 48
49void ide_power_enable(bool on) 49void 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 @@
25#include "system.h" 25#include "system.h"
26#include "power.h" 26#include "power.h"
27 27
28#ifndef SIMULATOR
29
30void power_init(void) 28void power_init(void)
31{ 29{
32} 30}
@@ -43,22 +41,3 @@ bool ide_powered(void)
43void power_off(void) 41void power_off(void)
44{ 42{
45} 43}
46
47#else /* SIMULATOR */
48
49bool charger_inserted(void)
50{
51 return false;
52}
53
54void charger_enable(bool on)
55{
56 (void)on;
57}
58
59void ide_power_enable(bool on)
60{
61 (void)on;
62}
63
64#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)
141 141
142#endif /* CONFIG_TUNER */ 142#endif /* CONFIG_TUNER */
143 143
144bool charger_inserted(void) 144unsigned int power_input_status(void)
145{ 145{
146 return (GPIOA & 0x1) ? true : false; 146 return (GPIOA & 0x1) ?
147 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
147} 148}
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 @@
25#include "system.h" 25#include "system.h"
26#include "power.h" 26#include "power.h"
27 27
28#ifndef SIMULATOR
29
30void power_init(void) 28void power_init(void)
31{ 29{
32} 30}
@@ -43,26 +41,3 @@ bool ide_powered(void)
43void power_off(void) 41void power_off(void)
44{ 42{
45} 43}
46
47#else /* SIMULATOR */
48
49bool charger_inserted(void)
50{
51 return false;
52}
53
54void charger_enable(bool on)
55{
56 (void)on;
57}
58
59void power_off(void)
60{
61}
62
63void ide_power_enable(bool on)
64{
65 (void)on;
66}
67
68#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 @@
25#include "system.h" 25#include "system.h"
26#include "power.h" 26#include "power.h"
27 27
28#ifndef SIMULATOR
29
30void power_init(void) 28void power_init(void)
31{ 29{
32} 30}
@@ -43,26 +41,3 @@ bool ide_powered(void)
43void power_off(void) 41void power_off(void)
44{ 42{
45} 43}
46
47#else /* SIMULATOR */
48
49bool charger_inserted(void)
50{
51 return false;
52}
53
54void charger_enable(bool on)
55{
56 (void)on;
57}
58
59void power_off(void)
60{
61}
62
63void ide_power_enable(bool on)
64{
65 (void)on;
66}
67
68#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 @@
26#include "button-target.h" 26#include "button-target.h"
27#include "tuner.h" 27#include "tuner.h"
28 28
29#ifndef SIMULATOR
30
31void power_init(void) 29void power_init(void)
32{ 30{
33 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ 31 unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
@@ -93,9 +91,10 @@ void EXT3(void)
93#endif 91#endif
94 92
95#if CONFIG_CHARGING 93#if CONFIG_CHARGING
96bool charger_inserted(void) 94unsigned int power_input_status(void)
97{ 95{
98 return (GPIOC & (1<<26)) ? false:true; 96 return ((GPIOC & (1<<26)) == 0) ?
97 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
99} 98}
100#endif 99#endif
101 100
@@ -147,26 +146,3 @@ bool tuner_power(bool status)
147} 146}
148 147
149#endif /* CONFIG_TUNER */ 148#endif /* CONFIG_TUNER */
150
151#else /* SIMULATOR */
152
153bool charger_inserted(void)
154{
155 return false;
156}
157
158void charger_enable(bool on)
159{
160 (void)on;
161}
162
163void power_off(void)
164{
165}
166
167void ide_power_enable(bool on)
168{
169 (void)on;
170}
171
172#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 @@
28#include "backlight.h" 28#include "backlight.h"
29#include "backlight-target.h" 29#include "backlight-target.h"
30 30
31#ifndef SIMULATOR
32
33void power_init(void) 31void power_init(void)
34{ 32{
35 /* Initialize IDE power pin */ 33 /* Initialize IDE power pin */
@@ -37,34 +35,17 @@ void power_init(void)
37 /* Charger detect */ 35 /* Charger detect */
38} 36}
39 37
40bool charger_inserted(void) 38unsigned int power_input_status(void)
41{ 39{
42 return false; 40 return POWER_INPUT_NONE;
43} 41}
44 42
45/* Returns true if the unit is charging the batteries. */ 43/* Returns true if the unit is charging the batteries. */
46bool charging_state(void) { 44bool charging_state(void)
47 return false;
48}
49
50void power_off(void)
51{
52}
53
54#else /* SIMULATOR */
55
56bool charger_inserted(void)
57{ 45{
58 return false; 46 return false;
59} 47}
60 48
61void charger_enable(bool on)
62{
63 (void)on;
64}
65
66void power_off(void) 49void power_off(void)
67{ 50{
68} 51}
69
70#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 @@
29#include "backlight.h" 29#include "backlight.h"
30#include "backlight-target.h" 30#include "backlight-target.h"
31 31
32#ifndef SIMULATOR
33
34void power_init(void) 32void power_init(void)
35{ 33{
36 /* Initialize IDE power pin */ 34 /* Initialize IDE power pin */
@@ -40,9 +38,9 @@ void power_init(void)
40 /* Charger detect */ 38 /* Charger detect */
41} 39}
42 40
43bool charger_inserted(void) 41unsigned int power_input_status(void)
44{ 42{
45 return false; 43 return POWER_INPUT_NONE;
46} 44}
47 45
48/* Returns true if the unit is charging the batteries. */ 46/* Returns true if the unit is charging the batteries. */
@@ -71,27 +69,3 @@ void power_off(void)
71 /* Hard shutdown */ 69 /* Hard shutdown */
72 IO_GIO_BITSET1|=1<<10; 70 IO_GIO_BITSET1|=1<<10;
73} 71}
74
75#else /* SIMULATOR */
76
77bool charger_inserted(void)
78{
79 return false;
80}
81
82void charger_enable(bool on)
83{
84 (void)on;
85}
86
87void power_off(void)
88{
89}
90
91void ide_power_enable(bool on)
92{
93 (void)on;
94}
95
96#endif /* SIMULATOR */
97
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 @@
27#include "power.h" 27#include "power.h"
28#include "system.h" 28#include "system.h"
29 29
30#ifndef SIMULATOR
31
32void power_init(void) 30void power_init(void)
33{ 31{
34 /* Set KEEPACT */ 32 /* Set KEEPACT */
@@ -47,9 +45,10 @@ void power_init(void)
47#endif 45#endif
48} 46}
49 47
50bool charger_inserted(void) 48unsigned int power_input_status(void)
51{ 49{
52 return (GPIO1_READ & 0x00000020) == 0; 50 return ((GPIO1_READ & 0x00000020) == 0) ?
51 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
53} 52}
54 53
55void ide_power_enable(bool on) 54void ide_power_enable(bool on)
@@ -77,8 +76,6 @@ void power_off(void)
77 asm("halt"); 76 asm("halt");
78} 77}
79 78
80#endif /* SIMULATOR */
81
82bool tuner_power(bool status) 79bool tuner_power(bool status)
83{ 80{
84 (void)status; 81 (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 @@
27#include "pcf50606.h" 27#include "pcf50606.h"
28#include "lcd-remote-target.h" 28#include "lcd-remote-target.h"
29 29
30#ifndef SIMULATOR
31
32void power_init(void) 30void power_init(void)
33{ 31{
34 /* Charger detect */ 32 /* Charger detect */
@@ -38,9 +36,10 @@ void power_init(void)
38 pcf50606_init(); 36 pcf50606_init();
39} 37}
40 38
41bool charger_inserted(void) 39unsigned int power_input_status(void)
42{ 40{
43 return (GPIO1_READ & 0x01000000) != 0; 41 return (GPIO1_READ & 0x01000000) ?
42 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
44} 43}
45 44
46void ide_power_enable(bool on) 45void ide_power_enable(bool on)
@@ -66,5 +65,3 @@ void power_off(void)
66 and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */ 65 and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */
67 asm("halt"); 66 asm("halt");
68} 67}
69
70#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 @@
27#include "pcf50606.h" 27#include "pcf50606.h"
28#include "lcd-remote-target.h" 28#include "lcd-remote-target.h"
29 29
30#ifndef SIMULATOR
31
32void power_init(void) 30void power_init(void)
33{ 31{
34 /* Charger detect */ 32 /* Charger detect */
@@ -38,9 +36,10 @@ void power_init(void)
38 pcf50606_init(); 36 pcf50606_init();
39} 37}
40 38
41bool charger_inserted(void) 39unsigned int power_input_status(void)
42{ 40{
43 return (GPIO1_READ & 0x01000000) != 0; 41 return (GPIO1_READ & 0x01000000) ?
42 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
44} 43}
45 44
46void ide_power_enable(bool on) 45void ide_power_enable(bool on)
@@ -67,8 +66,6 @@ void power_off(void)
67 asm("halt"); 66 asm("halt");
68} 67}
69 68
70#endif /* SIMULATOR */
71
72bool tuner_power(bool status) 69bool tuner_power(bool status)
73{ 70{
74 (void)status; 71 (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 @@
26#include "power.h" 26#include "power.h"
27#include "spdif.h" 27#include "spdif.h"
28 28
29
30#if CONFIG_TUNER 29#if CONFIG_TUNER
31
32bool tuner_power(bool status) 30bool tuner_power(bool status)
33{ 31{
34 (void)status; 32 (void)status;
35 return true; 33 return true;
36} 34}
37
38#endif /* #if CONFIG_TUNER */ 35#endif /* #if CONFIG_TUNER */
39 36
40#ifndef SIMULATOR
41
42void power_init(void) 37void power_init(void)
43{ 38{
44 or_l(0x00080000, &GPIO1_OUT); 39 or_l(0x00080000, &GPIO1_OUT);
@@ -56,14 +51,16 @@ void power_init(void)
56#endif 51#endif
57} 52}
58 53
59 54unsigned int power_input_status(void)
60bool charger_inserted(void) 55{
61{ 56 return (GPIO1_READ & 0x00400000) ?
62 return (GPIO1_READ & 0x00400000)?true:false; 57 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
63} 58}
59
64/* Returns true if the unit is charging the batteries. */ 60/* Returns true if the unit is charging the batteries. */
65bool charging_state(void) { 61bool charging_state(void)
66 return charger_inserted(); 62{
63 return (power_input_status() & POWER_INPUT_CHARGER) != 0;
67} 64}
68 65
69#ifdef HAVE_SPDIF_POWER 66#ifdef HAVE_SPDIF_POWER
@@ -119,5 +116,3 @@ void power_off(void)
119 asm("halt"); 116 asm("halt");
120 while(1); 117 while(1);
121} 118}
122
123#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 @@
25#include "system.h" 25#include "system.h"
26#include "power.h" 26#include "power.h"
27#include "pcf50606.h" 27#include "pcf50606.h"
28#include "usb.h"
29#include "logf.h"
28 30
29 31
30#if CONFIG_TUNER 32#if CONFIG_TUNER
31
32bool tuner_power(bool status) 33bool tuner_power(bool status)
33{ 34{
34 (void)status; 35 (void)status;
35 return true; 36 return true;
36} 37}
37
38#endif /* #if CONFIG_TUNER */ 38#endif /* #if CONFIG_TUNER */
39 39
40#ifndef SIMULATOR
41
42void power_init(void) 40void power_init(void)
43{ 41{
44 or_l(0x00080000, &GPIO1_OUT); 42 or_l(0x00080000, &GPIO1_OUT);
@@ -56,17 +54,54 @@ void power_init(void)
56 54
57 55
58#if CONFIG_CHARGING 56#if CONFIG_CHARGING
59bool charger_inserted(void) 57unsigned int power_input_status(void)
60{ 58{
61 return (GPIO1_READ & 0x00400000)?true:false; 59 unsigned int status = POWER_INPUT_NONE;
60
61 if (GPIO1_READ & 0x00400000)
62 status |= POWER_INPUT_MAIN_CHARGER;
63
64#ifdef HAVE_USB_POWER
65 if (usb_detect() == USB_INSERTED && pcf50606_usb_charging_enabled())
66 status |= POWER_INPUT_USB_CHARGER;
67 /* CHECK: Can the device be powered from USB w/o charging it? */
68#endif
69
70 return status;
62} 71}
72
73#ifdef HAVE_USB_POWER
74bool usb_charging_enable(bool on)
75{
76 bool rc = false;
77 int irqlevel;
78 logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
79 irqlevel = disable_irq_save();
80 pcf50606_set_usb_charging(on);
81 rc = on;
82 restore_irq(irqlevel);
83 return rc;
84}
85#endif /* HAVE_USB_POWER */
86
63#endif /* CONFIG_CHARGING */ 87#endif /* CONFIG_CHARGING */
64 88
65/* Returns true if the unit is charging the batteries. */ 89/* Returns true if the unit is charging the batteries. */
66bool charging_state(void) { 90bool charging_state(void)
91{
67 return (GPIO_READ & 0x00800000)?true:false; 92 return (GPIO_READ & 0x00800000)?true:false;
68} 93}
69 94
95bool usb_charging_enabled(void)
96{
97 bool rc = false;
98 /* TODO: read the state of the GPOOD2 register...
99 * (this also means to set the irq level here) */
100 rc = pcf50606_usb_charging_enabled();
101
102 logf("usb charging %s", rc ? "enabled" : "disabled" );
103 return rc;
104}
70 105
71void ide_power_enable(bool on) 106void ide_power_enable(bool on)
72{ 107{
@@ -90,5 +125,3 @@ void power_off(void)
90 asm("halt"); 125 asm("halt");
91 while(1); 126 while(1);
92} 127}
93
94#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 @@
28#include "usb.h" 28#include "usb.h"
29 29
30#if CONFIG_TUNER 30#if CONFIG_TUNER
31
32bool tuner_power(bool status) 31bool tuner_power(bool status)
33{ 32{
34 (void)status; 33 (void)status;
@@ -44,10 +43,20 @@ void power_init(void)
44 or_b(0x20, &PBDRL); /* hold power */ 43 or_b(0x20, &PBDRL); /* hold power */
45} 44}
46 45
47bool charger_inserted(void) 46unsigned int power_input_status(void)
48{ 47{
48 unsigned int status = POWER_INPUT_NONE;
49
49 /* FM or V2 can also charge from the USB port */ 50 /* FM or V2 can also charge from the USB port */
50 return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF); 51 if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF)
52 status = POWER_INPUT_MAIN_CHARGER;
53
54#ifdef HAVE_USB_POWER
55 if (usb_detect() == USB_INSERTED)
56 status |= POWER_INPUT_USB_CHARGER;
57#endif
58
59 return status;
51} 60}
52 61
53/* Returns true if the unit is charging the batteries. */ 62/* 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)
31{ 31{
32} 32}
33 33
34bool charger_inserted(void) 34unsigned int power_input_status(void)
35{ 35{
36 /* Player */ 36 /* Player */
37 return (PADR & 1) == 0; 37 return ((PADR & 1) == 0) ?
38 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
38} 39}
39 40
40void ide_power_enable(bool on) 41void 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)
36 charger_enable(false); /* Default to charger OFF */ 36 charger_enable(false); /* Default to charger OFF */
37} 37}
38 38
39bool charger_inserted(void) 39unsigned int power_input_status(void)
40{ 40{
41 /* Recorder */ 41 /* Recorder */
42 return adc_read(ADC_EXT_POWER) > 0x100; 42 return (adc_read(ADC_EXT_POWER) > 0x100) ?
43 POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
43} 44}
44 45
45void charger_enable(bool on) 46void charger_enable(bool on)
diff --git a/firmware/usb.c b/firmware/usb.c
index 00e0bb3607..9d4bb00180 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -42,9 +42,6 @@
42#ifdef HAVE_USBSTACK 42#ifdef HAVE_USBSTACK
43#include "usb_core.h" 43#include "usb_core.h"
44#endif 44#endif
45#ifdef IRIVER_H300_SERIES
46#include "pcf50606.h" /* for pcf50606_usb_charging_... */
47#endif
48#include "logf.h" 45#include "logf.h"
49 46
50/* Conditions under which we want the entire driver */ 47/* Conditions under which we want the entire driver */
@@ -588,40 +585,6 @@ bool usb_powered(void)
588{ 585{
589 return usb_state == USB_POWERED; 586 return usb_state == USB_POWERED;
590} 587}
591
592#if CONFIG_CHARGING
593bool usb_charging_enable(bool on)
594{
595 bool rc = false;
596#ifdef IRIVER_H300_SERIES
597 int irqlevel;
598 logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
599 irqlevel = disable_irq_save();
600 pcf50606_set_usb_charging(on);
601 rc = on;
602 restore_irq(irqlevel);
603#else
604 /* TODO: implement it for other targets... */
605 (void)on;
606#endif
607 return rc;
608}
609
610bool usb_charging_enabled(void)
611{
612 bool rc = false;
613#ifdef IRIVER_H300_SERIES
614 /* TODO: read the state of the GPOOD2 register...
615 * (this also means to set the irq level here) */
616 rc = pcf50606_usb_charging_enabled();
617#else
618 /* TODO: implement it for other targets... */
619#endif
620
621 logf("usb charging %s", rc ? "enabled" : "disabled" );
622 return rc;
623}
624#endif
625#endif 588#endif
626 589
627#else 590#else