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