diff options
-rw-r--r-- | common/battery.c | 13 | ||||
-rw-r--r-- | common/charge_state_v2.c | 18 | ||||
-rw-r--r-- | common/charger.c | 11 | ||||
-rw-r--r-- | include/battery.h | 5 | ||||
-rw-r--r-- | include/charger.h | 3 |
5 files changed, 40 insertions, 10 deletions
diff --git a/common/battery.c b/common/battery.c index 20baa1e431..323f3d2790 100644 --- a/common/battery.c +++ b/common/battery.c @@ -209,6 +209,14 @@ static void print_battery_info(void) } } +void print_battery_debug(void) +{ + print_battery_status(); + print_battery_params(); + print_battery_strings(); + print_battery_info(); +} + static int command_battery(int argc, char **argv) { int repeat = 1; @@ -233,10 +241,7 @@ static int command_battery(int argc, char **argv) } for (loop = 0; loop < repeat; loop++) { - print_battery_status(); - print_battery_params(); - print_battery_strings(); - print_battery_info(); + print_battery_debug(); /* * Running with a high repeat count will take so long the diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index a5a621da8b..3109f23363 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -43,6 +43,7 @@ test_export_static timestamp_t shutdown_warning_time; static timestamp_t precharge_start_time; static int battery_seems_to_be_dead; static int problems_exist; +static int debugging; /* Track problems in communicating with the battery or charger */ enum problem_type { @@ -245,6 +246,7 @@ static void dump_charge_state(void) ccprintf(" manual_mode = %d\n", manual_mode); ccprintf(" user_current_limit = %dmA\n", user_current_limit); ccprintf(" battery_seems_to_be_dead = %d\n", battery_seems_to_be_dead); + ccprintf(" debug output = %s\n", debugging ? "on" : "off"); #undef DUMP } @@ -270,6 +272,15 @@ static void show_charging_progress(void) curr.batt.state_of_charge, minutes / 60, minutes % 60, to_full ? "to full" : "to empty"); + + if (debugging) { + ccprintf("battery:\n"); + print_battery_debug(); + ccprintf("charger:\n"); + print_charger_debug(); + ccprintf("chg:\n"); + dump_charge_state(); + } } /* @@ -917,6 +928,11 @@ static int command_chgstate(int argc, char **argv) rv = charge_force_idle(val); if (rv) return rv; + } else if (!strcasecmp(argv[1], "debug")) { + if (argc <= 2) + return EC_ERROR_PARAM_COUNT; + if (!parse_bool(argv[2], &debugging)) + return EC_ERROR_PARAM2; } else { /* maybe handle board_discharge_on_ac() too? */ return EC_ERROR_PARAM1; @@ -927,6 +943,6 @@ static int command_chgstate(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(chgstate, command_chgstate, - "[idle on|off]", + "[idle|debug on|off]", "Get/set charge state machine status", NULL); diff --git a/common/charger.c b/common/charger.c index 8a07a62818..36d81fd3d0 100644 --- a/common/charger.c +++ b/common/charger.c @@ -5,6 +5,7 @@ * Common functions for battery charging. */ +#include "battery_smart.h" #include "charger.h" #include "common.h" #include "console.h" @@ -114,7 +115,7 @@ static int check_print_error(int rv) return 0; } -static int print_info(void) +void print_charger_debug(void) { int d; const struct charger_info *info = charger_get_info(); @@ -165,8 +166,6 @@ static int print_info(void) ccprintf("%5d\n", dptf_limit_ma); else ccputs("disabled\n"); - - return EC_SUCCESS; } static int command_charger(int argc, char **argv) @@ -174,8 +173,10 @@ static int command_charger(int argc, char **argv) int d; char *e; - if (argc != 3) - return print_info(); + if (argc != 3) { + print_charger_debug(); + return EC_SUCCESS; + } if (strcasecmp(argv[1], "input") == 0) { d = strtoi(argv[2], &e, 0); diff --git a/include/battery.h b/include/battery.h index e395839546..b61da1833c 100644 --- a/include/battery.h +++ b/include/battery.h @@ -309,4 +309,9 @@ int battery_set_vendor_param(uint32_t param, uint32_t value); */ int battery_wait_for_stable(void); +/** + * Print all battery info for debugging purposes + */ +void print_battery_debug(void); + #endif /* __CROS_EC_BATTERY_H */ diff --git a/include/charger.h b/include/charger.h index bb84990856..8b65c388f3 100644 --- a/include/charger.h +++ b/include/charger.h @@ -107,5 +107,8 @@ int charger_device_id(int *id); int charger_get_option(int *option); int charger_set_option(int option); +/* Print all charger info for debugging purposes */ +void print_charger_debug(void); + #endif /* __CROS_EC_CHARGER_H */ |