xt2000-uart.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef _uart_h_included_
  2. #define _uart_h_included_
  3. /*
  4. * THIS FILE IS GENERATED -- DO NOT MODIFY BY HAND
  5. *
  6. * include/asm-xtensa/xtensa/xt2000-uart.h -- NatSemi PC16552D DUART
  7. * definitions
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. *
  13. * Copyright (C) 2002 Tensilica Inc.
  14. */
  15. #include <xtensa/xt2000.h>
  16. /* 16550 UART DEVICE REGISTERS
  17. The XT2000 board aligns each register to a 32-bit word but the UART device only uses
  18. one byte of the word, which is the least-significant byte regardless of the
  19. endianness of the core (ie. byte offset 0 for little-endian and 3 for big-endian).
  20. So if using word accesses then endianness doesn't matter.
  21. The macros provided here do that.
  22. */
  23. struct uart_dev_s {
  24. union {
  25. unsigned int rxb; /* DLAB=0: receive buffer, read-only */
  26. unsigned int txb; /* DLAB=0: transmit buffer, write-only */
  27. unsigned int dll; /* DLAB=1: divisor, least-significant byte latch (was write-only?) */
  28. } w0;
  29. union {
  30. unsigned int ier; /* DLAB=0: interrupt-enable register (was write-only?) */
  31. unsigned int dlm; /* DLAB=1: divisor, most-significant byte latch (was write-only?) */
  32. } w1;
  33. union {
  34. unsigned int isr; /* DLAB=0: interrupt status register, read-only */
  35. unsigned int fcr; /* DLAB=0: FIFO control register, write-only */
  36. unsigned int afr; /* DLAB=1: alternate function register */
  37. } w2;
  38. unsigned int lcr; /* line control-register, write-only */
  39. unsigned int mcr; /* modem control-regsiter, write-only */
  40. unsigned int lsr; /* line status register, read-only */
  41. unsigned int msr; /* modem status register, read-only */
  42. unsigned int scr; /* scratch regsiter, read/write */
  43. };
  44. #define _RXB(u) ((u)->w0.rxb)
  45. #define _TXB(u) ((u)->w0.txb)
  46. #define _DLL(u) ((u)->w0.dll)
  47. #define _IER(u) ((u)->w1.ier)
  48. #define _DLM(u) ((u)->w1.dlm)
  49. #define _ISR(u) ((u)->w2.isr)
  50. #define _FCR(u) ((u)->w2.fcr)
  51. #define _AFR(u) ((u)->w2.afr)
  52. #define _LCR(u) ((u)->lcr)
  53. #define _MCR(u) ((u)->mcr)
  54. #define _LSR(u) ((u)->lsr)
  55. #define _MSR(u) ((u)->msr)
  56. #define _SCR(u) ((u)->scr)
  57. typedef volatile struct uart_dev_s uart_dev_t;
  58. /* IER bits */
  59. #define RCVR_DATA_REG_INTENABLE 0x01
  60. #define XMIT_HOLD_REG_INTENABLE 0x02
  61. #define RCVR_STATUS_INTENABLE 0x04
  62. #define MODEM_STATUS_INTENABLE 0x08
  63. /* FCR bits */
  64. #define _FIFO_ENABLE 0x01
  65. #define RCVR_FIFO_RESET 0x02
  66. #define XMIT_FIFO_RESET 0x04
  67. #define DMA_MODE_SELECT 0x08
  68. #define RCVR_TRIGGER_LSB 0x40
  69. #define RCVR_TRIGGER_MSB 0x80
  70. /* AFR bits */
  71. #define AFR_CONC_WRITE 0x01
  72. #define AFR_BAUDOUT_SEL 0x02
  73. #define AFR_RXRDY_SEL 0x04
  74. /* ISR bits */
  75. #define INT_STATUS(r) ((r)&1)
  76. #define INT_PRIORITY(r) (((r)>>1)&0x7)
  77. /* LCR bits */
  78. #define WORD_LENGTH(n) (((n)-5)&0x3)
  79. #define STOP_BIT_ENABLE 0x04
  80. #define PARITY_ENABLE 0x08
  81. #define EVEN_PARITY 0x10
  82. #define FORCE_PARITY 0x20
  83. #define XMIT_BREAK 0x40
  84. #define DLAB_ENABLE 0x80
  85. /* MCR bits */
  86. #define _DTR 0x01
  87. #define _RTS 0x02
  88. #define _OP1 0x04
  89. #define _OP2 0x08
  90. #define LOOP_BACK 0x10
  91. /* LSR Bits */
  92. #define RCVR_DATA_READY 0x01
  93. #define OVERRUN_ERROR 0x02
  94. #define PARITY_ERROR 0x04
  95. #define FRAMING_ERROR 0x08
  96. #define BREAK_INTERRUPT 0x10
  97. #define XMIT_HOLD_EMPTY 0x20
  98. #define XMIT_EMPTY 0x40
  99. #define FIFO_ERROR 0x80
  100. #define RCVR_READY(u) (_LSR(u)&RCVR_DATA_READY)
  101. #define XMIT_READY(u) (_LSR(u)&XMIT_HOLD_EMPTY)
  102. /* MSR bits */
  103. #define _RDR 0x01
  104. #define DELTA_DSR 0x02
  105. #define DELTA_RI 0x04
  106. #define DELTA_CD 0x08
  107. #define _CTS 0x10
  108. #define _DSR 0x20
  109. #define _RI 0x40
  110. #define _CD 0x80
  111. /* prototypes */
  112. void uart_init( uart_dev_t *u, int bitrate );
  113. void uart_out( uart_dev_t *u, char c );
  114. void uart_puts( uart_dev_t *u, char *s );
  115. char uart_in( uart_dev_t *u );
  116. void uart_enable_rcvr_int( uart_dev_t *u );
  117. void uart_disable_rcvr_int( uart_dev_t *u );
  118. #ifdef DUART16552_1_VADDR
  119. /* DUART present. */
  120. #define DUART_1_BASE (*(uart_dev_t*)DUART16552_1_VADDR)
  121. #define DUART_2_BASE (*(uart_dev_t*)DUART16552_2_VADDR)
  122. #define UART1_PUTS(s) uart_puts( &DUART_1_BASE, s )
  123. #define UART2_PUTS(s) uart_puts( &DUART_2_BASE, s )
  124. #else
  125. /* DUART not configured, use dummy placeholders to allow compiles to work. */
  126. #define DUART_1_BASE (*(uart_dev_t*)0)
  127. #define DUART_2_BASE (*(uart_dev_t*)0)
  128. #define UART1_PUTS(s)
  129. #define UART2_PUTS(s)
  130. #endif
  131. /* Compute 16-bit divisor for baudrate generator, with rounding: */
  132. #define DUART_DIVISOR(crystal,speed) (((crystal)/16 + (speed)/2)/(speed))
  133. #endif /*_uart_h_included_*/