8250.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
  40. #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
  41. #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
  42. #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
  43. #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
  44. #define PROBE_RSA (1 << 0)
  45. #define PROBE_ANY (~0)
  46. #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
  47. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  48. #define SERIAL8250_SHARE_IRQS 1
  49. #else
  50. #define SERIAL8250_SHARE_IRQS 0
  51. #endif
  52. static inline int serial_in(struct uart_8250_port *up, int offset)
  53. {
  54. return up->port.serial_in(&up->port, offset);
  55. }
  56. static inline void serial_out(struct uart_8250_port *up, int offset, int value)
  57. {
  58. up->port.serial_out(&up->port, offset, value);
  59. }
  60. void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
  61. static inline int serial_dl_read(struct uart_8250_port *up)
  62. {
  63. return up->dl_read(up);
  64. }
  65. static inline void serial_dl_write(struct uart_8250_port *up, int value)
  66. {
  67. up->dl_write(up, value);
  68. }
  69. #if defined(__alpha__) && !defined(CONFIG_PCI)
  70. /*
  71. * Digital did something really horribly wrong with the OUT1 and OUT2
  72. * lines on at least some ALPHA's. The failure mode is that if either
  73. * is cleared, the machine locks up with endless interrupts.
  74. */
  75. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  76. #elif defined(CONFIG_SBC8560)
  77. /*
  78. * WindRiver did something similarly broken on their SBC8560 board. The
  79. * UART tristates its IRQ output while OUT2 is clear, but they pulled
  80. * the interrupt line _up_ instead of down, so if we register the IRQ
  81. * while the UART is in that state, we die in an IRQ storm. */
  82. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
  83. #else
  84. #define ALPHA_KLUDGE_MCR 0
  85. #endif
  86. #ifdef CONFIG_SERIAL_8250_PNP
  87. int serial8250_pnp_init(void);
  88. void serial8250_pnp_exit(void);
  89. #else
  90. static inline int serial8250_pnp_init(void) { return 0; }
  91. static inline void serial8250_pnp_exit(void) { }
  92. #endif
  93. #ifdef CONFIG_ARCH_OMAP1
  94. static inline int is_omap1_8250(struct uart_8250_port *pt)
  95. {
  96. int res;
  97. switch (pt->port.mapbase) {
  98. case OMAP1_UART1_BASE:
  99. case OMAP1_UART2_BASE:
  100. case OMAP1_UART3_BASE:
  101. res = 1;
  102. break;
  103. default:
  104. res = 0;
  105. break;
  106. }
  107. return res;
  108. }
  109. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  110. {
  111. if (!cpu_is_omap1510())
  112. return 0;
  113. return is_omap1_8250(pt);
  114. }
  115. #else
  116. static inline int is_omap1_8250(struct uart_8250_port *pt)
  117. {
  118. return 0;
  119. }
  120. static inline int is_omap1510_8250(struct uart_8250_port *pt)
  121. {
  122. return 0;
  123. }
  124. #endif