xref: /optee_os/core/include/drivers/stm32_uart.h (revision 73ba32eb0f6cbb6ebbc59f13ea7eee44b387fe48)
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/stm32_gpio.h>
12 #include <drivers/serial.h>
13 #include <io.h>
14 #include <types_ext.h>
15 #include <stdbool.h>
16 
17 struct stm32_uart_pdata {
18 	struct io_pa_va base;
19 	struct serial_chip chip;
20 	bool secure;
21 	struct clk *clock;
22 #ifdef CFG_DRIVERS_PINCTRL
23 	struct pinctrl_state *pinctrl;
24 #else
25 	struct stm32_pinctrl *pinctrl;
26 	size_t pinctrl_count;
27 #endif
28 	struct pinctrl_state *pinctrl_sleep;
29 };
30 
31 /*
32  * stm32_uart_init - Initialize a UART serial chip and base address
33  * @pd: Output initialized UART platform data
34  * @base: UART interface physical base address
35  */
36 void stm32_uart_init(struct stm32_uart_pdata *pd, vaddr_t base);
37 
38 /*
39  * stm32_uart_init_from_dt_node - Initialize a UART instance from a DTB node
40  * @fdt: DTB base address
41  * @node: Target node offset in the DTB
42  * Returns an alloced (malloc) and inited UART platform data on success or NULL
43  *
44  * This function gets a STM32 UART configuration directives from a DTB node
45  * and initializes a UART driver instance.
46  * When the DTB specifies that the device is disabled, the function returns
47  * NULL. Other issues panic the sequence.
48  */
49 struct stm32_uart_pdata *stm32_uart_init_from_dt_node(void *fdt, int node);
50 
51 #endif /*DRIVERS_STM32_UART_H*/
52