zorro7xx.c 4.4 KB

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