2 * Oak Generic NCR5380 driver
4 * Copyright 1995-2002, Russell King
7 #include <linux/module.h>
8 #include <linux/ioport.h>
9 #include <linux/blkdev.h>
10 #include <linux/init.h>
12 #include <asm/ecard.h>
15 #include <scsi/scsi_host.h>
17 #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
19 #define NCR5380_read(reg) \
20 readb(priv(instance)->base + ((reg) << 2))
21 #define NCR5380_write(reg, value) \
22 writeb(value, priv(instance)->base + ((reg) << 2))
24 #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
25 #define NCR5380_dma_recv_setup oakscsi_pread
26 #define NCR5380_dma_send_setup oakscsi_pwrite
27 #define NCR5380_dma_residual(instance) (0)
29 #define NCR5380_queue_command oakscsi_queue_command
30 #define NCR5380_info oakscsi_info
32 #define NCR5380_implementation_fields \
35 #include "../NCR5380.h"
37 #undef START_DMA_INITIATOR_RECEIVE_REG
38 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
40 #define STAT ((128 + 16) << 2)
41 #define DATA ((128 + 8) << 2)
43 static inline int oakscsi_pwrite(struct Scsi_Host
*instance
,
44 unsigned char *addr
, int len
)
46 void __iomem
*base
= priv(instance
)->base
;
48 printk("writing %p len %d\n",addr
, len
);
53 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
58 static inline int oakscsi_pread(struct Scsi_Host
*instance
,
59 unsigned char *addr
, int len
)
61 void __iomem
*base
= priv(instance
)->base
;
62 printk("reading %p len %d\n", addr
, len
);
65 unsigned int status
, timeout
;
70 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
73 if(status
& 0x200 || !timeout
)
75 printk("status = %08X\n", status
);
82 readsw(base
+ DATA
, addr
, 128);
88 b
= (unsigned long) readw(base
+ DATA
);
102 #include "../NCR5380.c"
104 static struct scsi_host_template oakscsi_template
= {
105 .module
= THIS_MODULE
,
106 .name
= "Oak 16-bit SCSI",
107 .info
= oakscsi_info
,
108 .queuecommand
= oakscsi_queue_command
,
109 .eh_abort_handler
= NCR5380_abort
,
110 .eh_bus_reset_handler
= NCR5380_bus_reset
,
113 .sg_tablesize
= SG_ALL
,
115 .use_clustering
= DISABLE_CLUSTERING
,
116 .proc_name
= "oakscsi",
117 .cmd_size
= NCR5380_CMD_SIZE
,
121 static int oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
123 struct Scsi_Host
*host
;
126 ret
= ecard_request_resources(ec
);
130 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
136 priv(host
)->base
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
137 ecard_resource_len(ec
, ECARD_RES_MEMC
));
138 if (!priv(host
)->base
) {
144 host
->n_io_port
= 255;
146 ret
= NCR5380_init(host
, FLAG_DMA_FIXUP
| FLAG_LATE_DMA_SETUP
);
150 NCR5380_maybe_reset_bus(host
);
152 ret
= scsi_add_host(host
, &ec
->dev
);
156 scsi_scan_host(host
);
162 iounmap(priv(host
)->base
);
166 ecard_release_resources(ec
);
171 static void oakscsi_remove(struct expansion_card
*ec
)
173 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
175 ecard_set_drvdata(ec
, NULL
);
176 scsi_remove_host(host
);
179 iounmap(priv(host
)->base
);
181 ecard_release_resources(ec
);
184 static const struct ecard_id oakscsi_cids
[] = {
185 { MANU_OAK
, PROD_OAK_SCSI
},
189 static struct ecard_driver oakscsi_driver
= {
190 .probe
= oakscsi_probe
,
191 .remove
= oakscsi_remove
,
192 .id_table
= oakscsi_cids
,
198 static int __init
oakscsi_init(void)
200 return ecard_register_driver(&oakscsi_driver
);
203 static void __exit
oakscsi_exit(void)
205 ecard_remove_driver(&oakscsi_driver
);
208 module_init(oakscsi_init
);
209 module_exit(oakscsi_exit
);
211 MODULE_AUTHOR("Russell King");
212 MODULE_DESCRIPTION("Oak SCSI driver");
213 MODULE_LICENSE("GPL");