diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2009-08-16 05:17:35 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-26 13:51:08 -0400 |
commit | c737e22cde37e4e2ad126316e4aab7349a491ab3 (patch) | |
tree | 0989a46d73a2b63ebf5fa8d364d2affa10dd676b /drivers | |
parent | 5d3f2c38603289fdaa60644ceb93307f0abc77de (diff) |
m68k: amiga - A2091/A590 SCSI zorro_driver conversion
Acked-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/a2091.c | 186 |
1 files changed, 102 insertions, 84 deletions
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index 09b3d77db03f..fc4fce99528e 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c | |||
@@ -1,28 +1,20 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/mm.h> | ||
3 | #include <linux/slab.h> | ||
4 | #include <linux/blkdev.h> | ||
5 | #include <linux/init.h> | 2 | #include <linux/init.h> |
6 | #include <linux/interrupt.h> | 3 | #include <linux/interrupt.h> |
4 | #include <linux/mm.h> | ||
5 | #include <linux/slab.h> | ||
6 | #include <linux/spinlock.h> | ||
7 | #include <linux/zorro.h> | ||
7 | 8 | ||
8 | #include <asm/setup.h> | ||
9 | #include <asm/page.h> | 9 | #include <asm/page.h> |
10 | #include <asm/pgtable.h> | 10 | #include <asm/pgtable.h> |
11 | #include <asm/amigaints.h> | 11 | #include <asm/amigaints.h> |
12 | #include <asm/amigahw.h> | 12 | #include <asm/amigahw.h> |
13 | #include <linux/zorro.h> | ||
14 | #include <asm/irq.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | 13 | ||
17 | #include "scsi.h" | 14 | #include "scsi.h" |
18 | #include <scsi/scsi_host.h> | ||
19 | #include "wd33c93.h" | 15 | #include "wd33c93.h" |
20 | #include "a2091.h" | 16 | #include "a2091.h" |
21 | 17 | ||
22 | #include <linux/stat.h> | ||
23 | |||
24 | |||
25 | static int a2091_release(struct Scsi_Host *instance); | ||
26 | 18 | ||
27 | static irqreturn_t a2091_intr(int irq, void *data) | 19 | static irqreturn_t a2091_intr(int irq, void *data) |
28 | { | 20 | { |
@@ -147,85 +139,27 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
147 | } | 139 | } |
148 | } | 140 | } |
149 | 141 | ||
150 | static int __init a2091_detect(struct scsi_host_template *tpnt) | ||
151 | { | ||
152 | static unsigned char called = 0; | ||
153 | struct Scsi_Host *instance; | ||
154 | unsigned long address; | ||
155 | struct zorro_dev *z = NULL; | ||
156 | wd33c93_regs wdregs; | ||
157 | struct a2091_scsiregs *regs; | ||
158 | struct WD33C93_hostdata *hdata; | ||
159 | int num_a2091 = 0; | ||
160 | |||
161 | if (!MACH_IS_AMIGA || called) | ||
162 | return 0; | ||
163 | called = 1; | ||
164 | |||
165 | tpnt->proc_name = "A2091"; | ||
166 | tpnt->proc_info = &wd33c93_proc_info; | ||
167 | |||
168 | while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { | ||
169 | if (z->id != ZORRO_PROD_CBM_A590_A2091_1 && | ||
170 | z->id != ZORRO_PROD_CBM_A590_A2091_2) | ||
171 | continue; | ||
172 | address = z->resource.start; | ||
173 | if (!request_mem_region(address, 256, "wd33c93")) | ||
174 | continue; | ||
175 | |||
176 | instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); | ||
177 | if (instance == NULL) | ||
178 | goto release; | ||
179 | instance->base = ZTWO_VADDR(address); | ||
180 | instance->irq = IRQ_AMIGA_PORTS; | ||
181 | instance->unique_id = z->slotaddr; | ||
182 | regs = (struct a2091_scsiregs *)(instance->base); | ||
183 | regs->DAWR = DAWR_A2091; | ||
184 | wdregs.SASR = ®s->SASR; | ||
185 | wdregs.SCMD = ®s->SCMD; | ||
186 | hdata = shost_priv(instance); | ||
187 | hdata->no_sync = 0xff; | ||
188 | hdata->fast = 0; | ||
189 | hdata->dma_mode = CTRL_DMA; | ||
190 | wd33c93_init(instance, wdregs, dma_setup, dma_stop, | ||
191 | WD33C93_FS_8_10); | ||
192 | if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, | ||
193 | "A2091 SCSI", instance)) | ||
194 | goto unregister; | ||
195 | regs->CNTR = CNTR_PDMD | CNTR_INTEN; | ||
196 | num_a2091++; | ||
197 | continue; | ||
198 | |||
199 | unregister: | ||
200 | scsi_unregister(instance); | ||
201 | release: | ||
202 | release_mem_region(address, 256); | ||
203 | } | ||
204 | |||
205 | return num_a2091; | ||
206 | } | ||
207 | |||
208 | static int a2091_bus_reset(struct scsi_cmnd *cmd) | 142 | static int a2091_bus_reset(struct scsi_cmnd *cmd) |
209 | { | 143 | { |
144 | struct Scsi_Host *instance = cmd->device->host; | ||
145 | |||
210 | /* FIXME perform bus-specific reset */ | 146 | /* FIXME perform bus-specific reset */ |
211 | 147 | ||
212 | /* FIXME 2: kill this function, and let midlayer fall back | 148 | /* FIXME 2: kill this function, and let midlayer fall back |
213 | to the same action, calling wd33c93_host_reset() */ | 149 | to the same action, calling wd33c93_host_reset() */ |
214 | 150 | ||
215 | spin_lock_irq(cmd->device->host->host_lock); | 151 | spin_lock_irq(instance->host_lock); |
216 | wd33c93_host_reset(cmd); | 152 | wd33c93_host_reset(cmd); |
217 | spin_unlock_irq(cmd->device->host->host_lock); | 153 | spin_unlock_irq(instance->host_lock); |
218 | 154 | ||
219 | return SUCCESS; | 155 | return SUCCESS; |
220 | } | 156 | } |
221 | 157 | ||
222 | #define HOSTS_C | 158 | static struct scsi_host_template a2091_scsi_template = { |
223 | 159 | .module = THIS_MODULE, | |
224 | static struct scsi_host_template driver_template = { | ||
225 | .proc_name = "A2901", | ||
226 | .name = "Commodore A2091/A590 SCSI", | 160 | .name = "Commodore A2091/A590 SCSI", |
227 | .detect = a2091_detect, | 161 | .proc_info = wd33c93_proc_info, |
228 | .release = a2091_release, | 162 | .proc_name = "A2901", |
229 | .queuecommand = wd33c93_queuecommand, | 163 | .queuecommand = wd33c93_queuecommand, |
230 | .eh_abort_handler = wd33c93_abort, | 164 | .eh_abort_handler = wd33c93_abort, |
231 | .eh_bus_reset_handler = a2091_bus_reset, | 165 | .eh_bus_reset_handler = a2091_bus_reset, |
@@ -237,19 +171,103 @@ static struct scsi_host_template driver_template = { | |||
237 | .use_clustering = DISABLE_CLUSTERING | 171 | .use_clustering = DISABLE_CLUSTERING |
238 | }; | 172 | }; |
239 | 173 | ||
174 | static int __devinit a2091_probe(struct zorro_dev *z, | ||
175 | const struct zorro_device_id *ent) | ||
176 | { | ||
177 | struct Scsi_Host *instance; | ||
178 | int error; | ||
179 | struct a2091_scsiregs *regs; | ||
180 | wd33c93_regs wdregs; | ||
181 | struct WD33C93_hostdata *hdata; | ||
182 | |||
183 | if (!request_mem_region(z->resource.start, 256, "wd33c93")) | ||
184 | return -EBUSY; | ||
185 | |||
186 | instance = scsi_host_alloc(&a2091_scsi_template, | ||
187 | sizeof(struct WD33C93_hostdata)); | ||
188 | if (!instance) { | ||
189 | error = -ENOMEM; | ||
190 | goto fail_alloc; | ||
191 | } | ||
192 | |||
193 | instance->base = ZTWO_VADDR(z->resource.start); | ||
194 | instance->irq = IRQ_AMIGA_PORTS; | ||
195 | instance->unique_id = z->slotaddr; | ||
196 | |||
197 | regs = (struct a2091_scsiregs *)(instance->base); | ||
198 | regs->DAWR = DAWR_A2091; | ||
199 | |||
200 | wdregs.SASR = ®s->SASR; | ||
201 | wdregs.SCMD = ®s->SCMD; | ||
240 | 202 | ||
241 | #include "scsi_module.c" | 203 | hdata = shost_priv(instance); |
204 | hdata->no_sync = 0xff; | ||
205 | hdata->fast = 0; | ||
206 | hdata->dma_mode = CTRL_DMA; | ||
207 | |||
208 | wd33c93_init(instance, wdregs, dma_setup, dma_stop, WD33C93_FS_8_10); | ||
209 | error = request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, | ||
210 | "A2091 SCSI", instance); | ||
211 | if (error) | ||
212 | goto fail_irq; | ||
213 | |||
214 | regs->CNTR = CNTR_PDMD | CNTR_INTEN; | ||
215 | |||
216 | error = scsi_add_host(instance, NULL); | ||
217 | if (error) | ||
218 | goto fail_host; | ||
219 | |||
220 | zorro_set_drvdata(z, instance); | ||
221 | |||
222 | scsi_scan_host(instance); | ||
223 | return 0; | ||
242 | 224 | ||
243 | static int a2091_release(struct Scsi_Host *instance) | 225 | fail_host: |
226 | free_irq(IRQ_AMIGA_PORTS, instance); | ||
227 | fail_irq: | ||
228 | scsi_host_put(instance); | ||
229 | fail_alloc: | ||
230 | release_mem_region(z->resource.start, 256); | ||
231 | return error; | ||
232 | } | ||
233 | |||
234 | static void __devexit a2091_remove(struct zorro_dev *z) | ||
244 | { | 235 | { |
245 | #ifdef MODULE | 236 | struct Scsi_Host *instance = zorro_get_drvdata(z); |
246 | struct a2091_scsiregs *regs = (struct a2091_scsiregs *)(instance->base); | 237 | struct a2091_scsiregs *regs = (struct a2091_scsiregs *)(instance->base); |
247 | 238 | ||
248 | regs->CNTR = 0; | 239 | regs->CNTR = 0; |
249 | release_mem_region(ZTWO_PADDR(instance->base), 256); | 240 | scsi_remove_host(instance); |
250 | free_irq(IRQ_AMIGA_PORTS, instance); | 241 | free_irq(IRQ_AMIGA_PORTS, instance); |
251 | #endif | 242 | scsi_host_put(instance); |
252 | return 1; | 243 | release_mem_region(z->resource.start, 256); |
244 | } | ||
245 | |||
246 | static struct zorro_device_id a2091_zorro_tbl[] __devinitdata = { | ||
247 | { ZORRO_PROD_CBM_A590_A2091_1 }, | ||
248 | { ZORRO_PROD_CBM_A590_A2091_2 }, | ||
249 | { 0 } | ||
250 | }; | ||
251 | MODULE_DEVICE_TABLE(zorro, a2091_zorro_tbl); | ||
252 | |||
253 | static struct zorro_driver a2091_driver = { | ||
254 | .name = "a2091", | ||
255 | .id_table = a2091_zorro_tbl, | ||
256 | .probe = a2091_probe, | ||
257 | .remove = __devexit_p(a2091_remove), | ||
258 | }; | ||
259 | |||
260 | static int __init a2091_init(void) | ||
261 | { | ||
262 | return zorro_register_driver(&a2091_driver); | ||
263 | } | ||
264 | module_init(a2091_init); | ||
265 | |||
266 | static void __exit a2091_exit(void) | ||
267 | { | ||
268 | zorro_unregister_driver(&a2091_driver); | ||
253 | } | 269 | } |
270 | module_exit(a2091_exit); | ||
254 | 271 | ||
272 | MODULE_DESCRIPTION("Commodore A2091/A590 SCSI"); | ||
255 | MODULE_LICENSE("GPL"); | 273 | MODULE_LICENSE("GPL"); |