zorro7xx.c 4.4 KB

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