a4000t.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
  3. * Amiga Technologies A4000T SCSI controller.
  4. *
  5. * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
  6. * plus modifications of the 53c7xx.c driver to support the Amiga.
  7. *
  8. * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/init.h>
  13. #include <linux/interrupt.h>
  14. #include <asm/amigahw.h>
  15. #include <asm/amigaints.h>
  16. #include <scsi/scsi_host.h>
  17. #include <scsi/scsi_transport_spi.h>
  18. #include "53c700.h"
  19. MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
  20. MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
  21. MODULE_LICENSE("GPL");
  22. static struct scsi_host_template a4000t_scsi_driver_template = {
  23. .name = "A4000T builtin SCSI",
  24. .proc_name = "A4000t",
  25. .this_id = 7,
  26. .module = THIS_MODULE,
  27. };
  28. static struct platform_device *a4000t_scsi_device;
  29. #define A4000T_SCSI_ADDR 0xdd0040
  30. static int __devinit a4000t_probe(struct device *dev)
  31. {
  32. struct Scsi_Host *host;
  33. struct NCR_700_Host_Parameters *hostdata;
  34. if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI)))
  35. goto out;
  36. if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000,
  37. "A4000T builtin SCSI"))
  38. goto out;
  39. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  40. if (!hostdata) {
  41. printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n");
  42. goto out_release;
  43. }
  44. /* Fill in the required pieces of hostdata */
  45. hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);
  46. hostdata->clock = 50;
  47. hostdata->chip710 = 1;
  48. hostdata->dmode_extra = DMODE_FC2;
  49. hostdata->dcntl_extra = EA_710;
  50. /* and register the chip */
  51. host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, dev);
  52. if (!host) {
  53. printk(KERN_ERR "a4000t-scsi: No host detected; "
  54. "board configuration problem?\n");
  55. goto out_free;
  56. }
  57. host->this_id = 7;
  58. host->base = A4000T_SCSI_ADDR;
  59. host->irq = IRQ_AMIGA_PORTS;
  60. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
  61. host)) {
  62. printk(KERN_ERR "a4000t-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_release:
  73. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  74. out:
  75. return -ENODEV;
  76. }
  77. static __devexit int a4000t_device_remove(struct device *dev)
  78. {
  79. struct Scsi_Host *host = dev_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. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  86. return 0;
  87. }
  88. static struct device_driver a4000t_scsi_driver = {
  89. .name = "a4000t-scsi",
  90. .bus = &platform_bus_type,
  91. .probe = a4000t_probe,
  92. .remove = __devexit_p(a4000t_device_remove),
  93. };
  94. static int __init a4000t_scsi_init(void)
  95. {
  96. int err;
  97. err = driver_register(&a4000t_scsi_driver);
  98. if (err)
  99. return err;
  100. a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
  101. -1, NULL, 0);
  102. if (IS_ERR(a4000t_scsi_device)) {
  103. driver_unregister(&a4000t_scsi_driver);
  104. return PTR_ERR(a4000t_scsi_device);
  105. }
  106. return err;
  107. }
  108. static void __exit a4000t_scsi_exit(void)
  109. {
  110. platform_device_unregister(a4000t_scsi_device);
  111. driver_unregister(&a4000t_scsi_driver);
  112. }
  113. module_init(a4000t_scsi_init);
  114. module_exit(a4000t_scsi_exit);