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