2019-05-19 20:08:20 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* SCSI low-level driver for the 53c94 SCSI bus adaptor found
|
|
|
|
* on Power Macintosh computers, controlling the external SCSI chain.
|
|
|
|
* We assume the 53c94 is connected to a DBDMA (descriptor-based DMA)
|
|
|
|
* controller.
|
|
|
|
*
|
|
|
|
* Paul Mackerras, August 1996.
|
|
|
|
* Copyright (C) 1996 Paul Mackerras.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/interrupt.h>
|
2011-05-27 21:47:43 +08:00
|
|
|
#include <linux/module.h>
|
2016-02-06 04:58:12 +08:00
|
|
|
#include <linux/pci.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/dbdma.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/macio.h>
|
|
|
|
|
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_cmnd.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
|
|
|
|
#include "mac53c94.h"
|
|
|
|
|
|
|
|
enum fsc_phase {
|
|
|
|
idle,
|
|
|
|
selecting,
|
|
|
|
dataing,
|
|
|
|
completing,
|
|
|
|
busfreeing,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fsc_state {
|
|
|
|
struct mac53c94_regs __iomem *regs;
|
|
|
|
int intr;
|
|
|
|
struct dbdma_regs __iomem *dma;
|
|
|
|
int dmaintr;
|
|
|
|
int clk_freq;
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
struct scsi_cmnd *request_q;
|
|
|
|
struct scsi_cmnd *request_qtail;
|
|
|
|
struct scsi_cmnd *current_req; /* req we're currently working on */
|
|
|
|
enum fsc_phase phase; /* what we're currently trying to do */
|
|
|
|
struct dbdma_cmd *dma_cmds; /* space for dbdma commands, aligned */
|
|
|
|
void *dma_cmd_space;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
struct macio_dev *mdev;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void mac53c94_init(struct fsc_state *);
|
|
|
|
static void mac53c94_start(struct fsc_state *);
|
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 21:55:46 +08:00
|
|
|
static void mac53c94_interrupt(int, void *);
|
|
|
|
static irqreturn_t do_mac53c94_interrupt(int, void *);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void cmd_done(struct fsc_state *, int result);
|
|
|
|
static void set_dma_cmds(struct fsc_state *, struct scsi_cmnd *);
|
|
|
|
|
|
|
|
|
2010-11-16 15:10:29 +08:00
|
|
|
static int mac53c94_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct fsc_state *state;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (cmd->sc_data_direction == DMA_TO_DEVICE) {
|
|
|
|
int i;
|
|
|
|
printk(KERN_DEBUG "mac53c94_queue %p: command is", cmd);
|
|
|
|
for (i = 0; i < cmd->cmd_len; ++i)
|
2009-07-07 04:05:40 +08:00
|
|
|
printk(KERN_CONT " %.2x", cmd->cmnd[i]);
|
|
|
|
printk(KERN_CONT "\n");
|
|
|
|
printk(KERN_DEBUG "use_sg=%d request_bufflen=%d request_buffer=%p\n",
|
2007-05-26 11:46:30 +08:00
|
|
|
scsi_sg_count(cmd), scsi_bufflen(cmd), scsi_sglist(cmd));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cmd->scsi_done = done;
|
|
|
|
cmd->host_scribble = NULL;
|
|
|
|
|
|
|
|
state = (struct fsc_state *) cmd->device->host->hostdata;
|
|
|
|
|
|
|
|
if (state->request_q == NULL)
|
|
|
|
state->request_q = cmd;
|
|
|
|
else
|
|
|
|
state->request_qtail->host_scribble = (void *) cmd;
|
|
|
|
state->request_qtail = cmd;
|
|
|
|
|
|
|
|
if (state->phase == idle)
|
|
|
|
mac53c94_start(state);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-16 15:10:29 +08:00
|
|
|
static DEF_SCSI_QCMD(mac53c94_queue)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int mac53c94_host_reset(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
|
|
|
|
struct mac53c94_regs __iomem *regs = state->regs;
|
|
|
|
struct dbdma_regs __iomem *dma = state->dma;
|
2005-05-28 19:57:14 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(cmd->device->host->host_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
|
|
|
|
writeb(CMD_SCSI_RESET, ®s->command); /* assert RST */
|
|
|
|
udelay(100); /* leave it on for a while (>= 25us) */
|
|
|
|
writeb(CMD_RESET, ®s->command);
|
|
|
|
udelay(20);
|
|
|
|
mac53c94_init(state);
|
|
|
|
writeb(CMD_NOP, ®s->command);
|
2005-05-28 19:57:14 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mac53c94_init(struct fsc_state *state)
|
|
|
|
{
|
|
|
|
struct mac53c94_regs __iomem *regs = state->regs;
|
|
|
|
struct dbdma_regs __iomem *dma = state->dma;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
writeb(state->host->this_id | CF1_PAR_ENABLE, ®s->config1);
|
|
|
|
writeb(TIMO_VAL(250), ®s->sel_timeout); /* 250ms */
|
|
|
|
writeb(CLKF_VAL(state->clk_freq), ®s->clk_factor);
|
|
|
|
writeb(CF2_FEATURE_EN, ®s->config2);
|
|
|
|
writeb(0, ®s->config3);
|
|
|
|
writeb(0, ®s->sync_period);
|
|
|
|
writeb(0, ®s->sync_offset);
|
|
|
|
x = readb(®s->interrupt);
|
|
|
|
writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the next command for a 53C94.
|
|
|
|
* Should be called with interrupts disabled.
|
|
|
|
*/
|
|
|
|
static void mac53c94_start(struct fsc_state *state)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd;
|
|
|
|
struct mac53c94_regs __iomem *regs = state->regs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (state->phase != idle || state->current_req != NULL)
|
|
|
|
panic("inappropriate mac53c94_start (state=%p)", state);
|
|
|
|
if (state->request_q == NULL)
|
|
|
|
return;
|
|
|
|
state->current_req = cmd = state->request_q;
|
|
|
|
state->request_q = (struct scsi_cmnd *) cmd->host_scribble;
|
|
|
|
|
|
|
|
/* Off we go */
|
|
|
|
writeb(0, ®s->count_lo);
|
|
|
|
writeb(0, ®s->count_mid);
|
|
|
|
writeb(0, ®s->count_hi);
|
|
|
|
writeb(CMD_NOP + CMD_DMA_MODE, ®s->command);
|
|
|
|
udelay(1);
|
|
|
|
writeb(CMD_FLUSH, ®s->command);
|
|
|
|
udelay(1);
|
|
|
|
writeb(cmd->device->id, ®s->dest_id);
|
|
|
|
writeb(0, ®s->sync_period);
|
|
|
|
writeb(0, ®s->sync_offset);
|
|
|
|
|
|
|
|
/* load the command into the FIFO */
|
|
|
|
for (i = 0; i < cmd->cmd_len; ++i)
|
|
|
|
writeb(cmd->cmnd[i], ®s->fifo);
|
|
|
|
|
|
|
|
/* do select without ATN XXX */
|
|
|
|
writeb(CMD_SELECT, ®s->command);
|
|
|
|
state->phase = selecting;
|
|
|
|
|
2007-05-26 11:46:30 +08:00
|
|
|
set_dma_cmds(state, cmd);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
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 21:55:46 +08:00
|
|
|
static irqreturn_t do_mac53c94_interrupt(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->device->host;
|
|
|
|
|
|
|
|
spin_lock_irqsave(dev->host_lock, flags);
|
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 21:55:46 +08:00
|
|
|
mac53c94_interrupt(irq, dev_id);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(dev->host_lock, flags);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
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 21:55:46 +08:00
|
|
|
static void mac53c94_interrupt(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct fsc_state *state = (struct fsc_state *) dev_id;
|
|
|
|
struct mac53c94_regs __iomem *regs = state->regs;
|
|
|
|
struct dbdma_regs __iomem *dma = state->dma;
|
|
|
|
struct scsi_cmnd *cmd = state->current_req;
|
|
|
|
int nb, stat, seq, intr;
|
|
|
|
static int mac53c94_errors;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Apparently, reading the interrupt register unlatches
|
|
|
|
* the status and sequence step registers.
|
|
|
|
*/
|
|
|
|
seq = readb(®s->seqstep);
|
|
|
|
stat = readb(®s->status);
|
|
|
|
intr = readb(®s->interrupt);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printk(KERN_DEBUG "mac53c94_intr, intr=%x stat=%x seq=%x phase=%d\n",
|
|
|
|
intr, stat, seq, state->phase);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (intr & INTR_RESET) {
|
|
|
|
/* SCSI bus was reset */
|
|
|
|
printk(KERN_INFO "external SCSI bus reset detected\n");
|
|
|
|
writeb(CMD_NOP, ®s->command);
|
|
|
|
writel(RUN << 16, &dma->control); /* stop dma */
|
|
|
|
cmd_done(state, DID_RESET << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (intr & INTR_ILL_CMD) {
|
|
|
|
printk(KERN_ERR "53c94: invalid cmd, intr=%x stat=%x seq=%x phase=%d\n",
|
|
|
|
intr, stat, seq, state->phase);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stat & STAT_ERROR) {
|
|
|
|
#if 0
|
|
|
|
/* XXX these seem to be harmless? */
|
|
|
|
printk("53c94: bad error, intr=%x stat=%x seq=%x phase=%d\n",
|
|
|
|
intr, stat, seq, state->phase);
|
|
|
|
#endif
|
|
|
|
++mac53c94_errors;
|
|
|
|
writeb(CMD_NOP + CMD_DMA_MODE, ®s->command);
|
|
|
|
}
|
|
|
|
if (cmd == 0) {
|
|
|
|
printk(KERN_DEBUG "53c94: interrupt with no command active?\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stat & STAT_PARITY) {
|
|
|
|
printk(KERN_ERR "mac53c94: parity error\n");
|
|
|
|
cmd_done(state, DID_PARITY << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (state->phase) {
|
|
|
|
case selecting:
|
|
|
|
if (intr & INTR_DISCONNECT) {
|
|
|
|
/* selection timed out */
|
|
|
|
cmd_done(state, DID_BAD_TARGET << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (intr != INTR_BUS_SERV + INTR_DONE) {
|
|
|
|
printk(KERN_DEBUG "got intr %x during selection\n", intr);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((seq & SS_MASK) != SS_DONE) {
|
|
|
|
printk(KERN_DEBUG "seq step %x after command\n", seq);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
writeb(CMD_NOP, ®s->command);
|
|
|
|
/* set DMA controller going if any data to transfer */
|
|
|
|
if ((stat & (STAT_MSG|STAT_CD)) == 0
|
2007-05-26 11:46:30 +08:00
|
|
|
&& (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
|
2005-04-17 06:20:36 +08:00
|
|
|
nb = cmd->SCp.this_residual;
|
|
|
|
if (nb > 0xfff0)
|
|
|
|
nb = 0xfff0;
|
|
|
|
cmd->SCp.this_residual -= nb;
|
|
|
|
writeb(nb, ®s->count_lo);
|
|
|
|
writeb(nb >> 8, ®s->count_mid);
|
|
|
|
writeb(CMD_DMA_MODE + CMD_NOP, ®s->command);
|
|
|
|
writel(virt_to_phys(state->dma_cmds), &dma->cmdptr);
|
|
|
|
writel((RUN << 16) | RUN, &dma->control);
|
|
|
|
writeb(CMD_DMA_MODE + CMD_XFER_DATA, ®s->command);
|
|
|
|
state->phase = dataing;
|
|
|
|
break;
|
|
|
|
} else if ((stat & STAT_PHASE) == STAT_CD + STAT_IO) {
|
|
|
|
/* up to status phase already */
|
|
|
|
writeb(CMD_I_COMPLETE, ®s->command);
|
|
|
|
state->phase = completing;
|
|
|
|
} else {
|
|
|
|
printk(KERN_DEBUG "in unexpected phase %x after cmd\n",
|
|
|
|
stat & STAT_PHASE);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case dataing:
|
|
|
|
if (intr != INTR_BUS_SERV) {
|
|
|
|
printk(KERN_DEBUG "got intr %x before status\n", intr);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cmd->SCp.this_residual != 0
|
|
|
|
&& (stat & (STAT_MSG|STAT_CD)) == 0) {
|
|
|
|
/* Set up the count regs to transfer more */
|
|
|
|
nb = cmd->SCp.this_residual;
|
|
|
|
if (nb > 0xfff0)
|
|
|
|
nb = 0xfff0;
|
|
|
|
cmd->SCp.this_residual -= nb;
|
|
|
|
writeb(nb, ®s->count_lo);
|
|
|
|
writeb(nb >> 8, ®s->count_mid);
|
|
|
|
writeb(CMD_DMA_MODE + CMD_NOP, ®s->command);
|
|
|
|
writeb(CMD_DMA_MODE + CMD_XFER_DATA, ®s->command);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((stat & STAT_PHASE) != STAT_CD + STAT_IO) {
|
|
|
|
printk(KERN_DEBUG "intr %x before data xfer complete\n", intr);
|
|
|
|
}
|
|
|
|
writel(RUN << 16, &dma->control); /* stop dma */
|
2007-05-26 11:46:30 +08:00
|
|
|
scsi_dma_unmap(cmd);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* should check dma status */
|
|
|
|
writeb(CMD_I_COMPLETE, ®s->command);
|
|
|
|
state->phase = completing;
|
|
|
|
break;
|
|
|
|
case completing:
|
|
|
|
if (intr != INTR_DONE) {
|
|
|
|
printk(KERN_DEBUG "got intr %x on completion\n", intr);
|
|
|
|
cmd_done(state, DID_ERROR << 16);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cmd->SCp.Status = readb(®s->fifo);
|
|
|
|
cmd->SCp.Message = readb(®s->fifo);
|
|
|
|
cmd->result = CMD_ACCEPT_MSG;
|
|
|
|
writeb(CMD_ACCEPT_MSG, ®s->command);
|
|
|
|
state->phase = busfreeing;
|
|
|
|
break;
|
|
|
|
case busfreeing:
|
|
|
|
if (intr != INTR_DISCONNECT) {
|
|
|
|
printk(KERN_DEBUG "got intr %x when expected disconnect\n", intr);
|
|
|
|
}
|
|
|
|
cmd_done(state, (DID_OK << 16) + (cmd->SCp.Message << 8)
|
|
|
|
+ cmd->SCp.Status);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_DEBUG "don't know about phase %d\n", state->phase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_done(struct fsc_state *state, int result)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd;
|
|
|
|
|
|
|
|
cmd = state->current_req;
|
|
|
|
if (cmd != 0) {
|
|
|
|
cmd->result = result;
|
|
|
|
(*cmd->scsi_done)(cmd);
|
|
|
|
state->current_req = NULL;
|
|
|
|
}
|
|
|
|
state->phase = idle;
|
|
|
|
mac53c94_start(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up DMA commands for transferring data.
|
|
|
|
*/
|
|
|
|
static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd)
|
|
|
|
{
|
2007-05-26 11:46:30 +08:00
|
|
|
int i, dma_cmd, total, nseg;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct scatterlist *scl;
|
|
|
|
struct dbdma_cmd *dcmds;
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
u32 dma_len;
|
|
|
|
|
2007-05-26 11:46:30 +08:00
|
|
|
nseg = scsi_dma_map(cmd);
|
|
|
|
BUG_ON(nseg < 0);
|
|
|
|
if (!nseg)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
dma_cmd = cmd->sc_data_direction == DMA_TO_DEVICE ?
|
|
|
|
OUTPUT_MORE : INPUT_MORE;
|
|
|
|
dcmds = state->dma_cmds;
|
2007-05-26 11:46:30 +08:00
|
|
|
total = 0;
|
|
|
|
|
|
|
|
scsi_for_each_sg(cmd, scl, nseg, i) {
|
|
|
|
dma_addr = sg_dma_address(scl);
|
|
|
|
dma_len = sg_dma_len(scl);
|
|
|
|
if (dma_len > 0xffff)
|
|
|
|
panic("mac53c94: scatterlist element >= 64k");
|
|
|
|
total += dma_len;
|
2015-02-03 13:36:21 +08:00
|
|
|
dcmds->req_count = cpu_to_le16(dma_len);
|
|
|
|
dcmds->command = cpu_to_le16(dma_cmd);
|
|
|
|
dcmds->phy_addr = cpu_to_le32(dma_addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
dcmds->xfer_status = 0;
|
|
|
|
++dcmds;
|
|
|
|
}
|
2007-05-26 11:46:30 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
dma_cmd += OUTPUT_LAST - OUTPUT_MORE;
|
2015-02-03 13:36:21 +08:00
|
|
|
dcmds[-1].command = cpu_to_le16(dma_cmd);
|
|
|
|
dcmds->command = cpu_to_le16(DBDMA_STOP);
|
2005-04-17 06:20:36 +08:00
|
|
|
cmd->SCp.this_residual = total;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct scsi_host_template mac53c94_template = {
|
|
|
|
.proc_name = "53c94",
|
|
|
|
.name = "53C94",
|
|
|
|
.queuecommand = mac53c94_queue,
|
|
|
|
.eh_host_reset_handler = mac53c94_host_reset,
|
|
|
|
.can_queue = 1,
|
|
|
|
.this_id = 7,
|
|
|
|
.sg_tablesize = SG_ALL,
|
2018-12-13 23:17:08 +08:00
|
|
|
.max_segment_size = 65535,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2005-07-07 03:44:41 +08:00
|
|
|
static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct device_node *node = macio_get_of_node(mdev);
|
|
|
|
struct pci_dev *pdev = macio_get_pci_dev(mdev);
|
|
|
|
struct fsc_state *state;
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
void *dma_cmd_space;
|
2006-07-12 13:40:51 +08:00
|
|
|
const unsigned char *clkprop;
|
2005-12-13 15:01:21 +08:00
|
|
|
int proplen, rc = -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
|
2005-12-13 15:01:21 +08:00
|
|
|
printk(KERN_ERR "mac53c94: expected 2 addrs and intrs"
|
|
|
|
" (got %d/%d)\n",
|
|
|
|
macio_resource_count(mdev), macio_irq_count(mdev));
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (macio_request_resources(mdev, "mac53c94") != 0) {
|
|
|
|
printk(KERN_ERR "mac53c94: unable to request memory resources");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state));
|
|
|
|
if (host == NULL) {
|
|
|
|
printk(KERN_ERR "mac53c94: couldn't register host");
|
2005-12-13 15:01:21 +08:00
|
|
|
rc = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = (struct fsc_state *) host->hostdata;
|
|
|
|
macio_set_drvdata(mdev, state);
|
|
|
|
state->host = host;
|
|
|
|
state->pdev = pdev;
|
|
|
|
state->mdev = mdev;
|
|
|
|
|
|
|
|
state->regs = (struct mac53c94_regs __iomem *)
|
|
|
|
ioremap(macio_resource_start(mdev, 0), 0x1000);
|
|
|
|
state->intr = macio_irq(mdev, 0);
|
|
|
|
state->dma = (struct dbdma_regs __iomem *)
|
|
|
|
ioremap(macio_resource_start(mdev, 1), 0x1000);
|
|
|
|
state->dmaintr = macio_irq(mdev, 1);
|
|
|
|
if (state->regs == NULL || state->dma == NULL) {
|
2017-07-19 05:43:28 +08:00
|
|
|
printk(KERN_ERR "mac53c94: ioremap failed for %pOF\n", node);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
2007-05-01 11:54:02 +08:00
|
|
|
clkprop = of_get_property(node, "clock-frequency", &proplen);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (clkprop == NULL || proplen != sizeof(int)) {
|
2017-07-19 05:43:28 +08:00
|
|
|
printk(KERN_ERR "%pOF: can't get clock frequency, "
|
|
|
|
"assuming 25MHz\n", node);
|
2005-04-17 06:20:36 +08:00
|
|
|
state->clk_freq = 25000000;
|
|
|
|
} else
|
|
|
|
state->clk_freq = *(int *)clkprop;
|
|
|
|
|
|
|
|
/* Space for dma command list: +1 for stop command,
|
|
|
|
* +1 to allow for aligning.
|
|
|
|
* XXX FIXME: Use DMA consistent routines
|
|
|
|
*/
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 04:55:00 +08:00
|
|
|
dma_cmd_space = kmalloc_array(host->sg_tablesize + 2,
|
|
|
|
sizeof(struct dbdma_cmd),
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dma_cmd_space == 0) {
|
|
|
|
printk(KERN_ERR "mac53c94: couldn't allocate dma "
|
2017-07-19 05:43:28 +08:00
|
|
|
"command space for %pOF\n", node);
|
2005-12-13 15:01:21 +08:00
|
|
|
rc = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space);
|
|
|
|
memset(state->dma_cmds, 0, (host->sg_tablesize + 1)
|
|
|
|
* sizeof(struct dbdma_cmd));
|
|
|
|
state->dma_cmd_space = dma_cmd_space;
|
|
|
|
|
|
|
|
mac53c94_init(state);
|
|
|
|
|
2005-12-13 15:01:21 +08:00
|
|
|
if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94",state)) {
|
2017-07-19 05:43:28 +08:00
|
|
|
printk(KERN_ERR "mac53C94: can't get irq %d for %pOF\n",
|
|
|
|
state->intr, node);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto out_free_dma;
|
|
|
|
}
|
|
|
|
|
2005-12-13 15:01:21 +08:00
|
|
|
rc = scsi_add_host(host, &mdev->ofdev.dev);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_release_irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-12-13 15:01:21 +08:00
|
|
|
scsi_scan_host(host);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
2005-12-13 15:01:21 +08:00
|
|
|
out_release_irq:
|
|
|
|
free_irq(state->intr, state);
|
2005-04-17 06:20:36 +08:00
|
|
|
out_free_dma:
|
|
|
|
kfree(state->dma_cmd_space);
|
|
|
|
out_free:
|
|
|
|
if (state->dma != NULL)
|
|
|
|
iounmap(state->dma);
|
|
|
|
if (state->regs != NULL)
|
|
|
|
iounmap(state->regs);
|
|
|
|
scsi_host_put(host);
|
|
|
|
out_release:
|
|
|
|
macio_release_resources(mdev);
|
|
|
|
|
2005-12-13 15:01:21 +08:00
|
|
|
return rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mac53c94_remove(struct macio_dev *mdev)
|
|
|
|
{
|
|
|
|
struct fsc_state *fp = (struct fsc_state *)macio_get_drvdata(mdev);
|
|
|
|
struct Scsi_Host *host = fp->host;
|
|
|
|
|
|
|
|
scsi_remove_host(host);
|
|
|
|
|
|
|
|
free_irq(fp->intr, fp);
|
|
|
|
|
|
|
|
if (fp->regs)
|
2005-12-06 19:01:14 +08:00
|
|
|
iounmap(fp->regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (fp->dma)
|
2005-12-06 19:01:14 +08:00
|
|
|
iounmap(fp->dma);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(fp->dma_cmd_space);
|
|
|
|
|
|
|
|
scsi_host_put(host);
|
|
|
|
|
|
|
|
macio_release_resources(mdev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 03:44:41 +08:00
|
|
|
static struct of_device_id mac53c94_match[] =
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.name = "53c94",
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
};
|
2005-07-07 03:44:41 +08:00
|
|
|
MODULE_DEVICE_TABLE (of, mac53c94_match);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static struct macio_driver mac53c94_driver =
|
|
|
|
{
|
2010-06-02 15:09:18 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "mac53c94",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.of_match_table = mac53c94_match,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
.probe = mac53c94_probe,
|
|
|
|
.remove = mac53c94_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int __init init_mac53c94(void)
|
|
|
|
{
|
|
|
|
return macio_register_driver(&mac53c94_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_mac53c94(void)
|
|
|
|
{
|
|
|
|
return macio_unregister_driver(&mac53c94_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_mac53c94);
|
|
|
|
module_exit(exit_mac53c94);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("PowerMac 53c94 SCSI driver");
|
|
|
|
MODULE_AUTHOR("Paul Mackerras <paulus@samba.org>");
|
|
|
|
MODULE_LICENSE("GPL");
|