10 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/string.h>
14 #include <linux/slab.h>
17 #include <linux/stat.h>
20 #include <linux/module.h>
23 #include <asm/pgtable.h>
25 #include <asm/pci-bridge.h>
28 #include <scsi/scsi.h>
61 static void mac53c94_init(
struct fsc_state *);
62 static void mac53c94_start(
struct fsc_state *);
63 static void mac53c94_interrupt(
int,
void *);
64 static irqreturn_t do_mac53c94_interrupt(
int,
void *);
81 scsi_sg_count(cmd), scsi_bufflen(cmd), scsi_sglist(cmd));
97 mac53c94_start(state);
118 mac53c94_init(state);
121 spin_unlock_irqrestore(cmd->device->host->host_lock,
flags);
125 static void mac53c94_init(
struct fsc_state *state)
136 writeb(0, ®s->sync_period);
137 writeb(0, ®s->sync_offset);
146 static void mac53c94_start(
struct fsc_state *state)
153 panic(
"inappropriate mac53c94_start (state=%p)", state);
168 writeb(0, ®s->sync_period);
169 writeb(0, ®s->sync_offset);
179 set_dma_cmds(state, cmd);
188 mac53c94_interrupt(irq, dev_id);
189 spin_unlock_irqrestore(dev->
host_lock, flags);
193 static void mac53c94_interrupt(
int irq,
void *
dev_id)
200 static int mac53c94_errors;
212 intr, stat, seq, state->
phase);
224 printk(
KERN_ERR "53c94: invalid cmd, intr=%x stat=%x seq=%x phase=%d\n",
225 intr, stat, seq, state->
phase);
232 printk(
"53c94: bad error, intr=%x stat=%x seq=%x phase=%d\n",
233 intr, stat, seq, state->
phase);
247 switch (state->
phase) {
267 && (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) {
268 nb = cmd->
SCp.this_residual;
271 cmd->
SCp.this_residual -= nb;
298 if (cmd->
SCp.this_residual != 0
301 nb = cmd->
SCp.this_residual;
304 cmd->
SCp.this_residual -= nb;
333 if (intr != INTR_DISCONNECT) {
355 mac53c94_start(state);
363 int i, dma_cmd, total, nseg;
365 struct dbdma_cmd *dcmds;
375 OUTPUT_MORE : INPUT_MORE;
382 if (dma_len > 0xffff)
383 panic(
"mac53c94: scatterlist element >= 64k");
385 st_le16(&dcmds->req_count, dma_len);
386 st_le16(&dcmds->command, dma_cmd);
387 st_le32(&dcmds->phy_addr, dma_addr);
388 dcmds->xfer_status = 0;
392 dma_cmd += OUTPUT_LAST - OUTPUT_MORE;
393 st_le16(&dcmds[-1].
command, dma_cmd);
394 st_le16(&dcmds->command, DBDMA_STOP);
395 cmd->
SCp.this_residual = total;
399 .proc_name =
"53c94",
401 .queuecommand = mac53c94_queue,
402 .eh_host_reset_handler = mac53c94_host_reset,
410 static int mac53c94_probe(
struct macio_dev *mdev,
const struct of_device_id *
match)
417 const unsigned char *clkprop;
420 if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
423 macio_resource_count(mdev), macio_irq_count(mdev));
439 state = (
struct fsc_state *) host->hostdata;
440 macio_set_drvdata(mdev, state);
446 ioremap(macio_resource_start(mdev, 0), 0x1000);
447 state->
intr = macio_irq(mdev, 0);
449 ioremap(macio_resource_start(mdev, 1), 0x1000);
450 state->
dmaintr = macio_irq(mdev, 1);
458 if (clkprop ==
NULL || proplen !=
sizeof(
int)) {
471 if (dma_cmd_space == 0) {
473 "command space for %s\n", node->
full_name);
477 state->
dma_cmds = (
struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space);
479 *
sizeof(
struct dbdma_cmd));
482 mac53c94_init(state);
484 if (
request_irq(state->
intr, do_mac53c94_interrupt, 0,
"53C94",state)) {
490 rc = scsi_add_host(host, &mdev->ofdev.dev);
492 goto out_release_irq;
513 static int mac53c94_remove(
struct macio_dev *mdev)
545 static struct macio_driver mac53c94_driver =
550 .of_match_table = mac53c94_match,
552 .probe = mac53c94_probe,
553 .remove = mac53c94_remove,
557 static int __init init_mac53c94(
void)
562 static void __exit exit_mac53c94(
void)