| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 |  | 
 | 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> | 
 | 36 | #include <linux/config.h>  | 
 | 37 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #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 | 
 | 99 | one machine.  Specialix specifies max 4 boards in one machine. I don't | 
 | 100 | know why. If you want to try anyway you'll have to increase the number | 
 | 101 | of boards in rio.h.  You'll have to allocate more majors if you need | 
 | 102 | more 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 |  | 
 | 115 | #ifndef RIO_WINDOW_LEN  | 
 | 116 | #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 | 
 | 143 | #endif  | 
 | 144 |  | 
 | 145 |  | 
 | 146 | /* These constants are derived from SCO Source */ | 
 | 147 | static struct Conf | 
 | 148 | RIOConf = | 
 | 149 | { | 
 | 150 |   /* locator */         "RIO Config here", | 
 | 151 |   /* startuptime */     HZ*2,           /* how long to wait for card to run */ | 
 | 152 |   /* slowcook */        0,              /* TRUE -> always use line disc. */ | 
 | 153 |   /* intrpolltime */    1,              /* The frequency of OUR polls */ | 
 | 154 |   /* breakinterval */   25,             /* x10 mS XXX: units seem to be 1ms not 10! -- REW*/ | 
 | 155 |   /* timer */           10,             /* mS */ | 
 | 156 |   /* RtaLoadBase */     0x7000, | 
 | 157 |   /* HostLoadBase */    0x7C00, | 
 | 158 |   /* XpHz */            5,              /* number of Xprint hits per second */ | 
 | 159 |   /* XpCps */           120,            /* Xprint characters per second */ | 
 | 160 |   /* XpOn */            "\033d#",       /* start Xprint for a wyse 60 */ | 
 | 161 |   /* XpOff */           "\024",         /* end Xprint for a wyse 60 */ | 
 | 162 |   /* MaxXpCps */        2000,           /* highest Xprint speed */ | 
 | 163 |   /* MinXpCps */        10,             /* slowest Xprint speed */ | 
 | 164 |   /* SpinCmds */        1,              /* non-zero for mega fast boots */ | 
 | 165 |   /* First Addr */      0x0A0000,       /* First address to look at */ | 
 | 166 |   /* Last Addr */       0xFF0000,       /* Last address looked at */ | 
 | 167 |   /* BufferSize */      1024,           /* Bytes per port of buffering */ | 
 | 168 |   /* LowWater */        256,            /* how much data left before wakeup */ | 
 | 169 |   /* LineLength */      80,             /* how wide is the console? */ | 
 | 170 |   /* CmdTimeout */      HZ,             /* how long a close command may take */ | 
 | 171 | }; | 
 | 172 |  | 
 | 173 |  | 
 | 174 |  | 
 | 175 |  | 
 | 176 | /* Function prototypes */ | 
 | 177 |  | 
 | 178 | static void rio_disable_tx_interrupts (void * ptr);  | 
 | 179 | static void rio_enable_tx_interrupts (void * ptr);  | 
 | 180 | static void rio_disable_rx_interrupts (void * ptr);  | 
 | 181 | static void rio_enable_rx_interrupts (void * ptr);  | 
 | 182 | static int  rio_get_CD (void * ptr);  | 
 | 183 | static void rio_shutdown_port (void * ptr); | 
 | 184 | static int  rio_set_real_termios (void  *ptr); | 
 | 185 | static void rio_hungup (void  *ptr); | 
 | 186 | static void rio_close (void  *ptr); | 
 | 187 | static int rio_chars_in_buffer (void * ptr); | 
 | 188 | static int rio_fw_ioctl (struct inode *inode, struct file *filp, | 
 | 189 | 		         unsigned int cmd, unsigned long arg); | 
 | 190 | static int rio_init_drivers(void); | 
 | 191 |  | 
 | 192 | static void my_hd (void *addr, int len); | 
 | 193 |  | 
 | 194 | static struct tty_driver *rio_driver, *rio_driver2; | 
 | 195 |  | 
 | 196 | /* The name "p" is a bit non-descript. But that's what the rio-lynxos | 
 | 197 | sources use all over the place. */ | 
 | 198 | struct rio_info *p; | 
 | 199 |  | 
 | 200 | int rio_debug; | 
 | 201 |  | 
 | 202 |  | 
 | 203 | /* You can have the driver poll your card.  | 
 | 204 |     - Set rio_poll to 1 to poll every timer tick (10ms on Intel).  | 
 | 205 |       This is used when the card cannot use an interrupt for some reason. | 
 | 206 | */ | 
 | 207 | static int rio_poll = 1; | 
 | 208 |  | 
 | 209 |  | 
 | 210 | /* These are the only open spaces in my computer. Yours may have more | 
 | 211 |    or less.... */ | 
 | 212 | static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000}; | 
 | 213 |  | 
| Tobias Klauser | fe97107 | 2006-01-09 20:54:02 -0800 | [diff] [blame] | 214 | #define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 |  | 
 | 216 |  | 
 | 217 | /* Set the mask to all-ones. This alas, only supports 32 interrupts.  | 
 | 218 |    Some architectures may need more. -- Changed to LONG to | 
 | 219 |    support up to 64 bits on 64bit architectures. -- REW 20/06/99 */ | 
