Skip to content

Commit 7f20297

Browse files
committed
drivers: serial: Add De-init to bflb uart driver
Allows BFLB uart peripheral to de-init. Signed-off-by: Camille BAUD <[email protected]>
1 parent e5838ff commit 7f20297

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/serial/uart_bflb.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,22 @@ 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+
const struct bflb_config *cfg = dev->config;
432+
433+
uart_bflb_enabled(dev, 0);
434+
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
435+
/* disable all irqs */
436+
sys_write32(0x0, cfg->base_reg + UART_INT_EN_OFFSET);
437+
/* clear all IRQS */
438+
sys_write32(0xFF, cfg->base_reg + UART_INT_CLEAR_OFFSET);
439+
/* mask all IRQs */
440+
sys_write32(0xFFFFFFFFU, cfg->base_reg + UART_INT_MASK_OFFSET);
441+
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
442+
return 0;
443+
}
444+
429445
static int uart_bflb_poll_in(const struct device *dev, unsigned char *c)
430446
{
431447
const struct bflb_config *cfg = dev->config;
@@ -561,7 +577,8 @@ static DEVICE_API(uart, uart_bflb_driver_api) = {
561577
.rx_fifo_threshold = 0, \
562578
BFLB_UART_IRQ_HANDLER_FUNC(instance) \
563579
}; \
564-
DEVICE_DT_INST_DEFINE(instance, &uart_bflb_init, \
580+
DEVICE_DT_INST_DEINIT_DEFINE(instance, &uart_bflb_init, \
581+
&uart_bflb_deinit, \
565582
PM_DEVICE_DT_INST_GET(instance), \
566583
&uart##instance##_bflb_data, \
567584
&uart##instance##_bflb_config, PRE_KERNEL_1, \

0 commit comments

Comments
 (0)