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>
18 #include <scsi/scsi_host.h>
21 /*#define PSEUDO_DMA*/
23 #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_show_info oakscsi_show_info
35 #define NCR5380_write_info oakscsi_write_info
37 #define NCR5380_implementation_fields \
40 #define BOARD_NORMAL 0
41 #define BOARD_NCR53C400 1
43 #include "../NCR5380.h"
45 #undef START_DMA_INITIATOR_RECEIVE_REG
46 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
48 const char * oakscsi_info (struct Scsi_Host
*spnt
)
53 #define STAT ((128 + 16) << 2)
54 #define DATA ((128 + 8) << 2)
56 static inline int NCR5380_pwrite(struct Scsi_Host
*instance
, unsigned char *addr
,
59 void __iomem
*base
= priv(instance
)->base
;
61 printk("writing %p len %d\n",addr
, len
);
67 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
71 static inline int NCR5380_pread(struct Scsi_Host
*instance
, unsigned char *addr
,
74 void __iomem
*base
= priv(instance
)->base
;
75 printk("reading %p len %d\n", addr
, len
);
78 unsigned int status
, timeout
;
83 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
86 if(status
& 0x200 || !timeout
)
88 printk("status = %08X\n", status
);
95 readsw(base
+ DATA
, addr
, 128);
101 b
= (unsigned long) readw(base
+ DATA
);
115 #include "../NCR5380.c"
117 static struct scsi_host_template oakscsi_template
= {
118 .module
= THIS_MODULE
,
119 .show_info
= oakscsi_show_info
,
120 .write_info
= oakscsi_write_info
,
121 .name
= "Oak 16-bit SCSI",
122 .info
= oakscsi_info
,
123 .queuecommand
= oakscsi_queue_command
,
124 .eh_abort_handler
= NCR5380_abort
,
125 .eh_bus_reset_handler
= NCR5380_bus_reset
,
128 .sg_tablesize
= SG_ALL
,
130 .use_clustering
= DISABLE_CLUSTERING
,
131 .proc_name
= "oakscsi",
134 static int oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
136 struct Scsi_Host
*host
;
139 ret
= ecard_request_resources(ec
);
143 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
149 priv(host
)->base
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
150 ecard_resource_len(ec
, ECARD_RES_MEMC
));
151 if (!priv(host
)->base
) {
156 host
->irq
= IRQ_NONE
;
157 host
->n_io_port
= 255;
159 NCR5380_init(host
, 0);
161 printk("scsi%d: at port 0x%08lx irqs disabled",
162 host
->host_no
, host
->io_port
);
163 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
164 host
->can_queue
, host
->cmd_per_lun
, OAKSCSI_PUBLIC_RELEASE
);
165 printk("\nscsi%d:", host
->host_no
);
166 NCR5380_print_options(host
);
169 ret
= scsi_add_host(host
, &ec
->dev
);
173 scsi_scan_host(host
);
177 iounmap(priv(host
)->base
);
181 ecard_release_resources(ec
);
186 static void oakscsi_remove(struct expansion_card
*ec
)
188 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
190 ecard_set_drvdata(ec
, NULL
);
191 scsi_remove_host(host
);
194 iounmap(priv(host
)->base
);
196 ecard_release_resources(ec
);
199 static const struct ecard_id oakscsi_cids
[] = {
200 { MANU_OAK
, PROD_OAK_SCSI
},
204 static struct ecard_driver oakscsi_driver
= {
205 .probe
= oakscsi_probe
,
206 .remove
= oakscsi_remove
,
207 .id_table
= oakscsi_cids
,
213 static int __init
oakscsi_init(void)
215 return ecard_register_driver(&oakscsi_driver
);
218 static void __exit
oakscsi_exit(void)
220 ecard_remove_driver(&oakscsi_driver
);
223 module_init(oakscsi_init
);
224 module_exit(oakscsi_exit
);
226 MODULE_AUTHOR("Russell King");
227 MODULE_DESCRIPTION("Oak SCSI driver");
228 MODULE_LICENSE("GPL");