8250.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Driver for 8250/16550-type serial ports
  3. *
  4. * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
  5. *
  6. * Copyright (C) 2001 Russell King.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/serial_8250.h>
  14. #include <linux/dmaengine.h>
  15. struct uart_8250_dma {
  16. dma_filter_fn fn;
  17. void *rx_param;
  18. void *tx_param;
  19. int rx_chan_id;
  20. int tx_chan_id;
  21. struct dma_slave_config rxconf;
  22. struct dma_slave_config txconf;
  23. struct dma_chan *rxchan;
  24. struct dma_chan *txchan;
  25. dma_addr_t rx_addr;
  26. dma_addr_t tx_addr;
  27. dma_cookie_t rx_cookie;
  28. dma_cookie_t tx_cookie;
  29. void *rx_buf;
  30. size_t rx_size;
  31. size_t tx_size;
  32. unsigned char tx_running:1;
  33. };
  34. struct old_serial_port {
  35. unsigned int uart;
  36. unsigned int baud_base;
  37. unsigned int port;
  38. unsigned int irq;
  39. unsigned int flags;
  40. unsigned char hub6;
  41. unsigned char io_type;
  42. unsigned char *iomem_base;
  43. unsigned short iomem_reg_shift;
  44. unsigned long irqflags;
  45. };
  46. struct serial8250_config {
  47. const char *name;
  48. unsigned short fifo_size;
  49. unsigned short tx_loadsz;
  50. unsigned char fcr;
  51. unsigned int flags;
  52. };
  53. #define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
  54. #define UART_CAP_EFR (1 << 9) /* UART has EFR */
  55. #define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
  56. #define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
  57. #define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
  58. #define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
  59. #define UART_CAP_HFIFO (1 << 14) /* UART has a "hidden" FIFO */
  60. #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
  61. #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
  62. #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
  63. #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
  64. #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
  65. #define PROBE_RSA (1 << 0)
  66. #define PROBE_ANY (~0)
  67. #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
  68. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  69. #define SERIAL8250_SHARE_IRQS 1
  70. #else
  71. #define SERIAL8250_SHARE_IRQS 0
  72. #endif
  73. static inline int serial_in(struct uart_8250_port *up, int offset)
  74. {
  75. return up->port.serial_in(&up->port, offset);
  76. }
  77. static inline void serial_out(struct uart_8250_port *up, int offset, int value)
  78. {
  79. up->port.serial_out(&up->port, offset, value);
  80. }
  81. void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
  82. static inline int serial_dl_read(struct uart_8250_port *up)
  83. {
  84. return up->dl_read(up);
  85. }
  86. static inline void serial_dl_write(struct uart_8250_port *up, int value)
  87. {
  88. up->dl_write(up, value);
  89. }
  90. #if defined(__alpha__) && !defined(CONFIG_PCI)
  91. /*
  92. * Digital did something really horribly wrong with the OUT1 and OUT2
  93. * lines on at least some ALPHA's. The failure mode is that if either
  94. * is cleared, the machine locks up with endless interrupts.
  95. */
  96. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  97. #elif defined(CONFIG_SBC8560)
  98. /*
  99. * WindRiver did something similarly broken on their SBC8560 board. The
  100. * UART tristates its IRQ output while OUT2 is clear, but they pulled
  101. * the interrupt line _up_ instead of down, so if we register the IRQ
  102. * while the UART is in that state, we die in an IRQ storm. */
  103. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
  104. #else
  105. #define ALPHA_KLUDGE_MCR 0
  106. #endif
  107. #ifdef CONFIG_SERIAL_8250_PNP
  108. int serial8250_pnp_init(void);
  109. void serial8250_pnp_exit(void);
  110. #else
  111. static inline int serial8250_pnp_init(void) { return 0; }
  112. static inline void serial8250_pnp_exit(void) { }
  113. #endif
  114. #ifdef CONFIG_ARCH_OMAP1
  115. static inline int is_omap1_8250(struct uart_8250_port *pt)
  116. {
  117. int res;
  118. switch (pt->port.mapbase) {
  119. case OMAP1_UART1_BASE:
  120. case OMAP1_UART2_BASE:
  121. case OMAP1_UART3_BASE:
  122. res = 1;
  123. break;
  124. default:
  125. res = 0;
  126. break;
  127. }
  128. return res;
  129. }
  130. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  131. {
  132. if (!cpu_is_omap1510())
  133. return 0;
  134. return is_omap1_8250(pt);
  135. }
  136. #else
  137. static inline int is_omap1_8250(struct uart_8250_port *pt)
  138. {
  139. return 0;
  140. }
  141. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  142. {
  143. return 0;
  144. }
  145. #endif
  146. #ifdef CONFIG_SERIAL_8250_DMA
  147. extern int serial8250_tx_dma(struct uart_8250_port *);
  148. extern int serial8250_rx_dma(struct uart_8250_port *, unsigned int iir);
  149. extern int serial8250_request_dma(struct uart_8250_port *);
  150. extern void serial8250_release_dma(struct uart_8250_port *);
  151. #else
  152. static inline int serial8250_tx_dma(struct uart_8250_port *p)
  153. {
  154. return -1;
  155. }
  156. static inline int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
  157. {
  158. return -1;
  159. }
  160. static inline int serial8250_request_dma(struct uart_8250_port *p)
  161. {
  162. return -1;
  163. }
  164. static inline void serial8250_release_dma(struct uart_8250_port *p) { }
  165. #endif