wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 1 | #ifndef __SERIAL_H__ |
| 2 | #define __SERIAL_H__ |
| 3 | |
Mike Frysinger | 078f2f1 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 4 | #include <post.h> |
| 5 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 6 | struct serial_device { |
Mike Frysinger | 6b300dc | 2011-11-10 14:11:04 +0000 | [diff] [blame] | 7 | /* enough bytes to match alignment of following func pointer */ |
Marek Vasut | 80919de | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 8 | char name[16]; |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 9 | |
Marek Vasut | b46931d | 2012-09-07 14:35:31 +0200 | [diff] [blame] | 10 | int (*start)(void); |
| 11 | int (*stop)(void); |
Marek Vasut | 80919de | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 12 | void (*setbrg)(void); |
| 13 | int (*getc)(void); |
| 14 | int (*tstc)(void); |
| 15 | void (*putc)(const char c); |
| 16 | void (*puts)(const char *s); |
Mike Frysinger | 078f2f1 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 17 | #if CONFIG_POST & CONFIG_SYS_POST_UART |
Marek Vasut | 80919de | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 18 | void (*loop)(int); |
Mike Frysinger | 078f2f1 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 19 | #endif |
Marek Vasut | 80919de | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 20 | struct serial_device *next; |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | extern struct serial_device serial_smc_device; |
| 24 | extern struct serial_device serial_scc_device; |
Gerlando Falauto | 34148d6 | 2011-11-18 06:49:11 +0000 | [diff] [blame] | 25 | extern struct serial_device *default_serial_console(void); |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 26 | |
Gerlando Falauto | 34148d6 | 2011-11-18 06:49:11 +0000 | [diff] [blame] | 27 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \ |
| 28 | defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \ |
| 29 | defined(CONFIG_405EX) || defined(CONFIG_440) || \ |
| 30 | defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \ |
| 31 | defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \ |
| 32 | defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \ |
Michal Simek | f5c5b3f | 2012-07-02 12:38:14 +0200 | [diff] [blame] | 33 | defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT) || \ |
| 34 | defined(CONFIG_MICROBLAZE) |
wdenk | 96c7a8c | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 35 | extern struct serial_device serial0_device; |
| 36 | extern struct serial_device serial1_device; |
Marek Vasut | 3f08506 | 2012-09-12 20:02:05 +0200 | [diff] [blame] | 37 | #endif |
| 38 | |
Wolfgang Denk | 44df561 | 2006-08-30 23:02:10 +0200 | [diff] [blame] | 39 | extern struct serial_device eserial1_device; |
| 40 | extern struct serial_device eserial2_device; |
wdenk | 96c7a8c | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 41 | |
Mike Frysinger | 53ba322 | 2011-04-29 23:23:28 -0400 | [diff] [blame] | 42 | extern void serial_register(struct serial_device *); |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 43 | extern void serial_initialize(void); |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 44 | extern void serial_stdio_init(void); |
Gerlando Falauto | 9299958 | 2011-11-18 06:49:12 +0000 | [diff] [blame] | 45 | extern int serial_assign(const char *name); |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 46 | extern void serial_reinit_all(void); |
| 47 | |
Tom Rix | a36796b | 2009-10-31 12:37:44 -0500 | [diff] [blame] | 48 | /* For usbtty */ |
Tom Rix | 7bea868 | 2009-10-31 12:37:45 -0500 | [diff] [blame] | 49 | #ifdef CONFIG_USB_TTY |
| 50 | |
Tom Rix | a36796b | 2009-10-31 12:37:44 -0500 | [diff] [blame] | 51 | extern int usbtty_getc(void); |
| 52 | extern void usbtty_putc(const char c); |
| 53 | extern void usbtty_puts(const char *str); |
| 54 | extern int usbtty_tstc(void); |
| 55 | |
Tom Rix | 7bea868 | 2009-10-31 12:37:45 -0500 | [diff] [blame] | 56 | #else |
| 57 | |
| 58 | /* stubs */ |
| 59 | #define usbtty_getc() 0 |
| 60 | #define usbtty_putc(a) |
| 61 | #define usbtty_puts(a) |
| 62 | #define usbtty_tstc() 0 |
| 63 | |
| 64 | #endif /* CONFIG_USB_TTY */ |
| 65 | |
Marek Vasut | 52039da | 2012-09-14 23:45:51 +0200 | [diff] [blame] | 66 | #if defined(CONFIG_MPC512X) |
Anatolij Gustschin | 65c3dfc | 2010-04-24 19:27:06 +0200 | [diff] [blame] | 67 | extern struct stdio_dev *open_port(int num, int baudrate); |
| 68 | extern int close_port(int num); |
| 69 | extern int write_port(struct stdio_dev *port, char *buf); |
| 70 | extern int read_port(struct stdio_dev *port, char *buf, int size); |
| 71 | #endif |
| 72 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 73 | #endif |