1 // SPDX-License-Identifier: GPL-2.0-only
3 * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
4 * Amiga MacroSystemUS WarpEngine 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.
10 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <linux/zorro.h>
17 #include <linux/slab.h>
19 #include <asm/amigahw.h>
20 #include <asm/amigaints.h>
22 #include <scsi/scsi_host.h>
23 #include <scsi/scsi_transport_spi.h>
27 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
28 MODULE_DESCRIPTION("Amiga Zorro NCR53C710 driver");
29 MODULE_LICENSE("GPL");
32 static struct scsi_host_template zorro7xx_scsi_driver_template
= {
33 .proc_name
= "zorro7xx",
35 .module
= THIS_MODULE
,
38 static struct zorro_driver_data
{
41 int absolute
; /* offset is absolute address */
42 } zorro7xx_driver_data
[] = {
43 { .name
= "PowerUP 603e+", .offset
= 0xf40000, .absolute
= 1 },
44 { .name
= "WarpEngine 40xx", .offset
= 0x40000 },
45 { .name
= "A4091", .offset
= 0x800000 },
46 { .name
= "GForce 040/060", .offset
= 0x40000 },
50 static struct zorro_device_id zorro7xx_zorro_tbl
[] = {
52 .id
= ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS
,
53 .driver_data
= (unsigned long)&zorro7xx_driver_data
[0],
56 .id
= ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx
,
57 .driver_data
= (unsigned long)&zorro7xx_driver_data
[1],
60 .id
= ZORRO_PROD_CBM_A4091_1
,
61 .driver_data
= (unsigned long)&zorro7xx_driver_data
[2],
64 .id
= ZORRO_PROD_CBM_A4091_2
,
65 .driver_data
= (unsigned long)&zorro7xx_driver_data
[2],
68 .id
= ZORRO_PROD_GVP_GFORCE_040_060
,
69 .driver_data
= (unsigned long)&zorro7xx_driver_data
[3],
73 MODULE_DEVICE_TABLE(zorro
, zorro7xx_zorro_tbl
);
75 static int zorro7xx_init_one(struct zorro_dev
*z
,
76 const struct zorro_device_id
*ent
)
78 struct Scsi_Host
*host
;
79 struct NCR_700_Host_Parameters
*hostdata
;
80 struct zorro_driver_data
*zdd
;
81 unsigned long board
, ioaddr
;
83 board
= zorro_resource_start(z
);
84 zdd
= (struct zorro_driver_data
*)ent
->driver_data
;
89 ioaddr
= board
+ zdd
->offset
;
92 if (!zorro_request_device(z
, zdd
->name
)) {
93 printk(KERN_ERR
"zorro7xx: cannot reserve region 0x%lx, abort\n",
98 hostdata
= kzalloc(sizeof(struct NCR_700_Host_Parameters
), GFP_KERNEL
);
100 printk(KERN_ERR
"zorro7xx: Failed to allocate host data\n");
104 /* Fill in the required pieces of hostdata */
105 if (ioaddr
> 0x01000000)
106 hostdata
->base
= ioremap(ioaddr
, zorro_resource_len(z
));
108 hostdata
->base
= ZTWO_VADDR(ioaddr
);
110 hostdata
->clock
= 50;
111 hostdata
->chip710
= 1;
113 /* Settings for at least WarpEngine 40xx */
114 hostdata
->ctest7_extra
= CTEST7_TT1
;
116 zorro7xx_scsi_driver_template
.name
= zdd
->name
;
118 /* and register the chip */
119 host
= NCR_700_detect(&zorro7xx_scsi_driver_template
, hostdata
,
122 printk(KERN_ERR
"zorro7xx: No host detected; "
123 "board configuration problem?\n");
129 host
->irq
= IRQ_AMIGA_PORTS
;
131 if (request_irq(host
->irq
, NCR_700_intr
, IRQF_SHARED
, "zorro7xx-scsi",
133 printk(KERN_ERR
"zorro7xx: request_irq failed\n");
137 zorro_set_drvdata(z
, host
);
138 scsi_scan_host(host
);
145 if (ioaddr
> 0x01000000)
146 iounmap(hostdata
->base
);
149 zorro_release_device(z
);
154 static void zorro7xx_remove_one(struct zorro_dev
*z
)
156 struct Scsi_Host
*host
= zorro_get_drvdata(z
);
157 struct NCR_700_Host_Parameters
*hostdata
= shost_priv(host
);
159 scsi_remove_host(host
);
161 NCR_700_release(host
);
163 free_irq(host
->irq
, host
);
164 zorro_release_device(z
);
167 static struct zorro_driver zorro7xx_driver
= {
168 .name
= "zorro7xx-scsi",
169 .id_table
= zorro7xx_zorro_tbl
,
170 .probe
= zorro7xx_init_one
,
171 .remove
= zorro7xx_remove_one
,
174 static int __init
zorro7xx_scsi_init(void)
176 return zorro_register_driver(&zorro7xx_driver
);
179 static void __exit
zorro7xx_scsi_exit(void)
181 zorro_unregister_driver(&zorro7xx_driver
);
184 module_init(zorro7xx_scsi_init
);
185 module_exit(zorro7xx_scsi_exit
);