ns16550.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 CONFIG_SYS_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. * further modified to support the DUART in the Galileo eval board
  12. * modifications (c) Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
  13. */
  14. #ifndef __NS16550_H__
  15. #define __NS16550_H__
  16. /* the padding is necessary because on the galileo board the UART is
  17. wired in with the 3 address lines shifted over by 2 bits */
  18. struct NS16550
  19. {
  20. unsigned char rbr; /* 0 = 0-3*/
  21. int pad1:24;
  22. unsigned char ier; /* 1 = 4-7*/
  23. int pad2:24;
  24. unsigned char fcr; /* 2 = 8-b*/
  25. int pad3:24;
  26. unsigned char lcr; /* 3 = c-f*/
  27. int pad4:24;
  28. unsigned char mcr; /* 4 = 10-13*/
  29. int pad5:24;
  30. unsigned char lsr; /* 5 = 14-17*/
  31. int pad6:24;
  32. unsigned char msr; /* 6 =18-1b*/
  33. int pad7:24;
  34. unsigned char scr; /* 7 =1c-1f*/
  35. int pad8:24;
  36. } __attribute__ ((packed));
  37. /* aliases */
  38. #define thr rbr
  39. #define iir fcr
  40. #define dll rbr
  41. #define dlm ier
  42. #define FCR_FIFO_EN 0x01 /*fifo enable*/
  43. #define FCR_RXSR 0x02 /*reciever soft reset*/
  44. #define FCR_TXSR 0x04 /*transmitter soft reset*/
  45. #define MCR_DTR 0x01
  46. #define MCR_RTS 0x02
  47. #define MCR_DMA_EN 0x04
  48. #define MCR_TX_DFR 0x08
  49. #define LCR_WLS_MSK 0x03 /* character length slect mask*/
  50. #define LCR_WLS_5 0x00 /* 5 bit character length */
  51. #define LCR_WLS_6 0x01 /* 6 bit character length */
  52. #define LCR_WLS_7 0x02 /* 7 bit character length */
  53. #define LCR_WLS_8 0x03 /* 8 bit character length */
  54. #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */
  55. #define LCR_PEN 0x08 /* Parity eneble*/
  56. #define LCR_EPS 0x10 /* Even Parity Select*/
  57. #define LCR_STKP 0x20 /* Stick Parity*/
  58. #define LCR_SBRK 0x40 /* Set Break*/
  59. #define LCR_BKSE 0x80 /* Bank select enable*/
  60. #define LSR_DR 0x01 /* Data ready */
  61. #define LSR_OE 0x02 /* Overrun */
  62. #define LSR_PE 0x04 /* Parity error */
  63. #define LSR_FE 0x08 /* Framing error */
  64. #define LSR_BI 0x10 /* Break */
  65. #define LSR_THRE 0x20 /* Xmit holding register empty */
  66. #define LSR_TEMT 0x40 /* Xmitter empty */
  67. #define LSR_ERR 0x80 /* Error */
  68. /* useful defaults for LCR*/
  69. #define LCR_8N1 0x03
  70. #define COM1 0x03F8
  71. #define COM2 0x02F8
  72. volatile struct NS16550 * NS16550_init(int chan, int baud_divisor);
  73. void NS16550_putc(volatile struct NS16550 *com_port, unsigned char c);
  74. unsigned char NS16550_getc(volatile struct NS16550 *com_port);
  75. int NS16550_tstc(volatile struct NS16550 *com_port);
  76. void NS16550_reinit(volatile struct NS16550 *com_port, int baud_divisor);
  77. typedef struct NS16550 *NS16550_t;
  78. extern const NS16550_t COM_PORTS[];
  79. #endif