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