blob: 8825bd61b7d09e881daf5a887e74480c212b4850 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
2/* rio_linux.c -- Linux driver for the Specialix RIO series cards.
3 *
4 *
5 * (C) 1999 R.E.Wolff@BitWizard.nl
6 *
7 * Specialix pays for the development and support of this driver.
8 * Please DO contact support@specialix.co.uk if you require
9 * support. But please read the documentation (rio.txt) first.
10 *
11 *
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied
20 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 * PURPOSE. See the GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public
24 * License along with this program; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
26 * USA.
27 *
28 * Revision history:
29 * $Log: rio.c,v $
30 * Revision 1.1 1999/07/11 10:13:54 wolff
31 * Initial revision
32 *
33 * */
34
35#include <linux/module.h>
Andrew Morton8d8706e2006-01-11 12:17:49 -080036#include <linux/config.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/kdev_t.h>
38#include <asm/io.h>
39#include <linux/kernel.h>
40#include <linux/sched.h>
41#include <linux/ioport.h>
42#include <linux/interrupt.h>
43#include <linux/errno.h>
44#include <linux/tty.h>
45#include <linux/tty_flip.h>
46#include <linux/mm.h>
47#include <linux/serial.h>
48#include <linux/fcntl.h>
49#include <linux/major.h>
50#include <linux/delay.h>
51#include <linux/pci.h>
52#include <linux/slab.h>
53#include <linux/miscdevice.h>
54#include <linux/init.h>
55
56#include <linux/generic_serial.h>
57#include <asm/uaccess.h>
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#include "linux_compat.h"
60#include "typdef.h"
61#include "pkt.h"
62#include "daemon.h"
63#include "rio.h"
64#include "riospace.h"
65#include "top.h"
66#include "cmdpkt.h"
67#include "map.h"
68#include "riotypes.h"
69#include "rup.h"
70#include "port.h"
71#include "riodrvr.h"
72#include "rioinfo.h"
73#include "func.h"
74#include "errors.h"
75#include "pci.h"
76
77#include "parmmap.h"
78#include "unixrup.h"
79#include "board.h"
80#include "host.h"
81#include "error.h"
82#include "phb.h"
83#include "link.h"
84#include "cmdblk.h"
85#include "route.h"
86#include "control.h"
87#include "cirrus.h"
88#include "rioioctl.h"
89#include "param.h"
90#include "list.h"
91#include "sam.h"
92#include "protsts.h"
93#include "rioboard.h"
94
95
96#include "rio_linux.h"
97
98/* I don't think that this driver can handle more than 512 ports on
99one machine. Specialix specifies max 4 boards in one machine. I don't
100know why. If you want to try anyway you'll have to increase the number
101of boards in rio.h. You'll have to allocate more majors if you need
102more than 512 ports.... */
103
104#ifndef RIO_NORMAL_MAJOR0
105/* This allows overriding on the compiler commandline, or in a "major.h"
106 include or something like that */
107#define RIO_NORMAL_MAJOR0 154
108#define RIO_NORMAL_MAJOR1 156
109#endif
110
111#ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8
112#define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000
113#endif
114
Andrew Morton8d8706e2006-01-11 12:17:49 -0800115#ifndef RIO_WINDOW_LEN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#define RIO_WINDOW_LEN 0x10000
117#endif
118
119
120/* Configurable options:
121 (Don't be too sure that it'll work if you toggle them) */
122
123/* Am I paranoid or not ? ;-) */
124#undef RIO_PARANOIA_CHECK
125
126
127/* 20 -> 2000 per second. The card should rate-limit interrupts at 1000
128 Hz, but it is user configurable. I don't recommend going above 1000
129 Hz. The interrupt ratelimit might trigger if the interrupt is
130 shared with a very active other device.
131 undef this if you want to disable the check....
132*/
133#define IRQ_RATE_LIMIT 200
134
135#if 0
136/* Not implemented */
137/*
138 * The following defines are mostly for testing purposes. But if you need
139 * some nice reporting in your syslog, you can define them also.
140 */
141#define RIO_REPORT_FIFO
142#define RIO_REPORT_OVERRUN
Andrew Morton8d8706e2006-01-11 12:17:49 -0800143#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145
146/* These constants are derived from SCO Source */
147static struct Conf
Andrew Morton8d8706e2006-01-11 12:17:49 -0800148 RIOConf = {
149 /* locator */ "RIO Config here",
150 /* startuptime */ HZ * 2,
151 /* how long to wait for card to run */
152 /* slowcook */ 0,
153 /* TRUE -> always use line disc. */
154 /* intrpolltime */ 1,
155 /* The frequency of OUR polls */
156 /* breakinterval */ 25,
157 /* x10 mS XXX: units seem to be 1ms not 10! -- REW */
158 /* timer */ 10,
159 /* mS */
160 /* RtaLoadBase */ 0x7000,
161 /* HostLoadBase */ 0x7C00,
162 /* XpHz */ 5,
163 /* number of Xprint hits per second */
164 /* XpCps */ 120,
165 /* Xprint characters per second */
166 /* XpOn */ "\033d#",
167 /* start Xprint for a wyse 60 */
168 /* XpOff */ "\024",
169 /* end Xprint for a wyse 60 */
170 /* MaxXpCps */ 2000,
171 /* highest Xprint speed */
172 /* MinXpCps */ 10,
173 /* slowest Xprint speed */
174 /* SpinCmds */ 1,
175 /* non-zero for mega fast boots */
176 /* First Addr */ 0x0A0000,
177 /* First address to look at */
178 /* Last Addr */ 0xFF0000,
179 /* Last address looked at */
180 /* BufferSize */ 1024,
181 /* Bytes per port of buffering */
182 /* LowWater */ 256,
183 /* how much data left before wakeup */
184 /* LineLength */ 80,
185 /* how wide is the console? */
186 /* CmdTimeout */ HZ,
187 /* how long a close command may take */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188};
189
190
191
192
193/* Function prototypes */
194
Andrew Morton8d8706e2006-01-11 12:17:49 -0800195static void rio_disable_tx_interrupts(void *ptr);
196static void rio_enable_tx_interrupts(void *ptr);
197static void rio_disable_rx_interrupts(void *ptr);
198static void rio_enable_rx_interrupts(void *ptr);
199static int rio_get_CD(void *ptr);
200static void rio_shutdown_port(void *ptr);
201static int rio_set_real_termios(void *ptr);
202static void rio_hungup(void *ptr);
203static void rio_close(void *ptr);
204static int rio_chars_in_buffer(void *ptr);
205static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206static int rio_init_drivers(void);
207
Andrew Morton8d8706e2006-01-11 12:17:49 -0800208static void my_hd(void *addr, int len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210static struct tty_driver *rio_driver, *rio_driver2;
211
212/* The name "p" is a bit non-descript. But that's what the rio-lynxos
213sources use all over the place. */
214struct rio_info *p;
215
216int rio_debug;
217
218
219/* You can have the driver poll your card.
220 - Set rio_poll to 1 to poll every timer tick (10ms on Intel).
221 This is used when the card cannot use an interrupt for some reason.
222*/
223static int rio_poll = 1;
224
225
226/* These are the only open spaces in my computer. Yours may have more
227 or less.... */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800228static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Tobias Klauserfe971072006-01-09 20:54:02 -0800230#define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232
233/* Set the mask to all-ones. This alas, only supports 32 interrupts.
234 Some architectures may need more. -- Changed to LONG to
235 support up to 64 bits on 64bit architectures. -- REW 20/06/99 */
Adrian Bunk408b6642005-05-01 08:59:29 -0700236static long rio_irqmask = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>");
239MODULE_DESCRIPTION("RIO driver");
240MODULE_LICENSE("GPL");
241module_param(rio_poll, int, 0);
242module_param(rio_debug, int, 0644);
243module_param(rio_irqmask, long, 0);
244
245static struct real_driver rio_real_driver = {
Andrew Morton8d8706e2006-01-11 12:17:49 -0800246 rio_disable_tx_interrupts,
247 rio_enable_tx_interrupts,
248 rio_disable_rx_interrupts,
249 rio_enable_rx_interrupts,
250 rio_get_CD,
251 rio_shutdown_port,
252 rio_set_real_termios,
253 rio_chars_in_buffer,
254 rio_close,
255 rio_hungup,
256 NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257};
258
259/*
260 * Firmware loader driver specific routines
261 *
262 */
263
264static struct file_operations rio_fw_fops = {
Andrew Morton8d8706e2006-01-11 12:17:49 -0800265 .owner = THIS_MODULE,
266 .ioctl = rio_fw_ioctl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267};
268
269static struct miscdevice rio_fw_device = {
270 RIOCTL_MISC_MINOR, "rioctl", &rio_fw_fops
271};
272
273
274
275
276
277#ifdef RIO_PARANOIA_CHECK
278
279/* This doesn't work. Who's paranoid around here? Not me! */
280
Andrew Morton8d8706e2006-01-11 12:17:49 -0800281static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282{
283
Andrew Morton8d8706e2006-01-11 12:17:49 -0800284 static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n";
285 static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Andrew Morton8d8706e2006-01-11 12:17:49 -0800287 if (!port) {
288 printk(badinfo, name, routine);
289 return 1;
290 }
291 if (port->magic != RIO_MAGIC) {
292 printk(badmagic, name, routine);
293 return 1;
294 }
295
296 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297}
298#else
299#define rio_paranoia_check(a,b,c) 0
300#endif
301
302
303#ifdef DEBUG
Andrew Morton8d8706e2006-01-11 12:17:49 -0800304static void my_hd(void *ad, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800306 int i, j, ch;
307 unsigned char *addr = ad;
308
309 for (i = 0; i < len; i += 16) {
310 rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i);
311 for (j = 0; j < 16; j++) {
312 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
313 }
314 for (j = 0; j < 16; j++) {
315 ch = addr[j + i];
316 rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch));
317 }
318 rio_dprintk(RIO_DEBUG_PARAM, "\n");
319 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321#else
322#define my_hd(ad,len) do{/* nothing*/ } while (0)
323#endif
324
325
Andrew Morton8d8706e2006-01-11 12:17:49 -0800326/* Delay a number of jiffies, allowing a signal to interrupt */
327int RIODelay(struct Port *PortP, int njiffies)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800329 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Andrew Morton8d8706e2006-01-11 12:17:49 -0800331 rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);
332 msleep_interruptible(jiffies_to_msecs(njiffies));
333 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
Andrew Morton8d8706e2006-01-11 12:17:49 -0800335 if (signal_pending(current))
336 return RIO_FAIL;
337 else
338 return !RIO_FAIL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339}
340
341
Andrew Morton8d8706e2006-01-11 12:17:49 -0800342/* Delay a number of jiffies, disallowing a signal to interrupt */
343int RIODelay_ni(struct Port *PortP, int njiffies)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800345 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
Andrew Morton8d8706e2006-01-11 12:17:49 -0800347 rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);
348 msleep(jiffies_to_msecs(njiffies));
349 func_exit();
350 return !RIO_FAIL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351}
352
353
354int rio_minor(struct tty_struct *tty)
355{
356 return tty->index + (tty->driver == rio_driver) ? 0 : 256;
357}
358
359
360int rio_ismodem(struct tty_struct *tty)
361{
362 return 1;
363}
364
365
Andrew Morton8d8706e2006-01-11 12:17:49 -0800366static int rio_set_real_termios(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800368 int rv, modem;
369 struct tty_struct *tty;
370 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Andrew Morton8d8706e2006-01-11 12:17:49 -0800372 tty = ((struct Port *) ptr)->gs.tty;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
Andrew Morton8d8706e2006-01-11 12:17:49 -0800374 modem = rio_ismodem(tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375
Andrew Morton8d8706e2006-01-11 12:17:49 -0800376 rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
Andrew Morton8d8706e2006-01-11 12:17:49 -0800378 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Andrew Morton8d8706e2006-01-11 12:17:49 -0800380 return rv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381}
382
383
Andrew Morton8d8706e2006-01-11 12:17:49 -0800384static void rio_reset_interrupt(struct Host *HostP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800386 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
Andrew Morton8d8706e2006-01-11 12:17:49 -0800388 switch (HostP->Type) {
389 case RIO_AT:
390 case RIO_MCA:
391 case RIO_PCI:
392 WBYTE(HostP->ResetInt, 0xff);
393 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
Andrew Morton8d8706e2006-01-11 12:17:49 -0800395 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396}
397
398
Andrew Morton8d8706e2006-01-11 12:17:49 -0800399static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800401 struct Host *HostP;
402 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
Andrew Morton8d8706e2006-01-11 12:17:49 -0800404 HostP = (struct Host *) ptr; /* &p->RIOHosts[(long)ptr]; */
405 rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Andrew Morton8d8706e2006-01-11 12:17:49 -0800407 /* AAargh! The order in which to do these things is essential and
408 not trivial.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Andrew Morton8d8706e2006-01-11 12:17:49 -0800410 - Rate limit goes before "recursive". Otherwise a series of
411 recursive calls will hang the machine in the interrupt routine.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Andrew Morton8d8706e2006-01-11 12:17:49 -0800413 - hardware twiddling goes before "recursive". Otherwise when we
414 poll the card, and a recursive interrupt happens, we won't
415 ack the card, so it might keep on interrupting us. (especially
416 level sensitive interrupt systems like PCI).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
Andrew Morton8d8706e2006-01-11 12:17:49 -0800418 - Rate limit goes before hardware twiddling. Otherwise we won't
419 catch a card that has gone bonkers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Andrew Morton8d8706e2006-01-11 12:17:49 -0800421 - The "initialized" test goes after the hardware twiddling. Otherwise
422 the card will stick us in the interrupt routine again.
423
424 - The initialized test goes before recursive.
425 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
427
428
429#ifdef IRQ_RATE_LIMIT
Andrew Morton8d8706e2006-01-11 12:17:49 -0800430 /* Aaargh! I'm ashamed. This costs more lines-of-code than the
431 actual interrupt routine!. (Well, used to when I wrote that comment) */
432 {
433 static int lastjif;
434 static int nintr = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
Andrew Morton8d8706e2006-01-11 12:17:49 -0800436 if (lastjif == jiffies) {
437 if (++nintr > IRQ_RATE_LIMIT) {
438 free_irq(HostP->Ivec, ptr);
439 printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
440 }
441 } else {
442 lastjif = jiffies;
443 nintr = 0;
444 }
445 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446#endif
Andrew Morton8d8706e2006-01-11 12:17:49 -0800447 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
448 if (HostP->Ivec == irq) {
449 /* Tell the card we've noticed the interrupt. */
450 rio_reset_interrupt(HostP);
451 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Andrew Morton8d8706e2006-01-11 12:17:49 -0800453 if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
454 return IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
Andrew Morton8d8706e2006-01-11 12:17:49 -0800456 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
457 printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec);
458 return IRQ_HANDLED;
459 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
Andrew Morton8d8706e2006-01-11 12:17:49 -0800461 RIOServiceHost(p, HostP, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
Andrew Morton8d8706e2006-01-11 12:17:49 -0800463 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Andrew Morton8d8706e2006-01-11 12:17:49 -0800465 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
466 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
467 func_exit();
468 return IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
471
Andrew Morton8d8706e2006-01-11 12:17:49 -0800472static void rio_pollfunc(unsigned long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800474 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Andrew Morton8d8706e2006-01-11 12:17:49 -0800476 rio_interrupt(0, &p->RIOHosts[data], NULL);
477 p->RIOHosts[data].timer.expires = jiffies + rio_poll;
478 add_timer(&p->RIOHosts[data].timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Andrew Morton8d8706e2006-01-11 12:17:49 -0800480 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481}
482
483
484/* ********************************************************************** *
485 * Here are the routines that actually *
486 * interface with the generic_serial driver *
487 * ********************************************************************** */
488
489/* Ehhm. I don't know how to fiddle with interrupts on the Specialix
490 cards. .... Hmm. Ok I figured it out. You don't. -- REW */
491
Andrew Morton8d8706e2006-01-11 12:17:49 -0800492static void rio_disable_tx_interrupts(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800494 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
Andrew Morton8d8706e2006-01-11 12:17:49 -0800496 /* port->gs.flags &= ~GS_TX_INTEN; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
Andrew Morton8d8706e2006-01-11 12:17:49 -0800498 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499}
500
501
Andrew Morton8d8706e2006-01-11 12:17:49 -0800502static void rio_enable_tx_interrupts(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800504 struct Port *PortP = ptr;
505 /* int hn; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Andrew Morton8d8706e2006-01-11 12:17:49 -0800507 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
Andrew Morton8d8706e2006-01-11 12:17:49 -0800509 /* hn = PortP->HostP - p->RIOHosts;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
Andrew Morton8d8706e2006-01-11 12:17:49 -0800511 rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn);
512 rio_interrupt (-1,(void *) hn, NULL); */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
Andrew Morton8d8706e2006-01-11 12:17:49 -0800514 RIOTxEnable((char *) PortP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515
Andrew Morton8d8706e2006-01-11 12:17:49 -0800516 /*
517 * In general we cannot count on "tx empty" interrupts, although
518 * the interrupt routine seems to be able to tell the difference.
519 */
520 PortP->gs.flags &= ~GS_TX_INTEN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Andrew Morton8d8706e2006-01-11 12:17:49 -0800522 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
525
Andrew Morton8d8706e2006-01-11 12:17:49 -0800526static void rio_disable_rx_interrupts(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800528 func_enter();
529 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530}
531
Andrew Morton8d8706e2006-01-11 12:17:49 -0800532static void rio_enable_rx_interrupts(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800534 /* struct rio_port *port = ptr; */
535 func_enter();
536 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537}
538
539
540/* Jeez. Isn't this simple? */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800541static int rio_get_CD(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800543 struct Port *PortP = ptr;
544 int rv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
Andrew Morton8d8706e2006-01-11 12:17:49 -0800546 func_enter();
547 rv = (PortP->ModemState & MSVR1_CD) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
Andrew Morton8d8706e2006-01-11 12:17:49 -0800549 rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv);
550
551 func_exit();
552 return rv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553}
554
555
556/* Jeez. Isn't this simple? Actually, we can sync with the actual port
557 by just pushing stuff into the queue going to the port... */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800558static int rio_chars_in_buffer(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800560 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561
Andrew Morton8d8706e2006-01-11 12:17:49 -0800562 func_exit();
563 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564}
565
566
567/* Nothing special here... */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800568static void rio_shutdown_port(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800570 struct Port *PortP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571
Andrew Morton8d8706e2006-01-11 12:17:49 -0800572 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
Andrew Morton8d8706e2006-01-11 12:17:49 -0800574 PortP = (struct Port *) ptr;
575 PortP->gs.tty = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576#if 0
Andrew Morton8d8706e2006-01-11 12:17:49 -0800577 port->gs.flags &= ~GS_ACTIVE;
578 if (!port->gs.tty) {
579 rio_dprintk(RIO_DBUG_TTY, "No tty.\n");
580 return;
581 }
582 if (!port->gs.tty->termios) {
583 rio_dprintk(RIO_DEBUG_TTY, "No termios.\n");
584 return;
585 }
586 if (port->gs.tty->termios->c_cflag & HUPCL) {
587 rio_setsignals(port, 0, 0);
588 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589#endif
590
Andrew Morton8d8706e2006-01-11 12:17:49 -0800591 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592}
593
594
595/* I haven't the foggiest why the decrement use count has to happen
596 here. The whole linux serial drivers stuff needs to be redesigned.
597 My guess is that this is a hack to minimize the impact of a bug
598 elsewhere. Thinking about it some more. (try it sometime) Try
599 running minicom on a serial port that is driven by a modularized
600 driver. Have the modem hangup. Then remove the driver module. Then
601 exit minicom. I expect an "oops". -- REW */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800602static void rio_hungup(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800604 struct Port *PortP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
Andrew Morton8d8706e2006-01-11 12:17:49 -0800606 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607
Andrew Morton8d8706e2006-01-11 12:17:49 -0800608 PortP = (struct Port *) ptr;
609 PortP->gs.tty = NULL;
610
611 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612}
613
614
615/* The standard serial_close would become shorter if you'd wrap it like
616 this.
617 rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;}
618 */
Andrew Morton8d8706e2006-01-11 12:17:49 -0800619static void rio_close(void *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800621 struct Port *PortP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Andrew Morton8d8706e2006-01-11 12:17:49 -0800623 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
Andrew Morton8d8706e2006-01-11 12:17:49 -0800625 PortP = (struct Port *) ptr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Andrew Morton8d8706e2006-01-11 12:17:49 -0800627 riotclose(ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
Andrew Morton8d8706e2006-01-11 12:17:49 -0800629 if (PortP->gs.count) {
630 printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
631 PortP->gs.count = 0;
632 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Andrew Morton8d8706e2006-01-11 12:17:49 -0800634 PortP->gs.tty = NULL;
635 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636}
637
638
639
Andrew Morton8d8706e2006-01-11 12:17:49 -0800640static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800642 int rc = 0;
643 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644
Andrew Morton8d8706e2006-01-11 12:17:49 -0800645 /* The "dev" argument isn't used. */
646 rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647
Andrew Morton8d8706e2006-01-11 12:17:49 -0800648 func_exit();
649 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650}
651
Andrew Morton8d8706e2006-01-11 12:17:49 -0800652extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653
Andrew Morton8d8706e2006-01-11 12:17:49 -0800654static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800656 int rc;
657 struct Port *PortP;
658 int ival;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659
Andrew Morton8d8706e2006-01-11 12:17:49 -0800660 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661
Andrew Morton8d8706e2006-01-11 12:17:49 -0800662 PortP = (struct Port *) tty->driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
Andrew Morton8d8706e2006-01-11 12:17:49 -0800664 rc = 0;
665 switch (cmd) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666#if 0
Andrew Morton8d8706e2006-01-11 12:17:49 -0800667 case TIOCGSOFTCAR:
668 rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), (unsigned int *) arg);
669 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670#endif
Andrew Morton8d8706e2006-01-11 12:17:49 -0800671 case TIOCSSOFTCAR:
672 if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
673 tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0);
674 }
675 break;
676 case TIOCGSERIAL:
677 rc = -EFAULT;
678 if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct)))
679 rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg);
680 break;
681 case TCSBRK:
682 if (PortP->State & RIO_DELETED) {
683 rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
684 rc = -EIO;
685 } else {
686 if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) {
687 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
688 rc = -EIO;
689 }
690 }
691 break;
692 case TCSBRKP:
693 if (PortP->State & RIO_DELETED) {
694 rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
695 rc = -EIO;
696 } else {
697 int l;
698 l = arg ? arg * 100 : 250;
699 if (l > 255)
700 l = 255;
701 if (RIOShortCommand(p, PortP, SBREAK, 2, arg ? arg * 100 : 250) == RIO_FAIL) {
702 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
703 rc = -EIO;
704 }
705 }
706 break;
707 case TIOCSSERIAL:
708 rc = -EFAULT;
709 if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct)))
710 rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg);
711 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712#if 0
Andrew Morton8d8706e2006-01-11 12:17:49 -0800713 /*
714 * note: these IOCTLs no longer reach here. Use
715 * tiocmset/tiocmget driver methods instead. The
716 * #if 0 disablement predates this comment.
717 */
718 case TIOCMGET:
719 rc = -EFAULT;
720 if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(unsigned int))) {
721 rc = 0;
722 ival = rio_getsignals(port);
723 put_user(ival, (unsigned int *) arg);
724 }
725 break;
726 case TIOCMBIS:
727 if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
728 rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1), ((ival & TIOCM_RTS) ? 1 : -1));
729 }
730 break;
731 case TIOCMBIC:
732 if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
733 rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1), ((ival & TIOCM_RTS) ? 0 : -1));
734 }
735 break;
736 case TIOCMSET:
737 if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
738 rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0), ((ival & TIOCM_RTS) ? 1 : 0));
739 }
740 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741#endif
Andrew Morton8d8706e2006-01-11 12:17:49 -0800742 default:
743 rc = -ENOIOCTLCMD;
744 break;
745 }
746 func_exit();
747 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748}
749
750
751/* The throttle/unthrottle scheme for the Specialix card is different
752 * from other drivers and deserves some explanation.
753 * The Specialix hardware takes care of XON/XOFF
754 * and CTS/RTS flow control itself. This means that all we have to
755 * do when signalled by the upper tty layer to throttle/unthrottle is
756 * to make a note of it here. When we come to read characters from the
757 * rx buffers on the card (rio_receive_chars()) we look to see if the
758 * upper layer can accept more (as noted here in rio_rx_throt[]).
759 * If it can't we simply don't remove chars from the cards buffer.
760 * When the tty layer can accept chars, we again note that here and when
761 * rio_receive_chars() is called it will remove them from the cards buffer.
762 * The card will notice that a ports buffer has drained below some low
763 * water mark and will unflow control the line itself, using whatever
764 * flow control scheme is in use for that port. -- Simon Allen
765 */
766
Andrew Morton8d8706e2006-01-11 12:17:49 -0800767static void rio_throttle(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800769 struct Port *port = (struct Port *) tty->driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770
Andrew Morton8d8706e2006-01-11 12:17:49 -0800771 func_enter();
772 /* If the port is using any type of input flow
773 * control then throttle the port.
774 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775
Andrew Morton8d8706e2006-01-11 12:17:49 -0800776 if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) {
777 port->State |= RIO_THROTTLE_RX;
778 }
779
780 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781}
782
783
Andrew Morton8d8706e2006-01-11 12:17:49 -0800784static void rio_unthrottle(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800786 struct Port *port = (struct Port *) tty->driver_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
Andrew Morton8d8706e2006-01-11 12:17:49 -0800788 func_enter();
789 /* Always unthrottle even if flow control is not enabled on
790 * this port in case we disabled flow control while the port
791 * was throttled
792 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
Andrew Morton8d8706e2006-01-11 12:17:49 -0800794 port->State &= ~RIO_THROTTLE_RX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795
Andrew Morton8d8706e2006-01-11 12:17:49 -0800796 func_exit();
797 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798}
799
800
801
802
803
804/* ********************************************************************** *
805 * Here are the initialization routines. *
806 * ********************************************************************** */
807
808
Andrew Morton8d8706e2006-01-11 12:17:49 -0800809static struct vpd_prom *get_VPD_PROM(struct Host *hp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800811 static struct vpd_prom vpdp;
812 char *p;
813 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Andrew Morton8d8706e2006-01-11 12:17:49 -0800815 func_enter();
816 rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817
Andrew Morton8d8706e2006-01-11 12:17:49 -0800818 p = (char *) &vpdp;
819 for (i = 0; i < sizeof(struct vpd_prom); i++)
820 *p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2);
821 /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822
Andrew Morton8d8706e2006-01-11 12:17:49 -0800823 /* Terminate the identifier string.
824 *** requires one extra byte in struct vpd_prom *** */
825 *p++ = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
Andrew Morton8d8706e2006-01-11 12:17:49 -0800827 if (rio_debug & RIO_DEBUG_PROBE)
828 my_hd((char *) &vpdp, 0x20);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829
Andrew Morton8d8706e2006-01-11 12:17:49 -0800830 func_exit();
831
832 return &vpdp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833}
834
835static struct tty_operations rio_ops = {
Andrew Morton8d8706e2006-01-11 12:17:49 -0800836 .open = riotopen,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 .close = gs_close,
838 .write = gs_write,
839 .put_char = gs_put_char,
840 .flush_chars = gs_flush_chars,
841 .write_room = gs_write_room,
842 .chars_in_buffer = gs_chars_in_buffer,
843 .flush_buffer = gs_flush_buffer,
844 .ioctl = rio_ioctl,
845 .throttle = rio_throttle,
846 .unthrottle = rio_unthrottle,
847 .set_termios = gs_set_termios,
848 .stop = gs_stop,
849 .start = gs_start,
850 .hangup = gs_hangup,
851};
852
853static int rio_init_drivers(void)
854{
855 int error = -ENOMEM;
856
857 rio_driver = alloc_tty_driver(256);
858 if (!rio_driver)
859 goto out;
860 rio_driver2 = alloc_tty_driver(256);
861 if (!rio_driver2)
862 goto out1;
863
864 func_enter();
865
866 rio_driver->owner = THIS_MODULE;
867 rio_driver->driver_name = "specialix_rio";
868 rio_driver->name = "ttySR";
869 rio_driver->major = RIO_NORMAL_MAJOR0;
870 rio_driver->type = TTY_DRIVER_TYPE_SERIAL;
871 rio_driver->subtype = SERIAL_TYPE_NORMAL;
872 rio_driver->init_termios = tty_std_termios;
873 rio_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
874 rio_driver->flags = TTY_DRIVER_REAL_RAW;
875 tty_set_operations(rio_driver, &rio_ops);
876
877 rio_driver2->owner = THIS_MODULE;
878 rio_driver2->driver_name = "specialix_rio";
879 rio_driver2->name = "ttySR";
880 rio_driver2->major = RIO_NORMAL_MAJOR1;
881 rio_driver2->type = TTY_DRIVER_TYPE_SERIAL;
882 rio_driver2->subtype = SERIAL_TYPE_NORMAL;
883 rio_driver2->init_termios = tty_std_termios;
884 rio_driver2->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
885 rio_driver2->flags = TTY_DRIVER_REAL_RAW;
886 tty_set_operations(rio_driver2, &rio_ops);
887
Andrew Morton8d8706e2006-01-11 12:17:49 -0800888 rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889
890 if ((error = tty_register_driver(rio_driver)))
891 goto out2;
892 if ((error = tty_register_driver(rio_driver2)))
893 goto out3;
894 func_exit();
895 return 0;
Andrew Morton8d8706e2006-01-11 12:17:49 -0800896 out3:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 tty_unregister_driver(rio_driver);
Andrew Morton8d8706e2006-01-11 12:17:49 -0800898 out2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 put_tty_driver(rio_driver2);
Andrew Morton8d8706e2006-01-11 12:17:49 -0800900 out1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 put_tty_driver(rio_driver);
Andrew Morton8d8706e2006-01-11 12:17:49 -0800902 out:
903 printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 return 1;
905}
906
907
Andrew Morton8d8706e2006-01-11 12:17:49 -0800908static void *ckmalloc(int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800910 void *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911
Andrew Morton8d8706e2006-01-11 12:17:49 -0800912 p = kmalloc(size, GFP_KERNEL);
913 if (p)
914 memset(p, 0, size);
915 return p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916}
917
918
919
Andrew Morton8d8706e2006-01-11 12:17:49 -0800920static int rio_init_datastructures(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800922 int i;
923 struct Port *port;
924 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925
Andrew Morton8d8706e2006-01-11 12:17:49 -0800926 /* Many drivers statically allocate the maximum number of ports
927 There is no reason not to allocate them dynamically. Is there? -- REW */
928 /* However, the RIO driver allows users to configure their first
929 RTA as the ports numbered 504-511. We therefore need to allocate
930 the whole range. :-( -- REW */
931
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932#define RI_SZ sizeof(struct rio_info)
933#define HOST_SZ sizeof(struct Host)
934#define PORT_SZ sizeof(struct Port *)
935#define TMIO_SZ sizeof(struct termios *)
Andrew Morton8d8706e2006-01-11 12:17:49 -0800936 rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
937
938 if (!(p = ckmalloc(RI_SZ)))
939 goto free0;
940 if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ)))
941 goto free1;
942 if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ)))
943 goto free2;
944 p->RIOConf = RIOConf;
945 rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946
947#if 1
Andrew Morton8d8706e2006-01-11 12:17:49 -0800948 for (i = 0; i < RIO_PORTS; i++) {
949 port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port));
950 if (!port) {
951 goto free6;
952 }
953 rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped);
954 port->PortNum = i;
955 port->gs.magic = RIO_MAGIC;
956 port->gs.close_delay = HZ / 2;
957 port->gs.closing_wait = 30 * HZ;
958 port->gs.rd = &rio_real_driver;
959 spin_lock_init(&port->portSem);
960 /*
961 * Initializing wait queue
962 */
963 init_waitqueue_head(&port->gs.open_wait);
964 init_waitqueue_head(&port->gs.close_wait);
965 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966#else
Andrew Morton8d8706e2006-01-11 12:17:49 -0800967 /* We could postpone initializing them to when they are configured. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968#endif
969
970
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971
Andrew Morton8d8706e2006-01-11 12:17:49 -0800972 if (rio_debug & RIO_DEBUG_INIT) {
973 my_hd(&rio_real_driver, sizeof(rio_real_driver));
974 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975
Andrew Morton8d8706e2006-01-11 12:17:49 -0800976
977 func_exit();
978 return 0;
979
980 free6:for (i--; i >= 0; i--)
981 kfree(p->RIOPortp[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982/*free5:
983 free4:
Andrew Morton8d8706e2006-01-11 12:17:49 -0800984 free3:*/ kfree(p->RIOPortp);
985 free2:kfree(p->RIOHosts);
986 free1:
987 rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp);
988 kfree(p);
989 free0:
990 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991}
992
Andrew Morton8d8706e2006-01-11 12:17:49 -0800993static void __exit rio_release_drivers(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800995 func_enter();
996 tty_unregister_driver(rio_driver2);
997 tty_unregister_driver(rio_driver);
998 put_tty_driver(rio_driver2);
999 put_tty_driver(rio_driver);
1000 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001}
1002
1003
1004#ifdef CONFIG_PCI
1005 /* This was written for SX, but applies to RIO too...
1006 (including bugs....)
1007
1008 There is another bit besides Bit 17. Turning that bit off
1009 (on boards shipped with the fix in the eeprom) results in a
1010 hang on the next access to the card.
Andrew Morton8d8706e2006-01-11 12:17:49 -08001011 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012
1013 /********************************************************
1014 * Setting bit 17 in the CNTRL register of the PLX 9050 *
1015 * chip forces a retry on writes while a read is pending.*
1016 * This is to prevent the card locking up on Intel Xeon *
1017 * multiprocessor systems with the NX chipset. -- NV *
1018 ********************************************************/
1019
1020/* Newer cards are produced with this bit set from the configuration
1021 EEprom. As the bit is read/write for the CPU, we can fix it here,
1022 if we detect that it isn't set correctly. -- REW */
1023
Andrew Morton8d8706e2006-01-11 12:17:49 -08001024static void fix_rio_pci(struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025{
Andrew Morton8d8706e2006-01-11 12:17:49 -08001026 unsigned int hwbase;
1027 unsigned long rebase;
1028 unsigned int t;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029
1030#define CNTRL_REG_OFFSET 0x50
1031#define CNTRL_REG_GOODVALUE 0x18260000
1032
Andrew Morton8d8706e2006-01-11 12:17:49 -08001033 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
1034 hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
1035 rebase = (ulong) ioremap(hwbase, 0x80);
1036 t = readl(rebase + CNTRL_REG_OFFSET);
1037 if (t != CNTRL_REG_GOODVALUE) {
1038 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
1039 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
1040 }
1041 iounmap((char *) rebase);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042}
1043#endif
1044
1045
Andrew Morton8d8706e2006-01-11 12:17:49 -08001046static int __init rio_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047{
Andrew Morton8d8706e2006-01-11 12:17:49 -08001048 int found = 0;
1049 int i;
1050 struct Host *hp;
1051 int retval;
1052 struct vpd_prom *vpdp;
1053 int okboard;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054
1055#ifdef CONFIG_PCI
Andrew Morton8d8706e2006-01-11 12:17:49 -08001056 struct pci_dev *pdev = NULL;
1057 unsigned int tint;
1058 unsigned short tshort;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059#endif
1060
Andrew Morton8d8706e2006-01-11 12:17:49 -08001061 func_enter();
1062 rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063
Andrew Morton8d8706e2006-01-11 12:17:49 -08001064 if (abs((long) (&rio_debug) - rio_debug) < 0x10000) {
1065 printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug);
1066 rio_debug = -1;
1067 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068
Andrew Morton8d8706e2006-01-11 12:17:49 -08001069 if (misc_register(&rio_fw_device) < 0) {
1070 printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
1071 return -EIO;
1072 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073
Andrew Morton8d8706e2006-01-11 12:17:49 -08001074 retval = rio_init_datastructures();
1075 if (retval < 0) {
1076 misc_deregister(&rio_fw_device);
1077 return retval;
1078 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079#ifdef CONFIG_PCI
Andrew Morton8d8706e2006-01-11 12:17:49 -08001080 /* First look for the JET devices: */
1081 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
1082 if (pci_enable_device(pdev))
1083 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084
Andrew Morton8d8706e2006-01-11 12:17:49 -08001085 /* Specialix has a whole bunch of cards with
1086 0x2000 as the device ID. They say its because
1087 the standard requires it. Stupid standard. */
1088 /* It seems that reading a word doesn't work reliably on 2.0.
1089 Also, reading a non-aligned dword doesn't work. So we read the
1090 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
1091 ourselves */
1092 /* I don't know why the define doesn't work, constant 0x2c does --REW */
1093 pci_read_config_dword(pdev, 0x2c, &tint);
1094 tshort = (tint >> 16) & 0xffff;
1095 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
1096 if (tshort != 0x0100) {
1097 rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort);
1098 continue;
1099 }
1100 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101
Andrew Morton8d8706e2006-01-11 12:17:49 -08001102 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103
Andrew Morton8d8706e2006-01-11 12:17:49 -08001104 hp = &p->RIOHosts[p->RIONumHosts];
1105 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
1106 hp->Ivec = pdev->irq;
1107 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1108 hp->Ivec = 0;
1109 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1110 hp->CardP = (struct DpRam *) hp->Caddr;
1111 hp->Type = RIO_PCI;
1112 hp->Copy = rio_pcicopy;
1113 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1114 spin_lock_init(&hp->HostLock);
1115 rio_reset_interrupt(hp);
1116 rio_start_card_running(hp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117
Andrew Morton8d8706e2006-01-11 12:17:49 -08001118 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1119 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
1120 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
1121 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
1122 p->RIOHosts[p->RIONumHosts].UniqueNum =
1123 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1124 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1125 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126
Andrew Morton8d8706e2006-01-11 12:17:49 -08001127 fix_rio_pci(pdev);
1128 p->RIOLastPCISearch = RIO_SUCCESS;
1129 p->RIONumHosts++;
1130 found++;
1131 } else {
1132 iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
1133 }
1134 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135
Andrew Morton8d8706e2006-01-11 12:17:49 -08001136 /* Then look for the older PCI card.... : */
1137
1138 /* These older PCI cards have problems (only byte-mode access is
1139 supported), which makes them a bit awkward to support.
1140 They also have problems sharing interrupts. Be careful.
1141 (The driver now refuses to share interrupts for these
1142 cards. This should be sufficient).
1143 */
1144
1145 /* Then look for the older RIO/PCI devices: */
1146 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) {
1147 if (pci_enable_device(pdev))
1148 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149
1150#ifdef CONFIG_RIO_OLDPCI
Andrew Morton8d8706e2006-01-11 12:17:49 -08001151 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
Andrew Morton8d8706e2006-01-11 12:17:49 -08001153 hp = &p->RIOHosts[p->RIONumHosts];
1154 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
1155 hp->Ivec = pdev->irq;
1156 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1157 hp->Ivec = 0;
1158 hp->Ivec |= 0x8000; /* Mark as non-sharable */
1159 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1160 hp->CardP = (struct DpRam *) hp->Caddr;
1161 hp->Type = RIO_PCI;
1162 hp->Copy = rio_pcicopy;
1163 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1164 spin_lock_init(&hp->HostLock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165
Andrew Morton8d8706e2006-01-11 12:17:49 -08001166 rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec);
1167 rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168
Andrew Morton8d8706e2006-01-11 12:17:49 -08001169 rio_reset_interrupt(hp);
1170 rio_start_card_running(hp);
1171 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1172 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
1173 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
1174 p->RIOHosts[p->RIONumHosts].UniqueNum =
1175 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1176 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1177 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178
Andrew Morton8d8706e2006-01-11 12:17:49 -08001179 p->RIOLastPCISearch = RIO_SUCCESS;
1180 p->RIONumHosts++;
1181 found++;
1182 } else {
1183 iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
1184 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185#else
Andrew Morton8d8706e2006-01-11 12:17:49 -08001186 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187#endif
Andrew Morton8d8706e2006-01-11 12:17:49 -08001188 }
1189#endif /* PCI */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190
Andrew Morton8d8706e2006-01-11 12:17:49 -08001191 /* Now probe for ISA cards... */
1192 for (i = 0; i < NR_RIO_ADDRS; i++) {
1193 hp = &p->RIOHosts[p->RIONumHosts];
1194 hp->PaddrP = rio_probe_addrs[i];
1195 /* There was something about the IRQs of these cards. 'Forget what.--REW */
1196 hp->Ivec = 0;
1197 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1198 hp->CardP = (struct DpRam *) hp->Caddr;
1199 hp->Type = RIO_AT;
1200 hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL
1201 * -- YES! this is now a normal copy. Only the
1202 * old PCI card uses the special PCI copy.
1203 * Moreover, the ISA card will work with the
1204 * special PCI copy anyway. -- REW */
1205 hp->Mode = 0;
1206 spin_lock_init(&hp->HostLock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207
Andrew Morton8d8706e2006-01-11 12:17:49 -08001208 vpdp = get_VPD_PROM(hp);
1209 rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n");
1210 okboard = 0;
1211 if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
1212 /* Board is present... */
1213 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) {
1214 /* ... and feeling fine!!!! */
1215 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1216 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
1217 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum);
1218 okboard++;
1219 found++;
1220 }
1221 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222
Andrew Morton8d8706e2006-01-11 12:17:49 -08001223 if (!okboard)
1224 iounmap((char *) (hp->Caddr));
1225 }
1226 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227
1228
Andrew Morton8d8706e2006-01-11 12:17:49 -08001229 for (i = 0; i < p->RIONumHosts; i++) {
1230 hp = &p->RIOHosts[i];
1231 if (hp->Ivec) {
1232 int mode = SA_SHIRQ;
1233 if (hp->Ivec & 0x8000) {
1234 mode = 0;
1235 hp->Ivec &= 0x7fff;
1236 }
1237 rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode);
1238 retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp);
1239 rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval);
1240 if (retval) {
1241 printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec);
1242 hp->Ivec = 0;
1243 }
1244 rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec);
1245 if (hp->Ivec != 0) {
1246 rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n");
1247 hp->Mode |= RIO_PCI_INT_ENABLE;
1248 } else
1249 hp->Mode &= !RIO_PCI_INT_ENABLE;
1250 rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode);
1251 rio_start_card_running(hp);
1252 }
1253 /* Init the timer "always" to make sure that it can safely be
1254 deleted when we unload... */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255
Andrew Morton8d8706e2006-01-11 12:17:49 -08001256 init_timer(&hp->timer);
1257 if (!hp->Ivec) {
1258 rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll);
1259 hp->timer.data = i;
1260 hp->timer.function = rio_pollfunc;
1261 hp->timer.expires = jiffies + rio_poll;
1262 add_timer(&hp->timer);
1263 }
1264 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265
Andrew Morton8d8706e2006-01-11 12:17:49 -08001266 if (found) {
1267 rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
1268 rio_init_drivers();
1269 } else {
1270 /* deregister the misc device we created earlier */
1271 misc_deregister(&rio_fw_device);
1272 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273
Andrew Morton8d8706e2006-01-11 12:17:49 -08001274 func_exit();
1275 return found ? 0 : -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276}
1277
1278
Andrew Morton8d8706e2006-01-11 12:17:49 -08001279static void __exit rio_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280{
Andrew Morton8d8706e2006-01-11 12:17:49 -08001281 int i;
1282 struct Host *hp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283
Andrew Morton8d8706e2006-01-11 12:17:49 -08001284 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285
Andrew Morton8d8706e2006-01-11 12:17:49 -08001286 for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) {
1287 RIOHostReset(hp->Type, hp->CardP, hp->Slot);
1288 if (hp->Ivec) {
1289 free_irq(hp->Ivec, hp);
1290 rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec);
1291 }
1292 /* It is safe/allowed to del_timer a non-active timer */
1293 del_timer(&hp->timer);
1294 }
1295
1296 if (misc_deregister(&rio_fw_device) < 0) {
1297 printk(KERN_INFO "rio: couldn't deregister control-device\n");
1298 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299
1300
Andrew Morton8d8706e2006-01-11 12:17:49 -08001301 rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302
Andrew Morton8d8706e2006-01-11 12:17:49 -08001303 rio_release_drivers();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304
Andrew Morton8d8706e2006-01-11 12:17:49 -08001305 /* Release dynamically allocated memory */
1306 kfree(p->RIOPortp);
1307 kfree(p->RIOHosts);
1308 kfree(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309
Andrew Morton8d8706e2006-01-11 12:17:49 -08001310 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311}
1312
1313module_init(rio_init);
1314module_exit(rio_exit);
1315
1316/*
1317 * Anybody who knows why this doesn't work for me, please tell me -- REW.
1318 * Snatched from scsi.c (fixed one spelling error):
1319 * Overrides for Emacs so that we follow Linus' tabbing style.
1320 * Emacs will notice this stuff at the end of the file and automatically
1321 * adjust the settings for this buffer only. This must remain at the end
1322 * of the file.
1323 * ---------------------------------------------------------------------------
1324 * Local Variables:
1325 * c-indent-level: 4
1326 * c-brace-imaginary-offset: 0
1327 * c-brace-offset: -4
1328 * c-argdecl-indent: 4
1329 * c-label-offset: -4
1330 * c-continued-statement-offset: 4
1331 * c-continued-brace-offset: 0
1332 * indent-tabs-mode: nil
1333 * tab-width: 8
1334 * End:
1335 */