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