summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Chen <marcochen@chromium.org>2019-05-21 20:41:44 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-24 21:13:58 -0700
commit3462b178484efa2e643b89291b3961e6aafca655 (patch)
tree39ae14a4b5af09562597df294421d07777a05b6d
parent6466d2fa96fd822ea09ab3c4fd43a1f2f58ec54a (diff)
downloadchrome-ec-3462b178484efa2e643b89291b3961e6aafca655.tar.gz
bobba: add blorb and droid into the support of controlling USB Type-A power.
Blorb and droid are first projects we are tyring to enable the control of USB Type-A power in the run time. This CL set inhibit_charging_in_suspend to USB_DISALLOW_SUSPEND_CHARGE in default and relies on OS to change this flag based on the status of USB device on the USB Type-A port. BUG=b:130767435 BRANCH=octopus TEST=1. `make BOARD=bobba -j4` 2. check power of USB Type-A port is disabled when OS gets into S0iX and no any USB device is ever connected to DUT. Change-Id: I19ff69df89a857cd3feb594641b6562f20356879 Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621451 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>
-rw-r--r--board/bobba/board.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/board/bobba/board.c b/board/bobba/board.c
index 15cf0c3003..32b79e886e 100644
--- a/board/bobba/board.c
+++ b/board/bobba/board.c
@@ -39,6 +39,7 @@
#include "tcpci.h"
#include "temp_sensor.h"
#include "thermistor.h"
+#include "usb_charge.h"
#include "usb_mux.h"
#include "usbc_ppc.h"
#include "util.h"
@@ -301,6 +302,39 @@ static void board_update_no_keypad_config_from_sku(void)
}
}
+static void board_usb_charge_mode_init(void)
+{
+ int i;
+
+ /*
+ * Only overriding the USB_DISALLOW_SUSPEND_CHARGE in RO is enough because
+ * USB_SYSJUMP_TAG preserves the settings to RW. And we should honor to it.
+ */
+ if (system_jumped_to_this_image())
+ return;
+
+ /* Currently only blorb and droid support this feature. */
+ if ((sku_id < 32 || sku_id > 39) && (sku_id < 40 || sku_id > 47))
+ return;
+
+ /*
+ * By default, turn the charging off when system suspends.
+ * If system power on with connecting a USB device,
+ * the OS must send an event to EC to clear the
+ * inhibit_charging_in_suspend.
+ */
+ for (i = 0; i < CONFIG_USB_PORT_POWER_SMART_PORT_COUNT; i++)
+ usb_charge_set_mode(i, CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE,
+ USB_DISALLOW_SUSPEND_CHARGE);
+}
+/*
+ * usb_charge_init() is hooked in HOOK_PRIO_DEFAULT and set inhibit_charge to
+ * USB_ALLOW_SUSPEND_CHARGE. As a result, in order to override this default
+ * setting to USB_DISALLOW_SUSPEND_CHARGE this function should be hooked after
+ * calling usb_charge_init().
+ */
+DECLARE_HOOK(HOOK_INIT, board_usb_charge_mode_init, HOOK_PRIO_DEFAULT + 1);
+
/* Read CBI from i2c eeprom and initialize variables for board variants */
static void cbi_init(void)
{