RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / drivers / scsi / amiga7xx.c
blobd5d3c4d5a253966986eedbfd0ed0a618153ac2aa
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.
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/zorro.h>
14 #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>
24 #include "scsi.h"
25 #include <scsi/scsi_host.h>
26 #include "53c7xx.h"
27 #include "amiga7xx.h"
30 static int amiga7xx_register_one(struct scsi_host_template *tpnt,
31 unsigned long address)
33 long long options;
34 int clock;
36 if (!request_mem_region(address, 0x1000, "ncr53c710"))
37 return 0;
39 address = (unsigned long)z_ioremap(address, 0x1000);
40 options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 | OPTION_INTFLY |
41 OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS |
42 OPTION_DISCONNECT;
43 clock = 50000000; /* 50 MHz SCSI Clock */
44 ncr53c7xx_init(tpnt, 0, 710, address, 0, IRQ_AMIGA_PORTS, DMA_NONE,
45 options, clock);
46 return 1;
50 #ifdef CONFIG_ZORRO
52 static struct {
53 zorro_id id;
54 unsigned long offset;
55 int absolute; /* offset is absolute address */
56 } amiga7xx_table[] = {
57 { .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS, .offset = 0xf40000,
58 .absolute = 1 },
59 { .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx, .offset = 0x40000 },
60 { .id = ZORRO_PROD_CBM_A4091_1, .offset = 0x800000 },
61 { .id = ZORRO_PROD_CBM_A4091_2, .offset = 0x800000 },
62 { .id = ZORRO_PROD_GVP_GFORCE_040_060, .offset = 0x40000 },
63 { 0 }
66 static int __init amiga7xx_zorro_detect(struct scsi_host_template *tpnt)
68 int num = 0, i;
69 struct zorro_dev *z = NULL;
70 unsigned long address;
72 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
73 for (i = 0; amiga7xx_table[i].id; i++)
74 if (z->id == amiga7xx_table[i].id)
75 break;
76 if (!amiga7xx_table[i].id)
77 continue;
78 if (amiga7xx_table[i].absolute)
79 address = amiga7xx_table[i].offset;
80 else
81 address = z->resource.start + amiga7xx_table[i].offset;
82 num += amiga7xx_register_one(tpnt, address);
84 return num;
87 #endif /* CONFIG_ZORRO */
90 int __init amiga7xx_detect(struct scsi_host_template *tpnt)
92 static unsigned char called = 0;
93 int num = 0;
95 if (called || !MACH_IS_AMIGA)
96 return 0;
98 tpnt->proc_name = "Amiga7xx";
100 if (AMIGAHW_PRESENT(A4000_SCSI))
101 num += amiga7xx_register_one(tpnt, 0xdd0040);
103 #ifdef CONFIG_ZORRO
104 num += amiga7xx_zorro_detect(tpnt);
105 #endif
107 called = 1;
108 return num;
111 static int amiga7xx_release(struct Scsi_Host *shost)
113 if (shost->irq)
114 free_irq(shost->irq, NULL);
115 if (shost->dma_channel != 0xff)
116 free_dma(shost->dma_channel);
117 if (shost->io_port && shost->n_io_port)
118 release_region(shost->io_port, shost->n_io_port);
119 scsi_unregister(shost);
120 return 0;
123 static struct scsi_host_template driver_template = {
124 .name = "Amiga NCR53c710 SCSI",
125 .detect = amiga7xx_detect,
126 .release = amiga7xx_release,
127 .queuecommand = NCR53c7xx_queue_command,
128 .abort = NCR53c7xx_abort,
129 .reset = NCR53c7xx_reset,
130 .can_queue = 24,
131 .this_id = 7,
132 .sg_tablesize = 63,
133 .cmd_per_lun = 3,
134 .use_clustering = DISABLE_CLUSTERING
138 #include "scsi_module.c"