From 029dc41acb2ed8d0aae79bfef8829312c68395dc Mon Sep 17 00:00:00 2001 From: Sam Hurst Date: Wed, 14 Dec 2022 11:44:32 -0800 Subject: [PATCH] drivers: usb_c: tcpc: stm32: Read UCPD Status Reg for source of IRQ At system startup, the SYSCFG ITLINE registers might not indicate an interrupt even though a UCPD interrupt is pending. This cause the ISR to be called repeatedly without being serviced, resulting in a system lockup. Reading the UCPD Status Reg instead of the SYSCFG ITLINE register fixes the issue. Signed-off-by: Sam Hurst --- drivers/usb_c/tcpc/ucpd_stm32.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb_c/tcpc/ucpd_stm32.c b/drivers/usb_c/tcpc/ucpd_stm32.c index b8e0db52a61..9083c244e5a 100644 --- a/drivers/usb_c/tcpc/ucpd_stm32.c +++ b/drivers/usb_c/tcpc/ucpd_stm32.c @@ -1023,15 +1023,24 @@ static void ucpd_isr(const struct device *dev_inst[]) */ uint32_t ucpd_base; + uint32_t sr0; + uint32_t sr1; /* * Since the UCPD peripherals share the same interrupt line, determine * which one generated the interrupt. */ - if (LL_SYSCFG_IsActiveFlag_UCPD1()) { + + /* Read UCPD1 Status Register */ + sr0 = LL_UCPD_ReadReg(((const struct tcpc_config *)dev_inst[0]->config)->ucpd_port, SR); + + /* Read UCPD2 Status Register */ + sr1 = LL_UCPD_ReadReg(((const struct tcpc_config *)dev_inst[1]->config)->ucpd_port, SR); + + if (sr0) { /* UCPD1 interrupt is pending */ ucpd_base = UCPD1_BASE; - } else if (LL_SYSCFG_IsActiveFlag_UCPD2()) { + } else if (sr1) { /* UCPD2 interrupt is pending */ ucpd_base = UCPD2_BASE; } else {