diff options
Diffstat (limited to 'drivers/char/rio/rio_linux.c')
-rw-r--r-- | drivers/char/rio/rio_linux.c | 1498 |
1 files changed, 699 insertions, 799 deletions
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index d7d484024e2..c9af283a811 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -33,7 +33,7 @@ * */ #include <linux/module.h> -#include <linux/config.h> +#include <linux/config.h> #include <linux/kdev_t.h> #include <asm/io.h> #include <linux/kernel.h> @@ -56,10 +56,6 @@ #include <linux/generic_serial.h> #include <asm/uaccess.h> -#if BITS_PER_LONG != 32 -# error FIXME: this driver only works on 32-bit platforms -#endif - #include "linux_compat.h" #include "typdef.h" #include "pkt.h" @@ -116,7 +112,7 @@ more than 512 ports.... */ #define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000 #endif -#ifndef RIO_WINDOW_LEN +#ifndef RIO_WINDOW_LEN #define RIO_WINDOW_LEN 0x10000 #endif @@ -136,42 +132,49 @@ more than 512 ports.... */ */ #define IRQ_RATE_LIMIT 200 -#if 0 -/* Not implemented */ -/* - * The following defines are mostly for testing purposes. But if you need - * some nice reporting in your syslog, you can define them also. - */ -#define RIO_REPORT_FIFO -#define RIO_REPORT_OVERRUN -#endif - /* These constants are derived from SCO Source */ static struct Conf -RIOConf = -{ - /* locator */ "RIO Config here", - /* startuptime */ HZ*2, /* how long to wait for card to run */ - /* slowcook */ 0, /* TRUE -> always use line disc. */ - /* intrpolltime */ 1, /* The frequency of OUR polls */ - /* breakinterval */ 25, /* x10 mS XXX: units seem to be 1ms not 10! -- REW*/ - /* timer */ 10, /* mS */ - /* RtaLoadBase */ 0x7000, - /* HostLoadBase */ 0x7C00, - /* XpHz */ 5, /* number of Xprint hits per second */ - /* XpCps */ 120, /* Xprint characters per second */ - /* XpOn */ "\033d#", /* start Xprint for a wyse 60 */ - /* XpOff */ "\024", /* end Xprint for a wyse 60 */ - /* MaxXpCps */ 2000, /* highest Xprint speed */ - /* MinXpCps */ 10, /* slowest Xprint speed */ - /* SpinCmds */ 1, /* non-zero for mega fast boots */ - /* First Addr */ 0x0A0000, /* First address to look at */ - /* Last Addr */ 0xFF0000, /* Last address looked at */ - /* BufferSize */ 1024, /* Bytes per port of buffering */ - /* LowWater */ 256, /* how much data left before wakeup */ - /* LineLength */ 80, /* how wide is the console? */ - /* CmdTimeout */ HZ, /* how long a close command may take */ + RIOConf = { + /* locator */ "RIO Config here", + /* startuptime */ HZ * 2, + /* how long to wait for card to run */ + /* slowcook */ 0, + /* TRUE -> always use line disc. */ + /* intrpolltime */ 1, + /* The frequency of OUR polls */ + /* breakinterval */ 25, + /* x10 mS XXX: units seem to be 1ms not 10! -- REW */ + /* timer */ 10, + /* mS */ + /* RtaLoadBase */ 0x7000, + /* HostLoadBase */ 0x7C00, + /* XpHz */ 5, + /* number of Xprint hits per second */ + /* XpCps */ 120, + /* Xprint characters per second */ + /* XpOn */ "\033d#", + /* start Xprint for a wyse 60 */ + /* XpOff */ "\024", + /* end Xprint for a wyse 60 */ + /* MaxXpCps */ 2000, + /* highest Xprint speed */ + /* MinXpCps */ 10, + /* slowest Xprint speed */ + /* SpinCmds */ 1, + /* non-zero for mega fast boots */ + /* First Addr */ 0x0A0000, + /* First address to look at */ + /* Last Addr */ 0xFF0000, + /* Last address looked at */ + /* BufferSize */ 1024, + /* Bytes per port of buffering */ + /* LowWater */ 256, + /* how much data left before wakeup */ + /* LineLength */ 80, + /* how wide is the console? */ + /* CmdTimeout */ HZ, + /* how long a close command may take */ }; @@ -179,21 +182,20 @@ RIOConf = /* Function prototypes */ -static void rio_disable_tx_interrupts (void * ptr); -static void rio_enable_tx_interrupts (void * ptr); -static void rio_disable_rx_interrupts (void * ptr); -static void rio_enable_rx_interrupts (void * ptr); -static int rio_get_CD (void * ptr); -static void rio_shutdown_port (void * ptr); -static int rio_set_real_termios (void *ptr); -static void rio_hungup (void *ptr); -static void rio_close (void *ptr); -static int rio_chars_in_buffer (void * ptr); -static int rio_fw_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); +static void rio_disable_tx_interrupts(void *ptr); +static void rio_enable_tx_interrupts(void *ptr); +static void rio_disable_rx_interrupts(void *ptr); +static void rio_enable_rx_interrupts(void *ptr); +static int rio_get_CD(void *ptr); +static void rio_shutdown_port(void *ptr); +static int rio_set_real_termios(void *ptr); +static void rio_hungup(void *ptr); +static void rio_close(void *ptr); +static int rio_chars_in_buffer(void *ptr); +static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); static int rio_init_drivers(void); -static void my_hd (void *addr, int len); +static void my_hd(void *addr, int len); static struct tty_driver *rio_driver, *rio_driver2; @@ -213,9 +215,9 @@ static int rio_poll = 1; /* These are the only open spaces in my computer. Yours may have more or less.... */ -static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000}; +static int rio_probe_addrs[] = { 0xc0000, 0xd0000, 0xe0000 }; -#define NR_RIO_ADDRS (sizeof(rio_probe_addrs)/sizeof (int)) +#define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) /* Set the mask to all-ones. This alas, only supports 32 interrupts. @@ -231,17 +233,17 @@ module_param(rio_debug, int, 0644); module_param(rio_irqmask, long, 0); static struct real_driver rio_real_driver = { - rio_disable_tx_interrupts, - rio_enable_tx_interrupts, - rio_disable_rx_interrupts, - rio_enable_rx_interrupts, - rio_get_CD, - rio_shutdown_port, - rio_set_real_termios, - rio_chars_in_buffer, - rio_close, - rio_hungup, - NULL + rio_disable_tx_interrupts, + rio_enable_tx_interrupts, + rio_disable_rx_interrupts, + rio_enable_rx_interrupts, + rio_get_CD, + rio_shutdown_port, + rio_set_real_termios, + rio_chars_in_buffer, + rio_close, + rio_hungup, + NULL }; /* @@ -250,8 +252,8 @@ static struct real_driver rio_real_driver = { */ static struct file_operations rio_fw_fops = { - .owner = THIS_MODULE, - .ioctl = rio_fw_ioctl, + .owner = THIS_MODULE, + .ioctl = rio_fw_ioctl, }; static struct miscdevice rio_fw_device = { @@ -266,25 +268,22 @@ static struct miscdevice rio_fw_device = { /* This doesn't work. Who's paranoid around here? Not me! */ -static inline int rio_paranoia_check(struct rio_port const * port, - char *name, const char *routine) +static inline int rio_paranoia_check(struct rio_port const *port, char *name, const char *routine) { - static const char *badmagic = - KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n"; - static const char *badinfo = - KERN_ERR "rio: Warning: null rio port for device %s in %s\n"; - - if (!port) { - printk (badinfo, name, routine); - return 1; - } - if (port->magic != RIO_MAGIC) { - printk (badmagic, name, routine); - return 1; - } - - return 0; + static const char *badmagic = KERN_ERR "rio: Warning: bad rio port magic number for device %s in %s\n"; + static const char *badinfo = KERN_ERR "rio: Warning: null rio port for device %s in %s\n"; + + if (!port) { + printk(badinfo, name, routine); + return 1; + } + if (port->magic != RIO_MAGIC) { + printk(badmagic, name, routine); + return 1; + } + + return 0; } #else #define rio_paranoia_check(a,b,c) 0 @@ -292,53 +291,53 @@ static inline int rio_paranoia_check(struct rio_port const * port, #ifdef DEBUG -static void my_hd (void *ad, int len) +static void my_hd(void *ad, int len) { - int i, j, ch; - unsigned char *addr = ad; - - for (i=0;i<len;i+=16) { - rio_dprintk (RIO_DEBUG_PARAM, "%08x ", (int) addr+i); - for (j=0;j<16;j++) { - rio_dprintk (RIO_DEBUG_PARAM, "%02x %s", addr[j+i], (j==7)?" ":""); - } - for (j=0;j<16;j++) { - ch = addr[j+i]; - rio_dprintk (RIO_DEBUG_PARAM, "%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch)); - } - rio_dprintk (RIO_DEBUG_PARAM, "\n"); - } + int i, j, ch; + unsigned char *addr = ad; + + for (i = 0; i < len; i += 16) { + rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i); + for (j = 0; j < 16; j++) { + rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); + } + for (j = 0; j < 16; j++) { + ch = addr[j + i]; + rio_dprintk(RIO_DEBUG_PARAM, "%c", (ch < 0x20) ? '.' : ((ch > 0x7f) ? '.' : ch)); + } + rio_dprintk(RIO_DEBUG_PARAM, "\n"); + } } #else #define my_hd(ad,len) do{/* nothing*/ } while (0) #endif -/* Delay a number of jiffies, allowing a signal to interrupt */ -int RIODelay (struct Port *PortP, int njiffies) +/* Delay a number of jiffies, allowing a signal to interrupt */ +int RIODelay(struct Port *PortP, int njiffies) { - func_enter (); + func_enter(); - rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies); - msleep_interruptible(jiffies_to_msecs(njiffies)); - func_exit(); + rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies\n", njiffies); + msleep_interruptible(jiffies_to_msecs(njiffies)); + func_exit(); - if (signal_pending(current)) - return RIO_FAIL; - else - return !RIO_FAIL; + if (signal_pending(current)) + return RIO_FAIL; + else + return !RIO_FAIL; } -/* Delay a number of jiffies, disallowing a signal to interrupt */ -int RIODelay_ni (struct Port *PortP, int njiffies) +/* Delay a number of jiffies, disallowing a signal to interrupt */ +int RIODelay_ni(struct Port *PortP, int njiffies) { - func_enter (); + func_enter(); - rio_dprintk (RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies); - msleep(jiffies_to_msecs(njiffies)); - func_exit(); - return !RIO_FAIL; + rio_dprintk(RIO_DEBUG_DELAY, "delaying %d jiffies (ni)\n", njiffies); + msleep(jiffies_to_msecs(njiffies)); + func_exit(); + return !RIO_FAIL; } @@ -354,126 +353,121 @@ int rio_ismodem(struct tty_struct *tty) } -static int rio_set_real_termios (void *ptr) +static int rio_set_real_termios(void *ptr) { - int rv, modem; - struct tty_struct *tty; - func_enter(); + int rv, modem; + struct tty_struct *tty; + func_enter(); - tty = ((struct Port *)ptr)->gs.tty; + tty = ((struct Port *) ptr)->gs.tty; - modem = rio_ismodem(tty); + modem = rio_ismodem(tty); - rv = RIOParam( (struct Port *) ptr, CONFIG, modem, 1); + rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1); - func_exit (); + func_exit(); - return rv; + return rv; } -static void rio_reset_interrupt (struct Host *HostP) +static void rio_reset_interrupt(struct Host *HostP) { - func_enter(); + func_enter(); - switch( HostP->Type ) { - case RIO_AT: - case RIO_MCA: - case RIO_PCI: - WBYTE(HostP->ResetInt , 0xff); - } + switch (HostP->Type) { + case RIO_AT: + case RIO_MCA: + case RIO_PCI: + WBYTE(HostP->ResetInt, 0xff); + } - func_exit(); + func_exit(); } -static irqreturn_t rio_interrupt (int irq, void *ptr, struct pt_regs *regs) +static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs) { - struct Host *HostP; - func_enter (); + struct Host *HostP; + func_enter(); - HostP = (struct Host*)ptr; /* &p->RIOHosts[(long)ptr]; */ - rio_dprintk (RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", - irq, HostP->Ivec); + HostP = (struct Host *) ptr; /* &p->RIOHosts[(long)ptr]; */ + rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec); - /* AAargh! The order in which to do these things is essential and - not trivial. - - - Rate limit goes before "recursive". Otherwise a series of - recursive calls will hang the machine in the interrupt routine. + /* AAargh! The order in which to do these things is essential and + not trivial. - - hardware twiddling goes before "recursive". Otherwise when we - poll the card, and a recursive interrupt happens, we won't - ack the card, so it might keep on interrupting us. (especially - level sensitive interrupt systems like PCI). + - Rate limit goes before "recursive". Otherwise a series of + recursive calls will hang the machine in the interrupt routine. - - Rate limit goes before hardware twiddling. Otherwise we won't - catch a card that has gone bonkers. + - hardware twiddling goes before "recursive". Otherwise when we + poll the card, and a recursive interrupt happens, we won't + ack the card, so it might keep on interrupting us. (especially + level sensitive interrupt systems like PCI). - - The "initialized" test goes after the hardware twiddling. Otherwise - the card will stick us in the interrupt routine again. + - Rate limit goes before hardware twiddling. Otherwise we won't + catch a card that has gone bonkers. - - The initialized test goes before recursive. - */ + - The "initialized" test goes after the hardware twiddling. Otherwise + the card will stick us in the interrupt routine again. + + - The initialized test goes before recursive. + */ #ifdef IRQ_RATE_LIMIT - /* Aaargh! I'm ashamed. This costs more lines-of-code than the - actual interrupt routine!. (Well, used to when I wrote that comment) */ - { - static int lastjif; - static int nintr=0; - - if (lastjif == jiffies) { - if (++nintr > IRQ_RATE_LIMIT) { - free_irq (HostP->Ivec, ptr); - printk (KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", - HostP->Ivec); - } - } else { - lastjif = jiffies; - nintr = 0; - } - } + /* Aaargh! I'm ashamed. This costs more lines-of-code than the + actual interrupt routine!. (Well, used to when I wrote that comment) */ + { + static int lastjif; + static int nintr = 0; + + if (lastjif == jiffies) { + if (++nintr > IRQ_RATE_LIMIT) { + free_irq(HostP->Ivec, ptr); + printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec); + } + } else { + lastjif = jiffies; + nintr = 0; + } + } #endif - rio_dprintk (RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); - if (HostP->Ivec == irq) { - /* Tell the card we've noticed the interrupt. */ - rio_reset_interrupt (HostP); - } - - if ((HostP->Flags & RUN_STATE) != RC_RUNNING) - return IRQ_HANDLED; - - if (test_and_set_bit (RIO_BOARD_INTR_LOCK, &HostP->locks)) { - printk (KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", - (int) ptr, HostP->Ivec); - return IRQ_HANDLED; - } - - RIOServiceHost(p, HostP, irq); - - rio_dprintk ( RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", - (int) ptr, HostP->Type); - - clear_bit (RIO_BOARD_INTR_LOCK, &HostP->locks); - rio_dprintk (RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", - irq, HostP->Ivec); - func_exit (); - return IRQ_HANDLED; + rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); + if (HostP->Ivec == irq) { + /* Tell the card we've noticed the interrupt. */ + rio_reset_interrupt(HostP); + } + + if ((HostP->Flags & RUN_STATE) != RC_RUNNING) + return IRQ_HANDLED; + + if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { + printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec); + return IRQ_HANDLED; + } + + RIOServiceHost(p, HostP, irq); + + rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type); + + clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); + rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); + func_exit(); + return IRQ_HANDLED; } -static void rio_pollfunc (unsigned long data) +static void rio_pollfunc(unsigned long data) { - func_enter (); + func_enter(); - rio_interrupt (0, &p->RIOHosts[data], NULL); - p->RIOHosts[data].timer.expires = jiffies + rio_poll; - add_timer (&p->RIOHosts[data].timer); + rio_interrupt(0, &p->RIOHosts[data], NULL); + p->RIOHosts[data].timer.expires = jiffies + rio_poll; + add_timer(&p->RIOHosts[data].timer); - func_exit (); + func_exit(); } @@ -485,106 +479,91 @@ static void rio_pollfunc (unsigned long data) /* Ehhm. I don't know how to fiddle with interrupts on the Specialix cards. .... Hmm. Ok I figured it out. You don't. -- REW */ -static void rio_disable_tx_interrupts (void * ptr) +static void rio_disable_tx_interrupts(void *ptr) { - func_enter(); + func_enter(); - /* port->gs.flags &= ~GS_TX_INTEN; */ + /* port->gs.flags &= ~GS_TX_INTEN; */ - func_exit(); + func_exit(); } -static void rio_enable_tx_interrupts (void * ptr) +static void rio_enable_tx_interrupts(void *ptr) { - struct Port *PortP = ptr; - /* int hn; */ + struct Port *PortP = ptr; + /* int hn; */ - func_enter(); + func_enter(); - /* hn = PortP->HostP - p->RIOHosts; + /* hn = PortP->HostP - p->RIOHosts; - rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn); - rio_interrupt (-1,(void *) hn, NULL); */ + rio_dprintk (RIO_DEBUG_TTY, "Pushing host %d\n", hn); + rio_interrupt (-1,(void *) hn, NULL); */ - RIOTxEnable((char *) PortP); + RIOTxEnable((char *) PortP); - /* - * In general we cannot count on "tx empty" interrupts, although - * the interrupt routine seems to be able to tell the difference. - */ - PortP->gs.flags &= ~GS_TX_INTEN; + /* + * In general we cannot count on "tx empty" interrupts, although + * the interrupt routine seems to be able to tell the difference. + */ + PortP->gs.flags &= ~GS_TX_INTEN; - func_exit(); + func_exit(); } -static void rio_disable_rx_interrupts (void * ptr) +static void rio_disable_rx_interrupts(void *ptr) { - func_enter(); - func_exit(); + func_enter(); + func_exit(); } -static void rio_enable_rx_interrupts (void * ptr) +static void rio_enable_rx_interrupts(void *ptr) { - /* struct rio_port *port = ptr; */ - func_enter(); - func_exit(); + /* struct rio_port *port = ptr; */ + func_enter(); + func_exit(); } /* Jeez. Isn't this simple? */ -static int rio_get_CD (void * ptr) +static int rio_get_CD(void *ptr) { - struct Port *PortP = ptr; - int rv; + struct Port *PortP = ptr; + int rv; - func_enter(); - rv = (PortP->ModemState & MSVR1_CD) != 0; + func_enter(); + rv = (PortP->ModemState & MSVR1_CD) != 0; + + rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); - rio_dprintk (RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); - - func_exit(); - return rv; + func_exit(); + return rv; } /* Jeez. Isn't this simple? Actually, we can sync with the actual port by just pushing stuff into the queue going to the port... */ -static int rio_chars_in_buffer (void * ptr) +static int rio_chars_in_buffer(void *ptr) { - func_enter(); + func_enter(); - func_exit(); - return 0; + func_exit(); + return 0; } /* Nothing special here... */ -static void rio_shutdown_port (void * ptr) +static void rio_shutdown_port(void *ptr) { - struct Port *PortP; - - func_enter(); - - PortP = (struct Port *)ptr; - PortP->gs.tty = NULL; -#if 0 - port->gs.flags &= ~ GS_ACTIVE; - if (!port->gs.tty) { - rio_dprintk (RIO_DBUG_TTY, "No tty.\n"); - return; - } - if (!port->gs.tty->termios) { - rio_dprintk (RIO_DEBUG_TTY, "No termios.\n"); - return; - } - if (port->gs.tty->termios->c_cflag & HUPCL) { - rio_setsignals (port, 0, 0); - } -#endif + struct Port *PortP; + + func_enter(); - func_exit(); + PortP = (struct Port *) ptr; + PortP->gs.tty = NULL; + func_exit(); } @@ -595,16 +574,16 @@ static void rio_shutdown_port (void * ptr) running minicom on a serial port that is driven by a modularized driver. Have the modem hangup. Then remove the driver module. Then exit minicom. I expect an "oops". -- REW */ -static void rio_hungup (void *ptr) +static void rio_hungup(void *ptr) { - struct Port *PortP; + struct Port *PortP; + + func_enter(); - func_enter(); - - PortP = (struct Port *)ptr; - PortP->gs.tty = NULL; + PortP = (struct Port *) ptr; + PortP->gs.tty = NULL; - func_exit (); + func_exit(); } @@ -612,146 +591,100 @@ static void rio_hungup (void *ptr) this. rs_close (...){save_flags;cli;real_close();dec_use_count;restore_flags;} */ -static void rio_close (void *ptr) +static void rio_close(void *ptr) { - struct Port *PortP; + struct Port *PortP; - func_enter (); + func_enter(); - PortP = (struct Port *)ptr; + PortP = (struct Port *) ptr; - riotclose (ptr); + riotclose(ptr); - if(PortP->gs.count) { - printk (KERN_ERR "WARNING port count:%d\n", PortP->gs.count); - PortP->gs.count = 0; - } + if (PortP->gs.count) { + printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count); + PortP->gs.count = 0; + } - PortP->gs.tty = NULL; - func_exit (); + PortP->gs.tty = NULL; + func_exit(); } -static int rio_fw_ioctl (struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - int rc = 0; - func_enter(); + int rc = 0; + func_enter(); - /* The "dev" argument isn't used. */ - rc = riocontrol (p, 0, cmd, (void *)arg, capable(CAP_SYS_ADMIN)); + /* The "dev" argument isn't used. */ + rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN)); - func_exit (); - return rc; + func_exit(); + return rc; } -extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, - int command, int len, int arg); +extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg); -static int rio_ioctl (struct tty_struct * tty, struct file * filp, - unsigned int cmd, unsigned long arg) +static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) { - int rc; - struct Port *PortP; - int ival; - - func_enter(); + int rc; + struct Port *PortP; + int ival; - PortP = (struct Port *)tty->driver_data; + func_enter(); - rc = 0; - switch (cmd) { -#if 0 - case TIOCGSOFTCAR: - rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), - (unsigned int *) arg); - break; -#endif - case TIOCSSOFTCAR: - if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { - tty->termios->c_cflag = - (tty->termios->c_cflag & ~CLOCAL) | - (ival ? CLOCAL : 0); - } - break; - case TIOCGSERIAL: - rc = -EFAULT; - if (access_ok(VERIFY_WRITE, (void *) arg, - sizeof(struct serial_struct))) - rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); - break; - case TCSBRK: - if ( PortP->State & RIO_DELETED ) { - rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); - rc = -EIO; - } else { - if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); - rc = -EIO; - } - } - break; - case TCSBRKP: - if ( PortP->State & RIO_DELETED ) { - rio_dprintk (RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); - rc = -EIO; - } else { - int l; - l = arg?arg*100:250; - if (l > 255) l = 255; - if (RIOShortCommand(p, PortP, SBREAK, 2, arg?arg*100:250) == RIO_FAIL) { - rio_dprintk (RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); - rc = -EIO; - } - } - break; - case TIOCSSERIAL: - rc = -EFAULT; - if (access_ok(VERIFY_READ, (void *) arg, - sizeof(struct serial_struct))) - rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg); - break; -#if 0 - /* - * note: these IOCTLs no longer reach here. Use - * tiocmset/tiocmget driver methods instead. The - * #if 0 disablement predates this comment. - */ - case TIOCMGET: - rc = -EFAULT; - if (access_ok(VERIFY_WRITE, (void *) arg, - sizeof(unsigned int))) { - rc = 0; - ival = rio_getsignals(port); - put_user(ival, (unsigned int *) arg); - } - break; - case TIOCMBIS: - if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { - rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1), - ((ival & TIOCM_RTS) ? 1 : -1)); - } - break; - case TIOCMBIC: - if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { - rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1), - ((ival & TIOCM_RTS) ? 0 : -1)); - } - break; - case TIOCMSET: - if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { - rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0), - ((ival & TIOCM_RTS) ? 1 : 0)); - } - break; -#endif - default: - rc = -ENOIOCTLCMD; - break; - } - func_exit(); - return rc; + PortP = (struct Port *) tty->driver_data; + + rc = 0; + switch (cmd) { + case TIOCSSOFTCAR: + if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { + tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); + } + break; + case TIOCGSERIAL: + rc = -EFAULT; + if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) + rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); + break; + case TCSBRK: + if (PortP->State & RIO_DELETED) { + rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); + rc = -EIO; + } else { + if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) { + rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); + rc = -EIO; + } + } + break; + case TCSBRKP: + if (PortP->State & RIO_DELETED) { + rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); + rc = -EIO; + } else { + int l; + l = arg ? arg * 100 : 250; + if (l > 255) + l = 255; + if (RIOShortCommand(p, PortP, SBREAK, 2, arg ? arg * 100 : 250) == RIO_FAIL) { + rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); + rc = -EIO; + } + } + break; + case TIOCSSERIAL: + rc = -EFAULT; + if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct))) + rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg); + break; + default: + rc = -ENOIOCTLCMD; + break; + } + func_exit(); + return rc; } @@ -771,37 +704,37 @@ static int rio_ioctl (struct tty_struct * tty, struct file * filp, * flow control scheme is in use for that port. -- Simon Allen */ -static void rio_throttle (struct tty_struct * tty) +static void rio_throttle(struct tty_struct *tty) { - struct Port *port = (struct Port *)tty->driver_data; - - func_enter(); - /* If the port is using any type of input flow - * control then throttle the port. - */ - - if((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) ) { - port->State |= RIO_THROTTLE_RX; - } - - func_exit(); + struct Port *port = (struct Port *) tty->driver_data; + + func_enter(); + /* If the port is using any type of input flow + * control then throttle the port. + */ + + if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty))) { + port->State |= RIO_THROTTLE_RX; + } + + func_exit(); } -static void rio_unthrottle (struct tty_struct * tty) +static void rio_unthrottle(struct tty_struct *tty) { - struct Port *port = (struct Port *)tty->driver_data; + struct Port *port = (struct Port *) tty->driver_data; - func_enter(); - /* Always unthrottle even if flow control is not enabled on - * this port in case we disabled flow control while the port - * was throttled - */ + func_enter(); + /* Always unthrottle even if flow control is not enabled on + * this port in case we disabled flow control while the port + * was throttled + */ - port->State &= ~RIO_THROTTLE_RX; + port->State &= ~RIO_THROTTLE_RX; - func_exit(); - return; + func_exit(); + return; } @@ -813,35 +746,34 @@ static void rio_unthrottle (struct tty_struct * tty) * ********************************************************************** */ -static struct vpd_prom *get_VPD_PROM (struct Host *hp) +static struct vpd_prom *get_VPD_PROM(struct Host *hp) { - static struct vpd_prom vpdp; - char *p; - int i; + static struct vpd_prom vpdp; + char *p; + int i; + + func_enter(); + rio_dprintk(RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", hp->Caddr + RIO_VPD_ROM); - func_enter(); - rio_dprintk (RIO_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", - hp->Caddr + RIO_VPD_ROM); + p = (char *) &vpdp; + for (i = 0; i < sizeof(struct vpd_prom); i++) + *p++ = readb(hp->Caddr + RIO_VPD_ROM + i * 2); + /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */ - p = (char *) &vpdp; - for (i=0;i< sizeof (struct vpd_prom);i++) - *p++ = readb (hp->Caddr+RIO_VPD_ROM + i*2); - /* read_rio_byte (hp, RIO_VPD_ROM + i*2); */ + /* Terminate the identifier string. + *** requires one extra byte in struct vpd_prom *** */ + *p++ = 0; - /* Terminate the identifier string. - *** requires one extra byte in struct vpd_prom *** */ - *p++=0; + if (rio_debug & RIO_DEBUG_PROBE) + my_hd((char *) &vpdp, 0x20); - if (rio_debug & RIO_DEBUG_PROBE) - my_hd ((char *)&vpdp, 0x20); - - func_exit(); + func_exit(); - return &vpdp; + return &vpdp; } static struct tty_operations rio_ops = { - .open = riotopen, + .open = riotopen, .close = gs_close, .write = gs_write, .put_char = gs_put_char, @@ -893,7 +825,7 @@ static int rio_init_drivers(void) rio_driver2->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(rio_driver2, &rio_ops); - rio_dprintk (RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios); + rio_dprintk(RIO_DEBUG_INIT, "set_termios = %p\n", gs_set_termios); if ((error = tty_register_driver(rio_driver))) goto out2; @@ -901,116 +833,111 @@ static int rio_init_drivers(void) goto out3; func_exit(); return 0; -out3: + out3: tty_unregister_driver(rio_driver); -out2: + out2: put_tty_driver(rio_driver2); -out1: + out1: put_tty_driver(rio_driver); -out: - printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", - error); + out: + printk(KERN_ERR "rio: Couldn't register a rio driver, error = %d\n", error); return 1; } -static void * ckmalloc (int size) +static void *ckmalloc(int size) { - void *p; + void *p; - p = kmalloc(size, GFP_KERNEL); - if (p) - memset(p, 0, size); - return p; + p = kmalloc(size, GFP_KERNEL); + if (p) + memset(p, 0, size); + return p; } -static int rio_init_datastructures (void) +static int rio_init_datastructures(void) { - int i; - struct Port *port; - func_enter(); - - /* Many drivers statically allocate the maximum number of ports - There is no reason not to allocate them dynamically. Is there? -- REW */ - /* However, the RIO driver allows users to configure their first - RTA as the ports numbered 504-511. We therefore need to allocate - the whole range. :-( -- REW */ - + int i; + struct Port *port; + func_enter(); + + /* Many drivers statically allocate the maximum number of ports + There is no reason not to allocate them dynamically. Is there? -- REW */ + /* However, the RIO driver allows users to configure their first + RTA as the ports numbered 504-511. We therefore need to allocate + the whole range. :-( -- REW */ + #define RI_SZ sizeof(struct rio_info) #define HOST_SZ sizeof(struct Host) #define PORT_SZ sizeof(struct Port *) #define TMIO_SZ sizeof(struct termios *) - rio_dprintk (RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", - RI_SZ, - RIO_HOSTS * HOST_SZ, - RIO_PORTS * PORT_SZ, - RIO_PORTS * TMIO_SZ, - RIO_PORTS * TMIO_SZ); - - if (!(p = ckmalloc ( RI_SZ))) goto free0; - if (!(p->RIOHosts = ckmalloc (RIO_HOSTS * HOST_SZ))) goto free1; - if (!(p->RIOPortp = ckmalloc (RIO_PORTS * PORT_SZ))) goto free2; - p->RIOConf = RIOConf; - rio_dprintk (RIO_DEBUG_INIT, "Got : %p %p %p\n", - p, p->RIOHosts, p->RIOPortp); + rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); + + if (!(p = ckmalloc(RI_SZ))) + goto free0; + if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ))) + goto free1; + if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ))) + goto free2; + p->RIOConf = RIOConf; + rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); #if 1 - for (i = 0; i < RIO_PORTS; i++) { - port = p->RIOPortp[i] = ckmalloc (sizeof (struct Port)); - if (!port) { - goto free6; - } - rio_dprintk (RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); - port->PortNum = i; - port->gs.magic = RIO_MAGIC; - port->gs.close_delay = HZ/2; - port->gs.closing_wait = 30 * HZ; - port->gs.rd = &rio_real_driver; - spin_lock_init(&port->portSem); - /* - * Initializing wait queue - */ - init_waitqueue_head(&port->gs.open_wait); - init_waitqueue_head(&port->gs.close_wait); - } + for (i = 0; i < RIO_PORTS; i++) { + port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port)); + if (!port) { + goto free6; + } + rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); + port->PortNum = i; + port->gs.magic = RIO_MAGIC; + port->gs.close_delay = HZ / 2; + port->gs.closing_wait = 30 * HZ; + port->gs.rd = &rio_real_driver; + spin_lock_init(&port->portSem); + /* + * Initializing wait queue + */ + init_waitqueue_head(&port->gs.open_wait); + init_waitqueue_head(&port->gs.close_wait); + } #else - /* We could postpone initializing them to when they are configured. */ + /* We could postpone initializing them to when they are configured. */ #endif - - if (rio_debug & RIO_DEBUG_INIT) { - my_hd (&rio_real_driver, sizeof (rio_real_driver)); - } - - func_exit(); - return 0; + if (rio_debug & RIO_DEBUG_INIT) { + my_hd(&rio_real_driver, sizeof(rio_real_driver)); + } - free6:for (i--;i>=0;i--) - kfree (p->RIOPortp[i]); + + func_exit(); + return 0; + + free6:for (i--; i >= 0; i--) + kfree(p->RIOPortp[i]); /*free5: free4: - free3:*/kfree (p->RIOPortp); - free2:kfree (p->RIOHosts); - free1: - rio_dprintk (RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", - p, p->RIOHosts, p->RIOPortp); - kfree(p); - free0: - return -ENOMEM; + free3:*/ kfree(p->RIOPortp); + free2:kfree(p->RIOHosts); + free1: + rio_dprintk(RIO_DEBUG_INIT, "Not enough memory! %p %p %p\n", p, p->RIOHosts, p->RIOPortp); + kfree(p); + free0: + return -ENOMEM; } -static void __exit rio_release_drivers(void) +static void __exit rio_release_drivers(void) { - func_enter(); - tty_unregister_driver(rio_driver2); - tty_unregister_driver(rio_driver); - put_tty_driver(rio_driver2); - put_tty_driver(rio_driver); - func_exit(); + func_enter(); + tty_unregister_driver(rio_driver2); + tty_unregister_driver(rio_driver); + put_tty_driver(rio_driver2); + put_tty_driver(rio_driver); + func_exit(); } @@ -1021,7 +948,7 @@ static void __exit rio_release_drivers(void) There is another bit besides Bit 17. Turning that bit off (on boards shipped with the fix in the eeprom) results in a hang on the next access to the card. - */ + */ /******************************************************** * Setting bit 17 in the CNTRL register of the PLX 9050 * @@ -1034,319 +961,293 @@ static void __exit rio_release_drivers(void) EEprom. As the bit is read/write for the CPU, we can fix it here, if we detect that it isn't set correctly. -- REW */ -static void fix_rio_pci (struct pci_dev *pdev) +static void fix_rio_pci(struct pci_dev *pdev) { - unsigned int hwbase; - unsigned long rebase; - unsigned int t; + unsigned int hwbase; + unsigned long rebase; + unsigned int t; #define CNTRL_REG_OFFSET 0x50 #define CNTRL_REG_GOODVALUE 0x18260000 - pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); - hwbase &= PCI_BASE_ADDRESS_MEM_MASK; - rebase = (ulong) ioremap(hwbase, 0x80); - t = readl (rebase + CNTRL_REG_OFFSET); - if (t != CNTRL_REG_GOODVALUE) { - printk (KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", - t, CNTRL_REG_GOODVALUE); - writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); - } - iounmap((char*) rebase); + pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); + hwbase &= PCI_BASE_ADDRESS_MEM_MASK; + rebase = (ulong) ioremap(hwbase, 0x80); + t = readl(rebase + CNTRL_REG_OFFSET); + if (t != CNTRL_REG_GOODVALUE) { + printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); + writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); + } + iounmap((char *) rebase); } #endif -static int __init rio_init(void) +static int __init rio_init(void) { - int found = 0; - int i; - struct Host *hp; - int retval; - struct vpd_prom *vpdp; - int okboard; + int found = 0; + int i; + struct Host *hp; + int retval; + struct vpd_prom *vpdp; + int okboard; #ifdef CONFIG_PCI - struct pci_dev *pdev = NULL; - unsigned int tint; - unsigned short tshort; + struct pci_dev *pdev = NULL; + unsigned int tint; + unsigned short tshort; #endif - func_enter(); - rio_dprintk (RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", - rio_debug); - - if (abs ((long) (&rio_debug) - rio_debug) < 0x10000) { - printk (KERN_WARNING "rio: rio_debug is an address, instead of a value. " - "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug); - rio_debug=-1; - } - - if (misc_register(&rio_fw_device) < 0) { - printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n"); - return -EIO; - } - - retval = rio_init_datastructures (); - if (retval < 0) { - misc_deregister(&rio_fw_device); - return retval; - } - + func_enter(); + rio_dprintk(RIO_DEBUG_INIT, "Initing rio module... (rio_debug=%d)\n", rio_debug); + + if (abs((long) (&rio_debug) - rio_debug) < 0x10000) { + printk(KERN_WARNING "rio: rio_debug is an address, instead of a value. " "Assuming -1. Was %x/%p.\n", rio_debug, &rio_debug); + rio_debug = -1; + } + + if (misc_register(&rio_fw_device) < 0) { + printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n"); + return -EIO; + } + + retval = rio_init_datastructures(); + if (retval < 0) { + misc_deregister(&rio_fw_device); + return retval; + } #ifdef CONFIG_PCI - /* First look for the JET devices: */ - while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, - PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, - pdev))) { - if (pci_enable_device(pdev)) continue; - - /* Specialix has a whole bunch of cards with - 0x2000 as the device ID. They say its because - the standard requires it. Stupid standard. */ - /* It seems that reading a word doesn't work reliably on 2.0. - Also, reading a non-aligned dword doesn't work. So we read the - whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) - ourselves */ - /* I don't know why the define doesn't work, constant 0x2c does --REW */ - pci_read_config_dword (pdev, 0x2c, &tint); - tshort = (tint >> 16) & 0xffff; - rio_dprintk (RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); - if (tshort != 0x0100) { - rio_dprintk (RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", - tshort); - continue; - } - rio_dprintk (RIO_DEBUG_PROBE, "cp1\n"); - - pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint); - - hp = &p->RIOHosts[p->RIONumHosts]; - hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; - hp->Ivec = pdev->irq; - if (((1 << hp->Ivec) & rio_irqmask) == 0) - hp->Ivec = 0; - hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; - hp->Type = RIO_PCI; - hp->Copy = rio_pcicopy; - hp->Mode = RIO_PCI_BOOT_FROM_RAM; - spin_lock_init(&hp->HostLock); - rio_reset_interrupt (hp); - rio_start_card_running (hp); - - rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", - (void *)p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr); - if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr, - RIO_PCI, 0 ) == RIO_SUCCESS) { - rio_dprintk (RIO_DEBUG_INIT, "Done RIOBoardTest\n"); - WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); - p->RIOHosts[p->RIONumHosts].UniqueNum = - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24); - rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", - p->RIOHosts[p->RIONumHosts].UniqueNum); - - fix_rio_pci (pdev); - p->RIOLastPCISearch = RIO_SUCCESS; - p->RIONumHosts++; - found++; - } else { - iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); - } - } - - /* Then look for the older PCI card.... : */ - - /* These older PCI cards have problems (only byte-mode access is - supported), which makes them a bit awkward to support. - They also have problems sharing interrupts. Be careful. - (The driver now refuses to share interrupts for these - cards. This should be sufficient). - */ - - /* Then look for the older RIO/PCI devices: */ - while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, - PCI_DEVICE_ID_SPECIALIX_RIO, - pdev))) { - if (pci_enable_device(pdev)) continue; + /* First look for the JET devices: */ + while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { + if (pci_enable_device(pdev)) + continue; + + /* Specialix has a whole bunch of cards with + 0x2000 as the device ID. They say its because + the standard requires it. Stupid standard. */ + /* It seems that reading a word doesn't work reliably on 2.0. + Also, reading a non-aligned dword doesn't work. So we read the + whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) + ourselves */ + /* I don't know why the define doesn't work, constant 0x2c does --REW */ + pci_read_config_dword(pdev, 0x2c, &tint); + tshort = (tint >> 16) & 0xffff; + rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); + if (tshort != 0x0100) { + rio_dprintk(RIO_DEBUG_PROBE, "But it's not a RIO card (%d)...\n", tshort); + continue; + } + rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); + + pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint); + + hp = &p->RIOHosts[p->RIONumHosts]; + hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; + hp->Ivec = pdev->irq; + if (((1 << hp->Ivec) & rio_irqmask) == 0) + hp->Ivec = 0; + hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); + hp->CardP = (struct DpRam *) hp->Caddr; + hp->Type = RIO_PCI; + hp->Copy = rio_pcicopy; + hp->Mode = RIO_PCI_BOOT_FROM_RAM; + spin_lock_init(&hp->HostLock); + rio_reset_interrupt(hp); + rio_start_card_running(hp); + + rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); + if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { + rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); + WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); + p->RIOHosts[p->RIONumHosts].UniqueNum = + ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | + ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); + rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); + + fix_rio_pci(pdev); + p->RIOLastPCISearch = RIO_SUCCESS; + p->RIONumHosts++; + found++; + } else { + iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); + } + } + + /* Then look for the older PCI card.... : */ + + /* These older PCI cards have problems (only byte-mode access is + supported), which makes them a bit awkward to support. + They also have problems sharing interrupts. Be careful. + (The driver now refuses to share interrupts for these + cards. This should be sufficient). + */ + + /* Then look for the older RIO/PCI devices: */ + while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_RIO, pdev))) { + if (pci_enable_device(pdev)) + continue; #ifdef CONFIG_RIO_OLDPCI - pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint); - - hp = &p->RIOHosts[p->RIONumHosts]; - hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; - hp->Ivec = pdev->irq; - if (((1 << hp->Ivec) & rio_irqmask) == 0) - hp->Ivec = 0; - hp->Ivec |= 0x8000; /* Mark as non-sharable */ - hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; - hp->Type = RIO_PCI; - hp->Copy = rio_pcicopy; - hp->Mode = RIO_PCI_BOOT_FROM_RAM; - spin_lock_init(&hp->HostLock); - - rio_dprintk (RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec); - rio_dprintk (RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode); - - rio_reset_interrupt (hp); - rio_start_card_running (hp); - rio_dprintk (RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", - (void *)p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr); - if (RIOBoardTest( p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr, - RIO_PCI, 0 ) == RIO_SUCCESS) { - WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); - p->RIOHosts[p->RIONumHosts].UniqueNum = - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) &0xFF)<< 0)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) &0xFF)<< 8)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) &0xFF)<<16)| - ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) &0xFF)<<24); - rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", - p->RIOHosts[p->RIONumHosts].UniqueNum); - - p->RIOLastPCISearch = RIO_SUCCESS; - p->RIONumHosts++; - found++; - } else { - iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); - } + pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint); + + hp = &p->RIOHosts[p->RIONumHosts]; + hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; + hp->Ivec = pdev->irq; + if (((1 << hp->Ivec) & rio_irqmask) == 0) + hp->Ivec = 0; + hp->Ivec |= 0x8000; /* Mark as non-sharable */ + hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); + hp->CardP = (struct DpRam *) hp->Caddr; + hp->Type = RIO_PCI; + hp->Copy = rio_pcicopy; + hp->Mode = RIO_PCI_BOOT_FROM_RAM; + spin_lock_init(&hp->HostLock); + + rio_dprintk(RIO_DEBUG_PROBE, "Ivec: %x\n", hp->Ivec); + rio_dprintk(RIO_DEBUG_PROBE, "Mode: %x\n", hp->Mode); + + rio_reset_interrupt(hp); + rio_start_card_running(hp); + rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); + if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { + WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); + p->RIOHosts[p->RIONumHosts].UniqueNum = + ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | + ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); + rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); + + p->RIOLastPCISearch = RIO_SUCCESS; + p->RIONumHosts++; + found++; + } else { + iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); + } #else - printk (KERN_ERR "Found an older RIO PCI card, but the driver is not " - "compiled to support it.\n"); + printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); #endif - } -#endif /* PCI */ - - /* Now probe for ISA cards... */ - for (i=0;i<NR_RIO_ADDRS;i++) { - hp = &p->RIOHosts[p->RIONumHosts]; - hp->PaddrP = rio_probe_addrs[i]; - /* There was something about the IRQs of these cards. 'Forget what.--REW */ - hp->Ivec = 0; - hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); - hp->CardP = (struct DpRam *) hp->Caddr; - hp->Type = RIO_AT; - hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL - * -- YES! this is now a normal copy. Only the - * old PCI card uses the special PCI copy. - * Moreover, the ISA card will work with the - * special PCI copy anyway. -- REW */ - hp->Mode = 0; - spin_lock_init(&hp->HostLock); - - vpdp = get_VPD_PROM (hp); - rio_dprintk (RIO_DEBUG_PROBE, "Got VPD ROM\n"); - okboard = 0; - 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)) { - /* Board is present... */ - if (RIOBoardTest (hp->PaddrP, - hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { - /* ... and feeling fine!!!! */ - rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", - p->RIOHosts[p->RIONumHosts].UniqueNum); - if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { - rio_dprintk (RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", - p->RIONumHosts, - p->RIOHosts[p->RIONumHosts-1].UniqueNum); - okboard++; - found++; - } - } - - if (!okboard) - iounmap ((char*) (hp->Caddr)); - } - } - - - for (i=0;i<p->RIONumHosts;i++) { - hp = &p->RIOHosts[i]; - if (hp->Ivec) { - int mode = SA_SHIRQ; - if (hp->Ivec & 0x8000) {mode = 0; hp->Ivec &= 0x7fff;} - rio_dprintk (RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp,hp->Ivec, hp->Mode); - retval = request_irq (hp->Ivec, rio_interrupt, mode, "rio", hp); - rio_dprintk (RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval); - if (retval) { - printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec); - hp->Ivec = 0; - } - rio_dprintk (RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec); - if (hp->Ivec != 0){ - rio_dprintk (RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n"); - hp->Mode |= RIO_PCI_INT_ENABLE; - } else - hp->Mode &= !RIO_PCI_INT_ENABLE; - rio_dprintk (RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode); - rio_start_card_running (hp); - } - /* Init the timer "always" to make sure that it can safely be - deleted when we unload... */ - - init_timer (&hp->timer); - if (!hp->Ivec) { - rio_dprintk (RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", - rio_poll); - hp->timer.data = i; - hp->timer.function = rio_pollfunc; - hp->timer.expires = jiffies + rio_poll; - add_timer (&hp->timer); - } - } - - if (found) { - rio_dprintk (RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found); - rio_init_drivers (); - } else { - /* deregister the misc device we created earlier */ - misc_deregister(&rio_fw_device); - } - - func_exit(); - return found?0:-EIO; + } +#endif /* PCI */ + + /* Now probe for ISA cards... */ + for (i = 0; i < NR_RIO_ADDRS; i++) { + hp = &p->RIOHosts[p->RIONumHosts]; + hp->PaddrP = rio_probe_addrs[i]; + /* There was something about the IRQs of these cards. 'Forget what.--REW */ + hp->Ivec = 0; + hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); + hp->CardP = (struct DpRam *) hp->Caddr; + hp->Type = RIO_AT; + hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL + * -- YES! this is now a normal copy. Only the + * old PCI card uses the special PCI copy. + * Moreover, the ISA card will work with the + * special PCI copy anyway. -- REW */ + hp->Mode = 0; + spin_lock_init(&hp->HostLock); + + vpdp = get_VPD_PROM(hp); + rio_dprintk(RIO_DEBUG_PROBE, "Got VPD ROM\n"); + okboard = 0; + 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)) { + /* Board is present... */ + if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { + /* ... and feeling fine!!!! */ + rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); + if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { + rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, host%d uniqid = %x.\n", p->RIONumHosts, p->RIOHosts[p->RIONumHosts - 1].UniqueNum); + okboard++; + found++; + } + } + + if (!okboard) + iounmap((char *) (hp->Caddr)); + } + } + + + for (i = 0; i < p->RIONumHosts; i++) { + hp = &p->RIOHosts[i]; + if (hp->Ivec) { + int mode = SA_SHIRQ; + if (hp->Ivec & 0x8000) { + mode = 0; + hp->Ivec &= 0x7fff; + } + rio_dprintk(RIO_DEBUG_INIT, "Requesting interrupt hp: %p rio_interrupt: %d Mode: %x\n", hp, hp->Ivec, hp->Mode); + retval = request_irq(hp->Ivec, rio_interrupt, mode, "rio", hp); + rio_dprintk(RIO_DEBUG_INIT, "Return value from request_irq: %d\n", retval); + if (retval) { + printk(KERN_ERR "rio: Cannot allocate irq %d.\n", hp->Ivec); + hp->Ivec = 0; + } + rio_dprintk(RIO_DEBUG_INIT, "Got irq %d.\n", hp->Ivec); + if (hp->Ivec != 0) { + rio_dprintk(RIO_DEBUG_INIT, "Enabling interrupts on rio card.\n"); + hp->Mode |= RIO_PCI_INT_ENABLE; + } else + hp->Mode &= !RIO_PCI_INT_ENABLE; + rio_dprintk(RIO_DEBUG_INIT, "New Mode: %x\n", hp->Mode); + rio_start_card_running(hp); + } + /* Init the timer "always" to make sure that it can safely be + deleted when we unload... */ + + init_timer(&hp->timer); + if (!hp->Ivec) { + rio_dprintk(RIO_DEBUG_INIT, "Starting polling at %dj intervals.\n", rio_poll); + hp->timer.data = i; + hp->timer.function = rio_pollfunc; + hp->timer.expires = jiffies + rio_poll; + add_timer(&hp->timer); + } + } + + if (found) { + rio_dprintk(RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found); + rio_init_drivers(); + } else { + /* deregister the misc device we created earlier */ + misc_deregister(&rio_fw_device); + } + + func_exit(); + return found ? 0 : -EIO; } -static void __exit rio_exit (void) +static void __exit rio_exit(void) { - int i; - struct Host *hp; - - func_enter(); + int i; + struct Host *hp; + + func_enter(); - for (i=0,hp=p->RIOHosts;i<p->RIONumHosts;i++, hp++) { - RIOHostReset (hp->Type, hp->CardP, hp->Slot); - if (hp->Ivec) { - free_irq (hp->Ivec, hp); - rio_dprintk (RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec); - } - /* It is safe/allowed to del_timer a non-active timer */ - del_timer (&hp->timer); - } + for (i = 0, hp = p->RIOHosts; i < p->RIONumHosts; i++, hp++) { + RIOHostReset(hp->Type, hp->CardP, hp->Slot); + if (hp->Ivec) { + free_irq(hp->Ivec, hp); + rio_dprintk(RIO_DEBUG_INIT, "freed irq %d.\n", hp->Ivec); + } + /* It is safe/allowed to del_timer a non-active timer */ + del_timer(&hp->timer); + } - if (misc_deregister(&rio_fw_device) < 0) { - printk (KERN_INFO "rio: couldn't deregister control-device\n"); - } + if (misc_deregister(&rio_fw_device) < 0) { + printk(KERN_INFO "rio: couldn't deregister control-device\n"); + } - rio_dprintk (RIO_DEBUG_CLEANUP, "Cleaning up drivers\n"); + rio_dprintk(RIO_DEBUG_CLEANUP, "Cleaning up drivers\n"); - rio_release_drivers (); + rio_release_drivers(); - /* Release dynamically allocated memory */ - kfree (p->RIOPortp); - kfree (p->RIOHosts); - kfree (p); + /* Release dynamically allocated memory */ + kfree(p->RIOPortp); + kfree(p->RIOHosts); + kfree(p); - func_exit(); + func_exit(); } module_init(rio_init); @@ -1372,4 +1273,3 @@ module_exit(rio_exit); * tab-width: 8 * End: */ - |