68328serial.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* 68328serial.h: Definitions for the mc68328 serial driver.
  2. *
  3. * Copyright (C) 1995 David S. Miller <davem@caip.rutgers.edu>
  4. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  5. * Copyright (C) 1998, 1999 D. Jeff Dionne <jeff@uclinux.org>
  6. * Copyright (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>
  7. *
  8. * VZ Support/Fixes Evan Stawnyczy <e@lineo.ca>
  9. */
  10. #ifndef _MC683XX_SERIAL_H
  11. #define _MC683XX_SERIAL_H
  12. #include <linux/config.h>
  13. struct serial_struct {
  14. int type;
  15. int line;
  16. int port;
  17. int irq;
  18. int flags;
  19. int xmit_fifo_size;
  20. int custom_divisor;
  21. int baud_base;
  22. unsigned short close_delay;
  23. char reserved_char[2];
  24. int hub6; /* FIXME: We don't have AT&T Hub6 boards! */
  25. unsigned short closing_wait; /* time to wait before closing */
  26. unsigned short closing_wait2; /* no longer used... */
  27. int reserved[4];
  28. };
  29. /*
  30. * For the close wait times, 0 means wait forever for serial port to
  31. * flush its output. 65535 means don't wait at all.
  32. */
  33. #define S_CLOSING_WAIT_INF 0
  34. #define S_CLOSING_WAIT_NONE 65535
  35. /*
  36. * Definitions for S_struct (and serial_struct) flags field
  37. */
  38. #define S_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes
  39. on the callout port */
  40. #define S_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */
  41. #define S_SAK 0x0004 /* Secure Attention Key (Orange book) */
  42. #define S_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */
  43. #define S_SPD_MASK 0x0030
  44. #define S_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */
  45. #define S_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */
  46. #define S_SPD_CUST 0x0030 /* Use user-specified divisor */
  47. #define S_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */
  48. #define S_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */
  49. #define S_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
  50. #define S_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */
  51. #define S_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */
  52. #define S_FLAGS 0x0FFF /* Possible legal S flags */
  53. #define S_USR_MASK 0x0430 /* Legal flags that non-privileged
  54. * users can set or reset */
  55. /* Internal flags used only by kernel/chr_drv/serial.c */
  56. #define S_INITIALIZED 0x80000000 /* Serial port was initialized */
  57. #define S_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */
  58. #define S_NORMAL_ACTIVE 0x20000000 /* Normal device is active */
  59. #define S_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */
  60. #define S_CLOSING 0x08000000 /* Serial port is closing */
  61. #define S_CTS_FLOW 0x04000000 /* Do CTS flow control */
  62. #define S_CHECK_CD 0x02000000 /* i.e., CLOCAL */
  63. /* Software state per channel */
  64. #ifdef __KERNEL__
  65. /*
  66. * I believe this is the optimal setting that reduces the number of interrupts.
  67. * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
  68. * if that bothers you), but in most cases it will not, since we try to
  69. * transmit characters every time rs_interrupt is called. Thus, quite often
  70. * you'll see that a receive interrupt occures before the transmit one.
  71. * -- Vladimir Gurevich
  72. */
  73. #define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
  74. /*
  75. * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
  76. * "Old data interrupt" which occures whenever the data stay in the FIFO
  77. * longer than 30 bits time. This allows us to use FIFO without compromising
  78. * latency. '328 does not have this feature and without the real 328-based
  79. * board I would assume that RXRE is the safest setting.
  80. *
  81. * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
  82. * interrupts. RXFE (receive queue full) causes the system to lose data
  83. * at least at 115200 baud
  84. *
  85. * If your board is busy doing other stuff, you might consider to use
  86. * RXRE (data ready intrrupt) instead.
  87. *
  88. * The other option is to make these INTR masks run-time configurable, so
  89. * that people can dynamically adapt them according to the current usage.
  90. * -- Vladimir Gurevich
  91. */
  92. /* (es) */
  93. #if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
  94. #define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
  95. #elif defined(CONFIG_M68328)
  96. #define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
  97. #else
  98. #error Please, define the Rx interrupt events for your CPU
  99. #endif
  100. /* (/es) */
  101. /*
  102. * This is our internal structure for each serial port's state.
  103. *
  104. * Many fields are paralleled by the structure used by the serial_struct
  105. * structure.
  106. *
  107. * For definitions of the flags field, see tty.h
  108. */
  109. struct m68k_serial {
  110. char soft_carrier; /* Use soft carrier on this channel */
  111. char break_abort; /* Is serial console in, so process brk/abrt */
  112. char is_cons; /* Is this our console. */
  113. /* We need to know the current clock divisor
  114. * to read the bps rate the chip has currently
  115. * loaded.
  116. */
  117. unsigned char clk_divisor; /* May be 1, 16, 32, or 64 */
  118. int baud;
  119. int magic;
  120. int baud_base;
  121. int port;
  122. int irq;
  123. int flags; /* defined in tty.h */
  124. int type; /* UART type */
  125. struct tty_struct *tty;
  126. int read_status_mask;
  127. int ignore_status_mask;
  128. int timeout;
  129. int xmit_fifo_size;
  130. int custom_divisor;
  131. int x_char; /* xon/xoff character */
  132. int close_delay;
  133. unsigned short closing_wait;
  134. unsigned short closing_wait2;
  135. unsigned long event;
  136. unsigned long last_active;
  137. int line;
  138. int count; /* # of fd on device */
  139. int blocked_open; /* # of blocked opens */
  140. unsigned char *xmit_buf;
  141. int xmit_head;
  142. int xmit_tail;
  143. int xmit_cnt;
  144. struct work_struct tqueue;
  145. struct work_struct tqueue_hangup;
  146. wait_queue_head_t open_wait;
  147. wait_queue_head_t close_wait;
  148. };
  149. #define SERIAL_MAGIC 0x5301
  150. /*
  151. * The size of the serial xmit buffer is 1 page, or 4096 bytes
  152. */
  153. #define SERIAL_XMIT_SIZE 4096
  154. /*
  155. * Events are used to schedule things to happen at timer-interrupt
  156. * time, instead of at rs interrupt time.
  157. */
  158. #define RS_EVENT_WRITE_WAKEUP 0
  159. /*
  160. * Define the number of ports supported and their irqs.
  161. */
  162. #ifndef CONFIG_68328_SERIAL_UART2
  163. #define NR_PORTS 1
  164. #define UART_IRQ_DEFNS {UART_IRQ_NUM}
  165. #else
  166. #define NR_PORTS 2
  167. #define UART_IRQ_DEFNS {UART1_IRQ_NUM, UART2_IRQ_NUM}
  168. #endif
  169. #endif /* __KERNEL__ */
  170. #endif /* !(_MC683XX_SERIAL_H) */