dmx3191d.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. Based on the generic NCR5380 driver by Drew Eckhardt et al.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/ioport.h>
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/pci.h>
  23. #include <linux/interrupt.h>
  24. #include <asm/io.h>
  25. #include <scsi/scsi_host.h>
  26. /*
  27. * Definitions for the generic 5380 driver.
  28. */
  29. #define NCR5380_read(reg) inb(hostdata->base + (reg))
  30. #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg))
  31. #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none
  32. #define NCR5380_dma_recv_setup NCR5380_dma_setup_none
  33. #define NCR5380_dma_send_setup NCR5380_dma_setup_none
  34. #define NCR5380_dma_residual NCR5380_dma_residual_none
  35. #define NCR5380_implementation_fields /* none */
  36. #include "NCR5380.h"
  37. #include "NCR5380.c"
  38. #define DMX3191D_DRIVER_NAME "dmx3191d"
  39. #define DMX3191D_REGION_LEN 8
  40. static struct scsi_host_template dmx3191d_driver_template = {
  41. .module = THIS_MODULE,
  42. .proc_name = DMX3191D_DRIVER_NAME,
  43. .name = "Domex DMX3191D",
  44. .info = NCR5380_info,
  45. .queuecommand = NCR5380_queue_command,
  46. .eh_abort_handler = NCR5380_abort,
  47. .eh_host_reset_handler = NCR5380_host_reset,
  48. .can_queue = 32,
  49. .this_id = 7,
  50. .sg_tablesize = SG_ALL,
  51. .cmd_per_lun = 2,
  52. .use_clustering = DISABLE_CLUSTERING,
  53. .cmd_size = NCR5380_CMD_SIZE,
  54. };
  55. static int dmx3191d_probe_one(struct pci_dev *pdev,
  56. const struct pci_device_id *id)
  57. {
  58. struct Scsi_Host *shost;
  59. struct NCR5380_hostdata *hostdata;
  60. unsigned long io;
  61. int error = -ENODEV;
  62. if (pci_enable_device(pdev))
  63. goto out;
  64. io = pci_resource_start(pdev, 0);
  65. if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
  66. printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
  67. io, io + DMX3191D_REGION_LEN);
  68. goto out_disable_device;
  69. }
  70. shost = scsi_host_alloc(&dmx3191d_driver_template,
  71. sizeof(struct NCR5380_hostdata));
  72. if (!shost)
  73. goto out_release_region;
  74. hostdata = shost_priv(shost);
  75. hostdata->base = io;
  76. /* This card does not seem to raise an interrupt on pdev->irq.
  77. * Steam-powered SCSI controllers run without an IRQ anyway.
  78. */
  79. shost->irq = NO_IRQ;
  80. error = NCR5380_init(shost, 0);
  81. if (error)
  82. goto out_host_put;
  83. NCR5380_maybe_reset_bus(shost);
  84. pci_set_drvdata(pdev, shost);
  85. error = scsi_add_host(shost, &pdev->dev);
  86. if (error)
  87. goto out_exit;
  88. scsi_scan_host(shost);
  89. return 0;
  90. out_exit:
  91. NCR5380_exit(shost);
  92. out_host_put:
  93. scsi_host_put(shost);
  94. out_release_region:
  95. release_region(io, DMX3191D_REGION_LEN);
  96. out_disable_device:
  97. pci_disable_device(pdev);
  98. out:
  99. return error;
  100. }
  101. static void dmx3191d_remove_one(struct pci_dev *pdev)
  102. {
  103. struct Scsi_Host *shost = pci_get_drvdata(pdev);
  104. struct NCR5380_hostdata *hostdata = shost_priv(shost);
  105. unsigned long io = hostdata->base;
  106. scsi_remove_host(shost);
  107. NCR5380_exit(shost);
  108. scsi_host_put(shost);
  109. release_region(io, DMX3191D_REGION_LEN);
  110. pci_disable_device(pdev);
  111. }
  112. static struct pci_device_id dmx3191d_pci_tbl[] = {
  113. {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
  114. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  115. { }
  116. };
  117. MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
  118. static struct pci_driver dmx3191d_pci_driver = {
  119. .name = DMX3191D_DRIVER_NAME,
  120. .id_table = dmx3191d_pci_tbl,
  121. .probe = dmx3191d_probe_one,
  122. .remove = dmx3191d_remove_one,
  123. };
  124. module_pci_driver(dmx3191d_pci_driver);
  125. MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  126. MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
  127. MODULE_LICENSE("GPL");