8250.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. struct old_serial_port {
  15. unsigned int uart;
  16. unsigned int baud_base;
  17. unsigned int port;
  18. unsigned int irq;
  19. unsigned int flags;
  20. unsigned char hub6;
  21. unsigned char io_type;
  22. unsigned char *iomem_base;
  23. unsigned short iomem_reg_shift;
  24. unsigned long irqflags;
  25. };
  26. struct serial8250_config {
  27. const char *name;
  28. unsigned short fifo_size;
  29. unsigned short tx_loadsz;
  30. unsigned char fcr;
  31. unsigned int flags;
  32. };
  33. #define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
  34. #define UART_CAP_EFR (1 << 9) /* UART has EFR */
  35. #define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
  36. #define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
  37. #define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
  38. #define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
  39. #define UART_CAP_HFIFO (1 << 14) /* UART has a "hidden" FIFO */
  40. #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
  41. #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
  42. #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
  43. #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
  44. #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
  45. #define PROBE_RSA (1 << 0)
  46. #define PROBE_ANY (~0)
  47. #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
  48. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  49. #define SERIAL8250_SHARE_IRQS 1
  50. #else
  51. #define SERIAL8250_SHARE_IRQS 0
  52. #endif
  53. static inline int serial_in(struct uart_8250_port *up, int offset)
  54. {
  55. return up->port.serial_in(&up->port, offset);
  56. }
  57. static inline void serial_out(struct uart_8250_port *up, int offset, int value)
  58. {
  59. up->port.serial_out(&up->port, offset, value);
  60. }
  61. void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
  62. static inline int serial_dl_read(struct uart_8250_port *up)
  63. {
  64. return up->dl_read(up);
  65. }
  66. static inline void serial_dl_write(struct uart_8250_port *up, int value)
  67. {
  68. up->dl_write(up, value);
  69. }
  70. #if defined(__alpha__) && !defined(CONFIG_PCI)
  71. /*
  72. * Digital did something really horribly wrong with the OUT1 and OUT2
  73. * lines on at least some ALPHA's. The failure mode is that if either
  74. * is cleared, the machine locks up with endless interrupts.
  75. */
  76. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  77. #elif defined(CONFIG_SBC8560)
  78. /*
  79. * WindRiver did something similarly broken on their SBC8560 board. The
  80. * UART tristates its IRQ output while OUT2 is clear, but they pulled
  81. * the interrupt line _up_ instead of down, so if we register the IRQ
  82. * while the UART is in that state, we die in an IRQ storm. */
  83. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
  84. #else
  85. #define ALPHA_KLUDGE_MCR 0
  86. #endif
  87. #ifdef CONFIG_SERIAL_8250_PNP
  88. int serial8250_pnp_init(void);
  89. void serial8250_pnp_exit(void);
  90. #else
  91. static inline int serial8250_pnp_init(void) { return 0; }
  92. static inline void serial8250_pnp_exit(void) { }
  93. #endif
  94. #ifdef CONFIG_ARCH_OMAP1
  95. static inline int is_omap1_8250(struct uart_8250_port *pt)
  96. {
  97. int res;
  98. switch (pt->port.mapbase) {
  99. case OMAP1_UART1_BASE:
  100. case OMAP1_UART2_BASE:
  101. case OMAP1_UART3_BASE:
  102. res = 1;
  103. break;
  104. default:
  105. res = 0;
  106. break;
  107. }
  108. return res;
  109. }
  110. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  111. {
  112. if (!cpu_is_omap1510())
  113. return 0;
  114. return is_omap1_8250(pt);
  115. }
  116. #else
  117. static inline int is_omap1_8250(struct uart_8250_port *pt)
  118. {
  119. return 0;
  120. }
  121. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  122. {
  123. return 0;
  124. }
  125. #endif