agk-dm-dm-crypt-tidy-crypt_endio
[linux-2.6/linux-trees-mm.git] / drivers / scsi / zorro7xx.c
blobac67394c737319582f808fe779c1e2ef8f7c134e
1 /*
2 * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
3 * Amiga MacroSystemUS WarpEngine SCSI controller.
4 * Amiga Technologies/DKB A4091 SCSI controller.
6 * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
7 * plus modifications of the 53c7xx.c driver to support the Amiga.
9 * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/zorro.h>
16 #include <asm/amigaints.h>
17 #include <scsi/scsi_host.h>
18 #include <scsi/scsi_transport_spi.h>
20 #include "53c700.h"
22 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
23 MODULE_DESCRIPTION("Amiga Zorro NCR53C710 driver");
24 MODULE_LICENSE("GPL");
27 static struct scsi_host_template zorro7xx_scsi_driver_template = {
28 .proc_name = "zorro7xx",
29 .this_id = 7,
30 .module = THIS_MODULE,
33 static struct zorro_driver_data {
34 const char *name;
35 unsigned long offset;
36 int absolute; /* offset is absolute address */
37 } zorro7xx_driver_data[] __devinitdata = {
38 { .name = "PowerUP 603e+", .offset = 0xf40000, .absolute = 1 },
39 { .name = "WarpEngine 40xx", .offset = 0x40000 },
40 { .name = "A4091", .offset = 0x800000 },
41 { .name = "GForce 040/060", .offset = 0x40000 },
42 { 0 }
45 static struct zorro_device_id zorro7xx_zorro_tbl[] __devinitdata = {
47 .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS,
48 .driver_data = (unsigned long)&zorro7xx_driver_data[0],
51 .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx,
52 .driver_data = (unsigned long)&zorro7xx_driver_data[1],
55 .id = ZORRO_PROD_CBM_A4091_1,
56 .driver_data = (unsigned long)&zorro7xx_driver_data[2],
59 .id = ZORRO_PROD_CBM_A4091_2,
60 .driver_data = (unsigned long)&zorro7xx_driver_data[2],
63 .id = ZORRO_PROD_GVP_GFORCE_040_060,
64 .driver_data = (unsigned long)&zorro7xx_driver_data[3],
66 { 0 }
69 static int __devinit zorro7xx_init_one(struct zorro_dev *z,
70 const struct zorro_device_id *ent)
72 struct Scsi_Host *host;
73 struct NCR_700_Host_Parameters *hostdata;
74 struct zorro_driver_data *zdd;
75 unsigned long board, ioaddr;
77 board = zorro_resource_start(z);
78 zdd = (struct zorro_driver_data *)ent->driver_data;
80 if (zdd->absolute) {
81 ioaddr = zdd->offset;
82 } else {
83 ioaddr = board + zdd->offset;
86 if (!zorro_request_device(z, zdd->name)) {
87 printk(KERN_ERR "zorro7xx: cannot reserve region 0x%lx, abort\n",
88 board);
89 return -EBUSY;
92 hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
93 if (!hostdata) {
94 printk(KERN_ERR "zorro7xx: Failed to allocate host data\n");
95 goto out_release;
98 /* Fill in the required pieces of hostdata */
99 if (ioaddr > 0x01000000)
100 hostdata->base = ioremap(ioaddr, zorro_resource_len(z));
101 else
102 hostdata->base = (void __iomem *)ZTWO_VADDR(ioaddr);
104 hostdata->clock = 50;
105 hostdata->chip710 = 1;
107 /* Settings for at least WarpEngine 40xx */
108 hostdata->ctest7_extra = CTEST7_TT1;
110 zorro7xx_scsi_driver_template.name = zdd->name;
112 /* and register the chip */
113 host = NCR_700_detect(&zorro7xx_scsi_driver_template, hostdata,
114 &z->dev);
115 if (!host) {
116 printk(KERN_ERR "zorro7xx: No host detected; "
117 "board configuration problem?\n");
118 goto out_free;
121 host->this_id = 7;
122 host->base = ioaddr;
123 host->irq = IRQ_AMIGA_PORTS;
125 if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "zorro7xx-scsi",
126 host)) {
127 printk(KERN_ERR "zorro7xx: request_irq failed\n");
128 goto out_put_host;
131 zorro_set_drvdata(z, host);
132 scsi_scan_host(host);
134 return 0;
136 out_put_host:
137 scsi_host_put(host);
138 out_free:
139 if (ioaddr > 0x01000000)
140 iounmap(hostdata->base);
141 kfree(hostdata);
142 out_release:
143 zorro_release_device(z);
145 return -ENODEV;
148 static __devexit void zorro7xx_remove_one(struct zorro_dev *z)
150 struct Scsi_Host *host = zorro_get_drvdata(z);
151 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
153 scsi_remove_host(host);
155 NCR_700_release(host);
156 kfree(hostdata);
157 free_irq(host->irq, host);
158 zorro_release_device(z);
161 static struct zorro_driver zorro7xx_driver = {
162 .name = "zorro7xx-scsi",
163 .id_table = zorro7xx_zorro_tbl,
164 .probe = zorro7xx_init_one,
165 .remove = __devexit_p(zorro7xx_remove_one),
168 static int __init zorro7xx_scsi_init(void)
170 return zorro_register_driver(&zorro7xx_driver);
173 static void __exit zorro7xx_scsi_exit(void)
175 zorro_unregister_driver(&zorro7xx_driver);
178 module_init(zorro7xx_scsi_init);
179 module_exit(zorro7xx_scsi_exit);