68328serial.h 5.9 KB

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