mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Add charger_get_params() function to query charger state.
This returns all the parameters of the charger that must be monitored frequently. While some of the fields are charger-specific, all of the parameters are present in all supported chargers. Nothing uses this yet. BUG=chrome-os-partner:20881 BRANCH=ToT TEST=make buildall -j All targets build; all tests pass. Change-Id: Id3e00532469b193aeab3acf93e94afe3ffb8c6b6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191985 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
@@ -36,7 +36,7 @@ const struct charger_info *charger_get_info(void)
|
||||
}
|
||||
|
||||
|
||||
int charger_get_status(int *status)
|
||||
int charger_get_status(int *status)
|
||||
{
|
||||
*status = CHARGER_LEVEL_2;
|
||||
if (mock_option & CHARGE_FLAG_INHIBIT_CHARGE)
|
||||
|
||||
@@ -96,6 +96,26 @@ int charger_closest_current(int current)
|
||||
return current - (current % info->current_step);
|
||||
}
|
||||
|
||||
void charger_get_params(struct charger_params *chg)
|
||||
{
|
||||
memset(chg, 0, sizeof(*chg));
|
||||
|
||||
if (charger_get_current(&chg->current))
|
||||
chg->flags |= CHG_FLAG_BAD_CURRENT;
|
||||
|
||||
if (charger_get_voltage(&chg->voltage))
|
||||
chg->flags |= CHG_FLAG_BAD_VOLTAGE;
|
||||
|
||||
if (charger_get_input_current(&chg->input_current))
|
||||
chg->flags |= CHG_FLAG_BAD_INPUT_CURRENT;
|
||||
|
||||
if (charger_get_status(&chg->status))
|
||||
chg->flags |= CHG_FLAG_BAD_STATUS;
|
||||
|
||||
if (charger_get_option(&chg->option))
|
||||
chg->flags |= CHG_FLAG_BAD_OPTION;
|
||||
}
|
||||
|
||||
static void print_item_name(const char *name)
|
||||
{
|
||||
ccprintf(" %-8s", name);
|
||||
|
||||
@@ -27,21 +27,41 @@ struct charger_info {
|
||||
uint16_t input_current_step;
|
||||
};
|
||||
|
||||
/*
|
||||
* Parameters common to all chargers. Current is in mA, voltage in mV.
|
||||
* The status and option values are charger-specific.
|
||||
*/
|
||||
struct charger_params {
|
||||
int current;
|
||||
int voltage;
|
||||
int input_current;
|
||||
int status;
|
||||
int option;
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Get the current charger_params. Failures are reported in .flags */
|
||||
void charger_get_params(struct charger_params *chg);
|
||||
|
||||
/* Bits to indicate which fields of struct charger_params could not be read */
|
||||
#define CHG_FLAG_BAD_CURRENT 0x00000001
|
||||
#define CHG_FLAG_BAD_VOLTAGE 0x00000002
|
||||
#define CHG_FLAG_BAD_INPUT_CURRENT 0x00000004
|
||||
#define CHG_FLAG_BAD_STATUS 0x00000008
|
||||
#define CHG_FLAG_BAD_OPTION 0x00000010
|
||||
/* All of the above CHG_FLAG_BAD_* bits */
|
||||
#define CHG_FLAG_BAD_ANY 0x0000001f
|
||||
|
||||
/* Power state machine post init */
|
||||
int charger_post_init(void);
|
||||
|
||||
/* Get charger information. */
|
||||
const struct charger_info *charger_get_info(void);
|
||||
|
||||
/* Get smart battery charger status. Supported flags:
|
||||
* CHARGER_CHARGE_INHIBITED
|
||||
* CHARGER_LEVEL_2
|
||||
*/
|
||||
/* Get smart battery charger status. Supported flags may vary. */
|
||||
int charger_get_status(int *status);
|
||||
|
||||
/* Set smart battery charger mode. Supported mode(s):
|
||||
* CHARGER_FLAG_INHIBIT_CHARGE
|
||||
*/
|
||||
/* Set smart battery charger mode. Supported modes may vary. */
|
||||
int charger_set_mode(int mode);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user