summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usb_port_power_smart.c13
-rw-r--r--include/ec_commands.h28
-rw-r--r--include/usb_charge.h23
3 files changed, 30 insertions, 34 deletions
diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c
index d37b218709..a7ef9cc3bc 100644
--- a/common/usb_port_power_smart.c
+++ b/common/usb_port_power_smart.c
@@ -107,6 +107,9 @@ int usb_charge_set_mode(int port_id, enum usb_charge_mode mode,
if (port_id >= CONFIG_USB_PORT_POWER_SMART_PORT_COUNT)
return EC_ERROR_INVAL;
+ if (mode == USB_CHARGE_MODE_DEFAULT)
+ mode = CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE;
+
switch (mode) {
case USB_CHARGE_MODE_DISABLED:
usb_charge_set_enabled(port_id, 0);
@@ -177,16 +180,6 @@ static int command_set_mode(int argc, char **argv)
DECLARE_CONSOLE_COMMAND(usbchargemode, command_set_mode,
"[<port> <0 | 1 | 2 | 3> [<0 | 1>]]",
"Set USB charge mode");
-/*
- * Modes:
- * 0 = Disabled.
- * 1 = Standard downstream port.
- * 2 = Charging downstream port, BC 1.2.
- * 3 = Dedicated charging port, BC 1.2.
- * Inhibit Charge:
- * 0 = Enable charging during system suspend
- * 1 = Disable charging during system suspend
- */
/*****************************************************************************/
/* Host commands */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index f4ee6d1103..5cfd86e97a 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -2874,10 +2874,34 @@ struct ec_params_config_power_button {
/* Set USB port charging mode */
#define EC_CMD_USB_CHARGE_SET_MODE 0x0030
+enum usb_charge_mode {
+ /* Disable USB port. */
+ USB_CHARGE_MODE_DISABLED,
+ /* Set USB port to Standard Downstream Port, USB 2.0 mode. */
+ USB_CHARGE_MODE_SDP2,
+ /* Set USB port to Charging Downstream Port, BC 1.2. */
+ USB_CHARGE_MODE_CDP,
+ /* Set USB port to Dedicated Charging Port, BC 1.2. */
+ USB_CHARGE_MODE_DCP_SHORT,
+ /* Enable USB port (for dumb ports). */
+ USB_CHARGE_MODE_ENABLED,
+ /* Set USB port to CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE. */
+ USB_CHARGE_MODE_DEFAULT,
+
+ USB_CHARGE_MODE_COUNT
+};
+
+enum usb_suspend_charge {
+ /* Enable charging in suspend */
+ USB_ALLOW_SUSPEND_CHARGE,
+ /* Disable charging in suspend */
+ USB_DISALLOW_SUSPEND_CHARGE
+};
+
struct ec_params_usb_charge_set_mode {
uint8_t usb_port_id;
- uint8_t mode:7;
- uint8_t inhibit_charge:1;
+ uint8_t mode:7; /* enum usb_charge_mode */
+ uint8_t inhibit_charge:1; /* enum usb_suspend_charge */
} __ec_align1;
/*****************************************************************************/
diff --git a/include/usb_charge.h b/include/usb_charge.h
index 6b83a1c52f..06e79733de 100644
--- a/include/usb_charge.h
+++ b/include/usb_charge.h
@@ -9,34 +9,13 @@
#define __CROS_EC_USB_CHARGE_H
#include "common.h"
+#include "ec_commands.h"
/* USB charger voltage */
#define USB_CHARGER_VOLTAGE_MV 5000
/* USB charger minimum current */
#define USB_CHARGER_MIN_CURR_MA 500
-enum usb_charge_mode {
- /* Disable USB port. */
- USB_CHARGE_MODE_DISABLED,
- /* Set USB port to Standard Downstream Port, USB 2.0 mode. */
- USB_CHARGE_MODE_SDP2,
- /* Set USB port to Charging Downstream Port, BC 1.2. */
- USB_CHARGE_MODE_CDP,
- /* Set USB port to Dedicated Charging Port, BC 1.2. */
- USB_CHARGE_MODE_DCP_SHORT,
- /* Enable USB port (for dumb ports). */
- USB_CHARGE_MODE_ENABLED,
-
- USB_CHARGE_MODE_COUNT
-};
-
-enum usb_suspend_charge {
- /* Enable charging in suspend */
- USB_ALLOW_SUSPEND_CHARGE,
- /* Disable charging in suspend */
- USB_DISALLOW_SUSPEND_CHARGE
-};
-
/**
* Set USB charge mode for the port.
*