zorro7xx.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
  4. * Amiga MacroSystemUS WarpEngine SCSI controller.
  5. * Amiga Technologies/DKB A4091 SCSI controller.
  6. *
  7. * Written 1997 by Alan Hourihane <[email protected]>
  8. * plus modifications of the 53c7xx.c driver to support the Amiga.
  9. *
  10. * Rewritten to use 53c700.c by Kars de Jong <[email protected]>
  11. */
  12. #include <linux/module.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/zorro.h>
  16. #include <linux/slab.h>
  17. #include <asm/amigahw.h>
  18. #include <asm/amigaints.h>
  19. #include <scsi/scsi_host.h>
  20. #include <scsi/scsi_transport_spi.h>
  21. #include "53c700.h"
  22. MODULE_AUTHOR("Alan Hourihane <[email protected]> / Kars de Jong <[email protected]>");
  23. MODULE_DESCRIPTION("Amiga Zorro NCR53C710 driver");
  24. MODULE_LICENSE("GPL");
  25. static struct scsi_host_template zorro7xx_scsi_driver_template = {
  26. .proc_name = "zorro7xx",
  27. .this_id = 7,
  28. .module = THIS_MODULE,
  29. };
  30. static struct zorro_driver_data {
  31. const char *name;
  32. unsigned long offset;
  33. int absolute; /* offset is absolute address */
  34. } zorro7xx_driver_data[] = {
  35. { .name = "PowerUP 603e+", .offset = 0xf40000, .absolute = 1 },
  36. { .name = "WarpEngine 40xx", .offset = 0x40000 },
  37. { .name = "A4091", .offset = 0x800000 },
  38. { .name = "GForce 040/060", .offset = 0x40000 },
  39. { 0 }
  40. };
  41. static struct zorro_device_id zorro7xx_zorro_tbl[] = {
  42. {
  43. .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS,
  44. .driver_data = (unsigned long)&zorro7xx_driver_data[0],
  45. },
  46. {
  47. .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx,
  48. .driver_data = (unsigned long)&zorro7xx_driver_data[1],
  49. },
  50. {
  51. .id = ZORRO_PROD_CBM_A4091_1,
  52. .driver_data = (unsigned long)&zorro7xx_driver_data[2],
  53. },
  54. {
  55. .id = ZORRO_PROD_CBM_A4091_2,
  56. .driver_data = (unsigned long)&zorro7xx_driver_data[2],
  57. },
  58. {
  59. .id = ZORRO_PROD_GVP_GFORCE_040_060,
  60. .driver_data = (unsigned long)&zorro7xx_driver_data[3],
  61. },
  62. { 0 }
  63. };
  64. MODULE_DEVICE_TABLE(zorro, zorro7xx_zorro_tbl);
  65. static int zorro7xx_init_one(struct zorro_dev *z,
  66. const struct zorro_device_id *ent)
  67. {
  68. struct Scsi_Host *host;
  69. struct NCR_700_Host_Parameters *hostdata;
  70. struct zorro_driver_data *zdd;
  71. unsigned long board, ioaddr;
  72. board = zorro_resource_start(z);
  73. zdd = (struct zorro_driver_data *)ent->driver_data;
  74. if (zdd->absolute) {
  75. ioaddr = zdd->offset;
  76. } else {
  77. ioaddr = board + zdd->offset;
  78. }
  79. if (!zorro_request_device(z, zdd->name)) {
  80. printk(KERN_ERR "zorro7xx: cannot reserve region 0x%lx, abort\n",
  81. board);
  82. return -EBUSY;
  83. }
  84. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  85. if (!hostdata) {
  86. printk(KERN_ERR "zorro7xx: Failed to allocate host data\n");
  87. goto out_release;
  88. }
  89. /* Fill in the required pieces of hostdata */
  90. if (ioaddr > 0x01000000)
  91. hostdata->base = ioremap(ioaddr, zorro_resource_len(z));
  92. else
  93. hostdata->base = ZTWO_VADDR(ioaddr);
  94. hostdata->clock = 50;
  95. hostdata->chip710 = 1;
  96. /* Settings for at least WarpEngine 40xx */
  97. hostdata->ctest7_extra = CTEST7_TT1;
  98. zorro7xx_scsi_driver_template.name = zdd->name;
  99. /* and register the chip */
  100. host = NCR_700_detect(&zorro7xx_scsi_driver_template, hostdata,
  101. &z->dev);
  102. if (!host) {
  103. printk(KERN_ERR "zorro7xx: No host detected; "
  104. "board configuration problem?\n");
  105. goto out_free;
  106. }
  107. host->this_id = 7;
  108. host->base = ioaddr;
  109. host->irq = IRQ_AMIGA_PORTS;
  110. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "zorro7xx-scsi",
  111. host)) {
  112. printk(KERN_ERR "zorro7xx: request_irq failed\n");
  113. goto out_put_host;
  114. }
  115. zorro_set_drvdata(z, host);
  116. scsi_scan_host(host);
  117. return 0;
  118. out_put_host:
  119. scsi_host_put(host);
  120. out_free:
  121. if (ioaddr > 0x01000000)
  122. iounmap(hostdata->base);
  123. kfree(hostdata);
  124. out_release:
  125. zorro_release_device(z);
  126. return -ENODEV;
  127. }
  128. static void zorro7xx_remove_one(struct zorro_dev *z)
  129. {
  130. struct Scsi_Host *host = zorro_get_drvdata(z);
  131. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  132. scsi_remove_host(host);
  133. NCR_700_release(host);
  134. if (host->base > 0x01000000)
  135. iounmap(hostdata->base);
  136. kfree(hostdata);
  137. free_irq(host->irq, host);
  138. zorro_release_device(z);
  139. }
  140. static struct zorro_driver zorro7xx_driver = {
  141. .name = "zorro7xx-scsi",
  142. .id_table = zorro7xx_zorro_tbl,
  143. .probe = zorro7xx_init_one,
  144. .remove = zorro7xx_remove_one,
  145. };
  146. static int __init zorro7xx_scsi_init(void)
  147. {
  148. return zorro_register_driver(&zorro7xx_driver);
  149. }
  150. static void __exit zorro7xx_scsi_exit(void)
  151. {
  152. zorro_unregister_driver(&zorro7xx_driver);
  153. }
  154. module_init(zorro7xx_scsi_init);
  155. module_exit(zorro7xx_scsi_exit);