ns16550.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * NS16550 Serial Port
  3. * originally from linux source (arch/ppc/boot/ns16550.h)
  4. * modified slightly to
  5. * have addresses as offsets from CFG_ISA_BASE
  6. * added a few more definitions
  7. * added prototypes for ns16550.c
  8. * reduced no of com ports to 2
  9. * modifications (c) Rob Taylor, Flying Pig Systems. 2000.
  10. * further modified to support the 8245 duart
  11. * modifications (c) Paul Jimenez, Musenki, Inc. 2001.
  12. */
  13. struct NS16550 {
  14. unsigned char rbrthrdlb; /* 0 */
  15. unsigned char ierdmb; /* 1 */
  16. unsigned char iirfcrafr; /* 2 */
  17. unsigned char lcr; /* 3 */
  18. unsigned char mcr; /* 4 */
  19. unsigned char lsr; /* 5 */
  20. unsigned char msr; /* 6 */
  21. unsigned char scr; /* 7 */
  22. unsigned char reserved[2]; /* 8 & 9 */
  23. unsigned char dsr; /* 10 */
  24. unsigned char dcr; /* 11 */
  25. };
  26. #define rbr rbrthrdlb
  27. #define thr rbrthrdlb
  28. #define dll rbrthrdlb
  29. #define ier ierdmb
  30. #define dlm ierdmb
  31. #define iir iirfcrafr
  32. #define fcr iirfcrafr
  33. #define afr iirfcrafr
  34. #define FCR_FIFO_EN 0x01 /*fifo enable */
  35. #define FCR_RXSR 0x02 /*reciever soft reset */
  36. #define FCR_TXSR 0x04 /*transmitter soft reset */
  37. #define FCR_DMS 0x08 /* DMA Mode Select */
  38. #define MCR_RTS 0x02 /* Readyu to Send */
  39. #define MCR_LOOP 0x10 /* Local loopback mode enable */
  40. /* #define MCR_DTR 0x01 noton 8245 duart */
  41. /* #define MCR_DMA_EN 0x04 noton 8245 duart */
  42. /* #define MCR_TX_DFR 0x08 noton 8245 duart */
  43. #define LCR_WLS_MSK 0x03 /* character length slect mask */
  44. #define LCR_WLS_5 0x00 /* 5 bit character length */
  45. #define LCR_WLS_6 0x01 /* 6 bit character length */
  46. #define LCR_WLS_7 0x02 /* 7 bit character length */
  47. #define LCR_WLS_8 0x03 /* 8 bit character length */
  48. #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
  49. #define LCR_PEN 0x08 /* Parity eneble */
  50. #define LCR_EPS 0x10 /* Even Parity Select */
  51. #define LCR_STKP 0x20 /* Stick Parity */
  52. #define LCR_SBRK 0x40 /* Set Break */
  53. #define LCR_BKSE 0x80 /* Bank select enable - aka DLAB on 8245 */
  54. #define LSR_DR 0x01 /* Data ready */
  55. #define LSR_OE 0x02 /* Overrun */
  56. #define LSR_PE 0x04 /* Parity error */
  57. #define LSR_FE 0x08 /* Framing error */
  58. #define LSR_BI 0x10 /* Break */
  59. #define LSR_THRE 0x20 /* Xmit holding register empty */
  60. #define LSR_TEMT 0x40 /* Xmitter empty */
  61. #define LSR_ERR 0x80 /* Error */
  62. /* useful defaults for LCR*/
  63. #define LCR_8N1 0x03
  64. volatile struct NS16550 *NS16550_init (int chan, int baud_divisor);
  65. void NS16550_putc (volatile struct NS16550 *com_port, unsigned char c);
  66. unsigned char NS16550_getc (volatile struct NS16550 *com_port);
  67. int NS16550_tstc (volatile struct NS16550 *com_port);
  68. void NS16550_reinit (volatile struct NS16550 *com_port, int baud_divisor);