mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 18:40:25 -04:00
usb: typec: tcpci: add vconn over current fault handling to maxim_core
Add TCPC_FAULT_STATUS_VCONN_OC constant and corresponding mask definition. Maxim TCPC is capable of detecting VConn over current faults, so add fault to alert mask. When a Vconn over current fault is triggered, put the port in an error recovery state via tcpm_port_error_recovery. Signed-off-by: RD Babiera <rdbabiera@google.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20231121203845.170234-6-rdbabiera@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
db9e547098
commit
5e4c8814a4
@@ -92,11 +92,16 @@ static void max_tcpci_init_regs(struct max_tcpci_chip *chip)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Vconn Over Current Protection */
|
||||
ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS_MASK, TCPC_FAULT_STATUS_MASK_VCONN_OC);
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
alert_mask = TCPC_ALERT_TX_SUCCESS | TCPC_ALERT_TX_DISCARDED | TCPC_ALERT_TX_FAILED |
|
||||
TCPC_ALERT_RX_HARD_RST | TCPC_ALERT_RX_STATUS | TCPC_ALERT_CC_STATUS |
|
||||
TCPC_ALERT_VBUS_DISCNCT | TCPC_ALERT_RX_BUF_OVF | TCPC_ALERT_POWER_STATUS |
|
||||
/* Enable Extended alert for detecting Fast Role Swap Signal */
|
||||
TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS;
|
||||
TCPC_ALERT_EXTND | TCPC_ALERT_EXTENDED_STATUS | TCPC_ALERT_FAULT;
|
||||
|
||||
ret = max_tcpci_write16(chip, TCPC_ALERT_MASK, alert_mask);
|
||||
if (ret < 0) {
|
||||
@@ -295,6 +300,19 @@ static irqreturn_t _max_tcpci_irq(struct max_tcpci_chip *chip, u16 status)
|
||||
}
|
||||
}
|
||||
|
||||
if (status & TCPC_ALERT_FAULT) {
|
||||
ret = max_tcpci_read8(chip, TCPC_FAULT_STATUS, ®_status);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = max_tcpci_write8(chip, TCPC_FAULT_STATUS, reg_status);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (reg_status & TCPC_FAULT_STATUS_VCONN_OC)
|
||||
tcpm_port_error_recovery(chip->port);
|
||||
}
|
||||
|
||||
if (status & TCPC_ALERT_EXTND) {
|
||||
ret = max_tcpci_read8(chip, TCPC_ALERT_EXTENDED, ®_status);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
|
||||
#define TCPC_ALERT_MASK 0x12
|
||||
#define TCPC_POWER_STATUS_MASK 0x14
|
||||
#define TCPC_FAULT_STATUS_MASK 0x15
|
||||
|
||||
#define TCPC_FAULT_STATUS_MASK 0x15
|
||||
#define TCPC_FAULT_STATUS_MASK_VCONN_OC BIT(1)
|
||||
|
||||
#define TCPC_EXTENDED_STATUS_MASK 0x16
|
||||
#define TCPC_EXTENDED_STATUS_MASK_VSAFE0V BIT(0)
|
||||
@@ -104,6 +106,7 @@
|
||||
|
||||
#define TCPC_FAULT_STATUS 0x1f
|
||||
#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7)
|
||||
#define TCPC_FAULT_STATUS_VCONN_OC BIT(1)
|
||||
|
||||
#define TCPC_ALERT_EXTENDED 0x21
|
||||
|
||||
|
||||
Reference in New Issue
Block a user