diff options
author | Diana Z <dzigterman@chromium.org> | 2021-05-27 16:03:52 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-07 18:07:00 +0000 |
commit | 43fffb5b0292ee1c48015b04ea55793a140d8177 (patch) | |
tree | d76e64b8bdf2d1ea028ac7c5a7f6e6e906adec75 /driver | |
parent | 3cd96f783607823625843bc248343b049344785e (diff) | |
download | chrome-ec-43fffb5b0292ee1c48015b04ea55793a140d8177.tar.gz |
TCPCI: Add OCP reporting
If a TCPC supports OCP and the TCPC has reported OCP in its fault
register, assume we should report this to the OCP module. Additionally,
enable fault alerts for all TCPCI TCPCs.
BRANCH=None
BUG=b:174334068
TEST=on galtic, verify OCP events are reported when current is
overdrawn
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I1a13b4a0869d8917f8660fd356d43c28e0e43814
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2923237
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/tcpci.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 6e73f2be72..021afc070f 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -116,6 +116,9 @@ static int tcpc_vbus[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Cached RP role values */ static int cached_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; +/* Cache our Device Capabilities at init for later reference */ +static int dev_cap_1[CONFIG_USB_PD_PORT_MAX_COUNT]; + #ifdef CONFIG_USB_PD_TCPC_LOW_POWER int tcpc_addr_write(int port, int i2c_addr, int reg, int val) { @@ -314,7 +317,8 @@ static int init_alert_mask(int port) */ mask = TCPC_REG_ALERT_TX_SUCCESS | TCPC_REG_ALERT_TX_FAILED | TCPC_REG_ALERT_TX_DISCARDED | TCPC_REG_ALERT_RX_STATUS | - TCPC_REG_ALERT_RX_HARD_RST | TCPC_REG_ALERT_CC_STATUS + TCPC_REG_ALERT_RX_HARD_RST | TCPC_REG_ALERT_CC_STATUS | + TCPC_REG_ALERT_FAULT #ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC | TCPC_REG_ALERT_POWER_STATUS #endif @@ -1058,6 +1062,12 @@ static int tcpci_handle_fault(int port, int fault) last_write_op[port].mask & 0xFFFF); } + /* Report overcurrent to the OCP module if enabled */ + if ((dev_cap_1[port] & TCPC_REG_DEV_CAP_1_VBUS_OCP_REPORTING) && + IS_ENABLED(CONFIG_USBC_OCP) && + (fault & TCPC_REG_FAULT_STATUS_VBUS_OVER_CURRENT)) + pd_handle_overcurrent(port); + if (tcpc_config[port].drv->handle_fault) rv = tcpc_config[port].drv->handle_fault(port, fault); @@ -1447,6 +1457,9 @@ int tcpci_tcpm_init(int port) /* Read chip info here when we know the chip is awake. */ tcpm_get_chip_info(port, 1, NULL); + /* Cache our device capabilities for future reference */ + tcpc_read16(port, TCPC_REG_DEV_CAP_1, &dev_cap_1[port]); + return EC_SUCCESS; } |