summaryrefslogtreecommitdiff
path: root/common/charger.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/charger.c')
-rw-r--r--common/charger.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/common/charger.c b/common/charger.c
index f9fd1c4640..e3d77976ae 100644
--- a/common/charger.c
+++ b/common/charger.c
@@ -359,6 +359,23 @@ int charger_is_sourcing_otg_power(int port)
return chg_chips[chgnum].drv->is_sourcing_otg_power(chgnum, port);
}
+enum ec_error_list charger_get_actual_current(int chgnum, int *current)
+{
+ /* Note: chgnum may be -1 if no active port is selected */
+ if (chgnum < 0)
+ return EC_ERROR_INVAL;
+
+ if (chgnum >= board_get_charger_chip_count()) {
+ CPRINTS("%s(%d) Invalid charger!", __func__, chgnum);
+ return EC_ERROR_INVAL;
+ }
+
+ if (!chg_chips[chgnum].drv->get_actual_current)
+ return EC_ERROR_UNIMPLEMENTED;
+
+ return chg_chips[chgnum].drv->get_actual_current(chgnum, current);
+}
+
enum ec_error_list charger_get_current(int chgnum, int *current)
{
/* Note: chgnum may be -1 if no active port is selected */
@@ -389,6 +406,22 @@ enum ec_error_list charger_set_current(int chgnum, int current)
return chg_chips[chgnum].drv->set_current(chgnum, current);
}
+enum ec_error_list charger_get_actual_voltage(int chgnum, int *voltage)
+{
+ if (chgnum < 0)
+ return EC_ERROR_INVAL;
+
+ if (chgnum >= board_get_charger_chip_count()) {
+ CPRINTS("%s(%d) Invalid charger!", __func__, chgnum);
+ return EC_ERROR_INVAL;
+ }
+
+ if (!chg_chips[chgnum].drv->get_actual_voltage)
+ return EC_ERROR_UNIMPLEMENTED;
+
+ return chg_chips[chgnum].drv->get_actual_voltage(chgnum, voltage);
+}
+
enum ec_error_list charger_get_voltage(int chgnum, int *voltage)
{
if (chgnum < 0)