From 80b8ef80b3cf4c1ac33e9715c18a6613b6cd61f4 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Thu, 4 Apr 2024 07:00:17 +0900 Subject: [PATCH] drivers: serial: pl011: Add capability for handling reset device Reset the device on initializing if the node inherits `reset-device.yaml`. Signed-off-by: TOKITA Hiroshi --- drivers/serial/uart_pl011.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/serial/uart_pl011.c b/drivers/serial/uart_pl011.c index 7b93e00682..cd8e24fb12 100644 --- a/drivers/serial/uart_pl011.c +++ b/drivers/serial/uart_pl011.c @@ -21,6 +21,9 @@ #if defined(CONFIG_PINCTRL) #include #endif +#if IS_ENABLED(CONFIG_RESET) +#include +#endif #ifdef CONFIG_CPU_CORTEX_M #include @@ -35,6 +38,9 @@ struct pl011_config { #if defined(CONFIG_PINCTRL) const struct pinctrl_dev_config *pincfg; #endif +#if IS_ENABLED(CONFIG_RESET) + const struct reset_dt_spec reset; +#endif #ifdef CONFIG_UART_INTERRUPT_DRIVEN uart_irq_config_func_t irq_config_func; #endif @@ -408,6 +414,15 @@ static int pl011_init(const struct device *dev) DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); +#if IS_ENABLED(CONFIG_RESET) + if (config->reset.dev) { + ret = reset_line_toggle_dt(&config->reset); + if (ret) { + return ret; + } + } +#endif + /* * If working in SBSA mode, we assume that UART is already configured, * or does not require configuration at all (if UART is emulated by @@ -505,6 +520,13 @@ static int pl011_init(const struct device *dev) #define PINCTRL_INIT(n) #endif /* CONFIG_PINCTRL */ +#if IS_ENABLED(CONFIG_RESET) +#define RESET_INIT(n) \ + IF_ENABLED(DT_INST_NODE_HAS_PROP(0, resets), (.reset = RESET_DT_SPEC_INST_GET(n),)) +#else +#define RESET_INIT(n) +#endif + #define ARM_PL011_DEFINE(n) \ static inline int pwr_on_arm_pl011_##n(void) \ { \