xref: /openbmc/u-boot/include/serial.h (revision 6f6ea814)
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  (*init) (void);
11 	int  (*uninit) (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 
21 	struct serial_device *next;
22 };
23 
24 extern struct serial_device serial_smc_device;
25 extern struct serial_device serial_scc_device;
26 extern struct serial_device *default_serial_console(void);
27 
28 #if	defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
29 	defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
30 	defined(CONFIG_405EX) || defined(CONFIG_440) || \
31 	defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \
32 	defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \
33 	defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \
34 	defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT) || \
35 	defined(CONFIG_MICROBLAZE)
36 extern struct serial_device serial0_device;
37 extern struct serial_device serial1_device;
38 #if defined(CONFIG_SYS_NS16550_SERIAL)
39 extern struct serial_device eserial1_device;
40 extern struct serial_device eserial2_device;
41 extern struct serial_device eserial3_device;
42 extern struct serial_device eserial4_device;
43 #endif /* CONFIG_SYS_NS16550_SERIAL */
44 
45 #endif
46 
47 #if defined(CONFIG_MPC512X)
48 extern struct serial_device serial1_device;
49 extern struct serial_device serial3_device;
50 extern struct serial_device serial4_device;
51 extern struct serial_device serial6_device;
52 #endif
53 
54 #if defined(CONFIG_XILINX_UARTLITE)
55 extern struct serial_device uartlite_serial0_device;
56 extern struct serial_device uartlite_serial1_device;
57 extern struct serial_device uartlite_serial2_device;
58 extern struct serial_device uartlite_serial3_device;
59 #endif
60 
61 #if defined(CONFIG_S3C2410)
62 extern struct serial_device s3c24xx_serial0_device;
63 extern struct serial_device s3c24xx_serial1_device;
64 extern struct serial_device s3c24xx_serial2_device;
65 #endif
66 
67 #if defined(CONFIG_S5P)
68 extern struct serial_device s5p_serial0_device;
69 extern struct serial_device s5p_serial1_device;
70 extern struct serial_device s5p_serial2_device;
71 extern struct serial_device s5p_serial3_device;
72 #endif
73 
74 #if defined(CONFIG_OMAP3_ZOOM2)
75 extern struct serial_device zoom2_serial_device0;
76 extern struct serial_device zoom2_serial_device1;
77 extern struct serial_device zoom2_serial_device2;
78 extern struct serial_device zoom2_serial_device3;
79 #endif
80 
81 extern struct serial_device serial_ffuart_device;
82 extern struct serial_device serial_btuart_device;
83 extern struct serial_device serial_stuart_device;
84 
85 #if defined(CONFIG_SYS_BFIN_UART)
86 extern void serial_register_bfin_uart(void);
87 extern struct serial_device bfin_serial0_device;
88 extern struct serial_device bfin_serial1_device;
89 extern struct serial_device bfin_serial2_device;
90 extern struct serial_device bfin_serial3_device;
91 #endif
92 
93 #if defined(CONFIG_ZYNQ_SERIAL)
94 extern struct serial_device uart_zynq_serial0_device;
95 extern struct serial_device uart_zynq_serial1_device;
96 #endif
97 
98 extern void serial_register(struct serial_device *);
99 extern void serial_initialize(void);
100 extern void serial_stdio_init(void);
101 extern int serial_assign(const char *name);
102 extern void serial_reinit_all(void);
103 
104 /* For usbtty */
105 #ifdef CONFIG_USB_TTY
106 
107 extern int usbtty_getc(void);
108 extern void usbtty_putc(const char c);
109 extern void usbtty_puts(const char *str);
110 extern int usbtty_tstc(void);
111 
112 #else
113 
114 /* stubs */
115 #define usbtty_getc() 0
116 #define usbtty_putc(a)
117 #define usbtty_puts(a)
118 #define usbtty_tstc() 0
119 
120 #endif /* CONFIG_USB_TTY */
121 
122 #if defined(CONFIG_MPC512X) &&  defined(CONFIG_SERIAL_MULTI)
123 extern struct stdio_dev *open_port(int num, int baudrate);
124 extern int close_port(int num);
125 extern int write_port(struct stdio_dev *port, char *buf);
126 extern int read_port(struct stdio_dev *port, char *buf, int size);
127 #endif
128 
129 #endif
130