dmx3191d.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. Based on the generic NCR5380 driver by Drew Eckhardt et al.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/ioport.h>
  10. #include <linux/kernel.h>
  11. #include <linux/module.h>
  12. #include <linux/pci.h>
  13. #include <linux/interrupt.h>
  14. #include <asm/io.h>
  15. #include <scsi/scsi_host.h>
  16. /*
  17. * Definitions for the generic 5380 driver.
  18. */
  19. #define NCR5380_read(reg) inb(hostdata->base + (reg))
  20. #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg))
  21. #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none
  22. #define NCR5380_dma_recv_setup NCR5380_dma_setup_none
  23. #define NCR5380_dma_send_setup NCR5380_dma_setup_none
  24. #define NCR5380_dma_residual NCR5380_dma_residual_none
  25. #define NCR5380_implementation_fields /* none */
  26. #include "NCR5380.h"
  27. #include "NCR5380.c"
  28. #define DMX3191D_DRIVER_NAME "dmx3191d"
  29. #define DMX3191D_REGION_LEN 8
  30. static struct scsi_host_template dmx3191d_driver_template = {
  31. .module = THIS_MODULE,
  32. .proc_name = DMX3191D_DRIVER_NAME,
  33. .name = "Domex DMX3191D",
  34. .info = NCR5380_info,
  35. .queuecommand = NCR5380_queue_command,
  36. .eh_abort_handler = NCR5380_abort,
  37. .eh_host_reset_handler = NCR5380_host_reset,
  38. .can_queue = 32,
  39. .this_id = 7,
  40. .sg_tablesize = SG_ALL,
  41. .cmd_per_lun = 2,
  42. .dma_boundary = PAGE_SIZE - 1,
  43. .cmd_size = NCR5380_CMD_SIZE,
  44. };
  45. static int dmx3191d_probe_one(struct pci_dev *pdev,
  46. const struct pci_device_id *id)
  47. {
  48. struct Scsi_Host *shost;
  49. struct NCR5380_hostdata *hostdata;
  50. unsigned long io;
  51. int error = -ENODEV;
  52. if (pci_enable_device(pdev))
  53. goto out;
  54. io = pci_resource_start(pdev, 0);
  55. if (!request_region(io, DMX3191D_REGION_LEN, DMX3191D_DRIVER_NAME)) {
  56. printk(KERN_ERR "dmx3191: region 0x%lx-0x%lx already reserved\n",
  57. io, io + DMX3191D_REGION_LEN);
  58. goto out_disable_device;
  59. }
  60. shost = scsi_host_alloc(&dmx3191d_driver_template,
  61. sizeof(struct NCR5380_hostdata));
  62. if (!shost)
  63. goto out_release_region;
  64. hostdata = shost_priv(shost);
  65. hostdata->base = io;
  66. /* This card does not seem to raise an interrupt on pdev->irq.
  67. * Steam-powered SCSI controllers run without an IRQ anyway.
  68. */
  69. shost->irq = NO_IRQ;
  70. error = NCR5380_init(shost, 0);
  71. if (error)
  72. goto out_host_put;
  73. NCR5380_maybe_reset_bus(shost);
  74. pci_set_drvdata(pdev, shost);
  75. error = scsi_add_host(shost, &pdev->dev);
  76. if (error)
  77. goto out_exit;
  78. scsi_scan_host(shost);
  79. return 0;
  80. out_exit:
  81. NCR5380_exit(shost);
  82. out_host_put:
  83. scsi_host_put(shost);
  84. out_release_region:
  85. release_region(io, DMX3191D_REGION_LEN);
  86. out_disable_device:
  87. pci_disable_device(pdev);
  88. out:
  89. return error;
  90. }
  91. static void dmx3191d_remove_one(struct pci_dev *pdev)
  92. {
  93. struct Scsi_Host *shost = pci_get_drvdata(pdev);
  94. struct NCR5380_hostdata *hostdata = shost_priv(shost);
  95. unsigned long io = hostdata->base;
  96. scsi_remove_host(shost);
  97. NCR5380_exit(shost);
  98. scsi_host_put(shost);
  99. release_region(io, DMX3191D_REGION_LEN);
  100. pci_disable_device(pdev);
  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. module_pci_driver(dmx3191d_pci_driver);
  115. MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  116. MODULE_DESCRIPTION("Domex DMX3191D SCSI driver");
  117. MODULE_LICENSE("GPL");