aurora.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /* $Id: aurora.h,v 1.6 2001/06/05 12:23:38 davem Exp $
  2. * linux/drivers/sbus/char/aurora.h -- Aurora multiport driver
  3. *
  4. * Copyright (c) 1999 by Oliver Aldulea (oli@bv.ro)
  5. *
  6. * This code is based on the RISCom/8 multiport serial driver written
  7. * by Dmitry Gorodchanin (pgmdsg@ibi.com), based on the Linux serial
  8. * driver, written by Linus Torvalds, Theodore T'so and others.
  9. * The Aurora multiport programming info was obtained mainly from the
  10. * Cirrus Logic CD180 documentation (available on the web), and by
  11. * doing heavy tests on the board. Many thanks to Eddie C. Dost for the
  12. * help on the sbus interface.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. *
  28. * Revision 1.0
  29. *
  30. * This is the first public release.
  31. *
  32. * This version needs a lot of feedback. This is the version that works
  33. * with _my_ board. My board is model 1600se, revision '@(#)1600se.fth
  34. * 1.2 3/28/95 1'. The driver might work with your board, but I do not
  35. * guarantee it. If you have _any_ type of board, I need to know if the
  36. * driver works or not, I need to know exactly your board parameters
  37. * (get them with 'cd /proc/openprom/iommu/sbus/sio16/; ls *; cat *')
  38. * Also, I need your board revision code, which is written on the board.
  39. * Send me the output of my driver too (it outputs through klogd).
  40. *
  41. * If the driver does not work, you can try enabling the debug options
  42. * to see what's wrong or what should be done.
  43. *
  44. * I'm sorry about the alignment of the code. It was written in a
  45. * 128x48 environment.
  46. *
  47. * I must say that I do not like Aurora Technologies' policy. I asked
  48. * them to help me do this driver faster, but they ended by something
  49. * like "don't call us, we'll call you", and I never heard anything
  50. * from them. They told me "knowing the way the board works, I don't
  51. * doubt you and others on the net will make the driver."
  52. * The truth about this board is that it has nothing intelligent on it.
  53. * If you want to say to somebody what kind of board you have, say that
  54. * it uses Cirrus Logic processors (CD180). The power of the board is
  55. * in those two chips. The rest of the board is the interface to the
  56. * sbus and to the peripherals. Still, they did something smart: they
  57. * reversed DTR and RTS to make on-board automatic hardware flow
  58. * control usable.
  59. * Thanks to Aurora Technologies for wasting my time, nerves and money.
  60. */
  61. #ifndef __LINUX_AURORA_H
  62. #define __LINUX_AURORA_H
  63. #include <linux/serial.h>
  64. #include <linux/serialP.h>
  65. #ifdef __KERNEL__
  66. /* This is the number of boards to support. I've only tested this driver with
  67. * one board, so it might not work.
  68. */
  69. #define AURORA_NBOARD 1
  70. /* Useful ? Yes. But you can safely comment the warnings if they annoy you
  71. * (let me say that again: the warnings in the code, not this define).
  72. */
  73. #define AURORA_PARANOIA_CHECK
  74. /* Well, after many lost nights, I found that the IRQ for this board is
  75. * selected from four built-in values by writing some bits in the
  76. * configuration register. This causes a little problem to occur: which
  77. * IRQ to select ? Which one is the best for the user ? Well, I finally
  78. * decided for the following algorithm: if the "bintr" value is not acceptable
  79. * (not within type_1_irq[], then test the "intr" value, if that fails too,
  80. * try each value from type_1_irq until succeded. Hope it's ok.
  81. * You can safely reorder the irq's.
  82. */
  83. #define TYPE_1_IRQS 4
  84. unsigned char type_1_irq[TYPE_1_IRQS] = {
  85. 3, 5, 9, 13
  86. };
  87. /* I know something about another method of interrupt setting, but not enough.
  88. * Also, this is for another type of board, so I first have to learn how to
  89. * detect it.
  90. #define TYPE_2_IRQS 3
  91. unsigned char type_2_irq[TYPE_2_IRQS] = {
  92. 0, 0, 0 ** could anyone find these for me ? (see AURORA_ALLIRQ below) **
  93. };
  94. unsigned char type_2_mask[TYPE_2_IRQS] = {
  95. 32, 64, 128
  96. };
  97. */
  98. /* The following section should only be modified by those who know what
  99. * they're doing (or don't, but want to help with some feedback). Modifying
  100. * anything raises a _big_ probability for your system to hang, but the
  101. * sacrifice worths. (I sacrificed my ext2fs many, many times...)
  102. */
  103. /* This one tries to dump to console the name of almost every function called,
  104. * and many other debugging info.
  105. */
  106. #undef AURORA_DEBUG
  107. /* These are the most dangerous and useful defines. They do printk() during
  108. * the interrupt processing routine(s), so if you manage to get "flooded" by
  109. * irq's, start thinking about the "Power off/on" button...
  110. */
  111. #undef AURORA_INTNORM /* This one enables the "normal" messages, but some
  112. * of them cause flood, so I preffered putting
  113. * them under a define */
  114. #undef AURORA_INT_DEBUG /* This one is really bad. */
  115. /* Here's something helpful: after n irq's, the board will be disabled. This
  116. * prevents irq flooding during debug (no need to think about power
  117. * off/on anymore...)
  118. */
  119. #define AURORA_FLOODPRO 10
  120. /* This one helps finding which irq the board calls, in case of a strange/
  121. * unsupported board. AURORA_INT_DEBUG should be enabled, because I don't
  122. * think /proc/interrupts or any command will be available in case of an irq
  123. * flood... "allirq" is the list of all free irq's.
  124. */
  125. /*
  126. #define AURORA_ALLIRQ 6
  127. int allirq[AURORA_ALLIRQ]={
  128. 2,3,5,7,9,13
  129. };
  130. */
  131. /* These must not be modified. These values are assumed during the code for
  132. * performance optimisations.
  133. */
  134. #define AURORA_NCD180 2 /* two chips per board */
  135. #define AURORA_NPORT 8 /* 8 ports per chip */
  136. /* several utilities */
  137. #define AURORA_BOARD(line) (((line) >> 4) & 0x01)
  138. #define AURORA_CD180(line) (((line) >> 3) & 0x01)
  139. #define AURORA_PORT(line) ((line) & 15)
  140. #define AURORA_TNPORTS (AURORA_NBOARD*AURORA_NCD180*AURORA_NPORT)
  141. /* Ticks per sec. Used for setting receiver timeout and break length */
  142. #define AURORA_TPS 4000
  143. #define AURORA_MAGIC 0x0A18
  144. /* Yeah, after heavy testing I decided it must be 6.
  145. * Sure, You can change it if needed.
  146. */
  147. #define AURORA_RXFIFO 6 /* Max. receiver FIFO size (1-8) */
  148. #define AURORA_RXTH 7
  149. struct aurora_reg1 {
  150. __volatile__ unsigned char r;
  151. };
  152. struct aurora_reg128 {
  153. __volatile__ unsigned char r[128];
  154. };
  155. struct aurora_reg4 {
  156. __volatile__ unsigned char r[4];
  157. };
  158. struct Aurora_board {
  159. unsigned long flags;
  160. struct aurora_reg1 * r0; /* This is the board configuration
  161. * register (write-only). */
  162. struct aurora_reg128 * r[2]; /* These are the registers for the
  163. * two chips. */
  164. struct aurora_reg4 * r3; /* These are used for hardware-based
  165. * acknowledge. Software-based ack is
  166. * not supported by CD180. */
  167. unsigned int oscfreq; /* The on-board oscillator
  168. * frequency, in Hz. */
  169. unsigned char irq;
  170. #ifdef MODULE
  171. signed char count; /* counts the use of the board */
  172. #endif
  173. /* Values for the dtr_rts swapped mode. */
  174. unsigned char DTR;
  175. unsigned char RTS;
  176. unsigned char MSVDTR;
  177. unsigned char MSVRTS;
  178. /* Values for hardware acknowledge. */
  179. unsigned char ACK_MINT, ACK_TINT, ACK_RINT;
  180. };
  181. /* Board configuration register */
  182. #define AURORA_CFG_ENABLE_IO 8
  183. #define AURORA_CFG_ENABLE_IRQ 4
  184. /* Board flags */
  185. #define AURORA_BOARD_PRESENT 0x00000001
  186. #define AURORA_BOARD_ACTIVE 0x00000002
  187. #define AURORA_BOARD_TYPE_2 0x00000004 /* don't know how to
  188. * detect this yet */
  189. #define AURORA_BOARD_DTR_FLOW_OK 0x00000008
  190. /* The story goes like this: Cirrus programmed the CD-180 chip to do automatic
  191. * hardware flow control, and do it using CTS and DTR. CTS is ok, but, if you
  192. * have a modem and the chip drops DTR, then the modem will drop the carrier
  193. * (ain't that cute...). Luckily, the guys at Aurora decided to swap DTR and
  194. * RTS, which makes the flow control usable. I hope that all the boards made
  195. * by Aurora have these two signals swapped. If your's doesn't but you have a
  196. * breakout box, you can try to reverse them yourself, then set the following
  197. * flag.
  198. */
  199. #undef AURORA_FORCE_DTR_FLOW
  200. /* In fact, a few more words have to be said about hardware flow control.
  201. * This driver handles "output" flow control through the on-board facility
  202. * CTS Auto Enable. For the "input" flow control there are two cases when
  203. * the flow should be controlled. The first case is when the kernel is so
  204. * busy that it cannot process IRQ's in time; this flow control can only be
  205. * activated by the on-board chip, and if the board has RTS and DTR swapped,
  206. * this facility is usable. The second case is when the application is so
  207. * busy that it cannot receive bytes from the kernel, and this flow must be
  208. * activated by software. This second case is not yet implemented in this
  209. * driver. Unfortunately, I estimate that the second case is the one that
  210. * occurs the most.
  211. */
  212. struct Aurora_port {
  213. int magic;
  214. int baud_base;
  215. int flags;
  216. struct tty_struct * tty;
  217. int count;
  218. int blocked_open;
  219. long event;
  220. int timeout;
  221. int close_delay;
  222. unsigned char * xmit_buf;
  223. int custom_divisor;
  224. int xmit_head;
  225. int xmit_tail;
  226. int xmit_cnt;
  227. wait_queue_head_t open_wait;
  228. wait_queue_head_t close_wait;
  229. struct tq_struct tqueue;
  230. struct tq_struct tqueue_hangup;
  231. short wakeup_chars;
  232. short break_length;
  233. unsigned short closing_wait;
  234. unsigned char mark_mask;
  235. unsigned char SRER;
  236. unsigned char MSVR;
  237. unsigned char COR2;
  238. #ifdef AURORA_REPORT_OVERRUN
  239. unsigned long overrun;
  240. #endif
  241. #ifdef AURORA_REPORT_FIFO
  242. unsigned long hits[10];
  243. #endif
  244. };
  245. #endif
  246. #endif /*__LINUX_AURORA_H*/