8250.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. /*
  27. * This replaces serial_uart_config in include/linux/serial.h
  28. */
  29. struct serial8250_config {
  30. const char *name;
  31. unsigned short fifo_size;
  32. unsigned short tx_loadsz;
  33. unsigned char fcr;
  34. unsigned int flags;
  35. };
  36. #define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
  37. #define UART_CAP_EFR (1 << 9) /* UART has EFR */
  38. #define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
  39. #define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
  40. #define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
  41. #define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
  42. #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
  43. #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
  44. #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
  45. #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
  46. #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */
  47. #define PROBE_RSA (1 << 0)
  48. #define PROBE_ANY (~0)
  49. #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
  50. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  51. #define SERIAL8250_SHARE_IRQS 1
  52. #else
  53. #define SERIAL8250_SHARE_IRQS 0
  54. #endif
  55. static inline int serial_in(struct uart_8250_port *up, int offset)
  56. {
  57. return up->port.serial_in(&up->port, offset);
  58. }
  59. static inline void serial_out(struct uart_8250_port *up, int offset, int value)
  60. {
  61. up->port.serial_out(&up->port, offset, value);
  62. }
  63. void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
  64. static inline int serial_dl_read(struct uart_8250_port *up)
  65. {
  66. return up->dl_read(up);
  67. }
  68. static inline void serial_dl_write(struct uart_8250_port *up, int value)
  69. {
  70. up->dl_write(up, value);
  71. }
  72. #if defined(__alpha__) && !defined(CONFIG_PCI)
  73. /*
  74. * Digital did something really horribly wrong with the OUT1 and OUT2
  75. * lines on at least some ALPHA's. The failure mode is that if either
  76. * is cleared, the machine locks up with endless interrupts.
  77. */
  78. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  79. #elif defined(CONFIG_SBC8560)
  80. /*
  81. * WindRiver did something similarly broken on their SBC8560 board. The
  82. * UART tristates its IRQ output while OUT2 is clear, but they pulled
  83. * the interrupt line _up_ instead of down, so if we register the IRQ
  84. * while the UART is in that state, we die in an IRQ storm. */
  85. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
  86. #else
  87. #define ALPHA_KLUDGE_MCR 0
  88. #endif