dmx3191d.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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(instance->io_port + reg)
  30. #define NCR5380_write(reg, value) outb(value, instance->io_port + reg)
  31. #define NCR5380_dma_xfer_len(instance, cmd, phase) (0)
  32. #define NCR5380_dma_recv_setup(instance, dst, len) (0)
  33. #define NCR5380_dma_send_setup(instance, src, len) (0)
  34. #define NCR5380_dma_residual(instance) (0)
  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_bus_reset_handler = NCR5380_bus_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. unsigned long io;
  60. int error = -ENODEV;
  61. if (pci_enable_device(pdev))
  62. goto out;
  63. io = pci_resource_start(pdev, 0);
  64. if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
  65. printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
  66. io, io + DMX3191D_REGION_LEN);
  67. goto out_disable_device;
  68. }
  69. shost = scsi_host_alloc(&dmx3191d_driver_template,
  70. sizeof(struct NCR5380_hostdata));
  71. if (!shost)
  72. goto out_release_region;
  73. shost->io_port = io;
  74. /* This card does not seem to raise an interrupt on pdev->irq.
  75. * Steam-powered SCSI controllers run without an IRQ anyway.
  76. */
  77. shost->irq = NO_IRQ;
  78. error = NCR5380_init(shost, 0);
  79. if (error)
  80. goto out_host_put;
  81. NCR5380_maybe_reset_bus(shost);
  82. pci_set_drvdata(pdev, shost);
  83. error = scsi_add_host(shost, &pdev->dev);
  84. if (error)
  85. goto out_exit;
  86. scsi_scan_host(shost);
  87. return 0;
  88. out_exit:
  89. NCR5380_exit(shost);
  90. out_host_put:
  91. scsi_host_put(shost);
  92. out_release_region:
  93. release_region(io, DMX3191D_REGION_LEN);
  94. out_disable_device:
  95. pci_disable_device(pdev);
  96. out:
  97. return error;
  98. }
  99. static void dmx3191d_remove_one(struct pci_dev *pdev)
  100. {
  101. struct Scsi_Host *shost = pci_get_drvdata(pdev);
  102. unsigned long io = shost->io_port;
  103. scsi_remove_host(shost);
  104. NCR5380_exit(shost);
  105. scsi_host_put(shost);
  106. release_region(io, DMX3191D_REGION_LEN);
  107. pci_disable_device(pdev);
  108. }
  109. static struct pci_device_id dmx3191d_pci_tbl[] = {
  110. {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
  111. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  112. { }
  113. };
  114. MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
  115. static struct pci_driver dmx3191d_pci_driver = {
  116. .name = DMX3191D_DRIVER_NAME,
  117. .id_table = dmx3191d_pci_tbl,
  118. .probe = dmx3191d_probe_one,
  119. .remove = dmx3191d_remove_one,
  120. };
  121. static int __init dmx3191d_init(void)
  122. {
  123. return pci_register_driver(&dmx3191d_pci_driver);
  124. }
  125. static void __exit dmx3191d_exit(void)
  126. {
  127. pci_unregister_driver(&dmx3191d_pci_driver);
  128. }
  129. module_init(dmx3191d_init);
  130. module_exit(dmx3191d_exit);
  131. MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  132. MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
  133. MODULE_LICENSE("GPL");