amiga7xx.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
  3. * Amiga MacroSystemUS WarpEngine SCSI controller.
  4. * Amiga Technologies A4000T SCSI controller.
  5. * Amiga Technologies/DKB A4091 SCSI controller.
  6. *
  7. * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
  8. * plus modifications of the 53c7xx.c driver to support the Amiga.
  9. */
  10. #include <linux/types.h>
  11. #include <linux/mm.h>
  12. #include <linux/blkdev.h>
  13. #include <linux/sched.h>
  14. #include <linux/zorro.h>
  15. #include <linux/stat.h>
  16. #include <asm/setup.h>
  17. #include <asm/page.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/amigaints.h>
  20. #include <asm/amigahw.h>
  21. #include <asm/dma.h>
  22. #include <asm/irq.h>
  23. #include "scsi.h"
  24. #include <scsi/scsi_host.h>
  25. #include "53c7xx.h"
  26. #include "amiga7xx.h"
  27. static int amiga7xx_register_one(struct scsi_host_template *tpnt,
  28. unsigned long address)
  29. {
  30. long long options;
  31. int clock;
  32. if (!request_mem_region(address, 0x1000, "ncr53c710"))
  33. return 0;
  34. address = (unsigned long)z_ioremap(address, 0x1000);
  35. options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 | OPTION_INTFLY |
  36. OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS |
  37. OPTION_DISCONNECT;
  38. clock = 50000000; /* 50 MHz SCSI Clock */
  39. ncr53c7xx_init(tpnt, 0, 710, address, 0, IRQ_AMIGA_PORTS, DMA_NONE,
  40. options, clock);
  41. return 1;
  42. }
  43. #ifdef CONFIG_ZORRO
  44. static struct {
  45. zorro_id id;
  46. unsigned long offset;
  47. int absolute; /* offset is absolute address */
  48. } amiga7xx_table[] = {
  49. { .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS, .offset = 0xf40000,
  50. .absolute = 1 },
  51. { .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx, .offset = 0x40000 },
  52. { .id = ZORRO_PROD_CBM_A4091_1, .offset = 0x800000 },
  53. { .id = ZORRO_PROD_CBM_A4091_2, .offset = 0x800000 },
  54. { .id = ZORRO_PROD_GVP_GFORCE_040_060, .offset = 0x40000 },
  55. { 0 }
  56. };
  57. static int __init amiga7xx_zorro_detect(struct scsi_host_template *tpnt)
  58. {
  59. int num = 0, i;
  60. struct zorro_dev *z = NULL;
  61. unsigned long address;
  62. while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
  63. for (i = 0; amiga7xx_table[i].id; i++)
  64. if (z->id == amiga7xx_table[i].id)
  65. break;
  66. if (!amiga7xx_table[i].id)
  67. continue;
  68. if (amiga7xx_table[i].absolute)
  69. address = amiga7xx_table[i].offset;
  70. else
  71. address = z->resource.start + amiga7xx_table[i].offset;
  72. num += amiga7xx_register_one(tpnt, address);
  73. }
  74. return num;
  75. }
  76. #endif /* CONFIG_ZORRO */
  77. int __init amiga7xx_detect(struct scsi_host_template *tpnt)
  78. {
  79. static unsigned char called = 0;
  80. int num = 0;
  81. if (called || !MACH_IS_AMIGA)
  82. return 0;
  83. tpnt->proc_name = "Amiga7xx";
  84. if (AMIGAHW_PRESENT(A4000_SCSI))
  85. num += amiga7xx_register_one(tpnt, 0xdd0040);
  86. #ifdef CONFIG_ZORRO
  87. num += amiga7xx_zorro_detect(tpnt);
  88. #endif
  89. called = 1;
  90. return num;
  91. }
  92. static int amiga7xx_release(struct Scsi_Host *shost)
  93. {
  94. if (shost->irq)
  95. free_irq(shost->irq, NULL);
  96. if (shost->dma_channel != 0xff)
  97. free_dma(shost->dma_channel);
  98. if (shost->io_port && shost->n_io_port)
  99. release_region(shost->io_port, shost->n_io_port);
  100. scsi_unregister(shost);
  101. return 0;
  102. }
  103. static struct scsi_host_template driver_template = {
  104. .name = "Amiga NCR53c710 SCSI",
  105. .detect = amiga7xx_detect,
  106. .release = amiga7xx_release,
  107. .queuecommand = NCR53c7xx_queue_command,
  108. .abort = NCR53c7xx_abort,
  109. .reset = NCR53c7xx_reset,
  110. .can_queue = 24,
  111. .this_id = 7,
  112. .sg_tablesize = 63,
  113. .cmd_per_lun = 3,
  114. .use_clustering = DISABLE_CLUSTERING
  115. };
  116. #include "scsi_module.c"