2 * Oak Generic NCR5380 driver
4 * Copyright 1995-2002, Russell King
7 #include <linux/module.h>
8 #include <linux/signal.h>
9 #include <linux/ioport.h>
10 #include <linux/delay.h>
11 #include <linux/blkdev.h>
12 #include <linux/init.h>
14 #include <asm/ecard.h>
16 #include <asm/system.h>
19 #include <scsi/scsi_host.h>
22 /*#define PSEUDO_DMA*/
24 #define OAKSCSI_PUBLIC_RELEASE 1
26 #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
27 #define NCR5380_local_declare() void __iomem *_base
28 #define NCR5380_setup(host) _base = priv(host)->base
30 #define NCR5380_read(reg) readb(_base + ((reg) << 2))
31 #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2))
32 #define NCR5380_intr oakscsi_intr
33 #define NCR5380_queue_command oakscsi_queue_command
34 #define NCR5380_proc_info oakscsi_proc_info
36 #define NCR5380_implementation_fields \
39 #define BOARD_NORMAL 0
40 #define BOARD_NCR53C400 1
42 #include "../NCR5380.h"
44 #undef START_DMA_INITIATOR_RECEIVE_REG
45 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
47 const char * oakscsi_info (struct Scsi_Host
*spnt
)
52 #define STAT ((128 + 16) << 2)
53 #define DATA ((128 + 8) << 2)
55 static inline int NCR5380_pwrite(struct Scsi_Host
*instance
, unsigned char *addr
,
58 void __iomem
*base
= priv(instance
)->base
;
60 printk("writing %p len %d\n",addr
, len
);
66 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
70 static inline int NCR5380_pread(struct Scsi_Host
*instance
, unsigned char *addr
,
73 void __iomem
*base
= priv(instance
)->base
;
74 printk("reading %p len %d\n", addr
, len
);
77 unsigned int status
, timeout
;
82 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
85 if(status
& 0x200 || !timeout
)
87 printk("status = %08X\n", status
);
94 readsw(base
+ DATA
, addr
, 128);
100 b
= (unsigned long) readw(base
+ DATA
);
114 #include "../NCR5380.c"
116 static struct scsi_host_template oakscsi_template
= {
117 .module
= THIS_MODULE
,
118 .proc_info
= oakscsi_proc_info
,
119 .name
= "Oak 16-bit SCSI",
120 .info
= oakscsi_info
,
121 .queuecommand
= oakscsi_queue_command
,
122 .eh_abort_handler
= NCR5380_abort
,
123 .eh_bus_reset_handler
= NCR5380_bus_reset
,
126 .sg_tablesize
= SG_ALL
,
128 .use_clustering
= DISABLE_CLUSTERING
,
129 .proc_name
= "oakscsi",
133 oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
135 struct Scsi_Host
*host
;
138 ret
= ecard_request_resources(ec
);
142 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
148 priv(host
)->base
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
149 ecard_resource_len(ec
, ECARD_RES_MEMC
));
150 if (!priv(host
)->base
) {
155 host
->irq
= IRQ_NONE
;
156 host
->n_io_port
= 255;
158 NCR5380_init(host
, 0);
160 printk("scsi%d: at port 0x%08lx irqs disabled",
161 host
->host_no
, host
->io_port
);
162 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
163 host
->can_queue
, host
->cmd_per_lun
, OAKSCSI_PUBLIC_RELEASE
);
164 printk("\nscsi%d:", host
->host_no
);
165 NCR5380_print_options(host
);
168 ret
= scsi_add_host(host
, &ec
->dev
);
172 scsi_scan_host(host
);
176 iounmap(priv(host
)->base
);
180 ecard_release_resources(ec
);
185 static void __devexit
oakscsi_remove(struct expansion_card
*ec
)
187 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
189 ecard_set_drvdata(ec
, NULL
);
190 scsi_remove_host(host
);
193 iounmap(priv(host
)->base
);
195 ecard_release_resources(ec
);
198 static const struct ecard_id oakscsi_cids
[] = {
199 { MANU_OAK
, PROD_OAK_SCSI
},
203 static struct ecard_driver oakscsi_driver
= {
204 .probe
= oakscsi_probe
,
205 .remove
= __devexit_p(oakscsi_remove
),
206 .id_table
= oakscsi_cids
,
212 static int __init
oakscsi_init(void)
214 return ecard_register_driver(&oakscsi_driver
);
217 static void __exit
oakscsi_exit(void)
219 ecard_remove_driver(&oakscsi_driver
);
222 module_init(oakscsi_init
);
223 module_exit(oakscsi_exit
);
225 MODULE_AUTHOR("Russell King");
226 MODULE_DESCRIPTION("Oak SCSI driver");
227 MODULE_LICENSE("GPL");