serialP.h 4.8 KB

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