1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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>
29#include <asm/io.h>
30
31#include <scsi/scsi_host.h>
32
33
34
35
36
37#define NCR5380_read(reg) inb(instance->io_port + reg)
38#define NCR5380_write(reg, value) outb(value, instance->io_port + reg)
39
40#define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
41#define NCR5380_dma_recv_setup(instance, dst, len) (0)
42#define NCR5380_dma_send_setup(instance, src, len) (0)
43#define NCR5380_dma_residual(instance) (0)
44
45#define NCR5380_implementation_fields
46
47#include "NCR5380.h"
48#include "NCR5380.c"
49
50#define DMX3191D_DRIVER_NAME "dmx3191d"
51#define DMX3191D_REGION_LEN 8
52
53
54static struct scsi_host_template dmx3191d_driver_template = {
55 .module = THIS_MODULE,
56 .proc_name = DMX3191D_DRIVER_NAME,
57 .name = "Domex DMX3191D",
58 .info = NCR5380_info,
59 .queuecommand = NCR5380_queue_command,
60 .eh_abort_handler = NCR5380_abort,
61 .eh_bus_reset_handler = NCR5380_bus_reset,
62 .can_queue = 32,
63 .this_id = 7,
64 .sg_tablesize = SG_ALL,
65 .cmd_per_lun = 2,
66 .use_clustering = DISABLE_CLUSTERING,
67 .cmd_size = NCR5380_CMD_SIZE,
68};
69
70static int dmx3191d_probe_one(struct pci_dev *pdev,
71 const struct pci_device_id *id)
72{
73 struct Scsi_Host *shost;
74 unsigned long io;
75 int error = -ENODEV;
76
77 if (pci_enable_device(pdev))
78 goto out;
79
80 io = pci_resource_start(pdev, 0);
81 if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
82 printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
83 io, io + DMX3191D_REGION_LEN);
84 goto out_disable_device;
85 }
86
87 shost = scsi_host_alloc(&dmx3191d_driver_template,
88 sizeof(struct NCR5380_hostdata));
89 if (!shost)
90 goto out_release_region;
91 shost->io_port = io;
92
93
94
95
96 shost->irq = NO_IRQ;
97
98 error = NCR5380_init(shost, 0);
99 if (error)
100 goto out_host_put;
101
102 NCR5380_maybe_reset_bus(shost);
103
104 pci_set_drvdata(pdev, shost);
105
106 error = scsi_add_host(shost, &pdev->dev);
107 if (error)
108 goto out_exit;
109
110 scsi_scan_host(shost);
111 return 0;
112
113out_exit:
114 NCR5380_exit(shost);
115out_host_put:
116 scsi_host_put(shost);
117 out_release_region:
118 release_region(io, DMX3191D_REGION_LEN);
119 out_disable_device:
120 pci_disable_device(pdev);
121 out:
122 return error;
123}
124
125static void dmx3191d_remove_one(struct pci_dev *pdev)
126{
127 struct Scsi_Host *shost = pci_get_drvdata(pdev);
128 unsigned long io = shost->io_port;
129
130 scsi_remove_host(shost);
131
132 NCR5380_exit(shost);
133 scsi_host_put(shost);
134 release_region(io, DMX3191D_REGION_LEN);
135 pci_disable_device(pdev);
136}
137
138static struct pci_device_id dmx3191d_pci_tbl[] = {
139 {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
140 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
141 { }
142};
143MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
144
145static struct pci_driver dmx3191d_pci_driver = {
146 .name = DMX3191D_DRIVER_NAME,
147 .id_table = dmx3191d_pci_tbl,
148 .probe = dmx3191d_probe_one,
149 .remove = dmx3191d_remove_one,
150};
151
152static int __init dmx3191d_init(void)
153{
154 return pci_register_driver(&dmx3191d_pci_driver);
155}
156
157static void __exit dmx3191d_exit(void)
158{
159 pci_unregister_driver(&dmx3191d_pci_driver);
160}
161
162module_init(dmx3191d_init);
163module_exit(dmx3191d_exit);
164
165MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
166MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
167MODULE_LICENSE("GPL");
168