@@ -426,6 +426,25 @@ static int uart_bflb_init(const struct device *dev)
426426 return rc ;
427427}
428428
429+ static int uart_bflb_deinit (const struct device * dev )
430+ {
431+ #ifdef CONFIG_UART_INTERRUPT_DRIVEN
432+ const struct bflb_config * cfg = dev -> config ;
433+ #endif /* CONFIG_UART_INTERRUPT_DRIVEN */
434+
435+ uart_bflb_enabled (dev , 0 );
436+ #ifdef CONFIG_UART_INTERRUPT_DRIVEN
437+ /* disable all irqs */
438+ sys_write32 (0x0 , cfg -> base_reg + UART_INT_EN_OFFSET );
439+ /* clear all IRQS */
440+ sys_write32 (0xFF , cfg -> base_reg + UART_INT_CLEAR_OFFSET );
441+ /* mask all IRQs */
442+ sys_write32 (0xFFFFFFFFU , cfg -> base_reg + UART_INT_MASK_OFFSET );
443+ #endif /* CONFIG_UART_INTERRUPT_DRIVEN */
444+
445+ return 0 ;
446+ }
447+
429448static int uart_bflb_poll_in (const struct device * dev , unsigned char * c )
430449{
431450 const struct bflb_config * cfg = dev -> config ;
@@ -561,7 +580,8 @@ static DEVICE_API(uart, uart_bflb_driver_api) = {
561580 .rx_fifo_threshold = 0, \
562581 BFLB_UART_IRQ_HANDLER_FUNC(instance) \
563582 }; \
564- DEVICE_DT_INST_DEFINE(instance, &uart_bflb_init, \
583+ DEVICE_DT_INST_DEINIT_DEFINE(instance, &uart_bflb_init, \
584+ &uart_bflb_deinit, \
565585 PM_DEVICE_DT_INST_GET(instance), \
566586 &uart##instance##_bflb_data, \
567587 &uart##instance##_bflb_config, PRE_KERNEL_1, \
0 commit comments