a4000t.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 platform_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,
  52. &dev->dev);
  53. if (!host) {
  54. printk(KERN_ERR "a4000t-scsi: No host detected; "
  55. "board configuration problem?\n");
  56. goto out_free;
  57. }
  58. host->this_id = 7;
  59. host->base = A4000T_SCSI_ADDR;
  60. host->irq = IRQ_AMIGA_PORTS;
  61. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
  62. host)) {
  63. printk(KERN_ERR "a4000t-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_release:
  74. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  75. out:
  76. return -ENODEV;
  77. }
  78. static __devexit int a4000t_device_remove(struct platform_device *dev)
  79. {
  80. struct Scsi_Host *host = platform_get_drvdata(dev);
  81. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  82. scsi_remove_host(host);
  83. NCR_700_release(host);
  84. kfree(hostdata);
  85. free_irq(host->irq, host);
  86. release_mem_region(A4000T_SCSI_ADDR, 0x1000);
  87. return 0;
  88. }
  89. static struct platform_driver a4000t_scsi_driver = {
  90. .driver = {
  91. .name = "a4000t-scsi",
  92. .owner = THIS_MODULE,
  93. },
  94. .probe = a4000t_probe,
  95. .remove = __devexit_p(a4000t_device_remove),
  96. };
  97. static int __init a4000t_scsi_init(void)
  98. {
  99. int err;
  100. err = platform_driver_register(&a4000t_scsi_driver);
  101. if (err)
  102. return err;
  103. a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
  104. -1, NULL, 0);
  105. if (IS_ERR(a4000t_scsi_device)) {
  106. platform_driver_register(&a4000t_scsi_driver);
  107. return PTR_ERR(a4000t_scsi_device);
  108. }
  109. return err;
  110. }
  111. static void __exit a4000t_scsi_exit(void)
  112. {
  113. platform_device_unregister(a4000t_scsi_device);
  114. platform_driver_unregister(&a4000t_scsi_driver);
  115. }
  116. module_init(a4000t_scsi_init);
  117. module_exit(a4000t_scsi_exit);