Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  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/*
 34 * Definitions for the generic 5380 driver.
 35 */
 36
 37#define DONT_USE_INTR
 
 38
 39#define NCR5380_read(reg)		inb(instance->io_port + reg)
 40#define NCR5380_write(reg, value)	outb(value, instance->io_port + reg)
 
 
 41
 42#define NCR5380_implementation_fields	/* none */
 43
 44#include "NCR5380.h"
 45#include "NCR5380.c"
 46
 47#define DMX3191D_DRIVER_NAME	"dmx3191d"
 48#define DMX3191D_REGION_LEN	8
 49
 50
 51static struct scsi_host_template dmx3191d_driver_template = {
 52	.module			= THIS_MODULE,
 53	.proc_name		= DMX3191D_DRIVER_NAME,
 54	.name			= "Domex DMX3191D",
 55	.info			= NCR5380_info,
 56	.queuecommand		= NCR5380_queue_command,
 57	.eh_abort_handler	= NCR5380_abort,
 58	.eh_bus_reset_handler	= NCR5380_bus_reset,
 59	.can_queue		= 32,
 60	.this_id		= 7,
 61	.sg_tablesize		= SG_ALL,
 62	.cmd_per_lun		= 2,
 63	.use_clustering		= DISABLE_CLUSTERING,
 64	.cmd_size		= NCR5380_CMD_SIZE,
 65	.max_sectors		= 128,
 66};
 67
 68static int dmx3191d_probe_one(struct pci_dev *pdev,
 69			      const struct pci_device_id *id)
 70{
 71	struct Scsi_Host *shost;
 
 72	unsigned long io;
 73	int error = -ENODEV;
 74
 75	if (pci_enable_device(pdev))
 76		goto out;
 77
 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;
 83	}
 84
 85	shost = scsi_host_alloc(&dmx3191d_driver_template,
 86			sizeof(struct NCR5380_hostdata));
 87	if (!shost)
 88		goto out_release_region;       
 89	shost->io_port = io;
 
 
 90
 91	/* This card does not seem to raise an interrupt on pdev->irq.
 92	 * Steam-powered SCSI controllers run without an IRQ anyway.
 93	 */
 94	shost->irq = NO_IRQ;
 95
 96	error = NCR5380_init(shost, FLAG_NO_PSEUDO_DMA);
 97	if (error)
 98		goto out_host_put;
 99
