diff options
author | Steve Bavin <pondlife@pondlife.me> | 2007-02-01 10:47:22 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2007-02-01 10:47:22 +0000 |
commit | 338d94f4661643dcd4c6440aa1c12af6933da4a5 (patch) | |
tree | 966f0bf5dcc7f4ccb71c266317adedd5705c5d2f /firmware/target | |
parent | 73ee2379c5361126d6fb9754845fc9e249614e40 (diff) | |
download | rockbox-338d94f4661643dcd4c6440aa1c12af6933da4a5.tar.gz rockbox-338d94f4661643dcd4c6440aa1c12af6933da4a5.zip |
FS#4770 - Add USB charging for the H300 series
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12169 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/coldfire/iriver/h300/pcf50606-h300.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iriver/h300/pcf50606-h300.c b/firmware/target/coldfire/iriver/h300/pcf50606-h300.c index 3a67d541d3..7d101f7347 100644 --- a/firmware/target/coldfire/iriver/h300/pcf50606-h300.c +++ b/firmware/target/coldfire/iriver/h300/pcf50606-h300.c @@ -21,6 +21,9 @@ #include "kernel.h" #include "pcf50606.h" #include "button-target.h" +#include "logf.h" + +static bool usb_ch_enabled = false; /* These voltages were determined by measuring the output of the PCF50606 on a running H300, and verified by disassembling the original firmware */ @@ -70,6 +73,27 @@ static inline void enable_pmu_interrupts(void) or_l(0x03000000, &INTPRI5); /* INT38 - Priority 3 */ } +/* enables/disables USB charging + * ATTENTION: make sure to set the irq level + * to highest before calling this function! */ +void pcf50606_set_usb_charging(bool on) +{ + if (on) + pcf50606_write(0x39, 0x00); /* Set GPOOD2 to High-Z for USB Charge Enable */ + else + pcf50606_write(0x39, 0x07); /* Set GPOOD2 to pulled down to disable USB charging */ + + usb_ch_enabled = on; + + logf("pcf50606_set_usb_charging(%s)\n", on ? "on" : "off" ); +} + +bool pcf50606_usb_charging_enabled(void) +{ + /* TODO: read the state of the GPOOD2 register... */ + return usb_ch_enabled; +} + void pcf50606_init(void) { pcf50606_i2c_init(); @@ -82,6 +106,8 @@ void pcf50606_init(void) pcf50606_write(0x09, 0x05); /* USB and ON key debounce: 14ms */ pcf50606_write(0x29, 0x1C); /* Disable the unused MBC module */ + pcf50606_set_usb_charging(false); /* Disable USB charging atm. */ + pcf50606_write(0x35, 0x13); /* Backlight PWM = 512Hz 50/50 */ pcf50606_write(0x3a, 0x3b); /* PWM output on GPOOD1 */ |