Blame view

drivers/scsi/dmx3191d.c 3.6 KB
74ba9207e   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
  /*
      dmx3191d.c - driver for the Domex DMX3191D SCSI card.
      Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
      Portions Copyright (C) 2004 by Christoph Hellwig <hch@lst.de>
  
      Based on the generic NCR5380 driver by Drew Eckhardt et al.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
12
13
14
15
16
17
18
19
20
  */
  
  #include <linux/init.h>
  #include <linux/ioport.h>
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/pci.h>
  #include <linux/interrupt.h>
  #include <asm/io.h>
  
  #include <scsi/scsi_host.h>
  
  /*
6070d81eb   Adam Buchbinder   tree-wide: fix mi...
21
   * Definitions for the generic 5380 driver.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23

61e1ce588   Finn Thain   scsi: ncr5380: Us...
24
25
  #define NCR5380_read(reg)		inb(hostdata->base + (reg))
  #define NCR5380_write(reg, value)	outb(value, hostdata->base + (reg))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26

4a98f896b   Finn Thain   scsi: ncr5380: Us...
27
28
29
30
  #define NCR5380_dma_xfer_len		NCR5380_dma_xfer_none
  #define NCR5380_dma_recv_setup		NCR5380_dma_setup_none
  #define NCR5380_dma_send_setup		NCR5380_dma_setup_none
  #define NCR5380_dma_residual		NCR5380_dma_residual_none
f825e40b2   Finn Thain   ncr5380: Remove P...
31

acfc8cad9   Finn Thain   ncr5380: Remove u...
32
  #define NCR5380_implementation_fields	/* none */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
36
37
38
39
40
41
  #include "NCR5380.h"
  #include "NCR5380.c"
  
  #define DMX3191D_DRIVER_NAME	"dmx3191d"
  #define DMX3191D_REGION_LEN	8
  
  
  static struct scsi_host_template dmx3191d_driver_template = {
aa2e2cb1d   Finn Thain   ncr5380: Fix and ...
42
  	.module			= THIS_MODULE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
  	.proc_name		= DMX3191D_DRIVER_NAME,
  	.name			= "Domex DMX3191D",
8c32513bd   Finn Thain   ncr5380: Cleanup ...
45
  	.info			= NCR5380_info,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
  	.queuecommand		= NCR5380_queue_command,
  	.eh_abort_handler	= NCR5380_abort,
12e5fc665   Hannes Reinecke   scsi: NCR5380: Mo...
48
  	.eh_host_reset_handler	= NCR5380_host_reset,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
51
52
  	.can_queue		= 32,
  	.this_id		= 7,
  	.sg_tablesize		= SG_ALL,
  	.cmd_per_lun		= 2,
4af14d113   Christoph Hellwig   scsi: remove the ...
53
  	.dma_boundary		= PAGE_SIZE - 1,
32b26a104   Finn Thain   ncr5380: Use stan...
54
  	.cmd_size		= NCR5380_CMD_SIZE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
  };
6f0397905   Greg Kroah-Hartman   Drivers: scsi: re...
56
57
  static int dmx3191d_probe_one(struct pci_dev *pdev,
  			      const struct pci_device_id *id)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
  {
  	struct Scsi_Host *shost;
820682b1b   Finn Thain   scsi: ncr5380: St...
60
  	struct NCR5380_hostdata *hostdata;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  	unsigned long io;
  	int error = -ENODEV;
  
  	if (pci_enable_device(pdev))
  		goto out;
  
  	io = pci_resource_start(pdev, 0);
  	if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
  		printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved
  ",
  				io, io + DMX3191D_REGION_LEN);
  		goto out_disable_device;
  	}
  
  	shost = scsi_host_alloc(&dmx3191d_driver_template,
  			sizeof(struct NCR5380_hostdata));
  	if (!shost)
  		goto out_release_region;       
820682b1b   Finn Thain   scsi: ncr5380: St...
79
80
81
  
  	hostdata = shost_priv(shost);
  	hostdata->base = io;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82

fd9cd67c3   Finn Thain   dmx3191d: Use NO_IRQ
83
84
85
86
  	/* This card does not seem to raise an interrupt on pdev->irq.
  	 * Steam-powered SCSI controllers run without an IRQ anyway.
  	 */
  	shost->irq = NO_IRQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87

7e9ec8d9c   Finn Thain   ncr5380: Remove F...
88
  	error = NCR5380_init(shost, 0);
0ad0eff98   Finn Thain   ncr5380: Introduc...
89
90
  	if (error)
  		goto out_host_put;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91

b6488f97d   Finn Thain   ncr5380: Split NC...
92
  	NCR5380_maybe_reset_bus(shost);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
94
95
96
  	pci_set_drvdata(pdev, shost);
  
  	error = scsi_add_host(shost, &pdev->dev);
  	if (error)
0ad0eff98   Finn Thain   ncr5380: Introduc...
97
  		goto out_exit;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
100
  
  	scsi_scan_host(shost);
  	return 0;
0ad0eff98   Finn Thain   ncr5380: Introduc...
101
102
103
104
  out_exit:
  	NCR5380_exit(shost);
  out_host_put:
  	scsi_host_put(shost);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
105
   out_release_region:
c3c026ba5   Adrian Bunk   [SCSI] dmx3191d: ...
106
  	release_region(io, DMX3191D_REGION_LEN);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
109
110
111
   out_disable_device:
  	pci_disable_device(pdev);
   out:
  	return error;
  }
6f0397905   Greg Kroah-Hartman   Drivers: scsi: re...
112
  static void dmx3191d_remove_one(struct pci_dev *pdev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
114
  {
  	struct Scsi_Host *shost = pci_get_drvdata(pdev);
820682b1b   Finn Thain   scsi: ncr5380: St...
115
116
  	struct NCR5380_hostdata *hostdata = shost_priv(shost);
  	unsigned long io = hostdata->base;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
117
118
119
120
  
  	scsi_remove_host(shost);
  
  	NCR5380_exit(shost);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
  	scsi_host_put(shost);
0ad0eff98   Finn Thain   ncr5380: Introduc...
122
123
  	release_region(io, DMX3191D_REGION_LEN);
  	pci_disable_device(pdev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
126
127
128
129
130
131
132
133
134
135
136
  }
  
  static struct pci_device_id dmx3191d_pci_tbl[] = {
  	{PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
  		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  	{ }
  };
  MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
  
  static struct pci_driver dmx3191d_pci_driver = {
  	.name		= DMX3191D_DRIVER_NAME,
  	.id_table	= dmx3191d_pci_tbl,
  	.probe		= dmx3191d_probe_one,
6f0397905   Greg Kroah-Hartman   Drivers: scsi: re...
137
  	.remove		= dmx3191d_remove_one,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
  };
5e315016d   Geliang Tang   scsi: dmx3191d: u...
139
  module_pci_driver(dmx3191d_pci_driver);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
  
  MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
  MODULE_LICENSE("GPL");