ns16550.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. */
  11. #if (CFG_NS16550_REG_SIZE == 1)
  12. struct NS16550 {
  13. unsigned char rbr; /* 0 */
  14. unsigned char ier; /* 1 */
  15. unsigned char fcr; /* 2 */
  16. unsigned char lcr; /* 3 */
  17. unsigned char mcr; /* 4 */
  18. unsigned char lsr; /* 5 */
  19. unsigned char msr; /* 6 */
  20. unsigned char scr; /* 7 */
  21. } __attribute__ ((packed));
  22. #elif (CFG_NS16550_REG_SIZE == 2)
  23. struct NS16550 {
  24. unsigned short rbr; /* 0 */
  25. unsigned short ier; /* 1 */
  26. unsigned short fcr; /* 2 */
  27. unsigned short lcr; /* 3 */
  28. unsigned short mcr; /* 4 */
  29. unsigned short lsr; /* 5 */
  30. unsigned short msr; /* 6 */
  31. unsigned short scr; /* 7 */
  32. } __attribute__ ((packed));
  33. #elif (CFG_NS16550_REG_SIZE == 4)
  34. struct NS16550 {
  35. unsigned long rbr; /* 0 */
  36. unsigned long ier; /* 1 */
  37. unsigned long fcr; /* 2 */
  38. unsigned long lcr; /* 3 */
  39. unsigned long mcr; /* 4 */
  40. unsigned long lsr; /* 5 */
  41. unsigned long msr; /* 6 */
  42. unsigned long scr; /* 7 */
  43. } __attribute__ ((packed));
  44. #elif (CFG_NS16550_REG_SIZE == -4)
  45. struct NS16550 {
  46. unsigned char rbr; /* 0 */
  47. int pad1:24;
  48. unsigned char ier; /* 1 */
  49. int pad2:24;
  50. unsigned char fcr; /* 2 */
  51. int pad3:24;
  52. unsigned char lcr; /* 3 */
  53. int pad4:24;
  54. unsigned char mcr; /* 4 */
  55. int pad5:24;
  56. unsigned char lsr; /* 5 */
  57. int pad6:24;
  58. unsigned char msr; /* 6 */
  59. int pad7:24;
  60. unsigned char scr; /* 7 */
  61. int pad8:24;
  62. #ifdef CONFIG_OMAP1510
  63. unsigned char mdr1; /* mode select reset TL16C750*/
  64. int pad9:24;
  65. unsigned long pad[10];
  66. unsigned char osc_12m_sel;
  67. int pad10:24;
  68. #endif
  69. } __attribute__ ((packed));
  70. #else
  71. #error "Please define NS16550 registers size."
  72. #endif
  73. #define thr rbr
  74. #define iir fcr
  75. #define dll rbr
  76. #define dlm ier
  77. typedef volatile struct NS16550 *NS16550_t;
  78. #define FCR_FIFO_EN 0x01 /* Fifo enable */
  79. #define FCR_RXSR 0x02 /* Receiver soft reset */
  80. #define FCR_TXSR 0x04 /* Transmitter soft reset */
  81. #define MCR_DTR 0x01
  82. #define MCR_RTS 0x02
  83. #define MCR_DMA_EN 0x04
  84. #define MCR_TX_DFR 0x08
  85. #define LCR_WLS_MSK 0x03 /* character length slect mask */
  86. #define LCR_WLS_5 0x00 /* 5 bit character length */
  87. #define LCR_WLS_6 0x01 /* 6 bit character length */
  88. #define LCR_WLS_7 0x02 /* 7 bit character length */
  89. #define LCR_WLS_8 0x03 /* 8 bit character length */
  90. #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
  91. #define LCR_PEN 0x08 /* Parity eneble */
  92. #define LCR_EPS 0x10 /* Even Parity Select */
  93. #define LCR_STKP 0x20 /* Stick Parity */
  94. #define LCR_SBRK 0x40 /* Set Break */
  95. #define LCR_BKSE 0x80 /* Bank select enable */
  96. #define LSR_DR 0x01 /* Data ready */
  97. #define LSR_OE 0x02 /* Overrun */
  98. #define LSR_PE 0x04 /* Parity error */
  99. #define LSR_FE 0x08 /* Framing error */
  100. #define LSR_BI 0x10 /* Break */
  101. #define LSR_THRE 0x20 /* Xmit holding register empty */
  102. #define LSR_TEMT 0x40 /* Xmitter empty */
  103. #define LSR_ERR 0x80 /* Error */
  104. #ifdef CONFIG_OMAP1510
  105. #define OSC_12M_SEL 0x01 /* selects 6.5 * current clk div */
  106. #endif
  107. /* useful defaults for LCR */
  108. #define LCR_8N1 0x03
  109. void NS16550_init (NS16550_t com_port, int baud_divisor);
  110. void NS16550_putc (NS16550_t com_port, char c);
  111. char NS16550_getc (NS16550_t com_port);
  112. int NS16550_tstc (NS16550_t com_port);
  113. void NS16550_reinit (NS16550_t com_port, int baud_divisor);