From c659f3d8d74fb5c43560f63370417b81be796539 Mon Sep 17 00:00:00 2001 From: Sam Hurst Date: Wed, 14 Dec 2022 11:48:04 -0800 Subject: [PATCH] drivers: usb_c: tcpc: stm32: Enable ISR after all UCPD devices initialized Since all UCPD devices share the same ISR, the interrupt should be enabled after all UCPD devices are initialized. Signed-off-by: Sam Hurst --- drivers/usb_c/tcpc/ucpd_stm32.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/usb_c/tcpc/ucpd_stm32.c b/drivers/usb_c/tcpc/ucpd_stm32.c index 53e030a869d..f009a5d4819 100644 --- a/drivers/usb_c/tcpc/ucpd_stm32.c +++ b/drivers/usb_c/tcpc/ucpd_stm32.c @@ -20,11 +20,6 @@ LOG_MODULE_REGISTER(ucpd_stm32, CONFIG_USBC_LOG_LEVEL); #include "ucpd_stm32_priv.h" -/** - * @brief Zephyr has difficulty with shared interrupt. This flag is used to - * configure a shared interrupt once and is set to false afterwards. - */ -static bool init_irq = true; static void config_tcpc_irq(void); /** @@ -1337,12 +1332,12 @@ static const struct tcpc_driver_api driver_api = { #define DEV_INST_INIT(n) dev_inst[n] = DEVICE_DT_INST_GET(n); static void config_tcpc_irq(void) { + static int inst_num; static const struct device *dev_inst[DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT)]; - if (init_irq) { - /* Only configure IRQ line once */ - init_irq = false; + /* Initialize and enable shared irq on last instance */ + if (++inst_num == DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT)) { DT_INST_FOREACH_STATUS_OKAY(DEV_INST_INIT) IRQ_CONNECT(DT_INST_IRQN(0),