diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-03-15 14:58:15 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-03-15 15:01:11 +0100 |
commit | a4fd5bf7cb3d8d071c5fb9d45255c8f85e517b7a (patch) | |
tree | 5c35337c12a983e7155f517aac6c1496225ef849 | |
parent | 5edae54e0d11e810040380aace455af7ec7c8d08 (diff) | |
download | rockbox-a4fd5bf7cb3d8d071c5fb9d45255c8f85e517b7a.tar.gz rockbox-a4fd5bf7cb3d8d071c5fb9d45255c8f85e517b7a.zip |
imx233: enable charging in bootloader USB mode by including powermgmt
Change-Id: I8b91b3ab60cb9ffaa127333e9bcef8c33be742fa
-rw-r--r-- | bootloader/imx233.c | 13 | ||||
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/powermgmt.c | 6 |
3 files changed, 18 insertions, 3 deletions
diff --git a/bootloader/imx233.c b/bootloader/imx233.c index 2380dfae5b..6d356b9cce 100644 --- a/bootloader/imx233.c +++ b/bootloader/imx233.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "system-target.h" | 39 | #include "system-target.h" |
40 | #include "fmradio_i2c.h" | 40 | #include "fmradio_i2c.h" |
41 | #include "version.h" | 41 | #include "version.h" |
42 | #include "powermgmt.h" | ||
42 | 43 | ||
43 | #include "usb.h" | 44 | #include "usb.h" |
44 | 45 | ||
@@ -81,6 +82,8 @@ static void usb_mode(int connect_timeout) | |||
81 | { | 82 | { |
82 | /* Got the message - wait for disconnect */ | 83 | /* Got the message - wait for disconnect */ |
83 | printf("Bootloader USB mode"); | 84 | printf("Bootloader USB mode"); |
85 | /* Enable power management to charge */ | ||
86 | powermgmt_init(); | ||
84 | 87 | ||
85 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | 88 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
86 | 89 | ||
@@ -89,6 +92,16 @@ static void usb_mode(int connect_timeout) | |||
89 | button = button_get_w_tmo(HZ/2); | 92 | button = button_get_w_tmo(HZ/2); |
90 | if(button == SYS_USB_DISCONNECTED) | 93 | if(button == SYS_USB_DISCONNECTED) |
91 | break; | 94 | break; |
95 | struct imx233_powermgmt_info_t info = imx233_powermgmt_get_info(); | ||
96 | lcd_putsf(0, 7, "Charging status: %s", | ||
97 | info.state == CHARGE_STATE_DISABLED ? "disabled" : | ||
98 | info.state == CHARGE_STATE_ERROR ? "error" : | ||
99 | info.state == DISCHARGING ? "discharging" : | ||
100 | info.state == TRICKLE ? "trickle" : | ||
101 | info.state == TOPOFF ? "topoff" : | ||
102 | info.state == CHARGING ? "charging" : "<unknown>"); | ||
103 | lcd_putsf(0, 8, "Battery: %d%%", battery_level()); | ||
104 | lcd_update(); | ||
92 | } | 105 | } |
93 | } | 106 | } |
94 | 107 | ||
diff --git a/firmware/SOURCES b/firmware/SOURCES index 9b0f83d0ed..a791cbbc94 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1335,9 +1335,9 @@ target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |||
1335 | target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c | 1335 | target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c |
1336 | target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c | 1336 | target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c |
1337 | target/arm/imx233/sansa-fuzeplus/adc-fuzeplus.c | 1337 | target/arm/imx233/sansa-fuzeplus/adc-fuzeplus.c |
1338 | target/arm/imx233/sansa-fuzeplus/powermgmt-fuzeplus.c | ||
1338 | #ifndef BOOTLOADER | 1339 | #ifndef BOOTLOADER |
1339 | target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c | 1340 | target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c |
1340 | target/arm/imx233/sansa-fuzeplus/powermgmt-fuzeplus.c | ||
1341 | #endif | 1341 | #endif |
1342 | #endif | 1342 | #endif |
1343 | 1343 | ||
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index b31dc81624..379b91ca13 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -889,9 +889,9 @@ void set_keypress_restarts_sleep_timer(bool enable) | |||
889 | sleeptimer_key_restarts = enable; | 889 | sleeptimer_key_restarts = enable; |
890 | } | 890 | } |
891 | 891 | ||
892 | #ifndef BOOTLOADER | ||
892 | static void handle_sleep_timer(void) | 893 | static void handle_sleep_timer(void) |
893 | { | 894 | { |
894 | #ifndef BOOTLOADER | ||
895 | if (!sleeptimer_active) | 895 | if (!sleeptimer_active) |
896 | return; | 896 | return; |
897 | 897 | ||
@@ -912,8 +912,8 @@ static void handle_sleep_timer(void) | |||
912 | sys_poweroff(); | 912 | sys_poweroff(); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | #endif /* BOOTLOADER */ | ||
916 | } | 915 | } |
916 | #endif /* BOOTLOADER */ | ||
917 | 917 | ||
918 | /* | 918 | /* |
919 | * We shut off in the following cases: | 919 | * We shut off in the following cases: |
@@ -929,6 +929,7 @@ static void handle_sleep_timer(void) | |||
929 | */ | 929 | */ |
930 | void handle_auto_poweroff(void) | 930 | void handle_auto_poweroff(void) |
931 | { | 931 | { |
932 | #ifndef BOOTLOADER | ||
932 | long timeout = poweroff_timeout*60*HZ; | 933 | long timeout = poweroff_timeout*60*HZ; |
933 | int audio_stat = audio_status(); | 934 | int audio_stat = audio_status(); |
934 | long tick = current_tick; | 935 | long tick = current_tick; |
@@ -968,4 +969,5 @@ void handle_auto_poweroff(void) | |||
968 | } | 969 | } |
969 | } else | 970 | } else |
970 | handle_sleep_timer(); | 971 | handle_sleep_timer(); |
972 | #endif | ||
971 | } | 973 | } |