mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
charger: Add CONFIG_CHARGE_STATE_DEBUG
Servo / Suzy-Q related debugging methods is a big challenge in factory especially after servo debug header is removed. Expose some information to OS from EC will do a great help for massive production. + expose charge/battery related state to ectool 1. chg_ctl_mode 2. manual_mode 3. battery_seems_to_be_dead 4. battery_seems_to_be_disconnected 5. battery_was_removed 6. disch_on_ac (learn mode state) BUG=b:65265543 BRANCH=master TEST=`ectool chargestate param 0x20000~0x20006 get correct state` Change-Id: Ic2ed38e2eb9def01be29729fa1fe1959eb73fe43 Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/646412 Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
@@ -1208,6 +1208,14 @@ static int charge_command_charge_state(struct host_cmd_handler_args *args)
|
||||
rv = charger_profile_override_get_param(
|
||||
in->get_param.param, &val);
|
||||
} else
|
||||
#endif
|
||||
#ifdef CONFIG_CHARGE_STATE_DEBUG
|
||||
/* debug params */
|
||||
if (in->get_param.param >= CS_PARAM_DEBUG_MIN &&
|
||||
in->get_param.param <= CS_PARAM_DEBUG_MAX) {
|
||||
rv = charge_get_charge_state_debug(
|
||||
in->get_param.param, &val);
|
||||
} else
|
||||
#endif
|
||||
/* standard params */
|
||||
switch (in->get_param.param) {
|
||||
@@ -1357,3 +1365,31 @@ static int command_chgstate(int argc, char **argv)
|
||||
DECLARE_CONSOLE_COMMAND(chgstate, command_chgstate,
|
||||
"[idle|discharge|debug on|off]",
|
||||
"Get/set charge state machine status");
|
||||
|
||||
#ifdef CONFIG_CHARGE_STATE_DEBUG
|
||||
int charge_get_charge_state_debug(int param, uint32_t *value)
|
||||
{
|
||||
switch (param) {
|
||||
case CS_PARAM_DEBUG_CTL_MODE:
|
||||
*value = chg_ctl_mode;
|
||||
break;
|
||||
case CS_PARAM_DEBUG_MANUAL_MODE:
|
||||
*value = manual_mode;
|
||||
break;
|
||||
case CS_PARAM_DEBUG_SEEMS_DEAD:
|
||||
*value = battery_seems_to_be_dead;
|
||||
break;
|
||||
case CS_PARAM_DEBUG_SEEMS_DISCONNECTED:
|
||||
*value = battery_seems_to_be_disconnected;
|
||||
break;
|
||||
case CS_PARAM_DEBUG_BATT_REMOVED:
|
||||
*value = battery_was_removed;
|
||||
break;
|
||||
default:
|
||||
*value = 0;
|
||||
return EC_ERROR_INVAL;
|
||||
}
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -50,5 +50,16 @@ struct charge_state_data {
|
||||
*/
|
||||
int charge_set_input_current_limit(int ma, int mv);
|
||||
|
||||
/*
|
||||
* Expose charge/battery related state
|
||||
*
|
||||
* @param param command to get corresponding data
|
||||
* @param value the corresponding data
|
||||
* @return EC_SUCCESS or error
|
||||
*/
|
||||
#ifdef CONFIG_CHARGE_STATE_DEBUG
|
||||
int charge_get_charge_state_debug(int param, uint32_t *value);
|
||||
#endif /* CONFIG_CHARGE_STATE_DEBUG */
|
||||
|
||||
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
|
||||
|
||||
|
||||
@@ -318,6 +318,12 @@
|
||||
*/
|
||||
#undef CONFIG_BATTERY_LEVEL_NEAR_FULL
|
||||
|
||||
/*
|
||||
* Expose some data when it is needed.
|
||||
* For example, battery disconnect state
|
||||
*/
|
||||
#undef CONFIG_CHARGE_STATE_DEBUG
|
||||
|
||||
/* Include support for Bluetooth LE */
|
||||
#undef CONFIG_BLUETOOTH_LE
|
||||
|
||||
|
||||
@@ -3473,6 +3473,15 @@ enum charge_state_params {
|
||||
CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
|
||||
CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
|
||||
|
||||
/* Range for CONFIG_CHARGE_STATE_DEBUG params */
|
||||
CS_PARAM_DEBUG_MIN = 0x20000,
|
||||
CS_PARAM_DEBUG_CTL_MODE = 0x20000,
|
||||
CS_PARAM_DEBUG_MANUAL_MODE,
|
||||
CS_PARAM_DEBUG_SEEMS_DEAD,
|
||||
CS_PARAM_DEBUG_SEEMS_DISCONNECTED,
|
||||
CS_PARAM_DEBUG_BATT_REMOVED,
|
||||
CS_PARAM_DEBUG_MAX = 0x2ffff,
|
||||
|
||||
/* Other custom param ranges go here... */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user