2005-04-17 05:20:36 +07:00
|
|
|
/* -*- mode: c; c-basic-offset: 8 -*- */
|
|
|
|
|
|
|
|
/* NCR Dual 700 MCA SCSI Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
|
|
|
|
**-----------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
**
|
|
|
|
**-----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Notes:
|
|
|
|
*
|
|
|
|
* Most of the work is done in the chip specific module, 53c700.o
|
|
|
|
*
|
|
|
|
* TODO List:
|
|
|
|
*
|
|
|
|
* 1. Extract the SCSI ID from the voyager CMOS table (necessary to
|
|
|
|
* support multi-host environments.
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
|
|
/* CHANGELOG
|
|
|
|
*
|
|
|
|
* Version 2.2
|
|
|
|
*
|
|
|
|
* Added mca_set_adapter_name().
|
|
|
|
*
|
|
|
|
* Version 2.1
|
|
|
|
*
|
|
|
|
* Modularise the driver into a Board piece (this file) and a chip
|
|
|
|
* piece 53c700.[ch] and 53c700.scr, added module options. You can
|
|
|
|
* now specify the scsi id by the parameters
|
|
|
|
*
|
|
|
|
* NCR_D700=slot:<n> [siop:<n>] id:<n> ....
|
|
|
|
*
|
|
|
|
* They need to be comma separated if compiled into the kernel
|
|
|
|
*
|
|
|
|
* Version 2.0
|
|
|
|
*
|
|
|
|
* Initial implementation of TCQ (Tag Command Queueing). TCQ is full
|
|
|
|
* featured and uses the clock algorithm to keep track of outstanding
|
|
|
|
* tags and guard against individual tag starvation. Also fixed a bug
|
|
|
|
* in all of the 1.x versions where the D700_data_residue() function
|
|
|
|
* was returning results off by 32 bytes (and thus causing the same 32
|
|
|
|
* bytes to be written twice corrupting the data block). It turns out
|
|
|
|
* the 53c700 only has a 6 bit DBC and DFIFO registers not 7 bit ones
|
|
|
|
* like the 53c710 (The 710 is the only data manual still available,
|
|
|
|
* which I'd been using to program the 700).
|
|
|
|
*
|
|
|
|
* Version 1.2
|
|
|
|
*
|
|
|
|
* Much improved message handling engine
|
|
|
|
*
|
|
|
|
* Version 1.1
|
|
|
|
*
|
|
|
|
* Add code to handle selection reasonably correctly. By the time we
|
|
|
|
* get the selection interrupt, we've already responded, but drop off the
|
|
|
|
* bus and hope the selector will go away.
|
|
|
|
*
|
|
|
|
* Version 1.0:
|
|
|
|
*
|
|
|
|
* Initial release. Fully functional except for procfs and tag
|
|
|
|
* command queueing. Has only been tested on cards with 53c700-66
|
|
|
|
* chips and only single ended. Features are
|
|
|
|
*
|
|
|
|
* 1. Synchronous data transfers to offset 8 (limit of 700-66) and
|
|
|
|
* 100ns (10MHz) limit of SCSI-2
|
|
|
|
*
|
|
|
|
* 2. Disconnection and reselection
|
|
|
|
*
|
|
|
|
* Testing:
|
|
|
|
*
|
|
|
|
* I've only really tested this with the 700-66 chip, but have done
|
|
|
|
* soak tests in multi-device environments to verify that
|
|
|
|
* disconnections and reselections are being processed correctly.
|
|
|
|
* */
|
|
|
|
|
|
|
|
#define NCR_D700_VERSION "2.2"
|
|
|
|
|
|
|
|
#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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_spi.h>
|
|
|
|
|
|
|
|
#include "53c700.h"
|
|
|
|
#include "NCR_D700.h"
|
|
|
|
|
|
|
|
static char *NCR_D700; /* command line from insmod */
|
|
|
|
|
|
|
|
MODULE_AUTHOR("James Bottomley");
|
|
|
|
MODULE_DESCRIPTION("NCR Dual700 SCSI Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
module_param(NCR_D700, charp, 0);
|
|
|
|
|
2006-07-12 22:55:39 +07:00
|
|
|
static __u8 __devinitdata id_array[2*(MCA_MAX_SLOT_NR + 1)] =
|
2005-04-17 05:20:36 +07:00
|
|
|
{ [0 ... 2*(MCA_MAX_SLOT_NR + 1)-1] = 7 };
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
#define ARG_SEP ' '
|
|
|
|
#else
|
|
|
|
#define ARG_SEP ','
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
param_setup(char *string)
|
|
|
|
{
|
|
|
|
char *pos = string, *next;
|
|
|
|
int slot = -1, siop = -1;
|
|
|
|
|
|
|
|
while(pos != NULL && (next = strchr(pos, ':')) != NULL) {
|
|
|
|
int val = (int)simple_strtoul(++next, NULL, 0);
|
|
|
|
|
|
|
|
if(!strncmp(pos, "slot:", 5))
|
|
|
|
slot = val;
|
|
|
|
else if(!strncmp(pos, "siop:", 5))
|
|
|
|
siop = val;
|
|
|
|
else if(!strncmp(pos, "id:", 3)) {
|
|
|
|
if(slot == -1) {
|
|
|
|
printk(KERN_WARNING "NCR D700: Must specify slot for id parameter\n");
|
|
|
|
} else if(slot > MCA_MAX_SLOT_NR) {
|
|
|
|
printk(KERN_WARNING "NCR D700: Illegal slot %d for id %d\n", slot, val);
|
|
|
|
} else {
|
|
|
|
if(siop != 0 && siop != 1) {
|
|
|
|
id_array[slot*2] = val;
|
|
|
|
id_array[slot*2 + 1] =val;
|
|
|
|
} else {
|
|
|
|
id_array[slot*2 + siop] = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if((pos = strchr(pos, ARG_SEP)) != NULL)
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Host template. The 53c700 routine NCR_700_detect will
|
|
|
|
* fill in all of the missing routines */
|
|
|
|
static struct scsi_host_template NCR_D700_driver_template = {
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.name = "NCR Dual 700 MCA",
|
|
|
|
.proc_name = "NCR_D700",
|
|
|
|
.this_id = 7,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* We needs this helper because we have two hosts per struct device */
|
|
|
|
struct NCR_D700_private {
|
|
|
|
struct device *dev;
|
|
|
|
struct Scsi_Host *hosts[2];
|
|
|
|
char name[30];
|
|
|
|
char pad;
|
|
|
|
};
|
|
|
|
|
2006-07-12 22:55:39 +07:00
|
|
|
static int __devinit
|
2005-04-17 05:20:36 +07:00
|
|
|
NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq,
|
|
|
|
int slot, u32 region, int differential)
|
|
|
|
{
|
|
|
|
struct NCR_700_Host_Parameters *hostdata;
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
int ret;
|
|
|
|
|
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 15:49:03 +07:00
|
|
|
hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!hostdata) {
|
|
|
|
printk(KERN_ERR "NCR D700: SIOP%d: Failed to allocate host"
|
|
|
|
"data, detatching\n", siop);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!request_region(region, 64, "NCR_D700")) {
|
|
|
|
printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n",
|
|
|
|
region);
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto region_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the three required pieces of hostdata */
|
2005-04-03 16:57:48 +07:00
|
|
|
hostdata->base = ioport_map(region, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
hostdata->differential = (((1<<siop) & differential) != 0);
|
|
|
|
hostdata->clock = NCR_D700_CLOCK_MHZ;
|
2007-01-25 00:31:30 +07:00
|
|
|
hostdata->burst_length = 8;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* and register the siop */
|
|
|
|
host = NCR_700_detect(&NCR_D700_driver_template, hostdata, p->dev);
|
|
|
|
if (!host) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto detect_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->hosts[siop] = host;
|
|
|
|
/* FIXME: read this from SUS */
|
|
|
|
host->this_id = id_array[slot * 2 + siop];
|
|
|
|
host->irq = irq;
|
2005-04-03 16:57:48 +07:00
|
|
|
host->base = region;
|
2005-04-17 05:20:36 +07:00
|
|
|
scsi_scan_host(host);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
detect_failed:
|
2006-03-11 05:24:08 +07:00
|
|
|
release_region(region, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
region_failed:
|
|
|
|
kfree(hostdata);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-05-13 03:29:13 +07:00
|
|
|
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 20:55:46 +07:00
|
|
|
NCR_D700_intr(int irq, void *data)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct NCR_D700_private *p = (struct NCR_D700_private *)data;
|
|
|
|
int i, found = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
if (p->hosts[i] &&
|
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 20:55:46 +07:00
|
|
|
NCR_700_intr(irq, p->hosts[i]) == IRQ_HANDLED)
|
2005-04-17 05:20:36 +07:00
|
|
|
found++;
|
|
|
|
|
|
|
|
return found ? IRQ_HANDLED : IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Detect a D700 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 */
|
2006-07-12 22:55:39 +07:00
|
|
|
static int __devinit
|
2005-04-17 05:20:36 +07:00
|
|
|
NCR_D700_probe(struct device *dev)
|
|
|
|
{
|
|
|
|
struct NCR_D700_private *p;
|
|
|
|
int differential;
|
|
|
|
static int banner = 1;
|
|
|
|
struct mca_device *mca_dev = to_mca_device(dev);
|
|
|
|
int slot = mca_dev->slot;
|
|
|
|
int found = 0;
|
|
|
|
int irq, i;
|
|
|
|
int pos3j, pos3k, pos3a, pos3b, pos4;
|
|
|
|
__u32 base_addr, offset_addr;
|
|
|
|
|
|
|
|
/* enable board interrupt */
|
|
|
|
pos4 = mca_device_read_pos(mca_dev, 4);
|
|
|
|
pos4 |= 0x4;
|
|
|
|
mca_device_write_pos(mca_dev, 4, pos4);
|
|
|
|
|
|
|
|
mca_device_write_pos(mca_dev, 6, 9);
|
|
|
|
pos3j = mca_device_read_pos(mca_dev, 3);
|
|
|
|
mca_device_write_pos(mca_dev, 6, 10);
|
|
|
|
pos3k = mca_device_read_pos(mca_dev, 3);
|
|
|
|
mca_device_write_pos(mca_dev, 6, 0);
|
|
|
|
pos3a = mca_device_read_pos(mca_dev, 3);
|
|
|
|
mca_device_write_pos(mca_dev, 6, 1);
|
|
|
|
pos3b = mca_device_read_pos(mca_dev, 3);
|
|
|
|
|
|
|
|
base_addr = ((pos3j << 8) | pos3k) & 0xfffffff0;
|
|
|
|
offset_addr = ((pos3a << 8) | pos3b) & 0xffffff70;
|
|
|
|
|
|
|
|
irq = (pos4 & 0x3) + 11;
|
|
|
|
if(irq >= 13)
|
|
|
|
irq++;
|
|
|
|
if(banner) {
|
|
|
|
printk(KERN_NOTICE "NCR D700: Driver Version " NCR_D700_VERSION "\n"
|
|
|
|
"NCR D700: Copyright (c) 2001 by James.Bottomley@HansenPartnership.com\n"
|
|
|
|
"NCR D700:\n");
|
|
|
|
banner = 0;
|
|
|
|
}
|
|
|
|
/* now do the bus related transforms */
|
|
|
|
irq = mca_device_transform_irq(mca_dev, irq);
|
|
|
|
base_addr = mca_device_transform_ioport(mca_dev, base_addr);
|
|
|
|
offset_addr = mca_device_transform_ioport(mca_dev, offset_addr);
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "NCR D700: found in slot %d irq = %d I/O base = 0x%x\n", slot, irq, offset_addr);
|
|
|
|
|
|
|
|
/*outb(BOARD_RESET, base_addr);*/
|
|
|
|
|
|
|
|
/* clear any pending interrupts */
|
|
|
|
(void)inb(base_addr + 0x08);
|
|
|
|
/* get modctl, used later for setting diff bits */
|
|
|
|
switch(differential = (inb(base_addr + 0x08) >> 6)) {
|
|
|
|
case 0x00:
|
|
|
|
/* only SIOP1 differential */
|
|
|
|
differential = 0x02;
|
|
|
|
break;
|
|
|
|
case 0x01:
|
|
|
|
/* Both SIOPs differential */
|
|
|
|
differential = 0x03;
|
|
|
|
break;
|
|
|
|
case 0x03:
|
|
|
|
/* No SIOPs differential */
|
|
|
|
differential = 0x00;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "D700: UNEXPECTED DIFFERENTIAL RESULT 0x%02x\n",
|
|
|
|
differential);
|
|
|
|
differential = 0x00;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
[SCSI] kmalloc + memset conversion to kzalloc
In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-08-11 15:13:24 +07:00
|
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
[SCSI] kmalloc + memset conversion to kzalloc
In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-08-11 15:13:24 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
p->dev = dev;
|
2008-12-04 04:41:36 +07:00
|
|
|
snprintf(p->name, sizeof(p->name), "D700(%s)", dev_name(dev));
|
2006-07-02 09:29:42 +07:00
|
|
|
if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_ERR "D700: request_irq failed\n");
|
|
|
|
kfree(p);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
/* plumb in both 700 chips */
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
int err;
|
|
|
|
|
2006-07-12 22:55:39 +07:00
|
|
|
if ((err = NCR_D700_probe_one(p, i, irq, slot,
|
2005-04-17 05:20:36 +07:00
|
|
|
offset_addr + (0x80 * i),
|
|
|
|
differential)) != 0)
|
|
|
|
printk("D700: 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_D700");
|
|
|
|
dev_set_drvdata(dev, p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-12 22:55:39 +07:00
|
|
|
static void __devexit
|
2005-04-17 05:20:36 +07:00
|
|
|
NCR_D700_remove_one(struct Scsi_Host *host)
|
|
|
|
{
|
|
|
|
scsi_remove_host(host);
|
|
|
|
NCR_700_release(host);
|
|
|
|
kfree((struct NCR_700_Host_Parameters *)host->hostdata[0]);
|
|
|
|
free_irq(host->irq, host);
|
|
|
|
release_region(host->base, 64);
|
|
|
|
}
|
|
|
|
|
2006-07-12 22:55:39 +07:00
|
|
|
static int __devexit
|
2005-04-17 05:20:36 +07:00
|
|
|
NCR_D700_remove(struct device *dev)
|
|
|
|
{
|
|
|
|
struct NCR_D700_private *p = dev_get_drvdata(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
NCR_D700_remove_one(p->hosts[i]);
|
|
|
|
|
|
|
|
kfree(p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static short NCR_D700_id_table[] = { NCR_D700_MCA_ID, 0 };
|
|
|
|
|
|
|
|
static struct mca_driver NCR_D700_driver = {
|
|
|
|
.id_table = NCR_D700_id_table,
|
|
|
|
.driver = {
|
|
|
|
.name = "NCR_D700",
|
|
|
|
.bus = &mca_bus_type,
|
|
|
|
.probe = NCR_D700_probe,
|
2006-07-12 22:55:39 +07:00
|
|
|
.remove = __devexit_p(NCR_D700_remove),
|
2005-04-17 05:20:36 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init NCR_D700_init(void)
|
|
|
|
{
|
|
|
|
#ifdef MODULE
|
|
|
|
if (NCR_D700)
|
|
|
|
param_setup(NCR_D700);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return mca_register_driver(&NCR_D700_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit NCR_D700_exit(void)
|
|
|
|
{
|
|
|
|
mca_unregister_driver(&NCR_D700_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(NCR_D700_init);
|
|
|
|
module_exit(NCR_D700_exit);
|
|
|
|
|
|
|
|
__setup("NCR_D700=", param_setup);
|