zorro7xx.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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[] = {
  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[] = {
  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. MODULE_DEVICE_TABLE(zorro, zorro7xx_zorro_tbl);
  64. static int zorro7xx_init_one(struct zorro_dev *z,
  65. const struct zorro_device_id *ent)
  66. {
  67. struct Scsi_Host *host;
  68. struct NCR_700_Host_Parameters *hostdata;
  69. struct zorro_driver_data *zdd;
  70. unsigned long board, ioaddr;
  71. board = zorro_resource_start(z);
  72. zdd = (struct zorro_driver_data *)ent->driver_data;
  73. if (zdd->absolute) {
  74. ioaddr = zdd->offset;
  75. } else {
  76. ioaddr = board + zdd->offset;
  77. }
  78. if (!zorro_request_device(z, zdd->name)) {
  79. printk(KERN_ERR "zorro7xx: cannot reserve region 0x%lx, abort\n",
  80. board);
  81. return -EBUSY;
  82. }
  83. hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
  84. if (!hostdata) {
  85. printk(KERN_ERR "zorro7xx: Failed to allocate host data\n");
  86. goto out_release;
  87. }
  88. /* Fill in the required pieces of hostdata */
  89. if (ioaddr > 0x01000000)
  90. hostdata->base = ioremap(ioaddr, zorro_resource_len(z));
  91. else
  92. hostdata->base = ZTWO_VADDR(ioaddr);
  93. hostdata->clock = 50;
  94. hostdata->chip710 = 1;
  95. /* Settings for at least WarpEngine 40xx */
  96. hostdata->ctest7_extra = CTEST7_TT1;
  97. zorro7xx_scsi_driver_template.name = zdd->name;
  98. /* and register the chip */
  99. host = NCR_700_detect(&zorro7xx_scsi_driver_template, hostdata,
  100. &z->dev);
  101. if (!host) {
  102. printk(KERN_ERR "zorro7xx: No host detected; "
  103. "board configuration problem?\n");
  104. goto out_free;
  105. }
  106. host->this_id = 7;
  107. host->base = ioaddr;
  108. host->irq = IRQ_AMIGA_PORTS;
  109. if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "zorro7xx-scsi",
  110. host)) {
  111. printk(KERN_ERR "zorro7xx: request_irq failed\n");
  112. goto out_put_host;
  113. }
  114. zorro_set_drvdata(z, host);
  115. scsi_scan_host(host);
  116. return 0;
  117. out_put_host:
  118. scsi_host_put(host);
  119. out_free:
  120. if (ioaddr > 0x01000000)
  121. iounmap(hostdata->base);
  122. kfree(hostdata);
  123. out_release:
  124. zorro_release_device(z);
  125. return -ENODEV;
  126. }
  127. static void zorro7xx_remove_one(struct zorro_dev *z)
  128. {
  129. struct Scsi_Host *host = zorro_get_drvdata(z);
  130. struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
  131. scsi_remove_host(host);
  132. NCR_700_release(host);
  133. kfree(hostdata);
  134. free_irq(host->irq, host);
  135. zorro_release_device(z);
  136. }
  137. static struct zorro_driver zorro7xx_driver = {
  138. .name = "zorro7xx-scsi",
  139. .id_table = zorro7xx_zorro_tbl,
  140. .probe = zorro7xx_init_one,
  141. .remove = zorro7xx_remove_one,
  142. };
  143. static int __init zorro7xx_scsi_init(void)
  144. {
  145. return zorro_register_driver(&zorro7xx_driver);
  146. }
  147. static void __exit zorro7xx_scsi_exit(void)
  148. {
  149. zorro_unregister_driver(&zorro7xx_driver);
  150. }
  151. module_init(zorro7xx_scsi_init);
  152. module_exit(zorro7xx_scsi_exit);