|
From: Kenn H. <ke...@us...> - 2004-08-06 00:01:31
|
Update of /cvsroot/linux-vax/kernel-2.5/drivers/char In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17516/drivers/char Modified Files: dz.c dz.h Log Message: Bring the DZ driver into the driver model. Note that this makes drivers/char/dz.c a vsbus-only driver, so I've removed the MIPS code. (This is OK, since this file no longer exists in Linus' tree.) Index: dz.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/drivers/char/dz.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- dz.h 10 Mar 2004 21:02:15 -0000 1.7 +++ dz.h 6 Aug 2004 00:01:08 -0000 1.8 @@ -187,9 +187,6 @@ static struct dz_serial multi[DZ_NB_PORT]; /* Four serial lines in the DZ chip */ static struct dz_serial *dz_console; -#ifdef CONFIG_VAX -static unsigned char dz_vsbus_rx_int, dz_vsbus_tx_int; -#endif /* * tmp_buf is used as a temporary buffer by serial_write. We need to * lock it in case the copy_from_user blocks while swapping in a page, Index: dz.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/drivers/char/dz.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- dz.c 30 Jul 2004 00:17:16 -0000 1.22 +++ dz.c 6 Aug 2004 00:01:08 -0000 1.23 @@ -25,6 +25,7 @@ #include <linux/module.h> #include <linux/config.h> +#include <linux/device.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/init.h> @@ -37,18 +38,12 @@ #include <linux/interrupt.h> #include <linux/serial.h> #include <linux/serialP.h> + #ifdef CONFIG_SERIO #include <linux/serio.h> #endif /* CONFIG_SERIO */ -#ifdef CONFIG_VAX -#define SERIAL_RX 0xB0 /* FIXME: this is wrong */ -#define SERIAL_TX 0xB1 /* FIXME: this is wrong */ -#define SERIAL SERIAL_RX -#define wbflush() do{}while(0) -#else -#include <asm-mips/wbflush.h> -#include <asm/dec/interrupts.h> /* for definition of SERIAL */ -#endif + +#include <asm/bus/vsbus.h> /* for definition of struct console */ #ifdef CONFIG_SERIAL_CONSOLE @@ -64,16 +59,9 @@ #include <asm/uaccess.h> #include <asm/irq.h> -#ifdef CONFIG_VAX #include <asm/mv.h> #include <asm/vsa.h> #include <asm/dz11.h> -#else -#include <asm/dec/machtype.h> -#include <asm/dec/kn01.h> -#include <asm/dec/kn02.h> -#include <asm/bootinfo.h> -#endif #ifdef DEBUG_DZ #include <linux/ptrace.h> @@ -376,55 +364,35 @@ * ------------------------------------------------------------ */ /* VAX has separate RX/TX interrupts */ -#ifdef CONFIG_VAX + static irqreturn_t dz_interrupt_rx (int irq, void *dev, struct pt_regs *regs) { - struct dz_serial *info; - unsigned short status; - - status = dz_in ((struct dz_serial *)dev, DZ_CSR); /* get the reason why we just got an irq */ - info = lines[LINE(status)]; /* re-arrange info the proper port */ + struct dz_serial *info; + unsigned short status; - if (status & DZ_RDONE) - receive_chars (info); /* the receive function */ + status = dz_in ((struct dz_serial *)dev, DZ_CSR); /* get the reason why we just got an irq */ + info = lines[LINE(status)]; /* re-arrange info the proper port */ - vsbus_clear_int(dz_vsbus_rx_int); + if (status & DZ_RDONE) + receive_chars (info); /* the receive function */ - return IRQ_HANDLED; + return IRQ_HANDLED; } static irqreturn_t dz_interrupt_tx (int irq, void *dev, struct pt_regs *regs) { - struct dz_serial *info; - unsigned short status; - - status = dz_in ((struct dz_serial *)dev, DZ_CSR); /* get the reason why we just got an irq */ - info = lines[LINE(status)]; /* re-arrange info the proper port */ - - if (status & DZ_TRDY) - transmit_chars (info); - - vsbus_clear_int(dz_vsbus_tx_int); - - return IRQ_HANDLED; -} -#else -static void dz_interrupt (int irq, void *dev, struct pt_regs *regs) -{ struct dz_serial *info; unsigned short status; - /* get the reason why we just got an irq */ - status = dz_in((struct dz_serial *)dev, DZ_CSR); + status = dz_in ((struct dz_serial *)dev, DZ_CSR); /* get the reason why we just got an irq */ info = lines[LINE(status)]; /* re-arrange info the proper port */ - if (status & DZ_RDONE) - receive_chars(info); /* the receive function */ - if (status & DZ_TRDY) transmit_chars (info); + + return IRQ_HANDLED; } -#endif + /* * ------------------------------------------------------------------- * Here ends the DZ interrupt routines. @@ -508,10 +476,6 @@ tmp |= (DZ_RIE | DZ_TIE | DZ_MSE); dz_out (info, DZ_CSR, tmp); -#ifdef CONFIG_VAX - vsbus_enable_int(dz_vsbus_rx_int); - vsbus_enable_int(dz_vsbus_tx_int); -#endif info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; change_speed (info); /* set up the speed */ @@ -899,7 +863,7 @@ tmp.type = info->type; tmp.line = info->line; tmp.port = info->port; - tmp.irq = SERIAL; + tmp.irq = 0; tmp.flags = info->flags; tmp.baud_base = info->baud_base; tmp.close_delay = info->close_delay; @@ -1352,13 +1316,14 @@ .hangup = dz_hangup, }; -int __init dz_init(void) +static int __init dz_probe(struct vsbus_device *vsbus_dev) { int i, flags; + unsigned long base_addr; struct dz_serial *info; -#ifdef CONFIG_VAX - int irq; -#endif + + printk("dz_probe: name = %s, base = 0x%08x, irqindex = %d\n", + vsbus_dev->dev.bus_id, vsbus_dev->phys_base, vsbus_dev->vsbus_irq); serial_driver = alloc_tty_driver(DZ_NB_PORT); if (!serial_driver) @@ -1382,21 +1347,16 @@ if (tty_register_driver(serial_driver)) panic("Couldn't register serial driver\n"); + /* FIXME: check this for NULL */ + base_addr = (unsigned long) ioremap(vsbus_dev->phys_base, 16); + save_flags(flags); cli(); for (i=0; i < DZ_NB_PORT; i++) { info = &multi[i]; lines[i] = info; info->magic = SERIAL_MAGIC; -#ifdef CONFIG_VAX - info->port = (unsigned long) dz11_addr; -#else - if ((mips_machtype == MACH_DS23100) || - (mips_machtype == MACH_DS5100)) - info->port = (unsigned long) KN01_DZ11_BASE; - else - info->port = (unsigned long) KN02_DZ11_BASE; -#endif + info->port = base_addr; info->line = i; info->tty = 0; info->close_delay = 50; @@ -1417,12 +1377,7 @@ if (! info->port) return 0; -#ifdef CONFIG_VAX printk("ttyS%02d at 0x%04x\n", info->line, info->port); -#else - printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line, - info->port, SERIAL); -#endif tty_register_device(serial_driver, info->line, NULL); @@ -1466,7 +1421,6 @@ int tmp; dz_out(info, DZ_CSR, DZ_CLR); while ((tmp = dz_in(info,DZ_CSR)) & DZ_CLR); - wbflush(); /* Enable scanning */ dz_out(info, DZ_CSR, DZ_MSE); @@ -1479,83 +1433,35 @@ */ restore_flags(flags); -#if CONFIG_VAX -#ifndef CONFIG_VAX_4000HC - { - short i; - unsigned char num; - unsigned long irq_mask; - - irq_mask = probe_irq_on(); - vsbus_probe_irq_on(); - i = dz_in(info, DZ_TCR); - dz_out(info, DZ_CSR, DZ_MSE|DZ_TIE); - dz_out(info, DZ_TCR, 0); - mdelay(1); - dz_out(info, DZ_TCR, 1); - mdelay(10); - dz_out(info, DZ_TCR, i); - num=vsbus_probe_irq_report(); - irq=probe_irq_off(irq_mask); - if (num) - { - dz_vsbus_rx_int=num; - dz_vsbus_tx_int=num+1; - } - - irq_mask = probe_irq_on(); - - vsbus_enable_int(num); - - i = dz_in(info, DZ_TCR); - dz_out(info, DZ_CSR, DZ_MSE|DZ_TIE); - dz_out(info, DZ_TCR, 0); - mdelay(1); - dz_out(info, DZ_TCR, 1); - mdelay(10); - dz_out(info, DZ_TCR, i); - vsbus_clear_int(num); - vsbus_disable_int(num); - irq=probe_irq_off(irq_mask); - } -#else -if (is_ka46()){ - dz_vsbus_tx_int=5; - dz_vsbus_rx_int=4; - irq=149; -} else { - dz_vsbus_tx_int=7; - dz_vsbus_rx_int=6; - irq=177; -} -#endif - printk("dz.c: using irq rx %d, irq tx %d\n", irq-1, irq); + /* The bus-specific IRQ we are handed in the vsbus_dev + * structure is the TX interrupt. The RX is always the + * next one up. + */ + printk("dz.c: using irq rx %d(bus %d), irq tx %d(bus %d)\n", + vsbus_irqindex_to_irq(vsbus_dev->vsbus_irq + 1), + vsbus_dev->vsbus_irq + 1, + vsbus_irqindex_to_irq(vsbus_dev->vsbus_irq), + vsbus_dev->vsbus_irq); - if (request_irq (irq, dz_interrupt_tx, SA_INTERRUPT, "DZ", lines[0])) - panic ("Unable to register DZ TX interrupt\n"); - if (request_irq (irq-1, dz_interrupt_rx, SA_INTERRUPT, "DZ", lines[0])) - panic ("Unable to register DZ RX interrupt\n"); -#else - if (request_irq(SERIAL, dz_interrupt_rx, SA_INTERRUPT, "DZ", lines[0])) - panic("Unable to register DZ interrupt\n"); -#endif - /* enable scanning */ - dz_out(info, DZ_CSR, DZ_MSE); + if (vsbus_request_irq (vsbus_dev->vsbus_irq, dz_interrupt_tx, SA_INTERRUPT, "DZ-TX", lines[0])) + panic ("Unable to register DZ TX interrupt\n"); + if (vsbus_request_irq (vsbus_dev->vsbus_irq + 1, dz_interrupt_rx, SA_INTERRUPT, "DZ-RX", lines[0])) + panic ("Unable to register DZ RX interrupt\n"); + + /* enable scanning */ + dz_out(info, DZ_CSR, DZ_MSE); return 0; } #ifdef CONFIG_SERIAL_CONSOLE -__initcall(dz_init); static void dz_console_put_char (unsigned char ch) { unsigned long flags; int loops = 2500; unsigned short tmp = ch; -#ifdef CONFIG_VAX unsigned short tcr, mask; -#endif /* * this code sends stuff out to serial device - spinning its wheels and * waiting. @@ -1566,11 +1472,10 @@ save_and_cli(flags); -#ifdef CONFIG_VAX - mask = 1 << dz_console->line; - tcr = dz_in (dz_console, DZ_TCR); /* read the TX flag */ - dz_out(dz_console, DZ_TCR, mask); -#endif + mask = 1 << dz_console->line; + tcr = dz_in (dz_console, DZ_TCR); /* read the TX flag */ + dz_out(dz_console, DZ_TCR, mask); + /* spin our wheels */ while (((dz_in(dz_console, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) ; @@ -1578,12 +1483,11 @@ /* Actually transmit the character. */ dz_out(dz_console, DZ_TDR, tmp); -#ifdef CONFIG_VAX - /* spin our wheels */ - while (((dz_in(dz_console,DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) - ; - dz_out(dz_console, DZ_TCR, tcr); -#endif + /* spin our wheels */ + while (((dz_in(dz_console,DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) + ; + dz_out(dz_console, DZ_TCR, tcr); + restore_flags(flags); } @@ -1676,20 +1580,11 @@ /* TOFIX: force to console line */ dz_console = &multi[CONSOLE_LINE]; -#ifdef CONFIG_VAX dz_console->port = (unsigned long)dz11_addr; -#else - if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100)) - dz_console->port = KN01_DZ11_BASE; - else - dz_console->port = KN02_DZ11_BASE; -#endif dz_console->line = CONSOLE_LINE; /* This line locks up Dave Airlie's VS3100m38 after HALT */ -#ifndef CONFIG_VAX - dz_out(dz_console, DZ_CSR, DZ_CLR); -#endif + /* dz_out(dz_console, DZ_CSR, DZ_CLR); */ while ((tmp = dz_in(dz_console,DZ_CSR)) & DZ_CLR) ; @@ -1715,12 +1610,12 @@ } static struct console dz_sercons = { - .name = "ttyS", - .write = dz_console_print, - .device = dz_console_device, - .setup = dz_console_setup, - .flags = CON_CONSDEV, - .index = CONSOLE_LINE, + .name = "ttyS", + .write = dz_console_print, + .device = dz_console_device, + .setup = dz_console_setup, + .flags = CON_CONSDEV, + .index = CONSOLE_LINE, }; void __init dz_serial_console_init(void) @@ -1730,4 +1625,18 @@ #endif /* ifdef CONFIG_SERIAL_CONSOLE */ +static struct vsbus_driver dz_driver = { + .probe = dz_probe, + .drv = { + .name = "dz", + }, +}; + +static int __init dz_init_new(void) +{ + return vsbus_register_driver(&dz_driver); +} + +module_init(dz_init_new); + MODULE_LICENSE("GPL"); |