wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 1 | #ifndef __SERIAL_H__ |
| 2 | #define __SERIAL_H__ |
| 3 | |
Mike Frysinger | 7b826c2 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 4 | #include <post.h> |
| 5 | |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 6 | struct serial_device { |
Mike Frysinger | f6add13 | 2011-11-10 14:11:04 +0000 | [diff] [blame] | 7 | /* enough bytes to match alignment of following func pointer */ |
Marek Vasut | 78322d6 | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 8 | char name[16]; |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 9 | |
Marek Vasut | 89143fb | 2012-09-07 14:35:31 +0200 | [diff] [blame] | 10 | int (*start)(void); |
| 11 | int (*stop)(void); |
Marek Vasut | 78322d6 | 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 | 7b826c2 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 17 | #if CONFIG_POST & CONFIG_SYS_POST_UART |
Marek Vasut | 78322d6 | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 18 | void (*loop)(int); |
Mike Frysinger | 7b826c2 | 2011-05-14 06:56:15 +0000 | [diff] [blame] | 19 | #endif |
Marek Vasut | 78322d6 | 2012-09-07 14:32:10 +0200 | [diff] [blame] | 20 | struct serial_device *next; |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
Marek Vasut | bfb7d7a | 2012-10-06 14:07:01 +0000 | [diff] [blame] | 23 | void default_serial_puts(const char *s); |
| 24 | |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 25 | extern struct serial_device serial_smc_device; |
| 26 | extern struct serial_device serial_scc_device; |
Gerlando Falauto | a6e6f7f | 2011-11-18 06:49:11 +0000 | [diff] [blame] | 27 | extern struct serial_device *default_serial_console(void); |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 28 | |
Matthias Fuchs | 3fb8588 | 2013-08-07 12:10:38 +0200 | [diff] [blame] | 29 | #if defined(CONFIG_405GP) || \ |
Gerlando Falauto | a6e6f7f | 2011-11-18 06:49:11 +0000 | [diff] [blame] | 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) || \ |
Tom Warren | 6d6c0ba | 2012-12-11 13:34:17 +0000 | [diff] [blame] | 35 | defined(CONFIG_TEGRA) || defined(CONFIG_SYS_COREBOOT) || \ |
Michal Simek | 7636ebe | 2012-07-02 12:38:14 +0200 | [diff] [blame] | 36 | defined(CONFIG_MICROBLAZE) |
wdenk | ff36fd8 | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 37 | extern struct serial_device serial0_device; |
| 38 | extern struct serial_device serial1_device; |
Marek Vasut | abc0ed8 | 2012-09-12 20:02:05 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
Wolfgang Denk | 0fd3025 | 2006-08-30 23:02:10 +0200 | [diff] [blame] | 41 | extern struct serial_device eserial1_device; |
| 42 | extern struct serial_device eserial2_device; |
wdenk | ff36fd8 | 2005-01-09 22:28:56 +0000 | [diff] [blame] | 43 | |
Mike Frysinger | 635f330 | 2011-04-29 23:23:28 -0400 | [diff] [blame] | 44 | extern void serial_register(struct serial_device *); |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 45 | extern void serial_initialize(void); |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 46 | extern void serial_stdio_init(void); |
Gerlando Falauto | 7813ca9 | 2011-11-18 06:49:12 +0000 | [diff] [blame] | 47 | extern int serial_assign(const char *name); |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 48 | extern void serial_reinit_all(void); |
| 49 | |
Tom Rix | 6299487 | 2009-10-31 12:37:44 -0500 | [diff] [blame] | 50 | /* For usbtty */ |
Tom Rix | 2ec1abe | 2009-10-31 12:37:45 -0500 | [diff] [blame] | 51 | #ifdef CONFIG_USB_TTY |
| 52 | |
Tom Rix | 6299487 | 2009-10-31 12:37:44 -0500 | [diff] [blame] | 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 | |
Tom Rix | 2ec1abe | 2009-10-31 12:37:45 -0500 | [diff] [blame] | 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 | |
Marek Vasut | 036036d | 2012-09-14 23:45:51 +0200 | [diff] [blame] | 68 | #if defined(CONFIG_MPC512X) |
Anatolij Gustschin | 8e234e3 | 2010-04-24 19:27:06 +0200 | [diff] [blame] | 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 | |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 75 | #endif |