summaryrefslogtreecommitdiff
path: root/firmware/powermgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r--firmware/powermgmt.c24
1 files changed, 18 insertions, 6 deletions
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: