8250.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/serial_reg.h>
  15. #include <linux/dmaengine.h>
  16. struct uart_8250_dma {
  17. /* Filter function */
  18. dma_filter_fn fn;
  19. /* Parameter to the filter function */
  20. void *rx_param;
  21. void *tx_param;
  22. struct dma_slave_config rxconf;
  23. struct dma_slave_config txconf;
  24. struct dma_chan *rxchan;
  25. struct dma_chan *txchan;
  26. dma_addr_t rx_addr;
  27. dma_addr_t tx_addr;
  28. dma_cookie_t rx_cookie;
  29. dma_cookie_t tx_cookie;
  30. void *rx_buf;
  31. size_t rx_size;
  32. size_t tx_size;
  33. unsigned char tx_running:1;
  34. };
  35. struct old_serial_port {
  36. unsigned int uart;
  37. unsigned int baud_base;
  38. unsigned int port;
  39. unsigned int irq;
  40. unsigned int flags;
  41. unsigned char hub6;
  42. unsigned char io_type;
  43. unsigned char *iomem_base;
  44. unsigned short iomem_reg_shift;
  45. unsigned long irqflags;
  46. };
  47. struct serial8250_config {
  48. const char *name;
  49. unsigned short fifo_size;
  50. unsigned short tx_loadsz;
  51. unsigned char fcr;
  52. unsigned char rxtrig_bytes[UART_FCR_R_TRIG_MAX_STATE];
  53. unsigned int flags;
  54. };
  55. #define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
  56. #define UART_CAP_EFR (1 << 9) /* UART has EFR */
  57. #define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
  58. #define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
  59. #define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
  60. #define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
  61. #define UART_CAP_HFIFO (1 << 14) /* UART has a "hidden" FIFO */
  62. #define UART_CAP_RPM (1 << 15) /* Runtime PM is active while idle */
  63. #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
  64. #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
  65. #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
  66. #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
  67. #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
  68. #define PROBE_RSA (1 << 0)
  69. #define PROBE_ANY (~0)
  70. #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
  71. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  72. #define SERIAL8250_SHARE_IRQS 1
  73. #else
  74. #define SERIAL8250_SHARE_IRQS 0
  75. #endif
  76. static inline int serial_in(struct uart_8250_port *up, int offset)
  77. {
  78. return up->port.serial_in(&up->port, offset);
  79. }
  80. static inline void serial_out(struct uart_8250_port *up, int offset, int value)
  81. {
  82. up->port.serial_out(&up->port, offset, value);
  83. }
  84. void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
  85. static inline int serial_dl_read(struct uart_8250_port *up)
  86. {
  87. return up->dl_read(up);
  88. }
  89. static inline void serial_dl_write(struct uart_8250_port *up, int value)
  90. {
  91. up->dl_write(up, value);
  92. }
  93. struct uart_8250_port *serial8250_get_port(int line);
  94. #if defined(__alpha__) && !defined(CONFIG_PCI)
  95. /*
  96. * Digital did something really horribly wrong with the OUT1 and OUT2
  97. * lines on at least some ALPHA's. The failure mode is that if either
  98. * is cleared, the machine locks up with endless interrupts.
  99. */
  100. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  101. #else
  102. #define ALPHA_KLUDGE_MCR 0
  103. #endif
  104. #ifdef CONFIG_SERIAL_8250_PNP
  105. int serial8250_pnp_init(void);
  106. void serial8250_pnp_exit(void);
  107. #else
  108. static inline int serial8250_pnp_init(void) { return 0; }
  109. static inline void serial8250_pnp_exit(void) { }
  110. #endif
  111. #ifdef CONFIG_ARCH_OMAP1
  112. static inline int is_omap1_8250(struct uart_8250_port *pt)
  113. {
  114. int res;
  115. switch (pt->port.mapbase) {
  116. case OMAP1_UART1_BASE:
  117. case OMAP1_UART2_BASE:
  118. case OMAP1_UART3_BASE:
  119. res = 1;
  120. break;
  121. default:
  122. res = 0;
  123. break;
  124. }
  125. return res;
  126. }
  127. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  128. {
  129. if (!cpu_is_omap1510())
  130. return 0;
  131. return is_omap1_8250(pt);
  132. }
  133. #else
  134. static inline int is_omap1_8250(struct uart_8250_port *pt)
  135. {
  136. return 0;
  137. }
  138. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  139. {
  140. return 0;
  141. }
  142. #endif
  143. #ifdef CONFIG_SERIAL_8250_DMA
  144. extern int serial8250_tx_dma(struct uart_8250_port *);
  145. extern int serial8250_rx_dma(struct uart_8250_port *, unsigned int iir);
  146. extern int serial8250_request_dma(struct uart_8250_port *);
  147. extern void serial8250_release_dma(struct uart_8250_port *);
  148. #else
  149. static inline int serial8250_tx_dma(struct uart_8250_port *p)
  150. {
  151. return -1;
  152. }
  153. static inline int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
  154. {
  155. return -1;
  156. }
  157. static inline int serial8250_request_dma(struct uart_8250_port *p)
  158. {
  159. return -1;
  160. }
  161. static inline void serial8250_release_dma(struct uart_8250_port *p) { }
  162. #endif