summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-05-07 16:10:03 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-05-08 13:17:16 -0700
commit41487381348ce30ac45f27b67af1dca013e2096c (patch)
tree8bc1d0d26a6d4bebe545c94d8832cb1ea7bca0da /baseboard
parent548e4d9708cc4402497ed290daf4df672114302c (diff)
downloadchrome-ec-41487381348ce30ac45f27b67af1dca013e2096c.tar.gz
yorp: renegotiate Vbus down before hibernating
When we support the lowest power mode for Nuvoton in the next spin, we will shed the TCPC/PPC power rail during hibernate. Before we drop the power for the PPCs we need to ensure that Vbus is lower than the hard-coded 6.8V dead-battery mode over-voltage threshold, otherwise we will lock ourselves out of power. BRANCH=none BUG=b:79218851 TEST=verified that yorp renegotiates Vbus to 5V when entering hibernate via ec `hibernate` cmd. Change-Id: I4a98573eefb5757eea02dc48c64d5f9358b5e0b7 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1047954 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r--baseboard/octopus/variant_ec_npcx796fb.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/baseboard/octopus/variant_ec_npcx796fb.c b/baseboard/octopus/variant_ec_npcx796fb.c
index f85184738d..6c839cbb10 100644
--- a/baseboard/octopus/variant_ec_npcx796fb.c
+++ b/baseboard/octopus/variant_ec_npcx796fb.c
@@ -5,9 +5,15 @@
/* Common code for VARIANT_OCTOPUS_EC_NPCX796FB configuration */
+#include "charge_manager.h"
+#include "chipset.h"
#include "gpio.h"
#include "i2c.h"
+#include "power.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
#include "util.h"
+#include "timer.h"
/******************************************************************************/
/* I2C port map configuration */
@@ -20,3 +26,43 @@ const struct i2c_port_t i2c_ports[] = {
{"sensor", I2C_PORT_SENSOR, 100, GPIO_I2C7_SCL, GPIO_I2C7_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+#define HIBERNATE_VBUS_LEVEL_MV 5000
+
+void board_hibernate(void)
+{
+ int port;
+
+ /*
+ * To support hibernate called from console commands, ectool commands
+ * and key sequence, shutdown the AP before hibernating.
+ */
+ chipset_force_shutdown();
+
+ /*
+ * If we are charging, then drop the Vbus level down to 5V to ensure
+ * that we don't get locked out of the 6.8V OVLO for our PPCs in
+ * dead-battery mode. This is needed when the TCPC/PPC rails go away.
+ * (b/79218851)
+ */
+ port = charge_manager_get_active_charge_port();
+ if (port != CHARGE_PORT_NONE)
+ pd_request_source_voltage(port, HIBERNATE_VBUS_LEVEL_MV);
+
+ /*
+ * Delay allows AP power state machine to settle down along
+ * with any PD contract renegotiation.
+ */
+ msleep(100);
+
+ for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) {
+ /*
+ * If Vbus isn't already on this port, then open the SNK path
+ * to allow AC to pass through to the charger when connected.
+ * This is need if the TCPC/PPC rails do not go away.
+ * (b/79173959)
+ */
+ if (!pd_is_vbus_present(port))
+ ppc_vbus_sink_enable(port, 1);
+ }
+}