zorro7xx.c 4.4 KB

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