serial.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef __SERIAL_H__
  2. #define __SERIAL_H__
  3. #include <post.h>
  4. struct serial_device {
  5. /* enough bytes to match alignment of following func pointer */
  6. char name[16];
  7. int (*start)(void);
  8. int (*stop)(void);
  9. void (*setbrg)(void);
  10. int (*getc)(void);
  11. int (*tstc)(void);
  12. void (*putc)(const char c);
  13. void (*puts)(const char *s);
  14. #if CONFIG_POST & CONFIG_SYS_POST_UART
  15. void (*loop)(int);
  16. #endif
  17. struct serial_device *next;
  18. };
  19. extern struct serial_device serial_smc_device;
  20. extern struct serial_device serial_scc_device;
  21. extern struct serial_device *default_serial_console(void);
  22. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
  23. defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
  24. defined(CONFIG_405EX) || defined(CONFIG_440) || \
  25. defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \
  26. defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \
  27. defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \
  28. defined(CONFIG_TEGRA20) || defined(CONFIG_SYS_COREBOOT) || \
  29. defined(CONFIG_MICROBLAZE)
  30. extern struct serial_device serial0_device;
  31. extern struct serial_device serial1_device;
  32. #endif
  33. extern struct serial_device eserial1_device;
  34. extern struct serial_device eserial2_device;
  35. #if defined(CONFIG_OMAP3_ZOOM2)
  36. extern struct serial_device zoom2_serial_device0;
  37. extern struct serial_device zoom2_serial_device1;
  38. extern struct serial_device zoom2_serial_device2;
  39. extern struct serial_device zoom2_serial_device3;
  40. #endif
  41. #if defined(CONFIG_SYS_BFIN_UART)
  42. extern void serial_register_bfin_uart(void);
  43. #endif
  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. /* For usbtty */
  50. #ifdef CONFIG_USB_TTY
  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. #else
  56. /* stubs */
  57. #define usbtty_getc() 0
  58. #define usbtty_putc(a)
  59. #define usbtty_puts(a)
  60. #define usbtty_tstc() 0
  61. #endif /* CONFIG_USB_TTY */
  62. #if defined(CONFIG_MPC512X) && defined(CONFIG_SERIAL_MULTI)
  63. extern struct stdio_dev *open_port(int num, int baudrate);
  64. extern int close_port(int num);
  65. extern int write_port(struct stdio_dev *port, char *buf);
  66. extern int read_port(struct stdio_dev *port, char *buf, int size);
  67. #endif
  68. #endif