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 62 #ifndef __LINUX_AURORA_H 63 #define __LINUX_AURORA_H 64 65 #include <linux/serial.h> 66 #include <linux/serialP.h> 67 68 #ifdef __KERNEL__ 69 70 /* This is the number of boards to support. I've only tested this driver with 71 * one board, so it might not work. 72 */ 73 #define AURORA_NBOARD 1 74 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). 77 */ 78 #define AURORA_PARANOIA_CHECK 79 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. 88 */ 89 #define TYPE_1_IRQS 4 90 unsigned char type_1_irq[TYPE_1_IRQS] = { 91 3, 5, 9, 13 92 }; 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) ** 99 }; 100 unsigned char type_2_mask[TYPE_2_IRQS] = { 101 32, 64, 128 102 }; 103 */ 104 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...) 109 */ 110 111 /* This one tries to dump to console the name of almost every function called, 112 * and many other debugging info. 113 */ 114 #undef AURORA_DEBUG 115 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... 119 */ 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. */ 124 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...) 128 */ 129 #define AURORA_FLOODPRO 10 130 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. 135 */ 136 /* 137 #define AURORA_ALLIRQ 6 138 int allirq[AURORA_ALLIRQ]={ 139 2,3,5,7,9,13 140 }; 141 */ 142 143 /* These must not be modified. These values are assumed during the code for 144 * performance optimisations. 145 */ 146 #define AURORA_NCD180 2 /* two chips per board */ 147 #define AURORA_NPORT 8 /* 8 ports per chip */ 148 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) 153 154 #define AURORA_TNPORTS (AURORA_NBOARD*AURORA_NCD180*AURORA_NPORT) 155 156 /* Ticks per sec. Used for setting receiver timeout and break length */ 157 #define AURORA_TPS 4000 158 159 #define AURORA_MAGIC 0x0A18 160 161 /* Yeah, after heavy testing I decided it must be 6. 162 * Sure, You can change it if needed. 163 */ 164 #define AURORA_RXFIFO 6 /* Max. receiver FIFO size (1-8) */ 165 166 #define AURORA_RXTH 7 167 168 struct aurora_reg1 { 169 __volatile__ unsigned char r; 170 }; 171 172 struct aurora_reg128 { 173 __volatile__ unsigned char r[128]; 174 }; 175 176 struct aurora_reg4 { 177 __volatile__ unsigned char r[4]; 178 }; 179 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; 202 }; 203 204 /* Board configuration register */ 205 #define AURORA_CFG_ENABLE_IO 8 206 #define AURORA_CFG_ENABLE_IRQ 4 207 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 214 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. 223 */ 224 #undef AURORA_FORCE_DTR_FLOW 225 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. 237 */ 238 239 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 long session; 251 long pgrp; 252 unsigned char * xmit_buf; 253 int custom_divisor; 254 int xmit_head; 255 int xmit_tail; 256 int xmit_cnt; 257 struct termios normal_termios; 258 wait_queue_head_t open_wait; 259 wait_queue_head_t close_wait; 260 struct tq_struct tqueue; 261 struct tq_struct tqueue_hangup; 262 short wakeup_chars; 263 short break_length; 264 unsigned short closing_wait; 265 unsigned char mark_mask; 266 unsigned char SRER; 267 unsigned char MSVR; 268 unsigned char COR2; 269 #ifdef AURORA_REPORT_OVERRUN 270 unsigned long overrun; 271 #endif 272 #ifdef AURORA_REPORT_FIFO 273 unsigned long hits[10]; 274 #endif 275 }; 276 277 #endif 278 #endif /*__LINUX_AURORA_H*/ 279 280