bvme6000_scsi.c 3.2 KB

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