| Adrian Bunk | 408b664 | 2005-05-01 08:59:29 -0700 | [diff] [blame] | 220 | static long rio_irqmask = -1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 |  | 
 | 222 | MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>"); | 
 | 223 | MODULE_DESCRIPTION("RIO driver"); | 
 | 224 | MODULE_LICENSE("GPL"); | 
 | 225 | module_param(rio_poll, int, 0); | 
 | 226 | module_param(rio_debug, int, 0644); | 
 | 227 | module_param(rio_irqmask, long, 0); | 
 | 228 |  | 
 | 229 | static struct real_driver rio_real_driver = { | 
 | 230 |   rio_disable_tx_interrupts, | 
 | 231 |   rio_enable_tx_interrupts, | 
 | 232 |   rio_disable_rx_interrupts, | 
 | 233 |   rio_enable_rx_interrupts, | 
 | 234 |   rio_get_CD, | 
 | 235 |   rio_shutdown_port,  | 
 | 236 |   rio_set_real_termios,  | 
 | 237 |   rio_chars_in_buffer, | 
 | 238 |   rio_close, | 
 | 239 |   rio_hungup, | 
 | 240 |   NULL | 
 | 241 | }; | 
 | 242 |  | 
 | 243 | /*  | 
 | 244 |  *  Firmware loader driver specific routines | 
 | 245 |  * | 
 | 246 |  */ | 
 | 247 |  | 
 | 248 | static struct file_operations rio_fw_fops = { | 
 | 249 | 	.owner		= THIS_MODULE, | 
 | 250 | 	.ioctl		= rio_fw_ioctl, | 
 | 251 | }; | 
 | 252 |  | 
 | 253 | static struct miscdevice rio_fw_device = { | 
 | 254 | 	RIOCTL_MISC_MINOR, "rioctl", &rio_fw_fops | 
 | 255 | }; | 
 | 256 |  | 
 | 257 |  | 
 | 258 |  | 
 | 259 |  | 
 | 260 |  | 
 | 261 | #ifdef RIO_PARANOIA_CHECK | 
 | 262 |  | 
 | 263 | /* This doesn't work. Who's paranoid around here? Not me! */ | 
 | 264 |  | 
 | 265 | static inline int rio_paranoia_check(struct rio_port const * port, | 
 | 266 | 				    char *name, const char *routine) | 
 | 267 | { | 
 | 268 |  | 
 | 269 |   static const char *badmagic = | 
 | 270 |     KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n"; | 
 | 271 |   static const char *badinfo = | 
 | 272 |     KERN_ERR "rio: Warning: null rio port for device %s in %s\n"; | 
 | 273 |   | 
 | 274 |   if (!port) { | 
 | 275 |     printk (badinfo, name, routine); | 
 | 276 |     return 1; | 
 | 277 |   } | 
 | 278 |   if (port->magic != RIO_MAGIC) { | 
 | 279 |     printk (badmagic, name, routine); | 
 | 280 |     return 1; | 
 | 281 |   } | 
 | 282 |  | 
 | 283 |   return 0; | 
 | 284 | } | 
 | 285 | #else | 
 | 286 | #define rio_paranoia_check(a,b,c) 0 | 
 | 287 | #endif | 
 | 288 |  | 
 | 289 |  | 
 | 290 | #ifdef DEBUG | 
 | 291 | static void my_hd (void *ad, int len) | 
 | 292 | { | 
 | 293 |   int i, j, ch; | 
 | 294 |   unsigned char *addr = ad; | 
 | 295 |    | 
 | 296 |   for (i=0;i<len;i+=16) { | 
 | 297 |     rio_dprintk (RIO_DEBUG_PARAM, "%08x ", (int) addr+i); | 
 | 298 |     for (j=0;j<16;j++) { | 
 | 299 |       rio_dprintk (RIO_DEBUG_PARAM, "%02x %s", addr[j+i], (j==7)?" ":""); | 
 | 300 |     } | 
 | 301 |     for (j=0;j<16;j++) { | 
 | 302 |       ch = addr[j+i]; | 
 | 303 |       rio_dprintk (RIO_DEBUG_PARAM, "%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch)); | 
 | 304 |     } | 
 | 305 |     rio_dprintk (RIO_DEBUG_PARAM, "\n"); | 
 | 306 |   } | 
 | 307 | } | 
 | 308 | #else | 
 | 309 | #define my_hd(ad,len) do{/* nothing*/ } while (0) | 
 | 310 | #endif | 
 | 311 |  | 
 | 312 |  | 
 | 313 | /* Delay a number of jiffies, allowing a signal to interrupt */  | 
 | 314 | int RIODelay (struct Port *PortP, int njiffies) | 
 | 315 | { | 
 | 316 |   func_enter (); | 
 | 317 |  | 
 | 318 |   rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies);   | 
 | 319 |   msleep_interruptible(jiffies_to_msecs(njiffies)); | 
 | 320 |   func_exit(); | 
 | 321 |  | 
 | 322 |   if (signal_pending(current)) | 
 | 323 |     return RIO_FAIL; | 
 | 324 |   else | 
 | 325 |     return !RIO_FAIL; | 
 | 326 | } | 
 | 327 |  | 
 | 328 |  | 
 | 329 | /* Delay a number of jiffies, disallowing a signal to interrupt */  | 
 | 330 | int RIODelay_ni (struct Port *PortP, int njiffies) | 
 | 331 | { | 
 | 332 |   func_enter (); | 
 | 333 |  | 
 | 334 |   rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies);   | 
 | 335 |   msleep(jiffies_to_msecs(njiffies)); | 
 | 336 |   func_exit(); | 
 | 337 |   return !RIO_FAIL; | 
 | 338 | } | 
 | 339 |  | 
 | 340 |  | 
 | 341 | int rio_minor(struct tty_struct *tty) | 
 | 342 | { | 
 | 343 | 	return tty->index + (tty->driver == rio_driver) ? 0 : 256; | 
 | 344 | } | 
 | 345 |  | 
 | 346 |  | 
 | 347 | int rio_ismodem(struct tty_struct *tty) | 
 | 348 | { | 
 | 349 | 	return 1; | 
 | 350 | } | 
 | 351 |  | 
 | 352 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | static int rio_set_real_termios (void *ptr) | 
 | 354 | { | 
 | 355 |   int rv, modem; | 
 | 356 |   struct tty_struct *tty; | 
 | 357 |   func_enter(); | 
 | 358 |  | 
 | 359 |   tty = ((struct Port *)ptr)->gs.tty; | 
 | 360 |  | 
 | 361 |   modem = rio_ismodem(tty); | 
 | 362 |  | 
 | 363 |   rv = RIOParam( (struct Port *) ptr, CONFIG, modem, 1); | 
 | 364 |  | 
 | 365 |   func_exit (); | 
 | 366 |  | 
 | 367 |   return rv; | 
 | 368 | } | 
 | 369 |  | 
 | 370 |  | 
 | 371 | static void rio_reset_interrupt (struct Host *HostP) | 
 | 372 | { | 
 | 373 |   func_enter(); | 
 | 374 |  | 
 | 375 |   switch( HostP->Type ) { | 
 | 376 |   case RIO_AT: | 
 | 377 |   case RIO_MCA: | 
 | 378 |   case RIO_PCI: | 
 | 379 |     WBYTE(HostP->ResetInt , 0xff); | 
 | 380 |   } | 
 | 381 |  | 
 | 382 |   func_exit(); | 
 | 383 | } | 
 | 384 |  | 
 | 385 |  | 
 | 386 | static irqreturn_t rio_interrupt (int irq, void *ptr, struct pt_regs *regs) | 
 | 387 | { | 
 | 388 |   struct Host *HostP; | 
 | 389 |   func_enter (); | 
 | 390 |  | 
 | 391 |   HostP = (struct Host*)ptr; /* &p->RIOHosts[(long)ptr]; */ | 
 | 392 |   rio_dprintk (RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n",  | 
 | 393 |                irq, HostP->Ivec);  | 
 | 394 |  | 
 | 395 |   /* AAargh! The order in which to do these things is essential and | 
 | 396 |      not trivial.  | 
 | 397 |       | 
 | 398 |      - Rate limit goes before "recursive". Otherwise a series of | 
 | 399 |        recursive calls will hang the machine in the interrupt routine.  | 
 | 400 |  | 
 | 401 |      - hardware twiddling goes before "recursive". Otherwise when we | 
 | 402 |        poll the card, and a recursive interrupt happens, we won't | 
 | 403 |        ack the card, so it might keep on interrupting us. (especially | 
 | 404 |        level sensitive interrupt systems like PCI). | 
 | 405 |  | 
 | 406 |      - Rate limit goes before hardware twiddling. Otherwise we won't | 
 | 407 |        catch a card that has gone bonkers. | 
 | 408 |  | 
 | 409 |      - The "initialized" test goes after the hardware twiddling. Otherwise | 
 | 410 |        the card will stick us in the interrupt routine again. | 
 | 411 |  | 
 | 412 |      - The initialized test goes before recursive.  | 
 | 413 |   */ | 
 | 414 |  | 
 | 415 |  | 
 | 416 |  | 
 | 417 | #ifdef IRQ_RATE_LIMIT | 
 | 418 |   /* Aaargh! I'm ashamed. This costs more lines-of-code than the | 
 | 419 |      actual interrupt routine!. (Well, used to when I wrote that comment) */ | 
 | 420 |   { | 
 | 421 |     static int lastjif; | 
 | 422 |     static int nintr=0; | 
 | 423 |  | 
 | 424 |     if (lastjif == jiffies) { | 
 | 425 |       if (++nintr > IRQ_RATE_LIMIT) { | 
 | 426 |         free_irq (HostP->Ivec, ptr); | 
 | 427 |         printk (KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n",  | 
 | 428 |                 HostP->Ivec); | 
 | 429 |       } | 
 | 430 |     } else { | 
 | 431 |       lastjif = jiffies; | 
 | 432 |       nintr = 0; | 
 | 433 |     } | 
 | 434 |   } | 
 | 435 | #endif | 
 | 436 |   rio_dprintk (RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");  | 
 | 437 |   if (HostP->Ivec == irq) { | 
 | 438 |     /* Tell the card we've noticed the interrupt. */ | 
 | 439 |     rio_reset_interrupt (HostP); | 
 | 440 |   } | 
 | 441 |  | 
 | 442 |   if ((HostP->Flags & RUN_STATE) != RC_RUNNING) | 
 | 443 |   	return IRQ_HANDLED; | 
 | 444 |  | 
 | 445 |   if (test_and_set_bit (RIO_BOARD_INTR_LOCK, &HostP->locks)) { | 
 | 446 |     printk (KERN_ERR "Recursive interrupt! (host %d/irq%d)\n",  | 
 | 447 |             (int) ptr, HostP->Ivec); | 
 | 448 |     return IRQ_HANDLED; | 
 | 449 |   } | 
 | 450 |  | 
 | 451 |   RIOServiceHost(p, HostP, irq); | 
 | 452 |  | 
 | 453 |   rio_dprintk ( RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n",  | 
 | 454 |                 (int) ptr, HostP->Type); | 
 | 455 |  | 
 | 456 |   clear_bit (RIO_BOARD_INTR_LOCK, &HostP->locks); | 
 | 457 |   rio_dprintk (RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n",  | 
 | 458 |                irq, HostP->Ivec);  | 
 | 459 |   func_exit (); | 
 | 460 |   return IRQ_HANDLED; | 
 | 461 | } | 
 | 462 |  | 
 | 463 |  | 
 | 464 | static void rio_pollfunc (unsigned long data) | 
 | 465 | { | 
 | 466 |   func_enter (); | 
 | 467 |  | 
 | 468 |   rio_interrupt (0, &p->RIOHosts[data], NULL); | 
 | 469 |   p->RIOHosts[data].timer.expires = jiffies + rio_poll; | 
 | 470 |   add_timer (&p->RIOHosts[data].timer); | 
 | 471 |  | 
 | 472 |   func_exit (); | 
 | 473 | } | 
 | 474 |  | 
 | 475 |  | 
 | 476 | /* ********************************************************************** * | 
 | 477 |  *                Here are the routines that actually                     * | 
 | 478 |  *              interface with the generic_serial driver                  * | 
 | 479 |  * ********************************************************************** */ | 
 | 480 |  | 
 | 481 | /* Ehhm. I don't know how to fiddle with interrupts on the Specialix  | 
 | 482 |    cards. ....   Hmm. Ok I figured it out. You don't.  -- REW */ | 
 | 483 |  | 
 | 484 | static void rio_disable_tx_interrupts (void * ptr)  | 
 | 485 | { | 
 | 486 |   func_enter(); | 
 | 487 |  | 
 | 488 |   /*  port->gs.flags &= ~GS_TX_INTEN; */ | 
 | 489 |  | 
 | 490 |   func_exit(); | 
 | 491 | } | 
 | 492 |  | 
 | 493 |  | 
 | 494 | static void rio_enable_tx_interrupts (void * ptr)  | 
 | 495 | { | 
 | 496 |   struct Port *PortP = ptr; | 
 | 497 |   /* int hn; */ | 
 | 498 |  | 
 | 499 |   func_enter(); | 
 | 500 |  | 
 | 501 |   /* hn = PortP->HostP - p->RIOHosts; | 
 | 502 |  | 
 | 503 |      rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn); | 
 | 504 |      rio_interrupt (-1,(void *) hn, NULL); */ | 
 | 505 |  | 
 | 506 |   RIOTxEnable((char *) PortP); | 
 | 507 |  | 
 | 508 |   /*  | 
 | 509 |    * In general we cannot count on "tx empty" interrupts, although | 
 | 510 |    * the interrupt routine seems to be able to tell the difference.  | 
 | 511 |    */ | 
 | 512 |   PortP->gs.flags &= ~GS_TX_INTEN; | 
 | 513 |  | 
 | 514 |   func_exit(); | 
 | 515 | } | 
 | 516 |  | 
 | 517 |  | 
 | 518 | static void rio_disable_rx_interrupts (void * ptr)  | 
 | 519 | { | 
 | 520 |   func_enter(); | 
 | 521 |   func_exit(); | 
 | 522 | } | 
 | 523 |  | 
 | 524 | static void rio_enable_rx_interrupts (void * ptr)  | 
 | 525 | { | 
 | 526 |   /*  struct rio_port *port = ptr; */ | 
 | 527 |   func_enter(); | 
 | 528 |   func_exit(); | 
 | 529 | } | 
 | 530 |  | 
 | 531 |  | 
 | 532 | /* Jeez. Isn't this simple?  */ | 
 | 533 | static int rio_get_CD (void * ptr)  | 
 | 534 | { | 
 | 535 |   struct Port *PortP = ptr; | 
 | 536 |   int rv; | 
 | 537 |  | 
 | 538 |   func_enter(); | 
 | 539 |   rv = (PortP->ModemState & MSVR1_CD) != 0; | 
 | 540 |  | 
 | 541 |   rio_dprintk (RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); | 
 | 542 |    | 
 | 543 |   func_exit();   | 
 | 544 |   return rv; | 
 | 545 | } | 
 | 546 |  | 
 | 547 |  | 
 | 548 | /* Jeez. Isn't this simple? Actually, we can sync with the actual port | 
 | 549 |    by just pushing stuff into the queue going to the port... */ | 
 | 550 | static int rio_chars_in_buffer (void * ptr)  | 
 | 551 | { | 
 | 552 |   func_enter(); | 
 | 553 |  | 
 | 554 |   func_exit();   | 
 | 555 |   return 0; | 
 | 556 | } | 
 | 557 |  | 
 | 558 |  | 
 | 559 | /* Nothing special here... */ | 
 | 560 | static void rio_shutdown_port (void * ptr)  | 
 | 561 | { | 
 | 562 |   struct Port *PortP; | 
 | 563 |  | 
 | 564 |   func_enter(); | 
 | 565 |  | 
 | 566 |   PortP = (struct Port *)ptr; | 
 | 567 |   PortP->gs.tty = NULL; | 
 | 568 | #if 0 | 
 | 569 |   port->gs.flags &= ~ GS_ACTIVE; | 
 | 570 |   if (!port->gs.tty) { | 
 | 571 |     rio_dprintk (RIO_DBUG_TTY, "No tty.\n"); | 
 | 572 |     return; | 
 | 573 |   } | 
 | 574 |   if (!port->gs.tty->termios) { | 
 | 575 |     rio_dprintk (RIO_DEBUG_TTY, "No termios.\n"); | 
 | 576 |     return; | 
 | 577 |   } | 
 | 578 |   if (port->gs.tty->termios->c_cflag & HUPCL) { | 
 | 579 |     rio_setsignals (port, 0, 0); | 
 | 580 |   } | 
 | 581 | #endif | 
 | 582 |  | 
 | 583 |   func_exit(); | 
 | 584 | } | 
 | 585 |  | 
 | 586 |  | 
 | 587 | /* I haven't the foggiest why the decrement use count has to happen | 
 | 588 |    here. The whole linux serial drivers stuff needs to be redesigned. | 
 | 589 |    My guess is that this is a hack to minimize the impact of a bug | 
 | 590 |    elsewhere. Thinking about it some more. (try it sometime) Try | 
 | 591 |    running minicom on a serial port that is driven by a modularized | 
 | 592 |    driver. Have the modem hangup. Then remove the driver module. Then | 
 | 593 |    exit minicom.  I expect an "oops".  -- REW */ | 
 | 594 | static void rio_hungup (void *ptr) | 
 | 595 | { | 
 | 596 |   struct Port *PortP; | 
 | 597 |  | 
 | 598 |   func_enter(); | 
 | 599 |    | 
 | 600 |   PortP = (struct Port *)ptr; | 
 | 601 |   PortP->gs.tty = NULL; | 
 | 602 |  | 
 | 603 |   func_exit (); | 
 | 604 | } | 
 | 605 |  | 
 | 606 |  | 
 | 607 | /* The standard serial_close would become shorter if you'd wrap it like | 
 | 608 |    this.  | 
 | 609 |    rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;} | 
 | 610 |  */ | 
 | 611 | static void rio_close (void *ptr) | 
 | 612 | { | 
 | 613 |   struct Port *PortP; | 
 | 614 |  | 
 | 615 |   func_enter (); | 
 | 616 |  | 
 | 617 |   PortP = (struct Port *)ptr; | 
 | 618 |  | 
 | 619 |   riotclose (ptr); | 
 | 620 |  | 
 | 621 |   if(PortP->gs.count) { | 
 | 622 |     printk (KERN_ERR "WARNING port count:%d\n", PortP->gs.count); | 
 | 623 |     PortP->gs.count = 0;  | 
 | 624 |   }                 | 
 | 625 |  | 
 | 626 |   PortP->gs.tty = NULL; | 
 | 627 |   func_exit (); | 
 | 628 | } | 
 | 629 |  | 
 | 630 |  | 
 | 631 |  | 
 | 632 | static int rio_fw_ioctl (struct inode *inode, struct file *filp, | 
 | 633 | 		         unsigned int cmd, unsigned long arg) | 
 | 634 | { | 
 | 635 |   int rc = 0; | 
 | 636 |   func_enter(); | 
 | 637 |  | 
 | 638 |   /* The "dev" argument isn't used. */ | 
 | 639 |   rc = riocontrol (p, 0, cmd, (void *)arg, capable(CAP_SYS_ADMIN)); | 
 | 640 |  | 
 | 641 |   func_exit (); | 
 | 642 |   return rc; | 
 | 643 | } | 
 | 644 |  | 
 | 645 | extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, | 
 | 646 |                int command, int len, int arg); | 
 | 647 |  | 
 | 648 | static int rio_ioctl (struct tty_struct * tty, struct file * filp,  | 
 | 649 |                      unsigned int cmd, unsigned long arg) | 
 | 650 | { | 
 | 651 |   int rc; | 
 | 652 |   struct Port *PortP; | 
 | 653 |   int ival; | 
 | 654 |  | 
 | 655 |   func_enter(); | 
 | 656 |  | 
 | 657 |   PortP = (struct Port *)tty->driver_data; | 
 | 658 |  | 
 | 659 |   rc  = 0; | 
 | 660 |   switch (cmd) { | 
 | 661 | #if 0 | 
 | 662 |   case TIOCGSOFTCAR: | 
 | 663 |     rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), | 
 | 664 |                   (unsigned int *) arg); | 
 | 665 |     break; | 
 | 666 | #endif | 
 | 667 |   case TIOCSSOFTCAR: | 
 | 668 |     if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { | 
 | 669 |       tty->termios->c_cflag = | 
 | 670 |         (tty->termios->c_cflag & ~CLOCAL) | | 
 | 671 |         (ival ? CLOCAL : 0); | 
 | 672 |     } | 
 | 673 |     break; | 
 | 674 |   case TIOCGSERIAL: | 
 | 675 |     rc = -EFAULT; | 
 | 676 |     if (access_ok(VERIFY_WRITE, (void *) arg, | 
 | 677 |                           sizeof(struct serial_struct))) | 
 | 678 |       rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); | 
 | 679 |     break; | 
 | 680 |   case TCSBRK: | 
 | 681 |     if ( PortP->State & RIO_DELETED ) { | 
 | 682 |       rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); | 
 | 683 |       rc = -EIO;       | 
 | 684 |     } else { | 
 | 685 |       if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) { | 
 | 686 |          rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); | 
 | 687 |          rc = -EIO; | 
 | 688 |       }           | 
 | 689 |     } | 
 | 690 |     break; | 
 | 691 |   case TCSBRKP: | 
 | 692 |     if ( PortP->State & RIO_DELETED ) { | 
 | 693 |       rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); | 
 | 694 |       rc = -EIO;       | 
 | 695 |     } else { | 
 | 696 |       int l; | 
 | 697 |       l = arg?arg*100:250; | 
 | 698 |       if (l > 255) l = 255; | 
 | 699 |       if (RIOShortCommand(p, PortP, SBREAK, 2, arg?arg*100:250) == RIO_FAIL) { | 
 | 700 |          rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); | 
 | 701 |          rc = -EIO; | 
 | 702 |       }           | 
 | 703 |     } | 
 | 704 |     break; | 
 | 705 |   case TIOCSSERIAL: | 
 | 706 |     rc = -EFAULT; | 
 | 707 |     if (access_ok(VERIFY_READ, (void *) arg, | 
 | 708 |                           sizeof(struct serial_struct))) | 
 | 709 |       rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg); | 
 | 710 |     break; | 
 | 711 | #if 0 | 
 | 712 |   /* | 
 | 713 |    * note: these IOCTLs no longer reach here.  Use | 
 | 714 |    * tiocmset/tiocmget driver methods instead.  The | 
 | 715 |    * #if 0 disablement predates this comment. | 
 | 716 |    */ | 
 | 717 |   case TIOCMGET: | 
 | 718 |     rc = -EFAULT; | 
 | 719 |     if (access_ok(VERIFY_WRITE, (void *) arg, | 
 | 720 |                           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), | 
 | 729 |                            ((ival & TIOCM_RTS) ? 1 : -1)); | 
 | 730 |     } | 
 | 731 |     break; | 
 | 732 |   case TIOCMBIC: | 
 | 733 |     if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { | 
 | 734 |       rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1), | 
 | 735 |                            ((ival & TIOCM_RTS) ? 0 : -1)); | 
 | 736 |     } | 
 | 737 |     break; | 
 | 738 |   case TIOCMSET: | 
 | 739 |     if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { | 
 | 740 |       rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0), | 
 | 741 |                            ((ival & TIOCM_RTS) ? 1 : 0)); | 
 | 742 |     } | 
 | 743 |     break; | 
 | 744 | #endif | 
 | 745 |   default: | 
 | 746 |     rc = -ENOIOCTLCMD; | 
 | 747 |     break; | 
 | 748 |   } | 
 | 749 |   func_exit(); | 
 | 750 |   return rc; | 
 | 751 | } | 
 | 752 |  | 
 | 753 |  | 
 | 754 | /* The throttle/unthrottle scheme for the Specialix card is different | 
 | 755 |  * from other drivers and deserves some explanation.  | 
 | 756 |  * The Specialix hardware takes care of XON/XOFF | 
 | 757 |  * and CTS/RTS flow control itself.  This means that all we have to | 
 | 758 |  * do when signalled by the upper tty layer to throttle/unthrottle is | 
 | 759 |  * to make a note of it here.  When we come to read characters from the | 
 | 760 |  * rx buffers on the card (rio_receive_chars()) we look to see if the | 
 | 761 |  * upper layer can accept more (as noted here in rio_rx_throt[]).  | 
 | 762 |  * If it can't we simply don't remove chars from the cards buffer.  | 
 | 763 |  * When the tty layer can accept chars, we again note that here and when | 
 | 764 |  * rio_receive_chars() is called it will remove them from the cards buffer. | 
 | 765 |  * The card will notice that a ports buffer has drained below some low | 
 | 766 |  * water mark and will unflow control the line itself, using whatever | 
 | 767 |  * flow control scheme is in use for that port. -- Simon Allen | 
 | 768 |  */ | 
 | 769 |  | 
 | 770 | static void rio_throttle (struct tty_struct * tty) | 
 | 771 | { | 
 | 772 |   struct Port *port = (struct Port *)tty->driver_data; | 
 | 773 |    | 
 | 774 |   func_enter(); | 
 | 775 |   /* If the port is using any type of input flow | 
 | 776 |    * control then throttle the port. | 
 | 777 |    */ | 
 | 778 |  | 
 | 779 |   if((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) ) { | 
 | 780 |     port->State |= RIO_THROTTLE_RX; | 
 | 781 |   } | 
 | 782 |  | 
 | 783 |   func_exit(); | 
 | 784 | } | 
 | 785 |  | 
 | 786 |  | 
 | 787 | static void rio_unthrottle (struct tty_struct * tty) | 
 | 788 | { | 
 | 789 |   struct Port *port = (struct Port *)tty->driver_data; | 
 | 790 |  | 
 | 791 |   func_enter(); | 
 | 792 |   /* Always unthrottle even if flow control is not enabled on | 
 | 793 |    * this port in case we disabled flow control while the port | 
 | 794 |    * was throttled | 
 | 795 |    */ | 
 | 796 |  | 
 | 797 |   port->State &= ~RIO_THROTTLE_RX; | 
 | 798 |  | 
 | 799 |   func_exit(); | 
 | 800 |   return; | 
 | 801 | } | 
 | 802 |  | 
 | 803 |  | 
 | 804 |  | 
 | 805 |  | 
 | 806 |  | 
 | 807 | /* ********************************************************************** * | 
 | 808 |  *                    Here are the initialization routines.               * | 
 | 809 |  * ********************************************************************** */ | 
 | 810 |  | 
 | 811 |  | 
 | 812 | static struct vpd_prom *get_VPD_PROM (struct Host *hp) | 
 | 813 | { | 
 | 814 |   static struct vpd_prom vpdp; | 
 | 815 |   char *p; | 
 | 816 |   int i; | 
 | 817 |  | 
 | 818 |   func_enter(); | 
 | 819 |   rio_dprintk (RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n",  | 
 | 820 |               hp->Caddr + RIO_VPD_ROM); | 
 | 821 |  | 
 | 822 |   p = (char *) &vpdp; | 
 | 823 |   for (i=0;i< sizeof (struct vpd_prom);i++) | 
 | 824 |     *p++ = readb (hp->Caddr+RIO_VPD_ROM + i*2); | 
 | 825 |       /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */ | 
 | 826 |  | 
 | 827 |   /* Terminate the identifier string.  | 
 | 828 |      *** requires one extra byte in struct vpd_prom *** */ | 
 | 829 |   *p++=0;  | 
 | 830 |  | 
 | 831 |   if (rio_debug & RIO_DEBUG_PROBE) | 
 | 832 |     my_hd ((char *)&vpdp, 0x20); | 
 | 833 |    | 
 | 834 |   func_exit(); | 
 | 835 |  | 
 | 836 |   return &vpdp; | 
 | 837 | } | 
 | 838 |  | 
 | 839 | static struct tty_operations rio_ops = { | 
 | 840 | 	.open  = riotopen, | 
 | 841 | 	.close = gs_close, | 
 | 842 | 	.write = gs_write, | 
 | 843 | 	.put_char = gs_put_char, | 
 | 844 | 	.flush_chars = gs_flush_chars, | 
 | 845 | 	.write_room = gs_write_room, | 
 | 846 | 	.chars_in_buffer = gs_chars_in_buffer, | 
 | 847 | 	.flush_buffer = gs_flush_buffer, | 
 | 848 | 	.ioctl = rio_ioctl, | 
 | 849 | 	.throttle = rio_throttle, | 
 | 850 | 	.unthrottle = rio_unthrottle, | 
 | 851 | 	.set_termios = gs_set_termios, | 
 | 852 | 	.stop = gs_stop, | 
 | 853 | 	.start = gs_start, | 
 | 854 | 	.hangup = gs_hangup, | 
 | 855 | }; | 
 | 856 |  | 
 | 857 | static int rio_init_drivers(void) | 
 | 858 | { | 
 | 859 | 	int error = -ENOMEM; | 
 | 860 |  | 
 | 861 | 	rio_driver = alloc_tty_driver(256); | 
 | 862 | 	if (!rio_driver) | 
 | 863 | 		goto out; | 
 | 864 | 	rio_driver2 = alloc_tty_driver(256); | 
 | 865 | 	if (!rio_driver2) | 
 | 866 | 		goto out1; | 
 | 867 |  | 
 | 868 | 	func_enter(); | 
 | 869 |  | 
 | 870 | 	rio_driver->owner = THIS_MODULE; | 
 | 871 | 	rio_driver->driver_name = "specialix_rio"; | 
 | 872 | 	rio_driver->name = "ttySR"; | 
 | 873 | 	rio_driver->major = RIO_NORMAL_MAJOR0; | 
 | 874 | 	rio_driver->type = TTY_DRIVER_TYPE_SERIAL; | 
 | 875 | 	rio_driver->subtype = SERIAL_TYPE_NORMAL; | 
 | 876 | 	rio_driver->init_termios = tty_std_termios; | 
 | 877 | 	rio_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 
 | 878 | 	rio_driver->flags = TTY_DRIVER_REAL_RAW; | 
 | 879 | 	tty_set_operations(rio_driver, &rio_ops); | 
 | 880 |  | 
 | 881 | 	rio_driver2->owner = THIS_MODULE; | 
 | 882 | 	rio_driver2->driver_name = "specialix_rio"; | 
 | 883 | 	rio_driver2->name = "ttySR"; | 
 | 884 | 	rio_driver2->major = RIO_NORMAL_MAJOR1; | 
 | 885 | 	rio_driver2->type = TTY_DRIVER_TYPE_SERIAL; | 
 | 886 | 	rio_driver2->subtype = SERIAL_TYPE_NORMAL; | 
 | 887 | 	rio_driver2->init_termios = tty_std_termios; | 
 | 888 | 	rio_driver2->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 
 | 889 | 	rio_driver2->flags = TTY_DRIVER_REAL_RAW; | 
 | 890 | 	tty_set_operations(rio_driver2, &rio_ops); | 
 | 891 |  | 
 | 892 | 	rio_dprintk (RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios); | 
 | 893 |  | 
 | 894 | 	if ((error = tty_register_driver(rio_driver))) | 
 | 895 | 		goto out2; | 
 | 896 | 	if ((error = tty_register_driver(rio_driver2))) | 
 | 897 | 		goto out3; | 
 | 898 | 	func_exit(); | 
 | 899 | 	return 0; | 
 | 900 | out3: | 
 | 901 | 	tty_unregister_driver(rio_driver); | 
 | 902 | out2: | 
 | 903 | 	put_tty_driver(rio_driver2); | 
 | 904 | out1: | 
 | 905 | 	put_tty_driver(rio_driver); | 
 | 906 | out: | 
 | 907 | 	printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", | 
 | 908 | 	     error); | 
 | 909 | 	return 1; | 
 | 910 | } | 
 | 911 |  | 
 | 912 |  | 
 | 913 | static void * ckmalloc (int size) | 
 | 914 | { | 
 | 915 |   void *p; | 
 | 916 |  | 
 | 917 |   p = kmalloc(size, GFP_KERNEL); | 
 | 918 |   if (p)  | 
 | 919 |     memset(p, 0, size); | 
 | 920 |   return p; | 
 | 921 | } | 
 | 922 |  | 
 | 923 |  | 
 | 924 |  | 
 | 925 | static int rio_init_datastructures (void) | 
 | 926 | { | 
 | 927 |   int i; | 
 | 928 |   struct Port *port; | 
 | 929 |   func_enter(); | 
 | 930 |  | 
 | 931 |   /* Many drivers statically allocate the maximum number of ports | 
 | 932 |      There is no reason not to allocate them dynamically. Is there? -- REW */ | 
 | 933 |   /* However, the RIO driver allows users to configure their first | 
 | 934 |      RTA as the ports numbered 504-511. We therefore need to allocate  | 
 | 935 |      the whole range. :-(   -- REW */ | 
 | 936 |    | 
 | 937 | #define RI_SZ   sizeof(struct rio_info) | 
 | 938 | #define HOST_SZ sizeof(struct Host) | 
 | 939 | #define PORT_SZ sizeof(struct Port *) | 
 | 940 | #define TMIO_SZ sizeof(struct termios *) | 
 | 941 |   rio_dprintk (RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n",  | 
 | 942 |                RI_SZ,  | 
 | 943 |                RIO_HOSTS * HOST_SZ, | 
 | 944 |                RIO_PORTS * PORT_SZ, | 
 | 945 |                RIO_PORTS * TMIO_SZ, | 
 | 946 |                RIO_PORTS * TMIO_SZ); | 
 | 947 |    | 
 | 948 |   if (!(p                  = ckmalloc (              RI_SZ))) goto free0; | 
 | 949 |   if (!(p->RIOHosts        = ckmalloc (RIO_HOSTS * HOST_SZ))) goto free1; | 
 | 950 |   if (!(p->RIOPortp        = ckmalloc (RIO_PORTS * PORT_SZ))) goto free2; | 
 | 951 |   p->RIOConf = RIOConf; | 
 | 952 |   rio_dprintk (RIO_DEBUG_INIT, "Got : %p %p %p\n",  | 
 | 953 |                p, p->RIOHosts, p->RIOPortp); | 
 | 954 |  | 
 | 955 | #if 1 | 
 | 956 |   for (i = 0; i < RIO_PORTS; i++) { | 
 | 957 |     port = p->RIOPortp[i] = ckmalloc (sizeof (struct Port)); | 
 | 958 |     if (!port) { | 
 | 959 |       goto free6; | 
 | 960 |     } | 
 | 961 |     rio_dprintk (RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); | 
 | 962 |     port->PortNum = i; | 
 | 963 |     port->gs.magic = RIO_MAGIC; | 
 | 964 |     port->gs.close_delay = HZ/2; | 
 | 965 |     port->gs.closing_wait = 30 * HZ; | 
 | 966 |     port->gs.rd = &rio_real_driver; | 
 | 967 |     spin_lock_init(&port->portSem); | 
 | 968 |     /* | 
 | 969 |      * Initializing wait queue | 
 | 970 |      */ | 
 | 971 |     init_waitqueue_head(&port->gs.open_wait); | 
 | 972 |     init_waitqueue_head(&port->gs.close_wait); | 
 | 973 |   } | 
 | 974 | #else | 
 | 975 |   /* We could postpone initializing them to when they are configured. */ | 
 | 976 | #endif | 
 | 977 |  | 
 | 978 |  | 
 | 979 |    | 
 | 980 |   if (rio_debug & RIO_DEBUG_INIT) { | 
 | 981 |     my_hd (&rio_real_driver, sizeof (rio_real_driver)); | 
 | 982 |   } | 
 | 983 |  | 
 | 984 |    | 
 | 985 |   func_exit(); | 
 | 986 |   return 0; | 
 | 987 |  | 
 | 988 |  free6:for (i--;i>=0;i--) | 
 | 989 |         kfree (p->RIOPortp[i]); | 
 | 990 | /*free5: | 
 | 991 |  free4: | 
 | 992 |  free3:*/kfree (p->RIOPortp); | 
 | 993 |  free2:kfree (p->RIOHosts); | 
 | 994 |  free1: | 
 | 995 |   rio_dprintk (RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n",  | 
 | 996 |         	       p, p->RIOHosts, p->RIOPortp); | 
 | 997 |   kfree(p);        	       | 
 | 998 |  free0: | 
 | 999 |   return -ENOMEM; | 
 | 1000 | } | 
 | 1001 |  | 
 | 1002 | static void  __exit rio_release_drivers(void) | 
 | 1003 | { | 
 | 1004 |   func_enter(); | 
 | 1005 |   tty_unregister_driver(rio_driver2); | 
 | 1006 |   tty_unregister_driver(rio_driver); | 
 | 1007 |   put_tty_driver(rio_driver2); | 
 | 1008 |   put_tty_driver(rio_driver); | 
 | 1009 |   func_exit(); | 
 | 1010 | } | 
 | 1011 |  | 
 | 1012 |  | 
 | 1013 | #ifdef CONFIG_PCI | 
 | 1014 |  /* This was written for SX, but applies to RIO too... | 
 | 1015 |     (including bugs....) | 
 | 1016 |  | 
 | 1017 |     There is another bit besides Bit 17. Turning that bit off | 
 | 1018 |     (on boards shipped with the fix in the eeprom) results in a  | 
 | 1019 |     hang on the next access to the card.  | 
 | 1020 |  */ | 
 | 1021 |  | 
 | 1022 |  /********************************************************  | 
 | 1023 |  * Setting bit 17 in the CNTRL register of the PLX 9050  *  | 
 | 1024 |  * chip forces a retry on writes while a read is pending.* | 
 | 1025 |  * This is to prevent the card locking up on Intel Xeon  * | 
 | 1026 |  * multiprocessor systems with the NX chipset.    -- NV  * | 
 | 1027 |  ********************************************************/ | 
 | 1028 |  | 
 | 1029 | /* Newer cards are produced with this bit set from the configuration | 
 | 1030 |    EEprom.  As the bit is read/write for the CPU, we can fix it here, | 
 | 1031 |    if we detect that it isn't set correctly. -- REW */ | 
 | 1032 |  | 
 | 1033 | static void fix_rio_pci (struct pci_dev *pdev) | 
 | 1034 | { | 
 | 1035 |   unsigned int hwbase; | 
 | 1036 |   unsigned long rebase; | 
 | 1037 |   unsigned int t; | 
 | 1038 |  | 
 | 1039 | #define CNTRL_REG_OFFSET        0x50 | 
 | 1040 | #define CNTRL_REG_GOODVALUE     0x18260000 | 
 | 1041 |  | 
 | 1042 |   pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); | 
 | 1043 |   hwbase &= PCI_BASE_ADDRESS_MEM_MASK; | 
 | 1044 |   rebase =  (ulong) ioremap(hwbase, 0x80); | 
 | 1045 |   t = readl (rebase + CNTRL_REG_OFFSET); | 
 | 1046 |   if (t != CNTRL_REG_GOODVALUE) { | 
 | 1047 |     printk (KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n",  | 
 | 1048 |             t, CNTRL_REG_GOODVALUE);  | 
 | 1049 |     writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);   | 
 | 1050 |   } | 
 | 1051 |   iounmap((char*) rebase); | 
 | 1052 | } | 
 | 1053 | #endif | 
 | 1054 |  | 
 | 1055 |  | 
 | 1056 | static int __init rio_init(void)  | 
 | 1057 | { | 
 | 1058 |   int found = 0; | 
 | 1059 |   int i; | 
 | 1060 |   struct Host *hp; | 
 | 1061 |   int retval; | 
 | 1062 |   struct vpd_prom *vpdp; | 
 | 1063 |   int okboard; | 
 | 1064 |  | 
 | 1065 | #ifdef CONFIG_PCI | 
 | 1066 |   struct pci_dev *pdev = NULL; | 
 | 1067 |   unsigned int tint; | 
 | 1068 |   unsigned short tshort; | 
 | 1069 | #endif | 
 | 1070 |  | 
 | 1071 |   func_enter(); | 
 | 1072 |   rio_dprintk (RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n",  | 
 | 1073 | 	       rio_debug); | 
 | 1074 |  | 
 | 1075 |   if (abs ((long) (&rio_debug) - rio_debug) < 0x10000) { | 
 | 1076 |     printk (KERN_WARNING "rio: rio_debug is an address, instead of a value. " | 
 | 1077 |             "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug); | 
 | 1078 |     rio_debug=-1; | 
 | 1079 |   } | 
 | 1080 |  | 
 | 1081 |   if (misc_register(&rio_fw_device) < 0) { | 
 | 1082 |     printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n"); | 
 | 1083 |     return -EIO; | 
 | 1084 |   } | 
 | 1085 |  | 
 | 1086 |   retval = rio_init_datastructures (); | 
 | 1087 |   if (retval < 0) { | 
 | 1088 |     misc_deregister(&rio_fw_device); | 
 | 1089 |     return retval; | 
 | 1090 |   } | 
 | 1091 |  | 
 | 1092 | #ifdef CONFIG_PCI | 
 | 1093 |     /* First look for the JET devices: */ | 
| Amit Gud | efe1ec2 | 2005-04-12 19:04:27 +0530 | [diff] [blame] | 1094 |     while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 |                                     PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8,  | 
 | 1096 |                                     pdev))) { | 
 | 1097 |        if (pci_enable_device(pdev)) continue; | 
 | 1098 |  | 
 | 1099 |       /* Specialix has a whole bunch of cards with | 
 | 1100 |          0x2000 as the device ID. They say its because | 
 | 1101 |          the standard requires it. Stupid standard. */ | 
 | 1102 |       /* It seems that reading a word doesn't work reliably on 2.0. | 
 | 1103 |          Also, reading a non-aligned dword doesn't work. So we read the | 
 | 1104 |          whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) | 
 | 1105 |          ourselves */ | 
 | 1106 |       /* I don't know why the define doesn't work, constant 0x2c does --REW */  | 
 | 1107 |       pci_read_config_dword (pdev, 0x2c, &tint); | 
 | 1108 |       tshort = (tint >> 16) & 0xffff; | 
 | 1109 |       rio_dprintk (RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); | 
 | 1110 |       if (tshort != 0x0100) { | 
 | 1111 |         rio_dprintk (RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n",  | 
 | 1112 |                     tshort); | 
 | 1113 |         continue; | 
 | 1114 |       } | 
 | 1115 |       rio_dprintk (RIO_DEBUG_PROBE, "cp1\n"); | 
 | 1116 |  | 
 | 1117 |       pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint); | 
 | 1118 |  | 
 | 1119 |       hp = &p->RIOHosts[p->RIONumHosts]; | 
 | 1120 |       hp->PaddrP =  tint & PCI_BASE_ADDRESS_MEM_MASK; | 
 | 1121 |       hp->Ivec = pdev->irq; | 
 | 1122 |       if (((1 << hp->Ivec) & rio_irqmask) == 0) | 
 | 1123 |               hp->Ivec = 0; | 
 | 1124 |       hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 
 | 1125 |       hp->CardP	= (struct DpRam *) hp->Caddr; | 
 | 1126 |       hp->Type  = RIO_PCI; | 
 | 1127 |       hp->Copy  = rio_pcicopy;  | 
 | 1128 |       hp->Mode  = RIO_PCI_BOOT_FROM_RAM; | 
 | 1129 |       spin_lock_init(&hp->HostLock); | 
 | 1130 |       rio_reset_interrupt (hp); | 
 | 1131 |       rio_start_card_running (hp); | 
 | 1132 |  | 
 | 1133 |       rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", | 
 | 1134 |                    (void *)p->RIOHosts[p->RIONumHosts].PaddrP, | 
 | 1135 |                    p->RIOHosts[p->RIONumHosts].Caddr); | 
 | 1136 |       if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP, | 
 | 1137 |                         p->RIOHosts[p->RIONumHosts].Caddr,  | 
 | 1138 |                         RIO_PCI, 0 ) == RIO_SUCCESS) { | 
 | 1139 |               rio_dprintk (RIO_DEBUG_INIT, "Done RIOBoardTest\n"); | 
 | 1140 |               WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); | 
 | 1141 |               p->RIOHosts[p->RIONumHosts].UniqueNum  = | 
 | 1142 |                       ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)| | 
 | 1143 |                       ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)| | 
 | 1144 |                       ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)| | 
 | 1145 |                       ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24); | 
 | 1146 |               rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", | 
 | 1147 |                            p->RIOHosts[p->RIONumHosts].UniqueNum); | 
 | 1148 |                | 
 | 1149 |               fix_rio_pci (pdev); | 
 | 1150 |               p->RIOLastPCISearch = RIO_SUCCESS; | 
 | 1151 |               p->RIONumHosts++; | 
 | 1152 |               found++; | 
 | 1153 |       } else { | 
 | 1154 |               iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); | 
 | 1155 |       } | 
 | 1156 |     } | 
 | 1157 |      | 
 | 1158 |     /* Then look for the older PCI card.... : */ | 
 | 1159 |  | 
 | 1160 |   /* These older PCI cards have problems (only byte-mode access is | 
 | 1161 |      supported), which makes them a bit awkward to support.  | 
 | 1162 |      They also have problems sharing interrupts. Be careful.  | 
 | 1163 |      (The driver now refuses to share interrupts for these | 
 | 1164 |      cards. This should be sufficient). | 
 | 1165 |   */ | 
 | 1166 |  | 
 | 1167 |     /* Then look for the older RIO/PCI devices: */ | 
