dmx3191d.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 DONT_USE_INTR
  30. #define NCR5380_read(reg) inb(port + reg)
  31. #define NCR5380_write(reg, value) outb(value, port + reg)
  32. #define NCR5380_implementation_fields /* none */
  33. #define NCR5380_local_declare() unsigned int port
  34. #define NCR5380_setup(instance) port = instance->io_port
  35. /*
  36. * Includes needed for NCR5380.[ch] (XXX: Move them to NCR5380.h)
  37. */
  38. #include <linux/delay.h>
  39. #include "NCR5380.h"
  40. #include "NCR5380.c"
  41. #define DMX3191D_DRIVER_NAME "dmx3191d"
  42. #define DMX3191D_REGION_LEN 8
  43. static struct scsi_host_template dmx3191d_driver_template = {
  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_bus_reset_handler = NCR5380_bus_reset,
  50. .can_queue = 32,
  51. .this_id = 7,
  52. .sg_tablesize = SG_ALL,
  53. .cmd_per_lun = 2,
  54. .use_clustering = DISABLE_CLUSTERING,
  55. };
  56. static int dmx3191d_probe_one(struct pci_dev *pdev,
  57. const struct pci_device_id *id)
  58. {
  59. struct Scsi_Host *shost;
  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. shost->io_port = io;
  75. /* This card does not seem to raise an interrupt on pdev->irq.
  76. * Steam-powered SCSI controllers run without an IRQ anyway.
  77. */
  78. shost->irq = NO_IRQ;
  79. NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
  80. pci_set_drvdata(pdev, shost);
  81. error = scsi_add_host(shost, &pdev->dev);
  82. if (error)
  83. goto out_release_region;
  84. scsi_scan_host(shost);
  85. return 0;
  86. out_release_region:
  87. release_region(io, DMX3191D_REGION_LEN);
  88. out_disable_device:
  89. pci_disable_device(pdev);
  90. out:
  91. return error;
  92. }
  93. static void dmx3191d_remove_one(struct pci_dev *pdev)
  94. {
  95. struct Scsi_Host *shost = pci_get_drvdata(pdev);
  96. scsi_remove_host(shost);
  97. NCR5380_exit(shost);
  98. release_region(shost->io_port, DMX3191D_REGION_LEN);
  99. pci_disable_device(pdev);
  100. scsi_host_put(shost);
  101. }
  102. static struct pci_device_id dmx3191d_pci_tbl[] = {
  103. {PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
  104. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
  105. { }
  106. };
  107. MODULE_DEVICE_TABLE(pci, dmx3191d_pci_tbl);
  108. static struct pci_driver dmx3191d_pci_driver = {
  109. .name = DMX3191D_DRIVER_NAME,
  110. .id_table = dmx3191d_pci_tbl,
  111. .probe = dmx3191d_probe_one,
  112. .remove = dmx3191d_remove_one,
  113. };
  114. static int __init dmx3191d_init(void)
  115. {
  116. return pci_register_driver(&dmx3191d_pci_driver);
  117. }
  118. static void __exit dmx3191d_exit(void)
  119. {
  120. pci_unregister_driver(&dmx3191d_pci_driver);
  121. }
  122. module_init(dmx3191d_init);
  123. module_exit(dmx3191d_exit);
  124. MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  125. MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
  126. MODULE_LICENSE("GPL");