0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/init.h>
0012 #include <linux/ioport.h>
0013 #include <linux/kernel.h>
0014 #include <linux/module.h>
0015 #include <linux/pci.h>
0016 #include <linux/interrupt.h>
0017 #include <asm/io.h>
0018
0019 #include <scsi/scsi_host.h>
0020
0021
0022
0023
0024
0025 #define NCR5380_read(reg) inb(hostdata->base + (reg))
0026 #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg))
0027
0028 #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none
0029 #define NCR5380_dma_recv_setup NCR5380_dma_setup_none
0030 #define NCR5380_dma_send_setup NCR5380_dma_setup_none
0031 #define NCR5380_dma_residual NCR5380_dma_residual_none
0032
0033 #define NCR5380_implementation_fields
0034
0035 #include "NCR5380.h"
0036 #include "NCR5380.c"
0037
0038 #define DMX3191D_DRIVER_NAME "dmx3191d"
0039 #define DMX3191D_REGION_LEN 8
0040
0041
0042 static struct scsi_host_template dmx3191d_driver_template = {
0043 .module = THIS_MODULE,
0044 .proc_name = DMX3191D_DRIVER_NAME,
0045 .name = "Domex DMX3191D",
0046 .info = NCR5380_info,
0047 .queuecommand = NCR5380_queue_command,
0048 .eh_abort_handler = NCR5380_abort,
0049 .eh_host_reset_handler = NCR5380_host_reset,
0050 .can_queue = 32,
0051 .this_id = 7,
0052 .sg_tablesize = SG_ALL,
0053 .cmd_per_lun = 2,
0054 .dma_boundary = PAGE_SIZE - 1,
0055 .cmd_size = sizeof(struct NCR5380_cmd),
0056 };
0057
0058 static int dmx3191d_probe_one(struct pci_dev *pdev,
0059 const struct pci_device_id *id)
0060 {
0061 struct Scsi_Host *shost;
0062 struct NCR5380_hostdata *hostdata;
0063 unsigned long io;
0064 int error = -ENODEV;
0065
0066 if (pci_enable_device(pdev))
0067 goto out;
0068
0069 io = pci_resource_start(pdev, 0);
0070 if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
0071 printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
0072 io, io + DMX3191D_REGION_LEN);
0073 goto out_disable_device;
0074 }
0075
0076 shost = scsi_host_alloc(&dmx3191d_driver_template,
0077 sizeof(struct NCR5380_hostdata));
0078 if (!shost)
0079 goto out_release_region;
0080
0081 hostdata = shost_priv(shost);
0082 hostdata->base = io;
0083
0084
0085
0086
0087 shost->irq = NO_IRQ;
0088
0089 error = NCR5380_init(shost, 0);
0090 if (error)
0091 goto out_host_put;
0092
0093 NCR5380_maybe_reset_bus(shost);
0094
0095 pci_set_drvdata(pdev, shost);
0096
0097 error = scsi_add_host(shost, &pdev->dev);
0098 if (error)
0099 goto out_exit;
0100
0101 scsi_scan_host(shost);
0102 return 0;
0103
0104 out_exit:
0105 NCR5380_exit(shost);
0106 out_host_put:
0107 scsi_host_put(shost);
0108 out_release_region:
0109 release_region(io, DMX3191D_REGION_LEN);
0110 out_disable_device:
0111 pci_disable_device(pdev);
0112 out:
0113 return error;
0114 }
0115
0116 static void dmx3191d_remove_one(struct pci_dev *pdev)
0117 {
0118 struct Scsi_Host *shost = pci_get_drvdata(pdev);
0119 struct NCR5380_hostdata *hostdata = shost_priv(shost);
0120 unsigned long io = hostdata->base;
0121
0122 scsi_remove_host(shost);
0123
0124 NCR5380_exit(shost);
0125 scsi_host_put(shost);
0126 release_region(io, DMX3191D_REGION_LEN);
0127 pci_disable_device(pdev);
0128 }
0129
0130 static struct pci_device_id dmx3191d_pci_tbl[] = {
0131 {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
0132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
0133 { }
0134 };
0135 MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
0136
0137 static struct pci_driver dmx3191d_pci_driver = {
0138 .name = DMX3191D_DRIVER_NAME,
0139 .id_table = dmx3191d_pci_tbl,
0140 .probe = dmx3191d_probe_one,
0141 .remove = dmx3191d_remove_one,
0142 };
0143
0144 module_pci_driver(dmx3191d_pci_driver);
0145
0146 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
0147 MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
0148 MODULE_LICENSE("GPL");