From 0d5ed7c306d01ac76549b748fb2f7db54a615196 Mon Sep 17 00:00:00 2001 From: Jori Rintahaka Date: Mon, 10 Mar 2025 12:46:56 +0200 Subject: [PATCH] drivers: bluetooth: hci: silabs: fix radio IRQ priorities Fix radio IRQ priorities. With the Controller update from SiSDK, its behavior changed so that it overwrites the IRQ priorities. Reconfigure the priorities after the Controller is initialized. Source interrupt numbers and priorities from devicetree. Also set the SYNTH IRQ priority on all HW, and set either the RDMAILBOX or HOSTMAILBOX IRQ depending on which one exists. Signed-off-by: Jori Rintahaka Signed-off-by: Aksel Skauge Mellbye --- drivers/bluetooth/hci/hci_silabs_efr32.c | 42 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/bluetooth/hci/hci_silabs_efr32.c b/drivers/bluetooth/hci/hci_silabs_efr32.c index b4eadcab9e2..7b7f880a016 100644 --- a/drivers/bluetooth/hci/hci_silabs_efr32.c +++ b/drivers/bluetooth/hci/hci_silabs_efr32.c @@ -55,20 +55,34 @@ void BTLE_LL_Process(uint32_t events); int16_t BTLE_LL_SetMaxPower(int16_t power); bool sli_pending_btctrl_events(void); +#define RADIO_IRQN(name) DT_IRQ_BY_NAME(DT_NODELABEL(radio), name, irq) +#define RADIO_IRQ_PRIO(name) DT_IRQ_BY_NAME(DT_NODELABEL(radio), name, priority) + void rail_isr_installer(void) { -#ifdef CONFIG_SOC_SERIES_EFR32MG24 - IRQ_CONNECT(SYNTH_IRQn, 0, SYNTH_IRQHandler, NULL, 0); -#else - IRQ_CONNECT(RDMAILBOX_IRQn, 0, RDMAILBOX_IRQHandler, NULL, 0); -#endif - IRQ_CONNECT(RAC_SEQ_IRQn, 0, RAC_SEQ_IRQHandler, NULL, 0); - IRQ_CONNECT(RAC_RSM_IRQn, 0, RAC_RSM_IRQHandler, NULL, 0); - IRQ_CONNECT(PROTIMER_IRQn, 0, PROTIMER_IRQHandler, NULL, 0); - IRQ_CONNECT(MODEM_IRQn, 0, MODEM_IRQHandler, NULL, 0); - IRQ_CONNECT(FRC_IRQn, 0, FRC_IRQHandler, NULL, 0); - IRQ_CONNECT(BUFC_IRQn, 0, BUFC_IRQHandler, NULL, 0); - IRQ_CONNECT(AGC_IRQn, 0, AGC_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(agc), RADIO_IRQ_PRIO(agc), AGC_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(bufc), RADIO_IRQ_PRIO(bufc), BUFC_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(frc_pri), RADIO_IRQ_PRIO(frc_pri), FRC_PRI_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(frc), RADIO_IRQ_PRIO(frc), FRC_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(modem), RADIO_IRQ_PRIO(modem), MODEM_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(protimer), RADIO_IRQ_PRIO(protimer), PROTIMER_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(rac_rsm), RADIO_IRQ_PRIO(rac_rsm), RAC_RSM_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(rac_seq), RADIO_IRQ_PRIO(rac_seq), RAC_SEQ_IRQHandler, NULL, 0); + IRQ_CONNECT(RADIO_IRQN(synth), RADIO_IRQ_PRIO(synth), SYNTH_IRQHandler, NULL, 0); + + /* Depending on the chip family, either HOSTMAILBOX, RDMAILBOX or neither is present */ + IF_ENABLED(DT_IRQ_HAS_NAME(DT_NODELABEL(radio), hostmailbox), ({ + IRQ_CONNECT(RADIO_IRQN(hostmailbox), + RADIO_IRQ_PRIO(hostmailbox), + HOSTMAILBOX_IRQHandler, + NULL, 0); + })); + IF_ENABLED(DT_IRQ_HAS_NAME(DT_NODELABEL(radio), rdmailbox), ({ + IRQ_CONNECT(RADIO_IRQN(rdmailbox), + RADIO_IRQ_PRIO(rdmailbox), + RDMAILBOX_IRQHandler, + NULL, 0); + })); } static bool slz_is_evt_discardable(const struct bt_hci_evt_hdr *hdr, const uint8_t *params, @@ -275,7 +289,6 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv) K_PRIO_COOP(CONFIG_BT_DRIVER_RX_HIGH_PRIO), 0, K_NO_WAIT); k_thread_name_set(&slz_rx_thread, "EFR32 HCI RX"); - rail_isr_installer(); sl_rail_util_pa_init(); /* Initialize Controller features based on Kconfig values */ @@ -301,6 +314,9 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv) } } + /* Set up interrupts after Controller init, because it will overwrite them. */ + rail_isr_installer(); + hci->recv = recv; LOG_DBG("SiLabs BT HCI started");