summaryrefslogtreecommitdiff
path: root/board/liara
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-12-04 15:14:33 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-17 20:20:26 -0800
commitb264288756ab77c2ef7950b19bcca99a15e2d5ce (patch)
tree3f00ada91c2adc40fc14709670950a08cec3286d /board/liara
parent66d7782a7b20fd974b18baeefb5e79feae80fb40 (diff)
downloadchrome-ec-b264288756ab77c2ef7950b19bcca99a15e2d5ce.tar.gz
USB PD: PPC: Add overcurrent handling.
The Type-C Power Path Controllers provide overcurrent protection. This commit adds support into the USB PD task for overcurrent events while we are in source role. The USB PD 3.0 spec recommends that ports issue a hard reset when an overcurrent condition occurs on a port. Additionally, we'll allow a source port to overcurrent 3 times before latching off VBUS from the port entirely. The source path will be re-enabled after ~1s after each overcurrent event. BUG=b:69935262,b:114680657 BRANCH=None 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: Ib070f261e98264cd88725ebce7d10e0798267e3b Signed-off-by: Aseda Aboagye <aaboagye@google.com> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1286300 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807633 Commit-Ready: Karthikeyan Ramasubramanian <kramasub@chromium.org> Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/liara')
-rw-r--r--board/liara/board.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/board/liara/board.c b/board/liara/board.c
index 0e8a9abb5e..67e79d76c1 100644
--- a/board/liara/board.c
+++ b/board/liara/board.c
@@ -114,12 +114,14 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-void board_overcurrent_event(int port)
+void board_overcurrent_event(int port, int is_overcurrented)
{
enum gpio_signal signal = (port == 0) ? GPIO_USB_C0_OC_L
: GPIO_USB_C1_OC_L;
+ /* Note that the levels are inverted because the pin is active low. */
+ int lvl = is_overcurrented ? 0 : 1;
- gpio_set_level(signal, 0);
+ gpio_set_level(signal, lvl);
CPRINTS("p%d: overcurrent!", port);
}