summaryrefslogtreecommitdiff
path: root/board/nocturne
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/nocturne
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/nocturne')
-rw-r--r--board/nocturne/board.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index ffa8c65920..20b4b3983b 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -572,28 +572,29 @@ static void board_quirks(void)
}
DECLARE_HOOK(HOOK_INIT, board_quirks, HOOK_PRIO_DEFAULT);
-void board_overcurrent_event(int port)
+void board_overcurrent_event(int port, int is_overcurrented)
{
+ int lvl;
+
/* Sanity check the port. */
if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT))
return;
/* Note that the levels are inverted because the pin is active low. */
+ lvl = is_overcurrented ? 0 : 1;
+
switch (port) {
case 0:
- gpio_set_level(GPIO_USB_C0_OC_ODL, 0);
+ gpio_set_level(GPIO_USB_C0_OC_ODL, lvl);
break;
case 1:
- gpio_set_level(GPIO_USB_C1_OC_ODL, 0);
+ gpio_set_level(GPIO_USB_C1_OC_ODL, lvl);
break;
default:
return;
};
-
- /* TODO(b/69935262): Write a PD log entry for the OC event. */
- CPRINTS("C%d: overcurrent!", port);
}
static int read_gyro_sensor_temp(int idx, int *temp_ptr)