1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2017-2023, STMicroelectronics 4 */ 5 6 #ifndef __DRIVERS_STM32_UART_H 7 #define __DRIVERS_STM32_UART_H 8 9 #include <drivers/clk.h> 10 #include <drivers/pinctrl.h> 11 #include <drivers/serial.h> 12 #include <io.h> 13 #include <types_ext.h> 14 #include <stdbool.h> 15 16 struct stm32_uart_pdata { 17 struct io_pa_va base; 18 struct serial_chip chip; 19 struct clk *clock; 20 struct pinctrl_state *pinctrl; 21 struct pinctrl_state *pinctrl_sleep; 22 }; 23 24 /* 25 * stm32_uart_init - Initialize a UART serial chip and base address 26 * @pd: Output initialized UART platform data 27 * @base: UART interface physical base address 28 */ 29 void stm32_uart_init(struct stm32_uart_pdata *pd, vaddr_t base); 30 31 /* 32 * stm32_uart_init_from_dt_node - Initialize a UART instance from a DTB node 33 * @fdt: DTB base address 34 * @node: Target node offset in the DTB 35 * Returns an alloced (malloc) and inited UART platform data on success or NULL 36 * 37 * This function gets a STM32 UART configuration directives from a DTB node 38 * and initializes a UART driver instance. 39 * When the DTB specifies that the device is disabled, the function returns 40 * NULL. Other issues panic the sequence. 41 */ 42 struct stm32_uart_pdata *stm32_uart_init_from_dt_node(void *fdt, int node); 43 44 #endif /*__DRIVERS_STM32_UART_H*/ 45