Lines Matching +full:pio +full:- +full:transfer
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1997-2005 Russell King
8 * 30-08-1997 RMK 0.0.0 Created, READONLY version.
9 * 22-01-1998 RMK 0.0.1 Updated to 2.1.80.
10 * 15-04-1998 RMK 0.0.1 Only do PIO if FAS216 will allow it.
11 * 02-05-1998 RMK 0.0.2 Updated & added DMA support.
12 * 27-06-1998 RMK Changed asm/delay.h to linux/delay.h
13 * 18-08-1998 RMK 0.0.3 Fixed synchronous transfer depth.
14 * 02-04-2000 RMK 0.0.4 Updated for new error handling code.
25 #include <linux/dma-mapping.h>
90 * Params : ec - expansion card structure
91 * : irqnr - interrupt number
96 struct cumanascsi2_info *info = ec->irq_data; in cumanascsi_2_irqenable()
97 writeb(ALATCH_ENA_INT, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_irqenable()
102 * Params : ec - expansion card structure
103 * : irqnr - interrupt number
108 struct cumanascsi2_info *info = ec->irq_data; in cumanascsi_2_irqdisable()
109 writeb(ALATCH_DIS_INT, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_irqdisable()
119 * Params : host - card to turn on/off
120 * : on_off - !0 to turn on, 0 to turn off
125 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_terminator_ctl()
128 info->terms = 1; in cumanascsi_2_terminator_ctl()
129 writeb(ALATCH_ENA_TERM, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_terminator_ctl()
131 info->terms = 0; in cumanascsi_2_terminator_ctl()
132 writeb(ALATCH_DIS_TERM, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_terminator_ctl()
138 * Params : irq - interrupt number
139 * dev_id - user-defined (Scsi_Host structure)
146 return fas216_intr(&info->info); in cumanascsi_2_intr()
150 * Purpose : initialises DMA/PIO
151 * Params : host - host
152 * SCpnt - command
153 * direction - DMA on to/off of card
154 * min_type - minimum DMA support that we must have for this transfer
155 * Returns : type of transfer to be performed
161 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_dma_setup()
163 int dmach = info->info.scsi.dma; in cumanascsi_2_dma_setup()
165 writeb(ALATCH_DIS_DMA, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_dma_setup()
168 (min_type == fasdma_real_all || SCp->this_residual >= 512)) { in cumanascsi_2_dma_setup()
171 bufs = copy_SCp_to_sg(&info->sg[0], SCp, NR_SG); in cumanascsi_2_dma_setup()
183 dma_map_sg(dev, info->sg, bufs, map_dir); in cumanascsi_2_dma_setup()
186 set_dma_sg(dmach, info->sg, bufs); in cumanascsi_2_dma_setup()
187 writeb(alatch_dir, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_dma_setup()
190 writeb(ALATCH_ENA_DMA, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_dma_setup()
191 writeb(ALATCH_DIS_BIT32, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_dma_setup()
203 * Prototype: void cumanascsi_2_dma_pseudo(host, SCpnt, direction, transfer)
205 * Params : host - host
206 * SCpnt - command
207 * direction - DMA on to/off of card
208 * transfer - minimum number of bytes we expect to transfer
212 fasdmadir_t direction, int transfer) in cumanascsi_2_dma_pseudo() argument
214 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_dma_pseudo()
218 length = SCp->this_residual; in cumanascsi_2_dma_pseudo()
219 addr = SCp->ptr; in cumanascsi_2_dma_pseudo()
225 unsigned int status = readb(info->base + CUMANASCSI2_STATUS); in cumanascsi_2_dma_pseudo()
234 writew(word, info->base + CUMANASCSI2_PSEUDODMA); in cumanascsi_2_dma_pseudo()
236 length -= 2; in cumanascsi_2_dma_pseudo()
242 if (transfer && (transfer & 255)) { in cumanascsi_2_dma_pseudo()
244 unsigned int status = readb(info->base + CUMANASCSI2_STATUS); in cumanascsi_2_dma_pseudo()
252 readsw(info->base + CUMANASCSI2_PSEUDODMA, in cumanascsi_2_dma_pseudo()
255 length -= 256; in cumanascsi_2_dma_pseudo()
261 unsigned int status = readb(info->base + CUMANASCSI2_STATUS); in cumanascsi_2_dma_pseudo()
269 word = readw(info->base + CUMANASCSI2_PSEUDODMA); in cumanascsi_2_dma_pseudo()
271 if (--length > 0) { in cumanascsi_2_dma_pseudo()
273 length --; in cumanascsi_2_dma_pseudo()
280 * Purpose : stops DMA/PIO
281 * Params : host - host
282 * SCpnt - command
287 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_dma_stop()
288 if (info->info.scsi.dma != NO_DMA) { in cumanascsi_2_dma_stop()
289 writeb(ALATCH_DIS_DMA, info->base + CUMANASCSI2_ALATCH); in cumanascsi_2_dma_stop()
290 disable_dma(info->info.scsi.dma); in cumanascsi_2_dma_stop()
296 * Params : host - driver host structure to return info for.
301 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_info()
305 host->hostt->name, info->info.scsi.type, info->ec->slot_no, in cumanascsi_2_info()
306 VERSION, info->terms ? "n" : "ff"); in cumanascsi_2_info()
313 * Params : host - host to setup
314 * : buffer - buffer containing string describing operation
315 * : length - length of string
316 * Returns : -EINVAL, or 0
325 length -= 11; in cumanascsi_2_set_proc_info()
333 ret = -EINVAL; in cumanascsi_2_set_proc_info()
335 ret = -EINVAL; in cumanascsi_2_set_proc_info()
338 ret = -EINVAL; in cumanascsi_2_set_proc_info()
347 info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi_2_show_info()
350 fas216_print_host(&info->info, m); in cumanascsi_2_show_info()
352 info->terms ? "n" : "ff"); in cumanascsi_2_show_info()
354 fas216_print_stats(&info->info, m); in cumanascsi_2_show_info()
355 fas216_print_devices(&info->info, m); in cumanascsi_2_show_info()
392 ret = -ENOMEM; in cumanascsi2_probe()
399 ret = -ENOMEM; in cumanascsi2_probe()
405 info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi2_probe()
406 info->ec = ec; in cumanascsi2_probe()
407 info->base = base; in cumanascsi2_probe()
409 cumanascsi_2_terminator_ctl(host, term[ec->slot_no]); in cumanascsi2_probe()
411 info->info.scsi.io_base = base + CUMANASCSI2_FAS216_OFFSET; in cumanascsi2_probe()
412 info->info.scsi.io_shift = CUMANASCSI2_FAS216_SHIFT; in cumanascsi2_probe()
413 info->info.scsi.irq = ec->irq; in cumanascsi2_probe()
414 info->info.scsi.dma = ec->dma; in cumanascsi2_probe()
415 info->info.ifcfg.clockrate = 40; /* MHz */ in cumanascsi2_probe()
416 info->info.ifcfg.select_timeout = 255; in cumanascsi2_probe()
417 info->info.ifcfg.asyncperiod = 200; /* ns */ in cumanascsi2_probe()
418 info->info.ifcfg.sync_max_depth = 7; in cumanascsi2_probe()
419 info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK; in cumanascsi2_probe()
420 info->info.ifcfg.disconnect_ok = 1; in cumanascsi2_probe()
421 info->info.ifcfg.wide_max_size = 0; in cumanascsi2_probe()
422 info->info.ifcfg.capabilities = FASCAP_PSEUDODMA; in cumanascsi2_probe()
423 info->info.dma.setup = cumanascsi_2_dma_setup; in cumanascsi2_probe()
424 info->info.dma.pseudo = cumanascsi_2_dma_pseudo; in cumanascsi2_probe()
425 info->info.dma.stop = cumanascsi_2_dma_stop; in cumanascsi2_probe()
427 ec->irqaddr = info->base + CUMANASCSI2_STATUS; in cumanascsi2_probe()
428 ec->irqmask = STATUS_INT; in cumanascsi2_probe()
436 ret = request_irq(ec->irq, cumanascsi_2_intr, in cumanascsi2_probe()
440 host->host_no, ec->irq, ret); in cumanascsi2_probe()
444 if (info->info.scsi.dma != NO_DMA) { in cumanascsi2_probe()
445 if (request_dma(info->info.scsi.dma, "cumanascsi2")) { in cumanascsi2_probe()
446 printk("scsi%d: DMA%d not free, using PIO\n", in cumanascsi2_probe()
447 host->host_no, info->info.scsi.dma); in cumanascsi2_probe()
448 info->info.scsi.dma = NO_DMA; in cumanascsi2_probe()
450 set_dma_speed(info->info.scsi.dma, 180); in cumanascsi2_probe()
451 info->info.ifcfg.capabilities |= FASCAP_DMA; in cumanascsi2_probe()
455 ret = fas216_add(host, &ec->dev); in cumanascsi2_probe()
459 if (info->info.scsi.dma != NO_DMA) in cumanascsi2_probe()
460 free_dma(info->info.scsi.dma); in cumanascsi2_probe()
461 free_irq(ec->irq, info); in cumanascsi2_probe()
479 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; in cumanascsi2_remove()
484 if (info->info.scsi.dma != NO_DMA) in cumanascsi2_remove()
485 free_dma(info->info.scsi.dma); in cumanascsi2_remove()
486 free_irq(ec->irq, info); in cumanascsi2_remove()
521 MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines");