a4000t.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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/amigaints.h>
  15. #include <scsi/scsi_host.h>
  16. #include <scsi/scsi_transport_spi.h>
  17. #include "53c700.h"
  18. MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
  19. MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
  20. MODULE_LICENSE("GPL");
  21. static struct scsi_host_template a4000t_scsi_driver_template = {
  22. .name = "A4000T builtin SCSI",
  23. .proc_name = "A4000t",
  24. .this_id = 7,
  25. .module = THIS_MODULE,
  26. };
  27. static struct platform_device *a4000t_scsi_device;
  28. #define A4000T_SCSI_ADDR 0xdd0040
  29. static int __devinit a4000t_probe(struct device *dev)
  30. {
  31. struct Scsi_Host * host = NULL;
  32. struct NCR_700_Host_Parameters *hostdata;
  33. if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI)))
  34. goto out;
  35. if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000,
  36. "A4000T builtin SCSI"))
  37. goto out;
  38. hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  39. if (hostdata == NULL) {
  40. printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n");
  41. goto out_release;
  42. }
  43. memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
  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. scsi_scan_host(host);
  66. return 0;
  67. out_put_host:
  68. scsi_host_put(host);
  69. out_free:
  70. kfree(hostdata);
  71. out_release:
  72. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  73. out:
  74. return -ENODEV;
  75. }
  76. static __devexit int a4000t_device_remove(struct device *dev)
  77. {
  78. struct Scsi_Host *host = dev_to_shost(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. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  85. return 0;
  86. }
  87. static struct device_driver a4000t_scsi_driver = {
  88. .name = "a4000t-scsi",
  89. .bus = &platform_bus_type,
  90. .probe = a4000t_probe,
  91. .remove = __devexit_p(a4000t_device_remove),
  92. };
  93. static int __init a4000t_scsi_init(void)
  94. {
  95. int err;
  96. err = driver_register(&a4000t_scsi_driver);
  97. if (err)
  98. return err;
  99. a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
  100. -1, NULL, 0);
  101. if (IS_ERR(a4000t_scsi_device)) {
  102. driver_unregister(&a4000t_scsi_driver);
  103. return PTR_ERR(a4000t_scsi_device);
  104. }
  105. return err;
  106. }
  107. static void __exit a4000t_scsi_exit(void)
  108. {
  109. platform_device_unregister(a4000t_scsi_device);
  110. driver_unregister(&a4000t_scsi_driver);
  111. }
  112. module_init(a4000t_scsi_init);
  113. module_exit(a4000t_scsi_exit);