From ac97fea2d7cc5440798cc5de787be4b4c0fa5a68 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 7 Sep 2017 10:29:28 -0700 Subject: [PATCH] Fizz: Refuse PR swap when powered by USB-C port This patch makes EC refuse PR swap when the system is powered through the USB-C port because switching from SNK to SRC will cause the system to shut down. BUG=b:65481832 BRANCH=none TEST=Boot Fizz on USB-C and BJ. Change-Id: I52c5813adc1ea9b4e69e65599c1794ae43192a1e Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/655643 Reviewed-by: Vincent Palatin --- board/fizz/usb_pd_policy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/board/fizz/usb_pd_policy.c b/board/fizz/usb_pd_policy.c index 179f1ca862..036cf13c64 100644 --- a/board/fizz/usb_pd_policy.c +++ b/board/fizz/usb_pd_policy.c @@ -128,6 +128,9 @@ int pd_board_checks(void) int pd_check_power_swap(int port) { + /* If type-c port is supplying power, we never swap PR (to source) */ + if (port == charge_manager_get_active_charge_port()) + return 0; /* * Allow power swap as long as we are acting as a dual role device, * otherwise assume our role is fixed (not in S0 or console command @@ -253,7 +256,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, static void board_charge_manager_init(void) { - int input_voltage, input_port; + int input_voltage; + enum charge_port input_port; int i, j; struct charge_port_info cpi = { .voltage = USB_CHARGER_VOLTAGE_MV,