2 dmx3191d.c - driver for the Domex DMX3191D SCSI card.
3 Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
4 Portions Copyright (C) 2004 by Christoph Hellwig <hch@lst.de>
6 Based on the generic NCR5380 driver by Drew Eckhardt et al.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/init.h>
24 #include <linux/ioport.h>
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/pci.h>
28 #include <linux/interrupt.h>
31 #include <scsi/scsi_host.h>
34 * Definitions for the generic 5380 driver.
39 #define NCR5380_read(reg) inb(instance->io_port + reg)
40 #define NCR5380_write(reg, value) outb(value, instance->io_port + reg)
42 #define NCR5380_implementation_fields /* none */
47 #define DMX3191D_DRIVER_NAME "dmx3191d"
48 #define DMX3191D_REGION_LEN 8
51 static struct scsi_host_template dmx3191d_driver_template
= {
52 .module
= THIS_MODULE
,
53 .proc_name
= DMX3191D_DRIVER_NAME
,
54 .name
= "Domex DMX3191D",
56 .queuecommand
= NCR5380_queue_command
,
57 .eh_abort_handler
= NCR5380_abort
,
58 .eh_bus_reset_handler
= NCR5380_bus_reset
,
61 .sg_tablesize
= SG_ALL
,
63 .use_clustering
= DISABLE_CLUSTERING
,
64 .cmd_size
= NCR5380_CMD_SIZE
,
68 static int dmx3191d_probe_one(struct pci_dev
*pdev
,
69 const struct pci_device_id
*id
)
71 struct Scsi_Host
*shost
;
75 if (pci_enable_device(pdev
))
78 io
= pci_resource_start(pdev
, 0);
79 if (!request_region(io
, DMX3191D_REGION_LEN
, DMX3191D_DRIVER_NAME
)) {
80 printk(KERN_ERR
"dmx3191: region 0x%lx-0x%lx already reserved\n",
81 io
, io
+ DMX3191D_REGION_LEN
);
82 goto out_disable_device
;
85 shost
= scsi_host_alloc(&dmx3191d_driver_template
,
86 sizeof(struct NCR5380_hostdata
));
88 goto out_release_region
;
91 /* This card does not seem to raise an interrupt on pdev->irq.
92 * Steam-powered SCSI controllers run without an IRQ anyway.
96 error
= NCR5380_init(shost
, FLAG_NO_PSEUDO_DMA
);
100 NCR5380_maybe_reset_bus(shost
);
102 pci_set_drvdata(pdev
, shost
);
104 error
= scsi_add_host(shost
, &pdev
->dev
);
108 scsi_scan_host(shost
);
114 scsi_host_put(shost
);
116 release_region(io
, DMX3191D_REGION_LEN
);
118 pci_disable_device(pdev
);
123 static void dmx3191d_remove_one(struct pci_dev
*pdev
)
125 struct Scsi_Host
*shost
= pci_get_drvdata(pdev
);
126 unsigned long io
= shost
->io_port
;
128 scsi_remove_host(shost
);
131 scsi_host_put(shost
);
132 release_region(io
, DMX3191D_REGION_LEN
);
133 pci_disable_device(pdev
);
136 static struct pci_device_id dmx3191d_pci_tbl
[] = {
137 {PCI_VENDOR_ID_DOMEX
, PCI_DEVICE_ID_DOMEX_DMX3191D
,
138 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 4},
141 MODULE_DEVICE_TABLE(pci
, dmx3191d_pci_tbl
);
143 static struct pci_driver dmx3191d_pci_driver
= {
144 .name
= DMX3191D_DRIVER_NAME
,
145 .id_table
= dmx3191d_pci_tbl
,
146 .probe
= dmx3191d_probe_one
,
147 .remove
= dmx3191d_remove_one
,
150 static int __init
dmx3191d_init(void)
152 return pci_register_driver(&dmx3191d_pci_driver
);
155 static void __exit
dmx3191d_exit(void)
157 pci_unregister_driver(&dmx3191d_pci_driver
);
160 module_init(dmx3191d_init
);
161 module_exit(dmx3191d_exit
);
163 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
164 MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
165 MODULE_LICENSE("GPL");