xref: /openbmc/u-boot/include/serial.h (revision ee52b188)
1 #ifndef __SERIAL_H__
2 #define __SERIAL_H__
3 
4 #include <post.h>
5 
6 struct serial_device {
7 	/* enough bytes to match alignment of following func pointer */
8 	char	name[16];
9 
10 	int	(*start)(void);
11 	int	(*stop)(void);
12 	void	(*setbrg)(void);
13 	int	(*getc)(void);
14 	int	(*tstc)(void);
15 	void	(*putc)(const char c);
16 	void	(*puts)(const char *s);
17 #if CONFIG_POST & CONFIG_SYS_POST_UART
18 	void	(*loop)(int);
19 #endif
20 	struct serial_device	*next;
21 };
22 
23 void default_serial_puts(const char *s);
24 
25 extern struct serial_device serial_smc_device;
26 extern struct serial_device serial_scc_device;
27 extern struct serial_device *default_serial_console(void);
28 
29 #if	defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
30 	defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
31 	defined(CONFIG_405EX) || defined(CONFIG_440) || \
32 	defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \
33 	defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \
34 	defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \
35 	defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT) || \
36 	defined(CONFIG_MICROBLAZE)
37 extern struct serial_device serial0_device;
38 extern struct serial_device serial1_device;
39 #endif
40 
41 extern struct serial_device eserial1_device;
42 extern struct serial_device eserial2_device;
43 
44 extern void serial_register(struct serial_device *);
45 extern void serial_initialize(void);
46 extern void serial_stdio_init(void);
47 extern int serial_assign(const char *name);
48 extern void serial_reinit_all(void);
49 
50 /* For usbtty */
51 #ifdef CONFIG_USB_TTY
52 
53 extern int usbtty_getc(void);
54 extern void usbtty_putc(const char c);
55 extern void usbtty_puts(const char *str);
56 extern int usbtty_tstc(void);
57 
58 #else
59 
60 /* stubs */
61 #define usbtty_getc() 0
62 #define usbtty_putc(a)
63 #define usbtty_puts(a)
64 #define usbtty_tstc() 0
65 
66 #endif /* CONFIG_USB_TTY */
67 
68 #if defined(CONFIG_MPC512X)
69 extern struct stdio_dev *open_port(int num, int baudrate);
70 extern int close_port(int num);
71 extern int write_port(struct stdio_dev *port, char *buf);
72 extern int read_port(struct stdio_dev *port, char *buf, int size);
73 #endif
74 
75 #endif
76