bvme6000_scsi.c 3.3 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 <asm/bvme6000hw.h>
  15. #include <scsi/scsi_host.h>
  16. #include <scsi/scsi_device.h>
  17. #include <scsi/scsi_transport.h>
  18. #include <scsi/scsi_transport_spi.h>
  19. #include "53c700.h"
  20. MODULE_AUTHOR("Richard Hirst <richard@sleepie.demon.co.uk>");
  21. MODULE_DESCRIPTION("BVME6000 NCR53C710 driver");
  22. MODULE_LICENSE("GPL");
  23. static struct scsi_host_template bvme6000_scsi_driver_template = {
  24. .name = "BVME6000 NCR53c710 SCSI",
  25. .proc_name = "BVME6000",
  26. .this_id = 7,
  27. .module = THIS_MODULE,
  28. };
  29. static struct platform_device *bvme6000_scsi_device;
  30. static __devinit int
  31. bvme6000_probe(struct platform_device *dev)
  32. {
  33. struct Scsi_Host *host;
  34. struct NCR_700_Host_Parameters *hostdata;
  35. if (!MACH_IS_BVME6000)
  36. goto out;
  37. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  38. if (!hostdata) {
  39. printk(KERN_ERR "bvme6000-scsi: "
  40. "Failed to allocate host data\n");
  41. goto out;
  42. }
  43. /* Fill in the required pieces of hostdata */
  44. hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;
  45. hostdata->clock = 40; /* XXX - depends on the CPU clock! */
  46. hostdata->chip710 = 1;
  47. hostdata->dmode_extra = DMODE_FC2;
  48. hostdata->dcntl_extra = EA_710;
  49. hostdata->ctest7_extra = CTEST7_TT1;
  50. /* and register the chip */
  51. host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata,
  52. &dev->dev);
  53. if (!host) {
  54. printk(KERN_ERR "bvme6000-scsi: No host detected; "
  55. "board configuration problem?\n");
  56. goto out_free;
  57. }
  58. host->base = BVME_NCR53C710_BASE;
  59. host->this_id = 7;
  60. host->irq = BVME_IRQ_SCSI;
  61. if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
  62. host)) {
  63. printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
  64. goto out_put_host;
  65. }
  66. platform_set_drvdata(dev, host);
  67. scsi_scan_host(host);
  68. return 0;
  69. out_put_host:
  70. scsi_host_put(host);
  71. out_free:
  72. kfree(hostdata);
  73. out:
  74. return -ENODEV;
  75. }
  76. static __devexit int
  77. bvme6000_device_remove(struct platform_device *dev)
  78. {
  79. struct Scsi_Host *host = platform_get_drvdata(dev);
  80. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  81. scsi_remove_host(host);
  82. NCR_700_release(host);
  83. kfree(hostdata);
  84. free_irq(host->irq, host);
  85. return 0;
  86. }
  87. static struct platform_driver bvme6000_scsi_driver = {
  88. .driver = {
  89. .name = "bvme6000-scsi",
  90. .owner = THIS_MODULE,
  91. },
  92. .probe = bvme6000_probe,
  93. .remove = __devexit_p(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);