| Amit Gud | efe1ec2 | 2005-04-12 19:04:27 +0530 | [diff] [blame] | 1168 |     while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 |                                     PCI_DEVICE_ID_SPECIALIX_RIO,  | 
 | 1170 |                                     pdev))) { | 
 | 1171 |        if (pci_enable_device(pdev)) continue; | 
 | 1172 |  | 
 | 1173 | #ifdef CONFIG_RIO_OLDPCI | 
 | 1174 |       pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint); | 
 | 1175 |  | 
 | 1176 |       hp = &p->RIOHosts[p->RIONumHosts]; | 
 | 1177 |       hp->PaddrP =  tint & PCI_BASE_ADDRESS_MEM_MASK; | 
 | 1178 |       hp->Ivec = pdev->irq; | 
 | 1179 |       if (((1 << hp->Ivec) & rio_irqmask) == 0)  | 
 | 1180 |       	hp->Ivec = 0; | 
 | 1181 |       hp->Ivec |= 0x8000; /* Mark as non-sharable */ | 
 | 1182 |       hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 
 | 1183 |       hp->CardP	= (struct DpRam *) hp->Caddr; | 
 | 1184 |       hp->Type  = RIO_PCI; | 
 | 1185 |       hp->Copy  = rio_pcicopy; | 
 | 1186 |       hp->Mode  = RIO_PCI_BOOT_FROM_RAM; | 
 | 1187 |       spin_lock_init(&hp->HostLock); | 
 | 1188 |  | 
 | 1189 |       rio_dprintk (RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec); | 
 | 1190 |       rio_dprintk (RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode); | 
 | 1191 |  | 
 | 1192 |       rio_reset_interrupt (hp); | 
 | 1193 |       rio_start_card_running (hp); | 
 | 1194 |        rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", | 
 | 1195 |                    (void *)p->RIOHosts[p->RIONumHosts].PaddrP, | 
 | 1196 |                    p->RIOHosts[p->RIONumHosts].Caddr); | 
 | 1197 |       if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP, | 
 | 1198 |                         p->RIOHosts[p->RIONumHosts].Caddr,  | 
 | 1199 |                         RIO_PCI, 0 ) == RIO_SUCCESS) { | 
 | 1200 |         WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); | 
 | 1201 |         p->RIOHosts[p->RIONumHosts].UniqueNum  = | 
 | 1202 |           ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)| | 
 | 1203 |           ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)| | 
 | 1204 |           ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)| | 
 | 1205 |           ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24); | 
 | 1206 |         rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", | 
 | 1207 |                    p->RIOHosts[p->RIONumHosts].UniqueNum); | 
 | 1208 |  | 
 | 1209 |         p->RIOLastPCISearch = RIO_SUCCESS; | 
 | 1210 |         p->RIONumHosts++; | 
 | 1211 |         found++; | 
 | 1212 |       } else { | 
 | 1213 |         iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); | 
 | 1214 |       } | 
 | 1215 | #else | 
 | 1216 |       printk (KERN_ERR "Found an older RIO PCI card, but the driver is not " | 
 | 1217 |               "compiled to support it.\n"); | 
 | 1218 | #endif | 
 | 1219 |     } | 
 | 1220 | #endif /* PCI */ | 
 | 1221 |  | 
 | 1222 |   /* Now probe for ISA cards... */ | 
 | 1223 |   for (i=0;i<NR_RIO_ADDRS;i++) { | 
 | 1224 |     hp = &p->RIOHosts[p->RIONumHosts]; | 
 | 1225 |     hp->PaddrP = rio_probe_addrs[i]; | 
 | 1226 |     /* There was something about the IRQs of these cards. 'Forget what.--REW */ | 
 | 1227 |     hp->Ivec = 0; | 
 | 1228 |     hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); | 
 | 1229 |     hp->CardP = (struct DpRam *) hp->Caddr; | 
 | 1230 |     hp->Type = RIO_AT; | 
 | 1231 |     hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL | 
 | 1232 |                              * -- YES! this is now a normal copy. Only the  | 
 | 1233 |                              * old PCI card uses the special PCI copy.  | 
 | 1234 |                              * Moreover, the ISA card will work with the  | 
 | 1235 |                              * special PCI copy anyway. -- REW */ | 
 | 1236 |     hp->Mode = 0; | 
 | 1237 |     spin_lock_init(&hp->HostLock); | 
 | 1238 |  | 
 | 1239 |     vpdp = get_VPD_PROM (hp); | 
 | 1240 |     rio_dprintk (RIO_DEBUG_PROBE, "Got VPD ROM\n"); | 
 | 1241 |     okboard = 0; | 
 | 1242 |     if ((strncmp (vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || | 
 | 1243 |         (strncmp (vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || | 
 | 1244 |         (strncmp (vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) { | 
 | 1245 |       /* Board is present... */ | 
 | 1246 |       if (RIOBoardTest (hp->PaddrP,  | 
 | 1247 |                         hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { | 
 | 1248 |         /* ... and feeling fine!!!! */ | 
 | 1249 |         rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", | 
 | 1250 |                    p->RIOHosts[p->RIONumHosts].UniqueNum); | 
 | 1251 |         if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {         | 
 | 1252 |           rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", | 
 | 1253 |                        p->RIONumHosts,  | 
 | 1254 |                        p->RIOHosts[p->RIONumHosts-1].UniqueNum); | 
 | 1255 |           okboard++; | 
 | 1256 |           found++; | 
 | 1257 |         } | 
 | 1258 |       } | 
 | 1259 |  | 
 | 1260 |     if (!okboard) | 
 | 1261 |       iounmap ((char*) (hp->Caddr)); | 
 | 1262 |     } | 
 | 1263 |   } | 
 | 1264 |  | 
 | 1265 |  | 
 | 1266 |   for (i=0;i<p->RIONumHosts;i++) { | 
 | 1267 |     hp = &p->RIOHosts[i]; | 
 | 1268 |     if (hp->Ivec) { | 
 | 1269 |       int mode = SA_SHIRQ; | 
 | 1270 |       if (hp->Ivec & 0x8000) {mode = 0; hp->Ivec &= 0x7fff;} | 
 | 1271 |       rio_dprintk (RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp,hp->Ivec, hp->Mode); | 
 | 1272 |       retval = request_irq (hp->Ivec, rio_interrupt, mode, "rio", hp); | 
 | 1273 |       rio_dprintk (RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval); | 
 | 1274 |       if (retval) { | 
 | 1275 |               printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec); | 
 | 1276 |               hp->Ivec = 0; | 
 | 1277 |       } | 
 | 1278 |       rio_dprintk (RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec); | 
 | 1279 |       if (hp->Ivec != 0){ | 
 | 1280 |               rio_dprintk (RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n");  | 
 | 1281 |               hp->Mode |= RIO_PCI_INT_ENABLE; | 
 | 1282 |       } else | 
 | 1283 |               hp->Mode &= !RIO_PCI_INT_ENABLE; | 
 | 1284 |       rio_dprintk (RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode); | 
 | 1285 |       rio_start_card_running (hp); | 
 | 1286 |     } | 
 | 1287 |     /* Init the timer "always" to make sure that it can safely be  | 
 | 1288 |        deleted when we unload... */ | 
 | 1289 |  | 
 | 1290 |     init_timer (&hp->timer); | 
 | 1291 |     if (!hp->Ivec) { | 
 | 1292 |       rio_dprintk (RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n",  | 
 | 1293 |                    rio_poll); | 
 | 1294 |       hp->timer.data = i; | 
 | 1295 |       hp->timer.function = rio_pollfunc; | 
 | 1296 |       hp->timer.expires = jiffies + rio_poll; | 
 | 1297 |       add_timer (&hp->timer); | 
 | 1298 |     } | 
 | 1299 |   } | 
 | 1300 |  | 
 | 1301 |   if (found) { | 
 | 1302 |     rio_dprintk (RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found); | 
 | 1303 |     rio_init_drivers (); | 
 | 1304 |   } else { | 
 | 1305 |     /* deregister the misc device we created earlier */ | 
 | 1306 |     misc_deregister(&rio_fw_device); | 
 | 1307 |   } | 
 | 1308 |  | 
 | 1309 |   func_exit(); | 
 | 1310 |   return found?0:-EIO; | 
 | 1311 | } | 
 | 1312 |  | 
 | 1313 |  | 
 | 1314 | static void __exit rio_exit (void) | 
 | 1315 | { | 
 | 1316 |   int i;  | 
 | 1317 |   struct Host *hp; | 
 | 1318 |    | 
 | 1319 |   func_enter(); | 
 | 1320 |  | 
 | 1321 |   for (i=0,hp=p->RIOHosts;i<p->RIONumHosts;i++, hp++) { | 
 | 1322 |     RIOHostReset (hp->Type, hp->CardP, hp->Slot); | 
 | 1323 |     if (hp->Ivec) { | 
 | 1324 |       free_irq (hp->Ivec, hp); | 
 | 1325 |       rio_dprintk (RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec); | 
 | 1326 |     } | 
 | 1327 |     /* It is safe/allowed to del_timer a non-active timer */ | 
 | 1328 |     del_timer (&hp->timer); | 
 | 1329 |   } | 
 | 1330 |  | 
 | 1331 |   if (misc_deregister(&rio_fw_device) < 0) { | 
 | 1332 |     printk (KERN_INFO "rio: couldn't deregister control-device\n"); | 
 | 1333 |   } | 
 | 1334 |  | 
 | 1335 |  | 
 | 1336 |   rio_dprintk (RIO_DEBUG_CLEANUP, "Cleaning up drivers\n"); | 
 | 1337 |  | 
 | 1338 |   rio_release_drivers (); | 
 | 1339 |  | 
 | 1340 |   /* Release dynamically allocated memory */ | 
 | 1341 |   kfree (p->RIOPortp); | 
 | 1342 |   kfree (p->RIOHosts); | 
 | 1343 |   kfree (p); | 
 | 1344 |  | 
 | 1345 |   func_exit(); | 
 | 1346 | } | 
 | 1347 |  | 
 | 1348 | module_init(rio_init); | 
 | 1349 | module_exit(rio_exit); | 
 | 1350 |  | 
 | 1351 | /* | 
 | 1352 |  * Anybody who knows why this doesn't work for me, please tell me -- REW. | 
 | 1353 |  * Snatched from scsi.c (fixed one spelling error): | 
 | 1354 |  * Overrides for Emacs so that we follow Linus' tabbing style. | 
 | 1355 |  * Emacs will notice this stuff at the end of the file and automatically | 
 | 1356 |  * adjust the settings for this buffer only.  This must remain at the end | 
 | 1357 |  * of the file. | 
 | 1358 |  * --------------------------------------------------------------------------- | 
 | 1359 |  * Local Variables: | 
 | 1360 |  * c-indent-level: 4 | 
 | 1361 |  * c-brace-imaginary-offset: 0 | 
 | 1362 |  * c-brace-offset: -4 | 
 | 1363 |  * c-argdecl-indent: 4 | 
 | 1364 |  * c-label-offset: -4 | 
 | 1365 |  * c-continued-statement-offset: 4 | 
 | 1366 |  * c-continued-brace-offset: 0 | 
 | 1367 |  * indent-tabs-mode: nil | 
 | 1368 |  * tab-width: 8 | 
 | 1369 |  * End: | 
 | 1370 |  */ | 
 | 1371 |  |