amiga7xx.c 3.5 KB

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