1
2 /*
3 dmx3191d.c - midlevel driver for the Domex DMX3191D SCSI card.
4 Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
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 <asm/io.h>
24 #include <asm/system.h>
25 #include <linux/blk.h>
26 #include <linux/init.h>
27 #include <linux/ioport.h>
28 #include <linux/module.h>
29 #include <linux/pci.h>
30 #include <linux/sched.h>
31 #include <linux/signal.h>
32 #include <linux/stat.h>
33 #include <linux/version.h>
34
35 #include "scsi.h"
36 #include "hosts.h"
37 #include "constants.h"
38 #include "sd.h"
39
40 #include "dmx3191d.h"
41
42 /* play with these values to tune up your system performances */
43 /* default setting from g_NCR5380.c */
44 /*
45 #define USLEEP
46 #define USLEEP_POLL 1
47 #define USLEEP_SLEEP 20
48 #define USLEEP_WAITLONG 500
49 */
50
51 #define AUTOSENSE
52 #include "NCR5380.h"
53 #include "NCR5380.c"
54
55
dmx3191d_detect(Scsi_Host_Template * tmpl)56 int __init dmx3191d_detect(Scsi_Host_Template *tmpl) {
57 int boards = 0;
58 struct Scsi_Host *instance = NULL;
59 struct pci_dev *pdev = NULL;
60
61 if (!pci_present()) {
62 printk(KERN_WARNING "dmx3191: PCI support not enabled\n");
63 return 0;
64 }
65
66 tmpl->proc_name = DMX3191D_DRIVER_NAME;
67
68 while ((pdev = pci_find_device(PCI_VENDOR_ID_DOMEX,
69 PCI_DEVICE_ID_DOMEX_DMX3191D, pdev))) {
70
71 unsigned long port;
72 if (pci_enable_device(pdev))
73 continue;
74
75 port = pci_resource_start (pdev, 0);
76
77 if (!request_region(port, DMX3191D_REGION, DMX3191D_DRIVER_NAME)) {
78 printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
79 port, port + DMX3191D_REGION);
80 continue;
81 }
82
83 instance = scsi_register(tmpl, sizeof(struct NCR5380_hostdata));
84 if(instance == NULL)
85 {
86 release_region(port, DMX3191D_REGION);
87 continue;
88 }
89 scsi_set_pci_device(instance, pdev);
90 instance->io_port = port;
91 instance->irq = pdev->irq;
92 NCR5380_init(instance, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
93
94 if (request_irq(pdev->irq, dmx3191d_do_intr, SA_SHIRQ,
95 DMX3191D_DRIVER_NAME, instance)) {
96 printk(KERN_WARNING "dmx3191: IRQ %d not available - switching to polled mode.\n", pdev->irq);
97 /* Steam powered scsi controllers run without an IRQ
98 anyway */
99 instance->irq = SCSI_IRQ_NONE;
100 }
101
102 boards++;
103 }
104 return boards;
105 }
106
dmx3191d_info(struct Scsi_Host * host)107 const char * dmx3191d_info(struct Scsi_Host *host) {
108 static const char *info ="Domex DMX3191D";
109
110 return info;
111 }
112
dmx3191d_release_resources(struct Scsi_Host * instance)113 int dmx3191d_release_resources(struct Scsi_Host *instance)
114 {
115 release_region(instance->io_port, DMX3191D_REGION);
116 if(instance->irq != SCSI_IRQ_NONE)
117 free_irq(instance->irq, instance);
118
119 return 0;
120 }
121
122 MODULE_LICENSE("GPL");
123
124 static Scsi_Host_Template driver_template = DMX3191D;
125 #include "scsi_module.c"
126
127