100	NCR5380_maybe_reset_bus(shost);
101
102	pci_set_drvdata(pdev, shost);
103
104	error = scsi_add_host(shost, &pdev->dev);
105	if (error)
106		goto out_exit;
107
108	scsi_scan_host(shost);
109	return 0;
110
111out_exit:
112	NCR5380_exit(shost);
113out_host_put:
114	scsi_host_put(shost);
115 out_release_region:
116	release_region(io, DMX3191D_REGION_LEN);
117 out_disable_device:
118	pci_disable_device(pdev);
119 out:
120	return error;
121}
122
123static void dmx3191d_remove_one(struct pci_dev *pdev)
124{
125	struct Scsi_Host *shost = pci_get_drvdata(pdev);
126	unsigned long io = shost->io_port;
 
127
128	scsi_remove_host(shost);
129
130	NCR5380_exit(shost);
131	scsi_host_put(shost);
132	release_region(io, DMX3191D_REGION_LEN);
133	pci_disable_device(pdev);
134}
135
136static 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},
139	{ }
140};
141MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
142
143static 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,
148};
149
150static int __init dmx3191d_init(void)
151{
152	return pci_register_driver(&dmx3191d_pci_driver);
153}
154
155static void __exit dmx3191d_exit(void)
156{
157	pci_unregister_driver(&dmx3191d_pci_driver);
158}
159
160module_init(dmx3191d_init);
161module_exit(dmx3191d_exit);
162
163MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
164MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
165MODULE_LICENSE("GPL");
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3    dmx3191d.c - driver for the Domex DMX3191D SCSI card.
  4    Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
  5    Portions Copyright (C) 2004 by Christoph Hellwig <hch@lst.de>
  6
  7    Based on the generic NCR5380 driver by Drew Eckhardt et al.
  8
 
 
 
 
 
 
 
 
 
 
 
 
 
  9*/
 10
 11#include <linux/init.h>
 12#include <linux/ioport.h>
 13#include <linux/kernel.h>
 14#include <linux/module.h>
 15#include <linux/pci.h>
 16#include <linux/interrupt.h>
 17#include <asm/io.h>
 18
 19#include <scsi/scsi_host.h>
 20
 21/*
 22 * Definitions for the generic 5380 driver.
 23 */
 24
 25#define NCR5380_read(reg)		inb(hostdata->base + (reg))
 26#define NCR5380_write(reg, value)	outb(value, hostdata->base + (reg))
 27
 28#define NCR5380_dma_xfer_len		NCR5380_dma_xfer_none
 29#define NCR5380_dma_recv_setup		NCR5380_dma_setup_none
 30#define NCR5380_dma_send_setup		NCR5380_dma_setup_none
 31#define NCR5380_dma_residual		NCR5380_dma_residual_none
 32
 33#define NCR5380_implementation_fields	/* none */
 34
 35#include "NCR5380.h"
 36#include "NCR5380.c"
 37
 38#define DMX3191D_DRIVER_NAME	"dmx3191d"
 39#define DMX3191D_REGION_LEN	8
 40
 41
 42static const struct scsi_host_template dmx3191d_driver_template = {
 43	.module			= THIS_MODULE,
 44	.proc_name		= DMX3191D_DRIVER_NAME,
 45	.name			= "Domex DMX3191D",
 46	.info			= NCR5380_info,
 47	.queuecommand		= NCR5380_queue_command,
 48	.eh_abort_handler	= NCR5380_abort,
 49	.eh_host_reset_handler	= NCR5380_host_reset,
 50	.can_queue		= 32,
 51	.this_id		= 7,
 52	.sg_tablesize		= SG_ALL,
 53	.cmd_per_lun		= 2,
 54	.dma_boundary		= PAGE_SIZE - 1,
 55	.cmd_size		= sizeof(struct NCR5380_cmd),
 
 56};
 57
 58static int dmx3191d_probe_one(struct pci_dev *pdev,
 59			      const struct pci_device_id *id)
 60{
 61	struct Scsi_Host *shost;
 62	struct NCR5380_hostdata *hostdata;
 63	unsigned long io;
 64	int error = -ENODEV;
 65
 66	if (pci_enable_device(pdev))
 67		goto out;
 68
 69	io = pci_resource_start(pdev, 0);
 70	if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
 71		printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
 72				io, io + DMX3191D_REGION_LEN);
 73		goto out_disable_device;
 74	}
 75
 76	shost = scsi_host_alloc(&dmx3191d_driver_template,
 77			sizeof(struct NCR5380_hostdata));
 78	if (!shost)
 79		goto out_release_region;       
 80
 81	hostdata = shost_priv(shost);
 82	hostdata->base = io;
 83
 84	/* This card does not seem to raise an interrupt on pdev->irq.
 85	 * Steam-powered SCSI controllers run without an IRQ anyway.
 86	 */
 87	shost->irq = NO_IRQ;
 88
 89	error = NCR5380_init(shost, 0);
 90	if (error)
 91		goto out_host_put;
 92
 93	NCR5380_maybe_reset_bus(shost);
 94
 95	pci_set_drvdata(pdev, shost);
 96
 97	error = scsi_add_host(shost, &pdev->dev);
 98	if (error)
 99		goto out_exit;
100
101	scsi_scan_host(shost);
102	return 0;
103
104out_exit:
105	NCR5380_exit(shost);
106out_host_put:
107	scsi_host_put(shost);
108 out_release_region:
109	release_region(io, DMX3191D_REGION_LEN);
110 out_disable_device:
111	pci_disable_device(pdev);
112 out:
113	return error;
114}
115
116static void dmx3191d_remove_one(struct pci_dev *pdev)
117{
118	struct Scsi_Host *shost = pci_get_drvdata(pdev);
119	struct NCR5380_hostdata *hostdata = shost_priv(shost);
120	unsigned long io = hostdata->base;
121
122	scsi_remove_host(shost);
123
124	NCR5380_exit(shost);
125	scsi_host_put(shost);
126	release_region(io, DMX3191D_REGION_LEN);
127	pci_disable_device(pdev);
128}
129
130static struct pci_device_id dmx3191d_pci_tbl[] = {
131	{PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
132		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
133	{ }
134};
135MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
136
137static struct pci_driver dmx3191d_pci_driver = {
138	.name		= DMX3191D_DRIVER_NAME,
139	.id_table	= dmx3191d_pci_tbl,
140	.probe		= dmx3191d_probe_one,
141	.remove		= dmx3191d_remove_one,
142};
143
144module_pci_driver(dmx3191d_pci_driver);
 
 
 
 
 
 
 
 
 
 
 
145
146MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
147MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
148MODULE_LICENSE("GPL");