blob: cc46d67b9f6f3ae7859330048998e14760be4b43 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
5
6 Based on the generic NCR5380 driver by Drew Eckhardt et al.
7
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.
12
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.
17
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.
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/*
Adam Buchbinder6070d812009-12-04 15:47:01 -050034 * Definitions for the generic 5380 driver.
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Finn Thainfd9cd672014-11-12 16:12:03 +110037#define DONT_USE_INTR
38
Finn Thain54d8fe42016-01-03 16:05:06 +110039#define NCR5380_read(reg) inb(instance->io_port + reg)
40#define NCR5380_write(reg, value) outb(value, instance->io_port + reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Finn Thainf825e402016-03-23 21:10:15 +110042#define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
Finn Thain6c4b88c2016-03-23 21:10:17 +110043#define NCR5380_dma_recv_setup(instance, dst, len) (0)
44#define NCR5380_dma_send_setup(instance, src, len) (0)
Finn Thain8053b0e2016-03-23 21:10:19 +110045#define NCR5380_dma_residual(instance) (0)
Finn Thainf825e402016-03-23 21:10:15 +110046
Finn Thainacfc8ca2014-11-12 16:11:48 +110047#define NCR5380_implementation_fields /* none */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include "NCR5380.h"
50#include "NCR5380.c"
51
52#define DMX3191D_DRIVER_NAME "dmx3191d"
53#define DMX3191D_REGION_LEN 8
54
55
56static struct scsi_host_template dmx3191d_driver_template = {
Finn Thainaa2e2cb2016-01-03 16:05:48 +110057 .module = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 .proc_name = DMX3191D_DRIVER_NAME,
59 .name = "Domex DMX3191D",
Finn Thain8c325132014-11-12 16:11:58 +110060 .info = NCR5380_info,
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .queuecommand = NCR5380_queue_command,
62 .eh_abort_handler = NCR5380_abort,
63 .eh_bus_reset_handler = NCR5380_bus_reset,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .can_queue = 32,
65 .this_id = 7,
66 .sg_tablesize = SG_ALL,
67 .cmd_per_lun = 2,
68 .use_clustering = DISABLE_CLUSTERING,
Finn Thain32b26a12016-01-03 16:05:58 +110069 .cmd_size = NCR5380_CMD_SIZE,
Finn Thain0a4e3612016-01-03 16:06:07 +110070 .max_sectors = 128,
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
Greg Kroah-Hartman6f039792012-12-21 13:08:55 -080073static int dmx3191d_probe_one(struct pci_dev *pdev,
74 const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
76 struct Scsi_Host *shost;
77 unsigned long io;
78 int error = -ENODEV;
79
80 if (pci_enable_device(pdev))
81 goto out;
82
83 io = pci_resource_start(pdev, 0);
84 if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
85 printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
86 io, io + DMX3191D_REGION_LEN);
87 goto out_disable_device;
88 }
89
90 shost = scsi_host_alloc(&dmx3191d_driver_template,
91 sizeof(struct NCR5380_hostdata));
92 if (!shost)
93 goto out_release_region;
94 shost->io_port = io;
Finn Thainfd9cd672014-11-12 16:12:03 +110095
96 /* This card does not seem to raise an interrupt on pdev->irq.
97 * Steam-powered SCSI controllers run without an IRQ anyway.
98 */
99 shost->irq = NO_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Finn Thain7e9ec8d2016-03-23 21:10:11 +1100101 error = NCR5380_init(shost, 0);
Finn Thain0ad0eff2016-01-03 16:05:21 +1100102 if (error)
103 goto out_host_put;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Finn Thainb6488f92016-01-03 16:05:08 +1100105 NCR5380_maybe_reset_bus(shost);
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 pci_set_drvdata(pdev, shost);
108
109 error = scsi_add_host(shost, &pdev->dev);
110 if (error)
Finn Thain0ad0eff2016-01-03 16:05:21 +1100111 goto out_exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113 scsi_scan_host(shost);
114 return 0;
115
Finn Thain0ad0eff2016-01-03 16:05:21 +1100116out_exit:
117 NCR5380_exit(shost);
118out_host_put:
119 scsi_host_put(shost);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 out_release_region:
Adrian Bunkc3c026b2006-03-10 23:24:21 +0100121 release_region(io, DMX3191D_REGION_LEN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 out_disable_device:
123 pci_disable_device(pdev);
124 out:
125 return error;
126}
127
Greg Kroah-Hartman6f039792012-12-21 13:08:55 -0800128static void dmx3191d_remove_one(struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
130 struct Scsi_Host *shost = pci_get_drvdata(pdev);
Finn Thain0ad0eff2016-01-03 16:05:21 +1100131 unsigned long io = shost->io_port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 scsi_remove_host(shost);
134
135 NCR5380_exit(shost);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 scsi_host_put(shost);
Finn Thain0ad0eff2016-01-03 16:05:21 +1100137 release_region(io, DMX3191D_REGION_LEN);
138 pci_disable_device(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139}
140
141static struct pci_device_id dmx3191d_pci_tbl[] = {
142 {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
143 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
144 { }
145};
146MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
147
148static struct pci_driver dmx3191d_pci_driver = {
149 .name = DMX3191D_DRIVER_NAME,
150 .id_table = dmx3191d_pci_tbl,
151 .probe = dmx3191d_probe_one,
Greg Kroah-Hartman6f039792012-12-21 13:08:55 -0800152 .remove = dmx3191d_remove_one,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153};
154
155static int __init dmx3191d_init(void)
156{
Henrik Kretzschmardcbccbde2006-09-25 16:58:58 -0700157 return pci_register_driver(&dmx3191d_pci_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158}
159
160static void __exit dmx3191d_exit(void)
161{
162 pci_unregister_driver(&dmx3191d_pci_driver);
163}
164
165module_init(dmx3191d_init);
166module_exit(dmx3191d_exit);
167
168MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
169MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
170MODULE_LICENSE("GPL");