a4000t.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 <linux/slab.h>
  15. #include <asm/amigahw.h>
  16. #include <asm/amigaints.h>
  17. #include <scsi/scsi_host.h>
  18. #include <scsi/scsi_transport_spi.h>
  19. #include "53c700.h"
  20. MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
  21. MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
  22. MODULE_LICENSE("GPL");
  23. static struct scsi_host_template a4000t_scsi_driver_template = {
  24. .name = "A4000T builtin SCSI",
  25. .proc_name = "A4000t",
  26. .this_id = 7,
  27. .module = THIS_MODULE,
  28. };
  29. static struct platform_device *a4000t_scsi_device;
  30. #define A4000T_SCSI_ADDR 0xdd0040
  31. static int __devinit a4000t_probe(struct platform_device *dev)
  32. {
  33. struct Scsi_Host *host;
  34. struct NCR_700_Host_Parameters *hostdata;
  35. if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI)))
  36. goto out;
  37. if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000,
  38. "A4000T builtin SCSI"))
  39. goto out;
  40. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  41. if (!hostdata) {
  42. printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n");
  43. goto out_release;
  44. }
  45. /* Fill in the required pieces of hostdata */
  46. hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);
  47. hostdata->clock = 50;
  48. hostdata->chip710 = 1;
  49. hostdata->dmode_extra = DMODE_FC2;
  50. hostdata->dcntl_extra = EA_710;
  51. /* and register the chip */
  52. host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
  53. &dev->dev);
  54. if (!host) {
  55. printk(KERN_ERR "a4000t-scsi: No host detected; "
  56. "board configuration problem?\n");
  57. goto out_free;
  58. }
  59. host->this_id = 7;
  60. host->base = A4000T_SCSI_ADDR;
  61. host->irq = IRQ_AMIGA_PORTS;
  62. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
  63. host)) {
  64. printk(KERN_ERR "a4000t-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_release:
  75. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  76. out:
  77. return -ENODEV;
  78. }
  79. static __devexit int a4000t_device_remove(struct platform_device *dev)
  80. {
  81. struct Scsi_Host *host = platform_get_drvdata(dev);
  82. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  83. scsi_remove_host(host);
  84. NCR_700_release(host);
  85. kfree(hostdata);
  86. free_irq(host->irq, host);
  87. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  88. return 0;
  89. }
  90. static struct platform_driver a4000t_scsi_driver = {
  91. .driver = {
  92. .name = "a4000t-scsi",
  93. .owner = THIS_MODULE,
  94. },
  95. .probe = a4000t_probe,
  96. .remove = __devexit_p(a4000t_device_remove),
  97. };
  98. static int __init a4000t_scsi_init(void)
  99. {
  100. int err;
  101. err = platform_driver_register(&a4000t_scsi_driver);
  102. if (err)
  103. return err;
  104. a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
  105. -1, NULL, 0);
  106. if (IS_ERR(a4000t_scsi_device)) {
  107. platform_driver_unregister(&a4000t_scsi_driver);
  108. return PTR_ERR(a4000t_scsi_device);
  109. }
  110. return err;
  111. }
  112. static void __exit a4000t_scsi_exit(void)
  113. {
  114. platform_device_unregister(a4000t_scsi_device);
  115. platform_driver_unregister(&a4000t_scsi_driver);
  116. }
  117. module_init(a4000t_scsi_init);
  118. module_exit(a4000t_scsi_exit);