bvme6000_scsi.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Detection routine for the NCR53c710 based BVME6000 SCSI Controllers for Linux.
  4. *
  5. * Based on work by Alan Hourihane and Kars de Jong
  6. *
  7. * Rewritten to use 53c700.c by Richard Hirst <richard@sleepie.demon.co.uk>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/blkdev.h>
  11. #include <linux/device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/slab.h>
  16. #include <asm/bvme6000hw.h>
  17. #include <scsi/scsi_host.h>
  18. #include <scsi/scsi_device.h>
  19. #include <scsi/scsi_transport.h>
  20. #include <scsi/scsi_transport_spi.h>
  21. #include "53c700.h"
  22. MODULE_AUTHOR("Richard Hirst <richard@sleepie.demon.co.uk>");
  23. MODULE_DESCRIPTION("BVME6000 NCR53C710 driver");
  24. MODULE_LICENSE("GPL");
  25. static struct scsi_host_template bvme6000_scsi_driver_template = {
  26. .name = "BVME6000 NCR53c710 SCSI",
  27. .proc_name = "BVME6000",
  28. .this_id = 7,
  29. .module = THIS_MODULE,
  30. };
  31. static struct platform_device *bvme6000_scsi_device;
  32. static int
  33. bvme6000_probe(struct platform_device *dev)
  34. {
  35. struct Scsi_Host *host;
  36. struct NCR_700_Host_Parameters *hostdata;
  37. if (!MACH_IS_BVME6000)
  38. goto out;
  39. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  40. if (!hostdata) {
  41. printk(KERN_ERR "bvme6000-scsi: "
  42. "Failed to allocate host data\n");
  43. goto out;
  44. }
  45. /* Fill in the required pieces of hostdata */
  46. hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;
  47. hostdata->clock = 40; /* XXX - depends on the CPU clock! */
  48. hostdata->chip710 = 1;
  49. hostdata->dmode_extra = DMODE_FC2;
  50. hostdata->dcntl_extra = EA_710;
  51. hostdata->ctest7_extra = CTEST7_TT1;
  52. /* and register the chip */
  53. host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
  54. &dev->dev);
  55. if (!host) {
  56. printk(KERN_ERR "bvme6000-scsi: No host detected; "
  57. "board configuration problem?\n");
  58. goto out_free;
  59. }
  60. host->base = BVME_NCR53C710_BASE;
  61. host->this_id = 7;
  62. host->irq = BVME_IRQ_SCSI;
  63. if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
  64. host)) {
  65. printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
  66. goto out_put_host;
  67. }
  68. platform_set_drvdata(dev, host);
  69. scsi_scan_host(host);
  70. return 0;
  71. out_put_host:
  72. scsi_host_put(host);
  73. out_free:
  74. kfree(hostdata);
  75. out:
  76. return -ENODEV;
  77. }
  78. static int
  79. bvme6000_device_remove(struct platform_device *dev)
  80. {
  81. struct Scsi_Host *host = platform_get_drvdata(dev);
  82. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  83. scsi_remove_host(host);
  84. NCR_700_release(host);
  85. kfree(hostdata);
  86. free_irq(host->irq, host);
  87. return 0;
  88. }
  89. static struct platform_driver bvme6000_scsi_driver = {
  90. .driver = {
  91. .name = "bvme6000-scsi",
  92. },
  93. .probe = bvme6000_probe,
  94. .remove = bvme6000_device_remove,
  95. };
  96. static int __init bvme6000_scsi_init(void)
  97. {
  98. int err;
  99. err = platform_driver_register(&bvme6000_scsi_driver);
  100. if (err)
  101. return err;
  102. bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
  103. -1, NULL, 0);
  104. if (IS_ERR(bvme6000_scsi_device)) {
  105. platform_driver_unregister(&bvme6000_scsi_driver);
  106. return PTR_ERR(bvme6000_scsi_device);
  107. }
  108. return 0;
  109. }
  110. static void __exit bvme6000_scsi_exit(void)
  111. {
  112. platform_device_unregister(bvme6000_scsi_device);
  113. platform_driver_unregister(&bvme6000_scsi_driver);
  114. }
  115. module_init(bvme6000_scsi_init);
  116. module_exit(bvme6000_scsi_exit);