summaryrefslogtreecommitdiff
path: root/firmware/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index 651c17a4b3..0a329ad624 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -44,6 +44,10 @@
44#ifdef TARGET_TREE 44#ifdef TARGET_TREE
45#include "usb-target.h" 45#include "usb-target.h"
46#endif 46#endif
47#ifdef IRIVER_H300_SERIES
48#include "pcf50606.h" /* for pcf50606_usb_charging_... */
49#endif
50#include "logf.h"
47 51
48extern void dbg_ports(void); /* NASTY! defined in apps/ */ 52extern void dbg_ports(void); /* NASTY! defined in apps/ */
49 53
@@ -487,6 +491,40 @@ bool usb_powered(void)
487{ 491{
488 return usb_state == USB_POWERED; 492 return usb_state == USB_POWERED;
489} 493}
494
495#ifdef CONFIG_CHARGING
496bool usb_charging_enable(bool on)
497{
498 bool rc = false;
499#ifdef IRIVER_H300_SERIES
500 int irqlevel;
501 logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
502 irqlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
503 pcf50606_set_usb_charging(on);
504 rc = on;
505 (void)set_irq_level(irqlevel);
506#else
507 /* TODO: implement it for other targets... */
508 (void)on;
509#endif
510 return rc;
511}
512
513bool usb_charging_enabled(void)
514{
515 bool rc = false;
516#ifdef IRIVER_H300_SERIES
517 /* TODO: read the state of the GPOOD2 register...
518 * (this also means to set the irq level here) */
519 rc = pcf50606_usb_charging_enabled();
520#else
521 /* TODO: implement it for other targets... */
522#endif
523
524 logf("usb_charging_enabled: %s\n", rc ? "true" : "false" );
525 return rc;
526}
527#endif
490#endif 528#endif
491 529
492#else 530#else