summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Chen <marcochen@google.com>2019-05-21 21:16:45 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-24 21:14:00 -0700
commit65e137d416970043463d00905f96f7590e847fbe (patch)
tree0704cf8be3192a0ea0ef8efe6618242d59a5ba7b
parent583f6db2d7c22c402c260531c1834c9db39d974a (diff)
downloadchrome-ec-65e137d416970043463d00905f96f7590e847fbe.tar.gz
usb_port_power_smart: support a new usb_charge_mode - USB_CHARGE_MODE_DEFAULT.
OS can leverage `ectool usbchargemode` to control the usb_charge_mode in the EC. In this case, we might want to set mode back to the default one defined in the config of board level therefore the new usb_charge_mode is added for this purpose. BUG=b:130767435 BRANCH=octopus TEST=1. make -j buildall 2. ectool usbchargemode 0 0x5 0 3. usb charging mode is set to CDP in Octopus board Change-Id: Ib7397993fc49e6c744dc55b9adace95dd6b8bd3a Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621452 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-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.
*