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