10a16c8caSEtienne Carriere /* SPDX-License-Identifier: BSD-2-Clause */ 20a16c8caSEtienne Carriere /* 35b84bbd5SEtienne Carriere * Copyright (c) 2017-2023, STMicroelectronics 40a16c8caSEtienne Carriere */ 50a16c8caSEtienne Carriere 6*d50fee03SEtienne Carriere #ifndef __DRIVERS_STM32_UART_H 7*d50fee03SEtienne Carriere #define __DRIVERS_STM32_UART_H 80a16c8caSEtienne Carriere 95e369f14SEtienne Carriere #include <drivers/clk.h> 105b84bbd5SEtienne Carriere #include <drivers/pinctrl.h> 115b84bbd5SEtienne Carriere #include <drivers/serial.h> 125b84bbd5SEtienne Carriere #include <io.h> 135b84bbd5SEtienne Carriere #include <types_ext.h> 145b84bbd5SEtienne Carriere #include <stdbool.h> 150a16c8caSEtienne Carriere 16107d5ec2SEtienne Carriere struct stm32_uart_pdata { 170a16c8caSEtienne Carriere struct io_pa_va base; 180a16c8caSEtienne Carriere struct serial_chip chip; 195e369f14SEtienne Carriere struct clk *clock; 205b84bbd5SEtienne Carriere struct pinctrl_state *pinctrl; 215b84bbd5SEtienne Carriere struct pinctrl_state *pinctrl_sleep; 220a16c8caSEtienne Carriere }; 230a16c8caSEtienne Carriere 2487fdf271SEtienne Carriere /* 2587fdf271SEtienne Carriere * stm32_uart_init - Initialize a UART serial chip and base address 2687fdf271SEtienne Carriere * @pd: Output initialized UART platform data 2787fdf271SEtienne Carriere * @base: UART interface physical base address 2887fdf271SEtienne Carriere */ 29107d5ec2SEtienne Carriere void stm32_uart_init(struct stm32_uart_pdata *pd, vaddr_t base); 300a16c8caSEtienne Carriere 3187fdf271SEtienne Carriere /* 3287fdf271SEtienne Carriere * stm32_uart_init_from_dt_node - Initialize a UART instance from a DTB node 3387fdf271SEtienne Carriere * @fdt: DTB base address 3487fdf271SEtienne Carriere * @node: Target node offset in the DTB 3587fdf271SEtienne Carriere * Returns an alloced (malloc) and inited UART platform data on success or NULL 3687fdf271SEtienne Carriere * 3787fdf271SEtienne Carriere * This function gets a STM32 UART configuration directives from a DTB node 3887fdf271SEtienne Carriere * and initializes a UART driver instance. 3987fdf271SEtienne Carriere * When the DTB specifies that the device is disabled, the function returns 4087fdf271SEtienne Carriere * NULL. Other issues panic the sequence. 4187fdf271SEtienne Carriere */ 4287fdf271SEtienne Carriere struct stm32_uart_pdata *stm32_uart_init_from_dt_node(void *fdt, int node); 4387fdf271SEtienne Carriere 44*d50fee03SEtienne Carriere #endif /*__DRIVERS_STM32_UART_H*/ 45