Linux 2.6.17.7
[linux/fpc-iii.git] / drivers / sbus / char / aurora.h
blobb8b5476d986016ef47e0fd30f23b1db6fde8a9e5
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
4 * Copyright (c) 1999 by Oliver Aldulea (oli@bv.ro)
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.
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.
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.
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.
28 * Revision 1.0
30 * This is the first public release.
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).
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.
44 * I'm sorry about the alignment of the code. It was written in a
45 * 128x48 environment.
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.
62 #ifndef __LINUX_AURORA_H
63 #define __LINUX_AURORA_H
65 #include <linux/serial.h>
66 #include <linux/serialP.h>
68 #ifdef __KERNEL__
70 /* This is the number of boards to support. I've only tested this driver with
71 * one board, so it might not work.
73 #define AURORA_NBOARD 1
75 /* Useful ? Yes. But you can safely comment the warnings if they annoy you
76 * (let me say that again: the warnings in the code, not this define).
78 #define AURORA_PARANOIA_CHECK
80 /* Well, after many lost nights, I found that the IRQ for this board is
81 * selected from four built-in values by writing some bits in the
82 * configuration register. This causes a little problem to occur: which
83 * IRQ to select ? Which one is the best for the user ? Well, I finally
84 * decided for the following algorithm: if the "bintr" value is not acceptable
85 * (not within type_1_irq[], then test the "intr" value, if that fails too,
86 * try each value from type_1_irq until succeded. Hope it's ok.
87 * You can safely reorder the irq's.
89 #define TYPE_1_IRQS 4
90 unsigned char type_1_irq[TYPE_1_IRQS] = {
91 3, 5, 9, 13
93 /* I know something about another method of interrupt setting, but not enough.
94 * Also, this is for another type of board, so I first have to learn how to
95 * detect it.
96 #define TYPE_2_IRQS 3
97 unsigned char type_2_irq[TYPE_2_IRQS] = {
98 0, 0, 0 ** could anyone find these for me ? (see AURORA_ALLIRQ below) **
100 unsigned char type_2_mask[TYPE_2_IRQS] = {
101 32, 64, 128
105 /* The following section should only be modified by those who know what
106 * they're doing (or don't, but want to help with some feedback). Modifying
107 * anything raises a _big_ probability for your system to hang, but the
108 * sacrifice worths. (I sacrificed my ext2fs many, many times...)
111 /* This one tries to dump to console the name of almost every function called,
112 * and many other debugging info.
114 #undef AURORA_DEBUG
116 /* These are the most dangerous and useful defines. They do printk() during
117 * the interrupt processing routine(s), so if you manage to get "flooded" by
118 * irq's, start thinking about the "Power off/on" button...
120 #undef AURORA_INTNORM /* This one enables the "normal" messages, but some
121 * of them cause flood, so I preffered putting
122 * them under a define */
123 #undef AURORA_INT_DEBUG /* This one is really bad. */
125 /* Here's something helpful: after n irq's, the board will be disabled. This
126 * prevents irq flooding during debug (no need to think about power
127 * off/on anymore...)
129 #define AURORA_FLOODPRO 10
131 /* This one helps finding which irq the board calls, in case of a strange/
132 * unsupported board. AURORA_INT_DEBUG should be enabled, because I don't
133 * think /proc/interrupts or any command will be available in case of an irq
134 * flood... "allirq" is the list of all free irq's.
137 #define AURORA_ALLIRQ 6
138 int allirq[AURORA_ALLIRQ]={
139 2,3,5,7,9,13
143 /* These must not be modified. These values are assumed during the code for
144 * performance optimisations.
146 #define AURORA_NCD180 2 /* two chips per board */
147 #define AURORA_NPORT 8 /* 8 ports per chip */
149 /* several utilities */
150 #define AURORA_BOARD(line) (((line) >> 4) & 0x01)
151 #define AURORA_CD180(line) (((line) >> 3) & 0x01)
152 #define AURORA_PORT(line) ((line) & 15)
154 #define AURORA_TNPORTS (AURORA_NBOARD*AURORA_NCD180*AURORA_NPORT)
156 /* Ticks per sec. Used for setting receiver timeout and break length */
157 #define AURORA_TPS 4000
159 #define AURORA_MAGIC 0x0A18
161 /* Yeah, after heavy testing I decided it must be 6.
162 * Sure, You can change it if needed.
164 #define AURORA_RXFIFO 6 /* Max. receiver FIFO size (1-8) */
166 #define AURORA_RXTH 7
168 struct aurora_reg1 {
169 __volatile__ unsigned char r;
172 struct aurora_reg128 {
173 __volatile__ unsigned char r[128];
176 struct aurora_reg4 {
177 __volatile__ unsigned char r[4];
180 struct Aurora_board {
181 unsigned long flags;
182 struct aurora_reg1 * r0; /* This is the board configuration
183 * register (write-only). */
184 struct aurora_reg128 * r[2]; /* These are the registers for the
185 * two chips. */
186 struct aurora_reg4 * r3; /* These are used for hardware-based
187 * acknowledge. Software-based ack is
188 * not supported by CD180. */
189 unsigned int oscfreq; /* The on-board oscillator
190 * frequency, in Hz. */
191 unsigned char irq;
192 #ifdef MODULE
193 signed char count; /* counts the use of the board */
194 #endif
195 /* Values for the dtr_rts swapped mode. */
196 unsigned char DTR;
197 unsigned char RTS;
198 unsigned char MSVDTR;
199 unsigned char MSVRTS;
200 /* Values for hardware acknowledge. */
201 unsigned char ACK_MINT, ACK_TINT, ACK_RINT;
204 /* Board configuration register */
205 #define AURORA_CFG_ENABLE_IO 8
206 #define AURORA_CFG_ENABLE_IRQ 4
208 /* Board flags */
209 #define AURORA_BOARD_PRESENT 0x00000001
210 #define AURORA_BOARD_ACTIVE 0x00000002
211 #define AURORA_BOARD_TYPE_2 0x00000004 /* don't know how to
212 * detect this yet */
213 #define AURORA_BOARD_DTR_FLOW_OK 0x00000008
215 /* The story goes like this: Cirrus programmed the CD-180 chip to do automatic
216 * hardware flow control, and do it using CTS and DTR. CTS is ok, but, if you
217 * have a modem and the chip drops DTR, then the modem will drop the carrier
218 * (ain't that cute...). Luckily, the guys at Aurora decided to swap DTR and
219 * RTS, which makes the flow control usable. I hope that all the boards made
220 * by Aurora have these two signals swapped. If your's doesn't but you have a
221 * breakout box, you can try to reverse them yourself, then set the following
222 * flag.
224 #undef AURORA_FORCE_DTR_FLOW
226 /* In fact, a few more words have to be said about hardware flow control.
227 * This driver handles "output" flow control through the on-board facility
228 * CTS Auto Enable. For the "input" flow control there are two cases when
229 * the flow should be controlled. The first case is when the kernel is so
230 * busy that it cannot process IRQ's in time; this flow control can only be
231 * activated by the on-board chip, and if the board has RTS and DTR swapped,
232 * this facility is usable. The second case is when the application is so
233 * busy that it cannot receive bytes from the kernel, and this flow must be
234 * activated by software. This second case is not yet implemented in this
235 * driver. Unfortunately, I estimate that the second case is the one that
236 * occurs the most.
240 struct Aurora_port {
241 int magic;
242 int baud_base;
243 int flags;
244 struct tty_struct * tty;
245 int count;
246 int blocked_open;
247 long event;
248 int timeout;
249 int close_delay;
250 unsigned char * xmit_buf;
251 int custom_divisor;
252 int xmit_head;
253 int xmit_tail;
254 int xmit_cnt;
255 wait_queue_head_t open_wait;
256 wait_queue_head_t close_wait;
257 struct tq_struct tqueue;
258 struct tq_struct tqueue_hangup;
259 short wakeup_chars;
260 short break_length;
261 unsigned short closing_wait;
262 unsigned char mark_mask;
263 unsigned char SRER;
264 unsigned char MSVR;
265 unsigned char COR2;
266 #ifdef AURORA_REPORT_OVERRUN
267 unsigned long overrun;
268 #endif
269 #ifdef AURORA_REPORT_FIFO
270 unsigned long hits[10];
271 #endif
274 #endif
275 #endif /*__LINUX_AURORA_H*/