Lines Matching +full:module +full:- +full:instance
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/module.h>
34 struct Scsi_Host *instance = data; in a2091_intr() local
35 struct a2091_hostdata *hdata = shost_priv(instance); in a2091_intr()
36 unsigned int status = hdata->regs->ISTR; in a2091_intr()
42 spin_lock_irqsave(instance->host_lock, flags); in a2091_intr()
43 wd33c93_intr(instance); in a2091_intr()
44 spin_unlock_irqrestore(instance->host_lock, flags); in a2091_intr()
51 unsigned long len = scsi_pointer->this_residual; in dma_setup()
52 struct Scsi_Host *instance = cmd->device->host; in dma_setup() local
53 struct a2091_hostdata *hdata = shost_priv(instance); in dma_setup()
54 struct WD33C93_hostdata *wh = &hdata->wh; in dma_setup()
55 struct a2091_scsiregs *regs = hdata->regs; in dma_setup()
59 addr = dma_map_single(hdata->dev, scsi_pointer->ptr, in dma_setup()
61 if (dma_mapping_error(hdata->dev, addr)) { in dma_setup()
62 dev_warn(hdata->dev, "cannot map SCSI data block %p\n", in dma_setup()
63 scsi_pointer->ptr); in dma_setup()
66 scsi_pointer->dma_handle = addr; in dma_setup()
71 dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, in dma_setup()
72 scsi_pointer->this_residual, in dma_setup()
74 scsi_pointer->dma_handle = (dma_addr_t) NULL; in dma_setup()
76 wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; in dma_setup()
77 wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, in dma_setup()
81 if (!wh->dma_bounce_buffer) { in dma_setup()
82 wh->dma_bounce_len = 0; in dma_setup()
88 memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr, in dma_setup()
89 scsi_pointer->this_residual); in dma_setup()
93 addr = dma_map_single(hdata->dev, wh->dma_bounce_buffer, in dma_setup()
94 wh->dma_bounce_len, DMA_DIR(dir_in)); in dma_setup()
96 if (dma_mapping_error(hdata->dev, addr)) { in dma_setup()
97 dev_warn(hdata->dev, "cannot map bounce buffer %p\n", in dma_setup()
98 wh->dma_bounce_buffer); in dma_setup()
105 kfree(wh->dma_bounce_buffer); in dma_setup()
106 wh->dma_bounce_buffer = NULL; in dma_setup()
107 wh->dma_bounce_len = 0; in dma_setup()
111 scsi_pointer->dma_handle = addr; in dma_setup()
119 wh->dma_dir = dir_in; in dma_setup()
121 regs->CNTR = cntr; in dma_setup()
124 regs->ACR = addr; in dma_setup()
126 /* no more cache flush here - dma_map_single() takes care */ in dma_setup()
129 regs->ST_DMA = 1; in dma_setup()
135 static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, in dma_stop() argument
139 struct a2091_hostdata *hdata = shost_priv(instance); in dma_stop()
140 struct WD33C93_hostdata *wh = &hdata->wh; in dma_stop()
141 struct a2091_scsiregs *regs = hdata->regs; in dma_stop()
146 if (!wh->dma_dir) in dma_stop()
150 regs->CNTR = cntr; in dma_stop()
153 if (wh->dma_dir) { in dma_stop()
154 regs->FLUSH = 1; in dma_stop()
155 while (!(regs->ISTR & ISTR_FE_FLG)) in dma_stop()
160 regs->CINT = 1; in dma_stop()
163 regs->SP_DMA = 1; in dma_stop()
166 regs->CNTR = CNTR_PDMD | CNTR_INTEN; in dma_stop()
168 dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, in dma_stop()
169 scsi_pointer->this_residual, in dma_stop()
170 DMA_DIR(wh->dma_dir)); in dma_stop()
173 if (status && wh->dma_bounce_buffer) { in dma_stop()
174 if (wh->dma_dir) in dma_stop()
175 memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer, in dma_stop()
176 scsi_pointer->this_residual); in dma_stop()
177 kfree(wh->dma_bounce_buffer); in dma_stop()
178 wh->dma_bounce_buffer = NULL; in dma_stop()
179 wh->dma_bounce_len = 0; in dma_stop()
184 .module = THIS_MODULE,
196 .dma_boundary = PAGE_SIZE - 1,
202 struct Scsi_Host *instance; in a2091_probe() local
208 if (dma_set_mask_and_coherent(&z->dev, DMA_BIT_MASK(24))) { in a2091_probe()
209 dev_warn(&z->dev, "cannot use 24 bit DMA\n"); in a2091_probe()
210 return -ENODEV; in a2091_probe()
213 if (!request_mem_region(z->resource.start, 256, "wd33c93")) in a2091_probe()
214 return -EBUSY; in a2091_probe()
216 instance = scsi_host_alloc(&a2091_scsi_template, in a2091_probe()
218 if (!instance) { in a2091_probe()
219 error = -ENOMEM; in a2091_probe()
223 instance->irq = IRQ_AMIGA_PORTS; in a2091_probe()
224 instance->unique_id = z->slotaddr; in a2091_probe()
226 regs = ZTWO_VADDR(z->resource.start); in a2091_probe()
227 regs->DAWR = DAWR_A2091; in a2091_probe()
229 wdregs.SASR = ®s->SASR; in a2091_probe()
230 wdregs.SCMD = ®s->SCMD; in a2091_probe()
232 hdata = shost_priv(instance); in a2091_probe()
233 hdata->dev = &z->dev; in a2091_probe()
234 hdata->wh.no_sync = 0xff; in a2091_probe()
235 hdata->wh.fast = 0; in a2091_probe()
236 hdata->wh.dma_mode = CTRL_DMA; in a2091_probe()
237 hdata->regs = regs; in a2091_probe()
239 wd33c93_init(instance, wdregs, dma_setup, dma_stop, WD33C93_FS_8_10); in a2091_probe()
241 "A2091 SCSI", instance); in a2091_probe()
245 regs->CNTR = CNTR_PDMD | CNTR_INTEN; in a2091_probe()
247 error = scsi_add_host(instance, NULL); in a2091_probe()
251 zorro_set_drvdata(z, instance); in a2091_probe()
253 scsi_scan_host(instance); in a2091_probe()
257 free_irq(IRQ_AMIGA_PORTS, instance); in a2091_probe()
259 scsi_host_put(instance); in a2091_probe()
261 release_mem_region(z->resource.start, 256); in a2091_probe()
267 struct Scsi_Host *instance = zorro_get_drvdata(z); in a2091_remove() local
268 struct a2091_hostdata *hdata = shost_priv(instance); in a2091_remove()
270 hdata->regs->CNTR = 0; in a2091_remove()
271 scsi_remove_host(instance); in a2091_remove()
272 free_irq(IRQ_AMIGA_PORTS, instance); in a2091_remove()
273 scsi_host_put(instance); in a2091_remove()
274 release_mem_region(z->resource.start, 256); in a2091_remove()