From 82dbe746f3e0da4b5000d6ff0934137338da2db2 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Mon, 14 Jan 2019 13:05:11 -0700 Subject: board/octopus: Notify SoC about USB overcurrent Add board_overcurrent_event function to notify SoC about USB-C overcurrent events. BUG=b:115475862 BRANCH=octopus TEST=Boot to ChromeOS in grabbiter. No overcurrent events reported when the sink is drawing <= 3.20 A. Overcurrent events are reported when the sink is drawing > 3.25 A. After 3 reports, the port is latched off and power delivery is stopped. The port is re-enabled only after the sink is disconnected. Also when the sink is drawing current at 3.24 A, there is one report of overcurrent. The port gets disabled in response to that event. But the port is re-enabled after 1 second since overcurrent event is reported only once. After the port is re-enabled, the sink is able to draw the set current. When the overcurrent event is reported, I can see in the kernel logs that the overcurrent condition is detected by the kernel. EC Logs: [3391.984462 C1: PPC detected Vbus overcurrent!] [3391.984953 C1: overcurrent!] [3392.044935 C1: PPC detected Vbus overcurrent!] [3392.045425 C1: overcurrent!] [3392.061404 C1: PPC detected Vbus overcurrent!] [3392.061894 C1: overcurrent!] [3392.062142 C1: OC event limit reached! Source path disabled until physical disconnect.] [3392.077226 C1: PPC detected Vbus overcurrent!] [3392.077532 C1: overcurrent!] [3392.077891 C1: OC event limit reached! Source path disabled until physical disconnect.] [3392.092660 C1: PPC detected Vbus overcurrent!] [3392.092966 C1: overcurrent!] [3392.093213 C1: OC event limit reached! Source path disabled until physical disconnect.] Kernel Logs: [ 3356.560456] usb usb2-port1: over-current condition [ 3356.768434] usb usb2-port2: over-current condition [ 3356.976446] usb usb2-port4: over-current condition [ 3357.184441] usb usb2-port5: over-current condition [ 3357.392445] usb usb2-port6: over-current condition Change-Id: I69fdc473a3489922517dc91fc1ea149aabca01cb Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://chromium-review.googlesource.com/1410142 Commit-Ready: Karthikeyan Ramasubramanian Tested-by: Karthikeyan Ramasubramanian Reviewed-by: Jett Rink --- board/bobba/board.c | 10 ++++++++++ board/casta/board.c | 9 +++++++++ board/fleex/board.c | 10 ++++++++++ board/meep/board.c | 10 ++++++++++ board/phaser/board.c | 10 ++++++++++ board/yorp/board.c | 10 ++++++++++ 6 files changed, 59 insertions(+) diff --git a/board/bobba/board.c b/board/bobba/board.c index 1b6ba2feec..9e20943afe 100644 --- a/board/bobba/board.c +++ b/board/bobba/board.c @@ -321,3 +321,13 @@ void lid_angle_peripheral_enable(int enable) keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE); } #endif + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} diff --git a/board/casta/board.c b/board/casta/board.c index d5dc8833bf..124601fa75 100644 --- a/board/casta/board.c +++ b/board/casta/board.c @@ -88,3 +88,12 @@ const struct temp_sensor_t temp_sensors[] = { }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} diff --git a/board/fleex/board.c b/board/fleex/board.c index c1d0f16bd6..879c4fc959 100644 --- a/board/fleex/board.c +++ b/board/fleex/board.c @@ -278,3 +278,13 @@ static void update_gpios_from_board_id(void) } DECLARE_HOOK(HOOK_INIT, update_gpios_from_board_id, HOOK_PRIO_INIT_I2C + 1); + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} diff --git a/board/meep/board.c b/board/meep/board.c index 85831cd85e..591e8758b9 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -330,3 +330,13 @@ const int keyboard_factory_scan_pins[][2] = { const int keyboard_factory_scan_pins_used = ARRAY_SIZE(keyboard_factory_scan_pins); #endif + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} diff --git a/board/phaser/board.c b/board/phaser/board.c index 94e58e4e0b..ee3c8601cb 100644 --- a/board/phaser/board.c +++ b/board/phaser/board.c @@ -300,3 +300,13 @@ static void board_chipset_suspend(void) sb_quick_charge_mode(1); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} diff --git a/board/yorp/board.c b/board/yorp/board.c index 1b2dccf4b1..0cfeccbd2e 100644 --- a/board/yorp/board.c +++ b/board/yorp/board.c @@ -240,3 +240,13 @@ static void post_old_board_warning(void) } DECLARE_HOOK(HOOK_INIT, post_old_board_warning, HOOK_PRIO_INIT_I2C + 1); #endif + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Sanity check the port. */ + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + return; + + /* Note that the level is inverted because the pin is active low. */ + gpio_set_level(GPIO_USB_C_OC, !is_overcurrented); +} -- cgit v1.2.1