[SCSI] qla2xxx: Verify the RISC is not in ROM code if firmware-load is disabled.
[linux-2.6] / drivers / scsi / zorro7xx.c
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.
5  *
6  * Written 1997 by Alan Hourihane <alanh@fairlite.demon.co.uk>
7  * plus modifications of the 53c7xx.c driver to support the Amiga.
8  *
9  * Rewritten to use 53c700.c by Kars de Jong <jongk@linux-m68k.org>
10  */
11
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/zorro.h>
16
17 #include <asm/amigahw.h>
18 #include <asm/amigaints.h>
19
20 #include <scsi/scsi_host.h>
21 #include <scsi/scsi_transport_spi.h>
22
23 #include "53c700.h"
24
25 MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>");
26 MODULE_DESCRIPTION("Amiga Zorro NCR53C710 driver");
27 MODULE_LICENSE("GPL");
28
29
30 static struct scsi_host_template zorro7xx_scsi_driver_template = {
31         .proc_name      = "zorro7xx",
32         .this_id        = 7,
33         .module         = THIS_MODULE,
34 };
35
36 static struct zorro_driver_data {
37         const char *name;
38         unsigned long offset;
39         int absolute;   /* offset is absolute address */
40 } zorro7xx_driver_data[] __devinitdata = {
41         { .name = "PowerUP 603e+", .offset = 0xf40000, .absolute = 1 },
42         { .name = "WarpEngine 40xx", .offset = 0x40000 },
43         { .name = "A4091", .offset = 0x800000 },
44         { .name = "GForce 040/060", .offset = 0x40000 },
45         { 0 }
46 };
47
48 static struct zorro_device_id zorro7xx_zorro_tbl[] __devinitdata = {
49         {
50                 .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS,
51                 .driver_data = (unsigned long)&zorro7xx_driver_data[0],
52         },
53         {
54                 .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx,
55                 .driver_data = (unsigned long)&zorro7xx_driver_data[1],
56         },
57         {
58                 .id = ZORRO_PROD_CBM_A4091_1,
59                 .driver_data = (unsigned long)&zorro7xx_driver_data[2],
60         },
61         {
62                 .id = ZORRO_PROD_CBM_A4091_2,
63                 .driver_data = (unsigned long)&zorro7xx_driver_data[2],
64         },
65         {
66                 .id = ZORRO_PROD_GVP_GFORCE_040_060,
67                 .driver_data = (unsigned long)&zorro7xx_driver_data[3],
68         },
69         { 0 }
70 };
71
72 static int __devinit zorro7xx_init_one(struct zorro_dev *z,
73                                        const struct zorro_device_id *ent)
74 {
75         struct Scsi_Host *host;
76         struct NCR_700_Host_Parameters *hostdata;
77         struct zorro_driver_data *zdd;
78         unsigned long board, ioaddr;
79
80         board = zorro_resource_start(z);
81         zdd = (struct zorro_driver_data *)ent->driver_data;
82
83         if (zdd->absolute) {
84                 ioaddr = zdd->offset;
85         } else {
86                 ioaddr = board + zdd->offset;
87         }
88
89         if (!zorro_request_device(z, zdd->name)) {
90                 printk(KERN_ERR "zorro7xx: cannot reserve region 0x%lx, abort\n",
91                        board);
92                 return -EBUSY;
93         }
94
95         hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
96         if (!hostdata) {
97                 printk(KERN_ERR "zorro7xx: Failed to allocate host data\n");
98                 goto out_release;
99         }
100
101         /* Fill in the required pieces of hostdata */
102         if (ioaddr > 0x01000000)
103                 hostdata->base = ioremap(ioaddr, zorro_resource_len(z));
104         else
105                 hostdata->base = (void __iomem *)ZTWO_VADDR(ioaddr);
106
107         hostdata->clock = 50;
108         hostdata->chip710 = 1;
109
110         /* Settings for at least WarpEngine 40xx */
111         hostdata->ctest7_extra = CTEST7_TT1;
112
113         zorro7xx_scsi_driver_template.name = zdd->name;
114
115         /* and register the chip */
116         host = NCR_700_detect(&zorro7xx_scsi_driver_template, hostdata,
117                               &z->dev);
118         if (!host) {
119                 printk(KERN_ERR "zorro7xx: No host detected; "
120                                 "board configuration problem?\n");
121                 goto out_free;
122         }
123
124         host->this_id = 7;
125         host->base = ioaddr;
126         host->irq = IRQ_AMIGA_PORTS;
127
128         if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "zorro7xx-scsi",
129                         host)) {
130                 printk(KERN_ERR "zorro7xx: request_irq failed\n");
131                 goto out_put_host;
132         }
133
134         zorro_set_drvdata(z, host);
135         scsi_scan_host(host);
136
137         return 0;
138
139  out_put_host:
140         scsi_host_put(host);
141  out_free:
142         if (ioaddr > 0x01000000)
143                 iounmap(hostdata->base);
144         kfree(hostdata);
145  out_release:
146         zorro_release_device(z);
147
148         return -ENODEV;
149 }
150
151 static __devexit void zorro7xx_remove_one(struct zorro_dev *z)
152 {
153         struct Scsi_Host *host = zorro_get_drvdata(z);
154         struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
155
156         scsi_remove_host(host);
157
158         NCR_700_release(host);
159         kfree(hostdata);
160         free_irq(host->irq, host);
161         zorro_release_device(z);
162 }
163
164 static struct zorro_driver zorro7xx_driver = {
165         .name     = "zorro7xx-scsi",
166         .id_table = zorro7xx_zorro_tbl,
167         .probe    = zorro7xx_init_one,
168         .remove   = __devexit_p(zorro7xx_remove_one),
169 };
170
171 static int __init zorro7xx_scsi_init(void)
172 {
173         return zorro_register_driver(&zorro7xx_driver);
174 }
175
176 static void __exit zorro7xx_scsi_exit(void)
177 {
178         zorro_unregister_driver(&zorro7xx_driver);
179 }
180
181 module_init(zorro7xx_scsi_init);
182 module_exit(zorro7xx_scsi_exit);