bvme6000_scsi.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 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, dev);
  52. if (!host) {
  53. printk(KERN_ERR "bvme6000-scsi: No host detected; "
  54. "board configuration problem?\n");
  55. goto out_free;
  56. }
  57. host->base = BVME_NCR53C710_BASE;
  58. host->this_id = 7;
  59. host->irq = BVME_IRQ_SCSI;
  60. if (request_irq(BVME_IRQ_SCSI, NCR_700_intr, 0, "bvme6000-scsi",
  61. host)) {
  62. printk(KERN_ERR "bvme6000-scsi: request_irq failed\n");
  63. goto out_put_host;
  64. }
  65. dev_set_drvdata(dev, host);
  66. scsi_scan_host(host);
  67. return 0;
  68. out_put_host:
  69. scsi_host_put(host);
  70. out_free:
  71. kfree(hostdata);
  72. out:
  73. return -ENODEV;
  74. }
  75. static __devexit int
  76. bvme6000_device_remove(struct device *dev)
  77. {
  78. struct Scsi_Host *host = dev_get_drvdata(dev);
  79. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  80. scsi_remove_host(host);
  81. NCR_700_release(host);
  82. kfree(hostdata);
  83. free_irq(host->irq, host);
  84. return 0;
  85. }
  86. static struct device_driver bvme6000_scsi_driver = {
  87. .name = "bvme6000-scsi",
  88. .bus = &platform_bus_type,
  89. .probe = bvme6000_probe,
  90. .remove = __devexit_p(bvme6000_device_remove),
  91. };
  92. static int __init bvme6000_scsi_init(void)
  93. {
  94. int err;
  95. err = driver_register(&bvme6000_scsi_driver);
  96. if (err)
  97. return err;
  98. bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
  99. -1, NULL, 0);
  100. if (IS_ERR(bvme6000_scsi_device)) {
  101. driver_unregister(&bvme6000_scsi_driver);
  102. return PTR_ERR(bvme6000_scsi_device);
  103. }
  104. return 0;
  105. }
  106. static void __exit bvme6000_scsi_exit(void)
  107. {
  108. platform_device_unregister(bvme6000_scsi_device);
  109. driver_unregister(&bvme6000_scsi_driver);
  110. }
  111. module_init(bvme6000_scsi_init);
  112. module_exit(bvme6000_scsi_exit);