a4000t.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. static struct scsi_host_template a4000t_scsi_driver_template = {
  21. .name = "A4000T builtin SCSI",
  22. .proc_name = "A4000t",
  23. .this_id = 7,
  24. .module = THIS_MODULE,
  25. };
  26. #define A4000T_SCSI_OFFSET 0x40
  27. static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev)
  28. {
  29. struct resource *res;
  30. phys_addr_t scsi_addr;
  31. struct NCR_700_Host_Parameters *hostdata;
  32. struct Scsi_Host *host;
  33. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  34. if (!res)
  35. return -ENODEV;
  36. if (!request_mem_region(res->start, resource_size(res),
  37. "A4000T builtin SCSI"))
  38. return -EBUSY;
  39. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters),
  40. GFP_KERNEL);
  41. if (!hostdata) {
  42. dev_err(&pdev->dev, "Failed to allocate host data\n");
  43. goto out_release;
  44. }
  45. scsi_addr = res->start + A4000T_SCSI_OFFSET;
  46. /* Fill in the required pieces of hostdata */
  47. hostdata->base = ZTWO_VADDR(scsi_addr);
  48. hostdata->clock = 50;
  49. hostdata->chip710 = 1;
  50. hostdata->dmode_extra = DMODE_FC2;
  51. hostdata->dcntl_extra = EA_710;
  52. /* and register the chip */
  53. host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
  54. &pdev->dev);
  55. if (!host) {
  56. dev_err(&pdev->dev,
  57. "No host detected; board configuration problem?\n");
  58. goto out_free;
  59. }
  60. host->this_id = 7;
  61. host->base = scsi_addr;
  62. host->irq = IRQ_AMIGA_PORTS;
  63. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
  64. host)) {
  65. dev_err(&pdev->dev, "request_irq failed\n");
  66. goto out_put_host;
  67. }
  68. platform_set_drvdata(pdev, host);
  69. scsi_scan_host(host);
  70. return 0;
  71. out_put_host:
  72. scsi_host_put(host);
  73. out_free:
  74. kfree(hostdata);
  75. out_release:
  76. release_mem_region(res->start, resource_size(res));
  77. return -ENODEV;
  78. }
  79. static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
  80. {
  81. struct Scsi_Host *host = platform_get_drvdata(pdev);
  82. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  83. struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  84. scsi_remove_host(host);
  85. NCR_700_release(host);
  86. kfree(hostdata);
  87. free_irq(host->irq, host);
  88. release_mem_region(res->start, resource_size(res));
  89. return 0;
  90. }
  91. static struct platform_driver amiga_a4000t_scsi_driver = {
  92. .remove = __exit_p(amiga_a4000t_scsi_remove),
  93. .driver = {
  94. .name = "amiga-a4000t-scsi",
  95. },
  96. };
  97. module_platform_driver_probe(amiga_a4000t_scsi_driver, amiga_a4000t_scsi_probe);
  98. MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / "
  99. "Kars de Jong <jongk@linux-m68k.org>");
  100. MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
  101. MODULE_LICENSE("GPL");
  102. MODULE_ALIAS("platform:amiga-a4000t-scsi");