summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ec/google/chromeec/ec.c20
-rw-r--r--src/ec/google/chromeec/ec.h10
-rw-r--r--src/ec/google/chromeec/ec_commands.h10
3 files changed, 40 insertions, 0 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index b44fffe9bc..588d11528b 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -638,6 +638,26 @@ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type,
return 0;
}
+int google_chromeec_override_dedicated_charger_limit(u16 current_lim,
+ u16 voltage_lim)
+{
+ struct ec_params_dedicated_charger_limit p = {
+ .current_lim = current_lim,
+ .voltage_lim = voltage_lim,
+ };
+ struct chromeec_command cmd = {
+ .cmd_code = EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT,
+ .cmd_version = 0,
+ .cmd_data_in = &p,
+ .cmd_size_in = sizeof(p),
+ .cmd_data_out = NULL,
+ .cmd_size_out = 0,
+ .cmd_dev_index = 0,
+ };
+
+ return google_chromeec_command(&cmd);
+}
+
int google_chromeec_set_usb_pd_role(u8 port, enum usb_pd_control_role role)
{
struct ec_params_usb_pd_control req = {
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index 0b6f880909..e1bf6c8e76 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -91,6 +91,16 @@ int google_chromeec_set_usb_pd_role(u8 port, enum usb_pd_control_role role);
int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type,
u32 *max_watts);
+/*
+ * Set max current and voltage of a dedicated charger.
+ *
+ * @param current_lim Max current in mA
+ * @param voltage_lim Max voltage in mV
+ * @return non-zero for error, otherwise 0.
+ */
+int google_chromeec_override_dedicated_charger_limit(u16 current_lim,
+ u16 voltage_lim);
+
/* internal structure to send a command to the EC and wait for response. */
struct chromeec_command {
uint16_t cmd_code; /* command code in, status out */
diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h
index ee889b727b..0fbb1a6b8c 100644
--- a/src/ec/google/chromeec/ec_commands.h
+++ b/src/ec/google/chromeec/ec_commands.h
@@ -3533,6 +3533,16 @@ struct __ec_align2 ec_params_external_power_limit_v1 {
#define EC_POWER_LIMIT_NONE 0xffff
+/*
+ * Set maximum voltage & current of a dedicated charge port
+ */
+#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A3
+
+struct __ec_align2 ec_params_dedicated_charger_limit {
+ uint16_t current_lim; /* in mA */
+ uint16_t voltage_lim; /* in mV */
+};
+
/*****************************************************************************/
/* Hibernate/Deep Sleep Commands */