1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, Linaro Limited
4  */
5 
6 #ifndef __CONSOLE_H
7 #define __CONSOLE_H
8 
9 #include <compiler.h>
10 #include <tee_api_types.h>
11 
12 
13 void console_init(void);
14 void console_putc(int ch);
15 void console_flush(void);
16 
17 void plat_console_init(void);
18 
19 struct serial_chip;
20 void register_serial_console(struct serial_chip *chip);
21 
22 #ifdef CFG_DT
23 /*
24  * Get console info from a reacheable DTB. Check the embedded DTB and fall
25  * back to the external DTB.
26  *
27  * If the DTB does not specify a chosen (or secure-chosen) node, we assume
28  * DTB does not provide specific console directive. Early console may remain.
29  * If the DTB does not specify any console in the chosen (or secure-chosen)
30  * node, we assume there is no console. Early console would be disabled.
31  *
32  * @fdt_out: Output DTB address where console directive is found
33  * @offs_out: Output offset in the DTB where console directive is found
34  * @path_out: Output string configuration of the console from the DTB.
35  * (*path_out) shall be freed using nex_free().
36  * @params_out: Output console parameters found from the DTB.
37  * (*params_out) shall be freed using nex_free().
38  *
39  * Return a TEE_Result compliant return value
40  *
41  */
42 TEE_Result get_console_node_from_dt(void *fdt, int *offs_out,
43 				    char **path_out, char **params_out);
44 
45 /*
46  * Check if the /secure-chosen or /chosen node in the DT contains an
47  * stdout-path value for which we have a compatible driver. If so, switch
48  * the console to this device.
49  */
50 void configure_console_from_dt(void);
51 #else
configure_console_from_dt(void)52 static inline void configure_console_from_dt(void)
53 {}
54 #endif /* !CFG_DT */
55 
56 #endif /* __CONSOLE_H */
57 
58