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
25 #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
26 #define NCR5380_local_declare() void __iomem *_base
27 #define NCR5380_setup(host) _base = priv(host)->base
29 #define NCR5380_read(reg) readb(_base + ((reg) << 2))
30 #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2))
31 #define NCR5380_intr oakscsi_intr
32 #define NCR5380_queue_command oakscsi_queue_command
33 #define NCR5380_proc_info oakscsi_proc_info
35 #define NCR5380_implementation_fields \
38 #define BOARD_NORMAL 0
39 #define BOARD_NCR53C400 1
41 #include "../NCR5380.h"
43 #undef START_DMA_INITIATOR_RECEIVE_REG
44 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
46 const char * oakscsi_info (struct Scsi_Host
*spnt
)
51 #define STAT ((128 + 16) << 2)
52 #define DATA ((128 + 8) << 2)
54 static inline int NCR5380_pwrite(struct Scsi_Host
*instance
, unsigned char *addr
,
57 void __iomem
*base
= priv(instance
)->base
;
59 printk("writing %p len %d\n",addr
, len
);
65 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
69 static inline int NCR5380_pread(struct Scsi_Host
*instance
, unsigned char *addr
,
72 void __iomem
*base
= priv(instance
)->base
;
73 printk("reading %p len %d\n", addr
, len
);
76 unsigned int status
, timeout
;
81 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
84 if(status
& 0x200 || !timeout
)
86 printk("status = %08X\n", status
);
93 readsw(base
+ DATA
, addr
, 128);
99 b
= (unsigned long) readw(base
+ DATA
);
113 #include "../NCR5380.c"
115 static struct scsi_host_template oakscsi_template
= {
116 .module
= THIS_MODULE
,
117 .proc_info
= oakscsi_proc_info
,
118 .name
= "Oak 16-bit SCSI",
119 .info
= oakscsi_info
,
120 .queuecommand
= oakscsi_queue_command
,
121 .eh_abort_handler
= NCR5380_abort
,
122 .eh_bus_reset_handler
= NCR5380_bus_reset
,
125 .sg_tablesize
= SG_ALL
,
127 .use_clustering
= DISABLE_CLUSTERING
,
128 .proc_name
= "oakscsi",
132 oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
134 struct Scsi_Host
*host
;
137 ret
= ecard_request_resources(ec
);
141 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
147 priv(host
)->base
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
148 ecard_resource_len(ec
, ECARD_RES_MEMC
));
149 if (!priv(host
)->base
) {
154 host
->irq
= IRQ_NONE
;
155 host
->n_io_port
= 255;
157 NCR5380_init(host
, 0);
159 printk("scsi%d: at port 0x%08lx irqs disabled",
160 host
->host_no
, host
->io_port
);
161 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
162 host
->can_queue
, host
->cmd_per_lun
, OAKSCSI_PUBLIC_RELEASE
);
163 printk("\nscsi%d:", host
->host_no
);
164 NCR5380_print_options(host
);
167 ret
= scsi_add_host(host
, &ec
->dev
);
171 scsi_scan_host(host
);
175 iounmap(priv(host
)->base
);
179 ecard_release_resources(ec
);
184 static void __devexit
oakscsi_remove(struct expansion_card
*ec
)
186 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
188 ecard_set_drvdata(ec
, NULL
);
189 scsi_remove_host(host
);
192 iounmap(priv(host
)->base
);
194 ecard_release_resources(ec
);
197 static const struct ecard_id oakscsi_cids
[] = {
198 { MANU_OAK
, PROD_OAK_SCSI
},
202 static struct ecard_driver oakscsi_driver
= {
203 .probe
= oakscsi_probe
,
204 .remove
= __devexit_p(oakscsi_remove
),
205 .id_table
= oakscsi_cids
,
211 static int __init
oakscsi_init(void)
213 return ecard_register_driver(&oakscsi_driver
);
216 static void __exit
oakscsi_exit(void)
218 ecard_remove_driver(&oakscsi_driver
);
221 module_init(oakscsi_init
);
222 module_exit(oakscsi_exit
);
224 MODULE_AUTHOR("Russell King");
225 MODULE_DESCRIPTION("Oak SCSI driver");
226 MODULE_LICENSE("GPL");