2005-04-17 02:20:36 +04:00
|
|
|
/* -*- mode: c; c-basic-offset: 8 -*- */
|
|
|
|
|
|
|
|
/* NCR Quad 720 MCA SCSI Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 by James.Bottomley@HansenPartnership.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mca.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include "scsi.h"
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
|
|
|
|
#include "ncr53c8xx.h"
|
|
|
|
|
|
|
|
#include "NCR_Q720.h"
|
|
|
|
|
|
|
|
static struct ncr_chip q720_chip __initdata = {
|
|
|
|
.revision_id = 0x0f,
|
|
|
|
.burst_max = 3,
|
|
|
|
.offset_max = 8,
|
|
|
|
.nr_divisor = 4,
|
|
|
|
.features = FE_WIDE | FE_DIFF | FE_VARCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_AUTHOR("James Bottomley");
|
|
|
|
MODULE_DESCRIPTION("NCR Quad 720 SCSI Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
#define NCR_Q720_VERSION "0.9"
|
|
|
|
|
|
|
|
/* We needs this helper because we have up to four hosts per struct device */
|
|
|
|
struct NCR_Q720_private {
|
|
|
|
struct device *dev;
|
|
|
|
void __iomem * mem_base;
|
|
|
|
__u32 phys_mem_base;
|
|
|
|
__u32 mem_size;
|
|
|
|
__u8 irq;
|
|
|
|
__u8 siops;
|
|
|
|
__u8 irq_enable;
|
|
|
|
struct Scsi_Host *hosts[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct scsi_host_template NCR_Q720_tpnt = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.proc_name = "NCR_Q720",
|
|
|
|
};
|
|
|
|
|
|
|
|
static irqreturn_t
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 17:55:46 +04:00
|
|
|
NCR_Q720_intr(int irq, void *data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct NCR_Q720_private *p = (struct NCR_Q720_private *)data;
|
|
|
|
__u8 sir = (readb(p->mem_base + 0x0d) & 0xf0) >> 4;
|
|
|
|
__u8 siop;
|
|
|
|
|
|
|
|
sir |= ~p->irq_enable;
|
|
|
|
|
|
|
|
if(sir == 0xff)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
while((siop = ffz(sir)) < p->siops) {
|
|
|
|
sir |= 1<<siop;
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 17:55:46 +04:00
|
|
|
ncr53c8xx_intr(irq, p->hosts[siop]);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
NCR_Q720_probe_one(struct NCR_Q720_private *p, int siop,
|
|
|
|
int irq, int slot, __u32 paddr, void __iomem *vaddr)
|
|
|
|
{
|
|
|
|
struct ncr_device device;
|
|
|
|
__u8 scsi_id;
|
|
|
|
static int unit = 0;
|
|
|
|
__u8 scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1);
|
|
|
|
__u8 differential = readb(vaddr + NCR_Q720_SCSR_OFFSET) & 0x20;
|
|
|
|
__u8 version;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
scsi_id = scsr1 >> 4;
|
|
|
|
/* enable burst length 16 (FIXME: should allow this) */
|
|
|
|
scsr1 |= 0x02;
|
|
|
|
/* force a siop reset */
|
|
|
|
scsr1 |= 0x04;
|
|
|
|
writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1);
|
|
|
|
udelay(10);
|
|
|
|
version = readb(vaddr + 0x18) >> 4;
|
|
|
|
|
|
|
|
memset(&device, 0, sizeof(struct ncr_device));
|
|
|
|
/* Initialise ncr_device structure with items required by ncr_attach. */
|
|
|
|
device.chip = q720_chip;
|
|
|
|
device.chip.revision_id = version;
|
|
|
|
device.host_id = scsi_id;
|
|
|
|
device.dev = p->dev;
|
|
|
|
device.slot.base = paddr;
|
|
|
|
device.slot.base_c = paddr;
|
|
|
|
device.slot.base_v = vaddr;
|
|
|
|
device.slot.irq = irq;
|
|
|
|
device.differential = differential ? 2 : 0;
|
|
|
|
printk("Q720 probe unit %d (siop%d) at 0x%lx, diff = %d, vers = %d\n", unit, siop,
|
|
|
|
(unsigned long)paddr, differential, version);
|
|
|
|
|
|
|
|
p->hosts[siop] = ncr_attach(&NCR_Q720_tpnt, unit++, &device);
|
|
|
|
|
|
|
|
if (!p->hosts[siop])
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
p->irq_enable |= (1<<siop);
|
|
|
|
scsr1 = readb(vaddr + NCR_Q720_SCSR_OFFSET + 1);
|
|
|
|
/* clear the disable interrupt bit */
|
|
|
|
scsr1 &= ~0x01;
|
|
|
|
writeb(scsr1, vaddr + NCR_Q720_SCSR_OFFSET + 1);
|
|
|
|
|
|
|
|
error = scsi_add_host(p->hosts[siop], p->dev);
|
|
|
|
if (error)
|
|
|
|
ncr53c8xx_release(p->hosts[siop]);
|
|
|
|
else
|
|
|
|
scsi_scan_host(p->hosts[siop]);
|
|
|
|
return error;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Detect a Q720 card. Note, because of the setup --- the chips are
|
|
|
|
* essentially connectecd to the MCA bus independently, it is easier
|
|
|
|
* to set them up as two separate host adapters, rather than one
|
|
|
|
* adapter with two channels */
|
|
|
|
static int __init
|
|
|
|
NCR_Q720_probe(struct device *dev)
|
|
|
|
{
|
|
|
|
struct NCR_Q720_private *p;
|
|
|
|
static int banner = 1;
|
|
|
|
struct mca_device *mca_dev = to_mca_device(dev);
|
|
|
|
int slot = mca_dev->slot;
|
|
|
|
int found = 0;
|
|
|
|
int irq, i, siops;
|
|
|
|
__u8 pos2, pos4, asr2, asr9, asr10;
|
|
|
|
__u16 io_base;
|
|
|
|
__u32 base_addr, mem_size;
|
|
|
|
void __iomem *mem_base;
|
|
|
|
|
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing
this transformation:
@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@
x =
- kmalloc
+ kzalloc
(E1,E2)
... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);
@@
expression E1,E2,E3;
@@
- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)
[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 12:49:03 +04:00
|
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pos2 = mca_device_read_pos(mca_dev, 2);
|
|
|
|
/* enable device */
|
|
|
|
pos2 |= NCR_Q720_POS2_BOARD_ENABLE | NCR_Q720_POS2_INTERRUPT_ENABLE;
|
|
|
|
mca_device_write_pos(mca_dev, 2, pos2);
|
|
|
|
|
|
|
|
io_base = (pos2 & NCR_Q720_POS2_IO_MASK) << NCR_Q720_POS2_IO_SHIFT;
|
|
|
|
|
|
|
|
|
|
|
|
if(banner) {
|
|
|
|
printk(KERN_NOTICE "NCR Q720: Driver Version " NCR_Q720_VERSION "\n"
|
|
|
|
"NCR Q720: Copyright (c) 2003 by James.Bottomley@HansenPartnership.com\n"
|
|
|
|
"NCR Q720:\n");
|
|
|
|
banner = 0;
|
|
|
|
}
|
|
|
|
io_base = mca_device_transform_ioport(mca_dev, io_base);
|
|
|
|
|
|
|
|
/* OK, this is phase one of the bootstrap, we now know the
|
|
|
|
* I/O space base address. All the configuration registers
|
|
|
|
* are mapped here (including pos) */
|
|
|
|
|
|
|
|
/* sanity check I/O mapping */
|
|
|
|
i = inb(io_base) | (inb(io_base+1)<<8);
|
|
|
|
if(i != NCR_Q720_MCA_ID) {
|
|
|
|
printk(KERN_ERR "NCR_Q720, adapter failed to I/O map registers correctly at 0x%x(0x%x)\n", io_base, i);
|
|
|
|
kfree(p);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Phase II, find the ram base and memory map the board register */
|
|
|
|
pos4 = inb(io_base + 4);
|
|
|
|
/* enable streaming data */
|
|
|
|
pos4 |= 0x01;
|
|
|
|
outb(pos4, io_base + 4);
|
|
|
|
base_addr = (pos4 & 0x7e) << 20;
|
|
|
|
base_addr += (pos4 & 0x80) << 23;
|
|
|
|
asr10 = inb(io_base + 0x12);
|
|
|
|
base_addr += (asr10 & 0x80) << 24;
|
|
|
|
base_addr += (asr10 & 0x70) << 23;
|
|
|
|
|
|
|
|
/* OK, got the base addr, now we need to find the ram size,
|
|
|
|
* enable and map it */
|
|
|
|
asr9 = inb(io_base + 0x11);
|
|
|
|
i = (asr9 & 0xc0) >> 6;
|
|
|
|
if(i == 0)
|
|
|
|
mem_size = 1024;
|
|
|
|
else
|
|
|
|
mem_size = 1 << (19 + i);
|
|
|
|
|
|
|
|
/* enable the sram mapping */
|
|
|
|
asr9 |= 0x20;
|
|
|
|
|
|
|
|
/* disable the rom mapping */
|
|
|
|
asr9 &= ~0x10;
|
|
|
|
|
|
|
|
outb(asr9, io_base + 0x11);
|
|
|
|
|
|
|
|
if(!request_mem_region(base_addr, mem_size, "NCR_Q720")) {
|
|
|
|
printk(KERN_ERR "NCR_Q720: Failed to claim memory region 0x%lx\n-0x%lx",
|
|
|
|
(unsigned long)base_addr,
|
|
|
|
(unsigned long)(base_addr + mem_size));
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dma_declare_coherent_memory(dev, base_addr, base_addr,
|
|
|
|
mem_size, DMA_MEMORY_MAP)
|
|
|
|
!= DMA_MEMORY_MAP) {
|
|
|
|
printk(KERN_ERR "NCR_Q720: DMA declare memory failed\n");
|
|
|
|
goto out_release_region;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The first 1k of the memory buffer is a memory map of the registers
|
|
|
|
*/
|
|
|
|
mem_base = dma_mark_declared_memory_occupied(dev, base_addr,
|
|
|
|
1024);
|
|
|
|
if (IS_ERR(mem_base)) {
|
|
|
|
printk("NCR_Q720 failed to reserve memory mapped region\n");
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now also enable accesses in asr 2 */
|
|
|
|
asr2 = inb(io_base + 0x0a);
|
|
|
|
|
|
|
|
asr2 |= 0x01;
|
|
|
|
|
|
|
|
outb(asr2, io_base + 0x0a);
|
|
|
|
|
|
|
|
/* get the number of SIOPs (this should be 2 or 4) */
|
|
|
|
siops = ((asr2 & 0xe0) >> 5) + 1;
|
|
|
|
|
|
|
|
/* sanity check mapping (again) */
|
|
|
|
i = readw(mem_base);
|
|
|
|
if(i != NCR_Q720_MCA_ID) {
|
|
|
|
printk(KERN_ERR "NCR_Q720, adapter failed to memory map registers correctly at 0x%lx(0x%x)\n", (unsigned long)base_addr, i);
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq = readb(mem_base + 5) & 0x0f;
|
|
|
|
|
|
|
|
|
|
|
|
/* now do the bus related transforms */
|
|
|
|
irq = mca_device_transform_irq(mca_dev, irq);
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "NCR Q720: found in slot %d irq = %d mem base = 0x%lx siops = %d\n", slot, irq, (unsigned long)base_addr, siops);
|
|
|
|
printk(KERN_NOTICE "NCR Q720: On board ram %dk\n", mem_size/1024);
|
|
|
|
|
|
|
|
p->dev = dev;
|
|
|
|
p->mem_base = mem_base;
|
|
|
|
p->phys_mem_base = base_addr;
|
|
|
|
p->mem_size = mem_size;
|
|
|
|
p->irq = irq;
|
|
|
|
p->siops = siops;
|
|
|
|
|
2006-07-02 06:29:42 +04:00
|
|
|
if (request_irq(irq, NCR_Q720_intr, IRQF_SHARED, "NCR_Q720", p)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_ERR "NCR_Q720: request irq %d failed\n", irq);
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
/* disable all the siop interrupts */
|
|
|
|
for(i = 0; i < siops; i++) {
|
|
|
|
void __iomem *reg_scsr1 = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
|
|
|
|
+ i*NCR_Q720_SIOP_SHIFT + NCR_Q720_SCSR_OFFSET + 1;
|
|
|
|
__u8 scsr1 = readb(reg_scsr1);
|
|
|
|
scsr1 |= 0x01;
|
|
|
|
writeb(scsr1, reg_scsr1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plumb in all 720 chips */
|
|
|
|
for (i = 0; i < siops; i++) {
|
|
|
|
void __iomem *siop_v_base = mem_base + NCR_Q720_CHIP_REGISTER_OFFSET
|
|
|
|
+ i*NCR_Q720_SIOP_SHIFT;
|
|
|
|
__u32 siop_p_base = base_addr + NCR_Q720_CHIP_REGISTER_OFFSET
|
|
|
|
+ i*NCR_Q720_SIOP_SHIFT;
|
|
|
|
__u16 port = io_base + NCR_Q720_CHIP_REGISTER_OFFSET
|
|
|
|
+ i*NCR_Q720_SIOP_SHIFT;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
outb(0xff, port + 0x40);
|
|
|
|
outb(0x07, port + 0x41);
|
|
|
|
if ((err = NCR_Q720_probe_one(p, i, irq, slot,
|
|
|
|
siop_p_base, siop_v_base)) != 0)
|
|
|
|
printk("Q720: SIOP%d: probe failed, error = %d\n",
|
|
|
|
i, err);
|
|
|
|
else
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
kfree(p);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
mca_device_set_claim(mca_dev, 1);
|
|
|
|
mca_device_set_name(mca_dev, "NCR_Q720");
|
|
|
|
dev_set_drvdata(dev, p);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_release:
|
|
|
|
dma_release_declared_memory(dev);
|
|
|
|
out_release_region:
|
|
|
|
release_mem_region(base_addr, mem_size);
|
|
|
|
out_free:
|
|
|
|
kfree(p);
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit
|
|
|
|
NCR_Q720_remove_one(struct Scsi_Host *host)
|
|
|
|
{
|
|
|
|
scsi_remove_host(host);
|
|
|
|
ncr53c8xx_release(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __exit
|
|
|
|
NCR_Q720_remove(struct device *dev)
|
|
|
|
{
|
|
|
|
struct NCR_Q720_private *p = dev_get_drvdata(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < p->siops; i++)
|
|
|
|
if(p->hosts[i])
|
|
|
|
NCR_Q720_remove_one(p->hosts[i]);
|
|
|
|
|
|
|
|
dma_release_declared_memory(dev);
|
|
|
|
release_mem_region(p->phys_mem_base, p->mem_size);
|
|
|
|
free_irq(p->irq, p);
|
|
|
|
kfree(p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static short NCR_Q720_id_table[] = { NCR_Q720_MCA_ID, 0 };
|
|
|
|
|
|
|
|
static struct mca_driver NCR_Q720_driver = {
|
|
|
|
.id_table = NCR_Q720_id_table,
|
|
|
|
.driver = {
|
|
|
|
.name = "NCR_Q720",
|
|
|
|
.bus = &mca_bus_type,
|
|
|
|
.probe = NCR_Q720_probe,
|
|
|
|
.remove = __devexit_p(NCR_Q720_remove),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
NCR_Q720_init(void)
|
|
|
|
{
|
|
|
|
int ret = ncr53c8xx_init();
|
|
|
|
if (!ret)
|
|
|
|
ret = mca_register_driver(&NCR_Q720_driver);
|
|
|
|
if (ret)
|
|
|
|
ncr53c8xx_exit();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit
|
|
|
|
NCR_Q720_exit(void)
|
|
|
|
{
|
|
|
|
mca_unregister_driver(&NCR_Q720_driver);
|
|
|
|
ncr53c8xx_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(NCR_Q720_init);
|
|
|
|
module_exit(NCR_Q720_exit);
|