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>
19 #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
21 #define NCR5380_read(reg) \
22 readb(priv(instance)->base + ((reg) << 2))
23 #define NCR5380_write(reg, value) \
24 writeb(value, priv(instance)->base + ((reg) << 2))
26 #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
27 #define NCR5380_dma_recv_setup oakscsi_pread
28 #define NCR5380_dma_send_setup oakscsi_pwrite
30 #define NCR5380_queue_command oakscsi_queue_command
31 #define NCR5380_info oakscsi_info
33 #define NCR5380_implementation_fields \
36 #include "../NCR5380.h"
38 #undef START_DMA_INITIATOR_RECEIVE_REG
39 #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
41 #define STAT ((128 + 16) << 2)
42 #define DATA ((128 + 8) << 2)
44 static inline int oakscsi_pwrite(struct Scsi_Host
*instance
,
45 unsigned char *addr
, int len
)
47 void __iomem
*base
= priv(instance
)->base
;
49 printk("writing %p len %d\n",addr
, len
);
54 while (((status
= readw(base
+ STAT
)) & 0x100)==0);
59 static inline int oakscsi_pread(struct Scsi_Host
*instance
,
60 unsigned char *addr
, int len
)
62 void __iomem
*base
= priv(instance
)->base
;
63 printk("reading %p len %d\n", addr
, len
);
66 unsigned int status
, timeout
;
71 while (((status
= readw(base
+ STAT
)) & 0x100)==0)
74 if(status
& 0x200 || !timeout
)
76 printk("status = %08X\n", status
);
83 readsw(base
+ DATA
, addr
, 128);
89 b
= (unsigned long) readw(base
+ DATA
);
103 #include "../NCR5380.c"
105 static struct scsi_host_template oakscsi_template
= {
106 .module
= THIS_MODULE
,
107 .name
= "Oak 16-bit SCSI",
108 .info
= oakscsi_info
,
109 .queuecommand
= oakscsi_queue_command
,
110 .eh_abort_handler
= NCR5380_abort
,
111 .eh_bus_reset_handler
= NCR5380_bus_reset
,
114 .sg_tablesize
= SG_ALL
,
116 .use_clustering
= DISABLE_CLUSTERING
,
117 .proc_name
= "oakscsi",
118 .cmd_size
= NCR5380_CMD_SIZE
,
122 static int oakscsi_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
124 struct Scsi_Host
*host
;
127 ret
= ecard_request_resources(ec
);
131 host
= scsi_host_alloc(&oakscsi_template
, sizeof(struct NCR5380_hostdata
));
137 priv(host
)->base
= ioremap(ecard_resource_start(ec
, ECARD_RES_MEMC
),
138 ecard_resource_len(ec
, ECARD_RES_MEMC
));
139 if (!priv(host
)->base
) {
145 host
->n_io_port
= 255;
147 ret
= NCR5380_init(host
, FLAG_DMA_FIXUP
);
151 NCR5380_maybe_reset_bus(host
);
153 ret
= scsi_add_host(host
, &ec
->dev
);
157 scsi_scan_host(host
);
163 iounmap(priv(host
)->base
);
167 ecard_release_resources(ec
);
172 static void oakscsi_remove(struct expansion_card
*ec
)
174 struct Scsi_Host
*host
= ecard_get_drvdata(ec
);
176 ecard_set_drvdata(ec
, NULL
);
177 scsi_remove_host(host
);
180 iounmap(priv(host
)->base
);
182 ecard_release_resources(ec
);
185 static const struct ecard_id oakscsi_cids
[] = {
186 { MANU_OAK
, PROD_OAK_SCSI
},
190 static struct ecard_driver oakscsi_driver
= {
191 .probe
= oakscsi_probe
,
192 .remove
= oakscsi_remove
,
193 .id_table
= oakscsi_cids
,
199 static int __init
oakscsi_init(void)
201 return ecard_register_driver(&oakscsi_driver
);
204 static void __exit
oakscsi_exit(void)
206 ecard_remove_driver(&oakscsi_driver
);
209 module_init(oakscsi_init
);
210 module_exit(oakscsi_exit
);
212 MODULE_AUTHOR("Russell King");
213 MODULE_DESCRIPTION("Oak SCSI driver");
214 MODULE_LICENSE("GPL");