serialP.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Private header file for the (dumb) serial driver
  3. *
  4. * Copyright (C) 1997 by Theodore Ts'o.
  5. *
  6. * Redistribution of this file is permitted under the terms of the GNU
  7. * Public License (GPL)
  8. */
  9. #ifndef _LINUX_SERIALP_H
  10. #define _LINUX_SERIALP_H
  11. /*
  12. * This is our internal structure for each serial port's state.
  13. *
  14. * Many fields are paralleled by the structure used by the serial_struct
  15. * structure.
  16. *
  17. * For definitions of the flags field, see tty.h
  18. */
  19. #include <linux/version.h>
  20. #include <linux/config.h>
  21. #include <linux/termios.h>
  22. #include <linux/workqueue.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/circ_buf.h>
  25. #include <linux/wait.h>
  26. struct serial_state {
  27. int magic;
  28. int baud_base;
  29. unsigned long port;
  30. int irq;
  31. int flags;
  32. int hub6;
  33. int type;
  34. int line;
  35. int revision; /* Chip revision (950) */
  36. int xmit_fifo_size;
  37. int custom_divisor;
  38. int count;
  39. u8 *iomem_base;
  40. u16 iomem_reg_shift;
  41. unsigned short close_delay;
  42. unsigned short closing_wait; /* time to wait before closing */
  43. struct async_icount icount;
  44. int io_type;
  45. struct async_struct *info;
  46. struct pci_dev *dev;
  47. };
  48. struct async_struct {
  49. int magic;
  50. unsigned long port;
  51. int hub6;
  52. int flags;
  53. int xmit_fifo_size;
  54. struct serial_state *state;
  55. struct tty_struct *tty;
  56. int read_status_mask;
  57. int ignore_status_mask;
  58. int timeout;
  59. int quot;
  60. int x_char; /* xon/xoff character */
  61. int close_delay;
  62. unsigned short closing_wait;
  63. unsigned short closing_wait2; /* obsolete */
  64. int IER; /* Interrupt Enable Register */
  65. int MCR; /* Modem control register */
  66. int LCR; /* Line control register */
  67. int ACR; /* 16950 Additional Control Reg. */
  68. unsigned long event;
  69. unsigned long last_active;
  70. int line;
  71. int blocked_open; /* # of blocked opens */
  72. struct circ_buf xmit;
  73. spinlock_t xmit_lock;
  74. u8 *iomem_base;
  75. u16 iomem_reg_shift;
  76. int io_type;
  77. struct work_struct work;
  78. struct tasklet_struct tlet;
  79. #ifdef DECLARE_WAITQUEUE
  80. wait_queue_head_t open_wait;
  81. wait_queue_head_t close_wait;
  82. wait_queue_head_t delta_msr_wait;
  83. #else
  84. struct wait_queue *open_wait;
  85. struct wait_queue *close_wait;
  86. struct wait_queue *delta_msr_wait;
  87. #endif
  88. struct async_struct *next_port; /* For the linked list */
  89. struct async_struct *prev_port;
  90. };
  91. #define CONFIGURED_SERIAL_PORT(info) ((info)->port || ((info)->iomem_base))
  92. #define SERIAL_MAGIC 0x5301
  93. #define SSTATE_MAGIC 0x5302
  94. /*
  95. * Events are used to schedule things to happen at timer-interrupt
  96. * time, instead of at rs interrupt time.
  97. */
  98. #define RS_EVENT_WRITE_WAKEUP 0
  99. /*
  100. * Multiport serial configuration structure --- internal structure
  101. */
  102. struct rs_multiport_struct {
  103. int port1;
  104. unsigned char mask1, match1;
  105. int port2;
  106. unsigned char mask2, match2;
  107. int port3;
  108. unsigned char mask3, match3;
  109. int port4;
  110. unsigned char mask4, match4;
  111. int port_monitor;
  112. };
  113. #if defined(__alpha__) && !defined(CONFIG_PCI)
  114. /*
  115. * Digital did something really horribly wrong with the OUT1 and OUT2
  116. * lines on at least some ALPHA's. The failure mode is that if either
  117. * is cleared, the machine locks up with endless interrupts.
  118. *
  119. * This is still used by arch/mips/au1000/common/serial.c for some weird
  120. * reason (mips != alpha!)
  121. */
  122. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
  123. #elif defined(CONFIG_SBC8560)
  124. /*
  125. * WindRiver did something similarly broken on their SBC8560 board. The
  126. * UART tristates its IRQ output while OUT2 is clear, but they pulled
  127. * the interrupt line _up_ instead of down, so if we register the IRQ
  128. * while the UART is in that state, we die in an IRQ storm. */
  129. #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
  130. #else
  131. #define ALPHA_KLUDGE_MCR 0
  132. #endif
  133. /*
  134. * Definitions for PCI support.
  135. */
  136. #define SPCI_FL_BASE_MASK 0x0007
  137. #define SPCI_FL_BASE0 0x0000
  138. #define SPCI_FL_BASE1 0x0001
  139. #define SPCI_FL_BASE2 0x0002
  140. #define SPCI_FL_BASE3 0x0003
  141. #define SPCI_FL_BASE4 0x0004
  142. #define SPCI_FL_GET_BASE(x) (x & SPCI_FL_BASE_MASK)
  143. #define SPCI_FL_IRQ_MASK (0x0007 << 4)
  144. #define SPCI_FL_IRQBASE0 (0x0000 << 4)
  145. #define SPCI_FL_IRQBASE1 (0x0001 << 4)
  146. #define SPCI_FL_IRQBASE2 (0x0002 << 4)
  147. #define SPCI_FL_IRQBASE3 (0x0003 << 4)
  148. #define SPCI_FL_IRQBASE4 (0x0004 << 4)
  149. #define SPCI_FL_GET_IRQBASE(x) ((x & SPCI_FL_IRQ_MASK) >> 4)
  150. /* Use successive BARs (PCI base address registers),
  151. else use offset into some specified BAR */
  152. #define SPCI_FL_BASE_TABLE 0x0100
  153. /* Use successive entries in the irq resource table */
  154. #define SPCI_FL_IRQ_TABLE 0x0200
  155. /* Use the irq resource table instead of dev->irq */
  156. #define SPCI_FL_IRQRESOURCE 0x0400
  157. /* Use the Base address register size to cap number of ports */
  158. #define SPCI_FL_REGION_SZ_CAP 0x0800
  159. /* Do not use irq sharing for this device */
  160. #define SPCI_FL_NO_SHIRQ 0x1000
  161. /* This is a PNP device */
  162. #define SPCI_FL_ISPNP 0x2000
  163. #define SPCI_FL_PNPDEFAULT (SPCI_FL_IRQRESOURCE|SPCI_FL_ISPNP)
  164. #endif /* _LINUX_SERIAL_H */