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) readb(hostdata->io + ((reg) << 2))
20 #define NCR5380_write(reg, value) writeb(value, hostdata->io + ((reg) << 2))
22 #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none
23 #define NCR5380_dma_recv_setup oakscsi_pread
24 #define NCR5380_dma_send_setup oakscsi_pwrite
25 #define NCR5380_dma_residual NCR5380_dma_residual_none
27 #define NCR5380_queue_command oakscsi_queue_command
28 #define NCR5380_info oakscsi_info
30 #define NCR5380_implementation_fields /* none */
32 #include "../NCR5380.h"
34 #undef START_DMA_INITIATOR_RECEIVE_REG
35 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
37 #define STAT ((128 + 16) << 2)
38 #define DATA ((128 + 8) << 2)
40 static inline int oakscsi_pwrite(struct NCR5380_hostdata
*hostdata
,
41 unsigned char *addr
, int len
)
43 u8 __iomem
*base
= hostdata
->io
;
45 printk("writing %p len %d\n",addr
, len
);
50 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
55 static inline int oakscsi_pread(struct NCR5380_hostdata
*hostdata
,
56 unsigned char *addr
, int len
)
58 u8 __iomem
*base
= hostdata
->io
;
60 printk("reading %p len %d\n", addr
, len
);
63 unsigned int status
, timeout
;
68 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
71 if(status
& 0x200 || !timeout
)
73 printk("status = %08X\n", status
);
80 readsw(base
+ DATA
, addr
, 128);
86 b
= (unsigned long) readw(base
+ DATA
);
100 #include "../NCR5380.c"
102 static struct scsi_host_template oakscsi_template
= {
103 .module
= THIS_MODULE
,
104 .name
= "Oak 16-bit SCSI",
105 .info
= oakscsi_info
,
106 .queuecommand
= oakscsi_queue_command
,
107 .eh_abort_handler
= NCR5380_abort
,
108 .eh_bus_reset_handler
= NCR5380_bus_reset
,
111 .sg_tablesize
= SG_ALL
,
113 .use_clustering
= DISABLE_CLUSTERING
,
114 .proc_name
= "oakscsi",
115 .cmd_size
= NCR5380_CMD_SIZE
,
119 static int oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
121 struct Scsi_Host
*host
;
124 ret
= ecard_request_resources(ec
);
128 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
134 priv(host
)->io
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
135 ecard_resource_len(ec
, ECARD_RES_MEMC
));
136 if (!priv(host
)->io
) {
143 ret
= NCR5380_init(host
, FLAG_DMA_FIXUP
| FLAG_LATE_DMA_SETUP
);
147 NCR5380_maybe_reset_bus(host
);
149 ret
= scsi_add_host(host
, &ec
->dev
);
153 scsi_scan_host(host
);
159 iounmap(priv(host
)->io
);
163 ecard_release_resources(ec
);
168 static void oakscsi_remove(struct expansion_card
*ec
)
170 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
171 void __iomem
*base
= priv(host
)->io
;
173 ecard_set_drvdata(ec
, NULL
);
174 scsi_remove_host(host
);
179 ecard_release_resources(ec
);
182 static const struct ecard_id oakscsi_cids
[] = {
183 { MANU_OAK
, PROD_OAK_SCSI
},
187 static struct ecard_driver oakscsi_driver
= {
188 .probe
= oakscsi_probe
,
189 .remove
= oakscsi_remove
,
190 .id_table
= oakscsi_cids
,
196 static int __init
oakscsi_init(void)
198 return ecard_register_driver(&oakscsi_driver
);
201 static void __exit
oakscsi_exit(void)
203 ecard_remove_driver(&oakscsi_driver
);
206 module_init(oakscsi_init
);
207 module_exit(oakscsi_exit
);
209 MODULE_AUTHOR("Russell King");
210 MODULE_DESCRIPTION("Oak SCSI driver");
211 MODULE_LICENSE("GPL");