a4000t.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
  4. * Amiga Technologies A4000T SCSI controller.
  5. *
  6. * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
  7. * plus modifications of the 53c7xx.c driver to support the Amiga.
  8. *
  9. * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
  10. */
  11. #include <linux/module.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/slab.h>
  16. #include <asm/amigahw.h>
  17. #include <asm/amigaints.h>
  18. #include <scsi/scsi_host.h>
  19. #include <scsi/scsi_transport_spi.h>
  20. #include "53c700.h"
  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. #define A4000T_SCSI_OFFSET 0x40
  28. static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev)
  29. {
  30. struct resource *res;
  31. phys_addr_t scsi_addr;
  32. struct NCR_700_Host_Parameters *hostdata;
  33. struct Scsi_Host *host;
  34. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  35. if (!res)
  36. return -ENODEV;
  37. if (!request_mem_region(res->start, resource_size(res),
  38. "A4000T builtin SCSI"))
  39. return -EBUSY;
  40. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters),
  41. GFP_KERNEL);
  42. if (!hostdata) {
  43. dev_err(&pdev->dev, "Failed to allocate host data\n");
  44. goto out_release;
  45. }
  46. scsi_addr = res->start + A4000T_SCSI_OFFSET;
  47. /* Fill in the required pieces of hostdata */
  48. hostdata->base = ZTWO_VADDR(scsi_addr);
  49. hostdata->clock = 50;
  50. hostdata->chip710 = 1;
  51. hostdata->dmode_extra = DMODE_FC2;
  52. hostdata->dcntl_extra = EA_710;
  53. /* and register the chip */
  54. host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata,
  55. &pdev->dev);
  56. if (!host) {
  57. dev_err(&pdev->dev,
  58. "No host detected; board configuration problem?\n");
  59. goto out_free;
  60. }
  61. host->this_id = 7;
  62. host->base = scsi_addr;
  63. host->irq = IRQ_AMIGA_PORTS;
  64. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi",
  65. host)) {
  66. dev_err(&pdev->dev, "request_irq failed\n");
  67. goto out_put_host;
  68. }
  69. platform_set_drvdata(pdev, host);
  70. scsi_scan_host(host);
  71. return 0;
  72. out_put_host:
  73. scsi_host_put(host);
  74. out_free:
  75. kfree(hostdata);
  76. out_release:
  77. release_mem_region(res->start, resource_size(res));
  78. return -ENODEV;
  79. }
  80. static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
  81. {
  82. struct Scsi_Host *host = platform_get_drvdata(pdev);
  83. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  84. struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  85. scsi_remove_host(host);
  86. NCR_700_release(host);
  87. kfree(hostdata);
  88. free_irq(host->irq, host);
  89. release_mem_region(res->start, resource_size(res));
  90. return 0;
  91. }
  92. static struct platform_driver amiga_a4000t_scsi_driver = {
  93. .remove = __exit_p(amiga_a4000t_scsi_remove),
  94. .driver = {
  95. .name = "amiga-a4000t-scsi",
  96. },
  97. };
  98. module_platform_driver_probe(amiga_a4000t_scsi_driver, amiga_a4000t_scsi_probe);
  99. MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / "
  100. "Kars de Jong <jongk@linux-m68k.org>");
  101. MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver");
  102. MODULE_LICENSE("GPL");
  103. MODULE_ALIAS("platform:amiga-a4000t-scsi");