summaryrefslogtreecommitdiff
path: root/driver/ppc
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-11-05 15:20:45 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-05-09 20:26:03 +0000
commit7577f53e8095247585aef0a310defae0e602a24b (patch)
treef453d07bf6007caf123e345f58bb7ed3477db34f /driver/ppc
parent195e9d6ea1e679a4b92a67b08373f93808167df6 (diff)
downloadchrome-ec-7577f53e8095247585aef0a310defae0e602a24b.tar.gz
sn5s330: Add VCONN overcurrent logging.
The TI SN5S330 has VCONN overcurrent protection and will automatically latch off VCONN if a port overcurrents it. Keeping VCONN latched off is allowed per the USB Type-C spec. This commit simply logs a message on the EC console such that it will be easier to tell when it happens. BUG=none BRANCH=firmware-nocturne-10984.B TEST=flash nocturne, plug in a Type-C adapter which overcurrents VCONN, verify that a console message indicating the overcurrent event is shown. Change-Id: I22da6e8d43ac7739dc213d5a1f049b98d7ee829d Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1328321 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1330162 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1603127 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'driver/ppc')
-rw-r--r--driver/ppc/sn5s330.c20
-rw-r--r--driver/ppc/sn5s330.h8
2 files changed, 28 insertions, 0 deletions
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index c73182ca81..ef63402b6b 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -329,6 +329,12 @@ static int sn5s330_init(int port)
}
/*
+ * Unmask the VCONN ILIM interrupt so we can print VCONN overcurrent
+ * events.
+ */
+ clr_flags(port, SN5S330_INT_MASK_RISE_REG2, SN5S330_VCONN_ILIM);
+
+ /*
* Don't proceed with the rest of initialization if we're sysjumping.
* We would have already done this before.
*/
@@ -664,6 +670,20 @@ static void sn5s330_handle_interrupt(int port)
write_reg(port, SN5S330_INT_TRIP_RISE_REG3, rise);
write_reg(port, SN5S330_INT_TRIP_FALL_REG3, fall);
#endif /* CONFIG_USB_PD_VBUS_DETECT_PPC && CONFIG_USB_CHARGER */
+
+ /*
+ * VCONN may be latched off due to an overcurrent. Indicate
+ * when the VCONN overcurrent happens.
+ */
+ read_reg(port, SN5S330_INT_TRIP_RISE_REG2, &rise);
+ read_reg(port, SN5S330_INT_TRIP_FALL_REG2, &fall);
+
+ if (rise & SN5S330_VCONN_ILIM)
+ CPRINTS("ppc p%d: VCONN OC!", port);
+
+ /* Clear the interrupt sources. */
+ write_reg(port, SN5S330_INT_TRIP_RISE_REG2, rise);
+ write_reg(port, SN5S330_INT_TRIP_FALL_REG2, fall);
}
}
diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h
index 039fbe68e4..c5b16ea73b 100644
--- a/driver/ppc/sn5s330.h
+++ b/driver/ppc/sn5s330.h
@@ -136,6 +136,14 @@ enum sn5s330_pp_idx {
#define SN5S330_ILIM_PP1_MASK (1 << 4)
/*
+ * INT_MASK_RISE/FALL_EDGE2
+ *
+ * The VCONN_ILIM bit indicates an overcurrent condition on VCONN. By default,
+ * VCONN will be latched off.
+ */
+#define SN5S330_VCONN_ILIM (1 << 1)
+
+/*
* INT_MASK_RISE/FALL_EDGE_3
*
* The VBUS_GOOD bit indicates VBUS has increased beyond a 4.0V threshold.