Lines Matching +full:module +full:- +full:instance

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/dma-mapping.h>
11 #include <linux/module.h>
36 struct Scsi_Host *instance = data; in a3000_intr() local
37 struct a3000_hostdata *hdata = shost_priv(instance); in a3000_intr()
38 unsigned int status = hdata->regs->ISTR; in a3000_intr()
44 spin_lock_irqsave(instance->host_lock, flags); in a3000_intr()
45 wd33c93_intr(instance); in a3000_intr()
46 spin_unlock_irqrestore(instance->host_lock, flags); in a3000_intr()
49 pr_warn("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status); in a3000_intr()
56 unsigned long len = scsi_pointer->this_residual; in dma_setup()
57 struct Scsi_Host *instance = cmd->device->host; in dma_setup() local
58 struct a3000_hostdata *hdata = shost_priv(instance); in dma_setup()
59 struct WD33C93_hostdata *wh = &hdata->wh; in dma_setup()
60 struct a3000_scsiregs *regs = hdata->regs; in dma_setup()
64 addr = dma_map_single(hdata->dev, scsi_pointer->ptr, in dma_setup()
66 if (dma_mapping_error(hdata->dev, addr)) { in dma_setup()
67 dev_warn(hdata->dev, "cannot map SCSI data block %p\n", in dma_setup()
68 scsi_pointer->ptr); in dma_setup()
71 scsi_pointer->dma_handle = addr; in dma_setup()
78 * MSch 20220629 - only wrong alignment tested - bounce in dma_setup()
84 dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, in dma_setup()
85 scsi_pointer->this_residual, in dma_setup()
88 wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; in dma_setup()
89 wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, in dma_setup()
93 if (!wh->dma_bounce_buffer) { in dma_setup()
94 wh->dma_bounce_len = 0; in dma_setup()
95 scsi_pointer->dma_handle = (dma_addr_t) NULL; in dma_setup()
101 memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr, in dma_setup()
102 scsi_pointer->this_residual); in dma_setup()
105 addr = dma_map_single(hdata->dev, scsi_pointer->ptr, in dma_setup()
107 if (dma_mapping_error(hdata->dev, addr)) { in dma_setup()
108 dev_warn(hdata->dev, in dma_setup()
110 scsi_pointer->ptr); in dma_setup()
113 scsi_pointer->dma_handle = addr; in dma_setup()
121 wh->dma_dir = dir_in; in dma_setup()
123 regs->CNTR = cntr; in dma_setup()
126 regs->ACR = addr; in dma_setup()
128 /* no more cache flush here - dma_map_single() takes care */ in dma_setup()
132 regs->ST_DMA = 1; in dma_setup()
139 static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, in dma_stop() argument
143 struct a3000_hostdata *hdata = shost_priv(instance); in dma_stop()
144 struct WD33C93_hostdata *wh = &hdata->wh; in dma_stop()
145 struct a3000_scsiregs *regs = hdata->regs; in dma_stop()
150 if (!wh->dma_dir) in dma_stop()
153 regs->CNTR = cntr; in dma_stop()
157 if (wh->dma_dir) { in dma_stop()
158 regs->FLUSH = 1; in dma_stop()
160 while (!(regs->ISTR & ISTR_FE_FLG)) in dma_stop()
169 regs->CINT = 1; in dma_stop()
172 regs->SP_DMA = 1; in dma_stop()
176 regs->CNTR = CNTR_PDMD | CNTR_INTEN; in dma_stop()
179 dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, in dma_stop()
180 scsi_pointer->this_residual, in dma_stop()
181 DMA_DIR(wh->dma_dir)); in dma_stop()
184 if (status && wh->dma_bounce_buffer) { in dma_stop()
186 if (wh->dma_dir && SCpnt) in dma_stop()
187 memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer, in dma_stop()
188 scsi_pointer->this_residual); in dma_stop()
189 kfree(wh->dma_bounce_buffer); in dma_stop()
190 wh->dma_bounce_buffer = NULL; in dma_stop()
191 wh->dma_bounce_len = 0; in dma_stop()
193 kfree(wh->dma_bounce_buffer); in dma_stop()
194 wh->dma_bounce_buffer = NULL; in dma_stop()
195 wh->dma_bounce_len = 0; in dma_stop()
201 .module = THIS_MODULE,
202 .name = "Amiga 3000 built-in SCSI",
219 struct Scsi_Host *instance; in amiga_a3000_scsi_probe() local
225 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { in amiga_a3000_scsi_probe()
226 dev_warn(&pdev->dev, "cannot use 32 bit DMA\n"); in amiga_a3000_scsi_probe()
227 return -ENODEV; in amiga_a3000_scsi_probe()
232 return -ENODEV; in amiga_a3000_scsi_probe()
234 if (!request_mem_region(res->start, resource_size(res), "wd33c93")) in amiga_a3000_scsi_probe()
235 return -EBUSY; in amiga_a3000_scsi_probe()
237 instance = scsi_host_alloc(&amiga_a3000_scsi_template, in amiga_a3000_scsi_probe()
239 if (!instance) { in amiga_a3000_scsi_probe()
240 error = -ENOMEM; in amiga_a3000_scsi_probe()
244 instance->irq = IRQ_AMIGA_PORTS; in amiga_a3000_scsi_probe()
246 regs = ZTWO_VADDR(res->start); in amiga_a3000_scsi_probe()
247 regs->DAWR = DAWR_A3000; in amiga_a3000_scsi_probe()
249 wdregs.SASR = &regs->SASR; in amiga_a3000_scsi_probe()
250 wdregs.SCMD = &regs->SCMD; in amiga_a3000_scsi_probe()
252 hdata = shost_priv(instance); in amiga_a3000_scsi_probe()
253 hdata->dev = &pdev->dev; in amiga_a3000_scsi_probe()
254 hdata->wh.no_sync = 0xff; in amiga_a3000_scsi_probe()
255 hdata->wh.fast = 0; in amiga_a3000_scsi_probe()
256 hdata->wh.dma_mode = CTRL_DMA; in amiga_a3000_scsi_probe()
257 hdata->regs = regs; in amiga_a3000_scsi_probe()
259 wd33c93_init(instance, wdregs, dma_setup, dma_stop, WD33C93_FS_12_15); in amiga_a3000_scsi_probe()
261 "A3000 SCSI", instance); in amiga_a3000_scsi_probe()
265 regs->CNTR = CNTR_PDMD | CNTR_INTEN; in amiga_a3000_scsi_probe()
267 error = scsi_add_host(instance, NULL); in amiga_a3000_scsi_probe()
271 platform_set_drvdata(pdev, instance); in amiga_a3000_scsi_probe()
273 scsi_scan_host(instance); in amiga_a3000_scsi_probe()
277 free_irq(IRQ_AMIGA_PORTS, instance); in amiga_a3000_scsi_probe()
279 scsi_host_put(instance); in amiga_a3000_scsi_probe()
281 release_mem_region(res->start, resource_size(res)); in amiga_a3000_scsi_probe()
287 struct Scsi_Host *instance = platform_get_drvdata(pdev); in amiga_a3000_scsi_remove() local
288 struct a3000_hostdata *hdata = shost_priv(instance); in amiga_a3000_scsi_remove()
291 hdata->regs->CNTR = 0; in amiga_a3000_scsi_remove()
292 scsi_remove_host(instance); in amiga_a3000_scsi_remove()
293 free_irq(IRQ_AMIGA_PORTS, instance); in amiga_a3000_scsi_remove()
294 scsi_host_put(instance); in amiga_a3000_scsi_remove()
295 release_mem_region(res->start, resource_size(res)); in amiga_a3000_scsi_remove()
302 .name = "amiga-a3000-scsi",
308 MODULE_DESCRIPTION("Amiga 3000 built-in SCSI");
310 MODULE_ALIAS("platform:amiga-a3000-scsi");