Lines Matching +full:tf +full:- +full:a

1 // SPDX-License-Identifier: GPL-2.0-only
26 * devices (neither other pata_parport devices nor a printer).
30 parport_claim_or_block(pi->pardev); in pi_connect()
31 pi->proto->connect(pi); in pi_connect()
36 pi->proto->disconnect(pi); in pi_disconnect()
37 parport_release(pi->pardev); in pi_disconnect()
42 struct pi_adapter *pi = ap->host->private_data; in pata_parport_dev_select()
50 pi->proto->write_regr(pi, 0, ATA_REG_DEVICE, tmp); in pata_parport_dev_select()
56 struct pi_adapter *pi = ap->host->private_data; in pata_parport_set_devctl()
58 pi->proto->write_regr(pi, 1, 6, ctl); in pata_parport_set_devctl()
63 struct pi_adapter *pi = ap->host->private_data; in pata_parport_devchk()
68 pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 0x55); in pata_parport_devchk()
69 pi->proto->write_regr(pi, 0, ATA_REG_LBAL, 0xaa); in pata_parport_devchk()
71 pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 0xaa); in pata_parport_devchk()
72 pi->proto->write_regr(pi, 0, ATA_REG_LBAL, 0x55); in pata_parport_devchk()
74 pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 0x55); in pata_parport_devchk()
75 pi->proto->write_regr(pi, 0, ATA_REG_LBAL, 0xaa); in pata_parport_devchk()
77 nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT); in pata_parport_devchk()
78 lbal = pi->proto->read_regr(pi, 0, ATA_REG_LBAL); in pata_parport_devchk()
87 struct ata_port *ap = link->ap; in pata_parport_wait_after_reset()
88 struct pi_adapter *pi = ap->host->private_data; in pata_parport_wait_after_reset()
100 * present, so don't abort now if a slave device is present in pata_parport_wait_after_reset()
104 ret = -ENODEV; in pata_parport_wait_after_reset()
124 nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT); in pata_parport_wait_after_reset()
125 lbal = pi->proto->read_regr(pi, 0, ATA_REG_LBAL); in pata_parport_wait_after_reset()
128 /* give drive a breather */ in pata_parport_wait_after_reset()
134 if (rc != -ENODEV) in pata_parport_wait_after_reset()
152 struct pi_adapter *pi = ap->host->private_data; in pata_parport_bus_softreset()
155 pi->proto->write_regr(pi, 1, 6, ap->ctl); in pata_parport_bus_softreset()
157 pi->proto->write_regr(pi, 1, 6, ap->ctl | ATA_SRST); in pata_parport_bus_softreset()
159 pi->proto->write_regr(pi, 1, 6, ap->ctl); in pata_parport_bus_softreset()
160 ap->last_ctl = ap->ctl; in pata_parport_bus_softreset()
163 return pata_parport_wait_after_reset(&ap->link, devmask, deadline); in pata_parport_bus_softreset()
169 struct ata_port *ap = link->ap; in pata_parport_softreset()
185 if (rc && rc != -ENODEV) { in pata_parport_softreset()
191 classes[0] = ata_sff_dev_classify(&link->device[0], in pata_parport_softreset()
194 classes[1] = ata_sff_dev_classify(&link->device[1], in pata_parport_softreset()
202 struct pi_adapter *pi = ap->host->private_data; in pata_parport_check_status()
204 return pi->proto->read_regr(pi, 0, ATA_REG_STATUS); in pata_parport_check_status()
209 struct pi_adapter *pi = ap->host->private_data; in pata_parport_check_altstatus()
211 return pi->proto->read_regr(pi, 1, 6); in pata_parport_check_altstatus()
215 const struct ata_taskfile *tf) in pata_parport_tf_load() argument
217 struct pi_adapter *pi = ap->host->private_data; in pata_parport_tf_load()
219 if (tf->ctl != ap->last_ctl) { in pata_parport_tf_load()
220 pi->proto->write_regr(pi, 1, 6, tf->ctl); in pata_parport_tf_load()
221 ap->last_ctl = tf->ctl; in pata_parport_tf_load()
225 if (tf->flags & ATA_TFLAG_ISADDR) { in pata_parport_tf_load()
226 if (tf->flags & ATA_TFLAG_LBA48) { in pata_parport_tf_load()
227 pi->proto->write_regr(pi, 0, ATA_REG_FEATURE, in pata_parport_tf_load()
228 tf->hob_feature); in pata_parport_tf_load()
229 pi->proto->write_regr(pi, 0, ATA_REG_NSECT, in pata_parport_tf_load()
230 tf->hob_nsect); in pata_parport_tf_load()
231 pi->proto->write_regr(pi, 0, ATA_REG_LBAL, in pata_parport_tf_load()
232 tf->hob_lbal); in pata_parport_tf_load()
233 pi->proto->write_regr(pi, 0, ATA_REG_LBAM, in pata_parport_tf_load()
234 tf->hob_lbam); in pata_parport_tf_load()
235 pi->proto->write_regr(pi, 0, ATA_REG_LBAH, in pata_parport_tf_load()
236 tf->hob_lbah); in pata_parport_tf_load()
238 pi->proto->write_regr(pi, 0, ATA_REG_FEATURE, tf->feature); in pata_parport_tf_load()
239 pi->proto->write_regr(pi, 0, ATA_REG_NSECT, tf->nsect); in pata_parport_tf_load()
240 pi->proto->write_regr(pi, 0, ATA_REG_LBAL, tf->lbal); in pata_parport_tf_load()
241 pi->proto->write_regr(pi, 0, ATA_REG_LBAM, tf->lbam); in pata_parport_tf_load()
242 pi->proto->write_regr(pi, 0, ATA_REG_LBAH, tf->lbah); in pata_parport_tf_load()
245 if (tf->flags & ATA_TFLAG_DEVICE) in pata_parport_tf_load()
246 pi->proto->write_regr(pi, 0, ATA_REG_DEVICE, tf->device); in pata_parport_tf_load()
251 static void pata_parport_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in pata_parport_tf_read() argument
253 struct pi_adapter *pi = ap->host->private_data; in pata_parport_tf_read()
255 tf->status = pi->proto->read_regr(pi, 0, ATA_REG_STATUS); in pata_parport_tf_read()
256 tf->error = pi->proto->read_regr(pi, 0, ATA_REG_ERR); in pata_parport_tf_read()
257 tf->nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT); in pata_parport_tf_read()
258 tf->lbal = pi->proto->read_regr(pi, 0, ATA_REG_LBAL); in pata_parport_tf_read()
259 tf->lbam = pi->proto->read_regr(pi, 0, ATA_REG_LBAM); in pata_parport_tf_read()
260 tf->lbah = pi->proto->read_regr(pi, 0, ATA_REG_LBAH); in pata_parport_tf_read()
261 tf->device = pi->proto->read_regr(pi, 0, ATA_REG_DEVICE); in pata_parport_tf_read()
263 if (tf->flags & ATA_TFLAG_LBA48) { in pata_parport_tf_read()
264 pi->proto->write_regr(pi, 1, 6, tf->ctl | ATA_HOB); in pata_parport_tf_read()
265 tf->hob_feature = pi->proto->read_regr(pi, 0, ATA_REG_ERR); in pata_parport_tf_read()
266 tf->hob_nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT); in pata_parport_tf_read()
267 tf->hob_lbal = pi->proto->read_regr(pi, 0, ATA_REG_LBAL); in pata_parport_tf_read()
268 tf->hob_lbam = pi->proto->read_regr(pi, 0, ATA_REG_LBAM); in pata_parport_tf_read()
269 tf->hob_lbah = pi->proto->read_regr(pi, 0, ATA_REG_LBAH); in pata_parport_tf_read()
270 pi->proto->write_regr(pi, 1, 6, tf->ctl); in pata_parport_tf_read()
271 ap->last_ctl = tf->ctl; in pata_parport_tf_read()
276 const struct ata_taskfile *tf) in pata_parport_exec_command() argument
278 struct pi_adapter *pi = ap->host->private_data; in pata_parport_exec_command()
280 pi->proto->write_regr(pi, 0, ATA_REG_CMD, tf->command); in pata_parport_exec_command()
287 struct ata_port *ap = qc->dev->link->ap; in pata_parport_data_xfer()
288 struct pi_adapter *pi = ap->host->private_data; in pata_parport_data_xfer()
291 pi->proto->read_block(pi, buf, buflen); in pata_parport_data_xfer()
293 pi->proto->write_block(pi, buf, buflen); in pata_parport_data_xfer()
305 /* We only need to flush incoming data when a command was running */ in pata_parport_drain_fifo()
306 if (qc == NULL || qc->dma_dir == DMA_TO_DEVICE) in pata_parport_drain_fifo()
309 ap = qc->ap; in pata_parport_drain_fifo()
310 pi = ap->host->private_data; in pata_parport_drain_fifo()
314 pi->proto->read_block(pi, junk, 2); in pata_parport_drain_fifo()
347 parport_unregister_device(pi->pardev); in pi_release()
348 if (pi->proto->release_proto) in pi_release()
349 pi->proto->release_proto(pi); in pi_release()
350 module_put(pi->proto->owner); in pi_release()
358 pi->proto->connect(pi); in default_test_proto()
361 pi->proto->write_regr(pi, 0, 6, 0xa0 + j * 0x10); in default_test_proto()
363 pi->proto->write_regr(pi, 0, 2, k ^ 0xaa); in default_test_proto()
364 pi->proto->write_regr(pi, 0, 3, k ^ 0x55); in default_test_proto()
365 if (pi->proto->read_regr(pi, 0, 2) != (k ^ 0xaa)) in default_test_proto()
369 pi->proto->disconnect(pi); in default_test_proto()
371 dev_dbg(&pi->dev, "%s: port 0x%x, mode %d, test=(%d,%d)\n", in default_test_proto()
372 pi->proto->name, pi->port, pi->mode, e[0], e[1]); in default_test_proto()
381 parport_claim_or_block(pi->pardev); in pi_test_proto()
382 if (pi->proto->test_proto) in pi_test_proto()
383 res = pi->proto->test_proto(pi); in pi_test_proto()
386 parport_release(pi->pardev); in pi_test_proto()
395 if (pi->mode != -1) { in pi_probe_mode()
396 if (pi->mode >= max) in pi_probe_mode()
399 if (pi->mode >= pi->proto->epp_first) in pi_probe_mode()
401 if (range == 8 && pi->port % 8) in pi_probe_mode()
405 best = -1; in pi_probe_mode()
406 for (pi->mode = 0; pi->mode < max; pi->mode++) { in pi_probe_mode()
408 if (pi->mode >= pi->proto->epp_first) in pi_probe_mode()
410 if (range == 8 && pi->port % 8) in pi_probe_mode()
413 best = pi->mode; in pi_probe_mode()
415 pi->mode = best; in pi_probe_mode()
416 return best > -1; in pi_probe_mode()
426 if (s == -1) { in pi_probe_unit()
428 e = pi->proto->max_units; in pi_probe_unit()
431 if (pi->proto->test_port) { in pi_probe_unit()
432 parport_claim_or_block(pi->pardev); in pi_probe_unit()
433 max = pi->proto->test_port(pi); in pi_probe_unit()
434 parport_release(pi->pardev); in pi_probe_unit()
436 max = pi->proto->max_mode; in pi_probe_unit()
439 if (pi->proto->probe_unit) { in pi_probe_unit()
440 parport_claim_or_block(pi->pardev); in pi_probe_unit()
441 for (pi->unit = s; pi->unit < e; pi->unit++) { in pi_probe_unit()
442 if (pi->proto->probe_unit(pi)) { in pi_probe_unit()
443 parport_release(pi->pardev); in pi_probe_unit()
447 parport_release(pi->pardev); in pi_probe_unit()
458 ida_free(&pata_parport_bus_dev_ids, dev->id); in pata_parport_dev_release()
490 return pi->pardev->port == match->parport && pi->proto == match->proto; in pi_find_dev()
504 * Abort if there's a device already registered on the same parport in pi_init_one()
520 /* set up pi->dev before pi_probe_unit() so it can use dev_printk() */ in pi_init_one()
521 pi->dev.parent = &pata_parport_bus; in pi_init_one()
522 pi->dev.bus = &pata_parport_bus_type; in pi_init_one()
523 pi->dev.driver = &pr->driver; in pi_init_one()
524 pi->dev.release = pata_parport_dev_release; in pi_init_one()
525 pi->dev.id = id; in pi_init_one()
526 dev_set_name(&pi->dev, "pata_parport.%u", pi->dev.id); in pi_init_one()
527 if (device_register(&pi->dev)) { in pi_init_one()
528 put_device(&pi->dev); in pi_init_one()
529 /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ in pi_init_one()
533 pi->proto = pr; in pi_init_one()
535 if (!try_module_get(pi->proto->owner)) in pi_init_one()
537 if (pi->proto->init_proto && pi->proto->init_proto(pi) < 0) in pi_init_one()
540 pi->delay = (delay == -1) ? pi->proto->default_delay : delay; in pi_init_one()
541 pi->mode = mode; in pi_init_one()
542 pi->port = parport->base; in pi_init_one()
545 pi->pardev = parport_register_dev_model(parport, DRV_NAME, &par_cb, id); in pi_init_one()
546 if (!pi->pardev) in pi_init_one()
550 dev_info(&pi->dev, "Adapter not found\n"); in pi_init_one()
554 pi->proto->log_adapter(pi); in pi_init_one()
556 host = ata_host_alloc_pinfo(&pi->pardev->dev, ppi, 1); in pi_init_one()
559 dev_set_drvdata(&pi->dev, host); in pi_init_one()
560 host->private_data = pi; in pi_init_one()
562 ata_port_desc(host->ports[0], "port %s", pi->pardev->port->name); in pi_init_one()
563 ata_port_desc(host->ports[0], "protocol %s", pi->proto->name); in pi_init_one()
574 parport_unregister_device(pi->pardev); in pi_init_one()
575 if (pi->proto->release_proto) in pi_init_one()
576 pi->proto->release_proto(pi); in pi_init_one()
578 module_put(pi->proto->owner); in pi_init_one()
580 device_unregister(&pi->dev); in pi_init_one()
581 /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ in pi_init_one()
591 pr->driver.bus = &pata_parport_bus_type; in pata_parport_register_driver()
592 pr->driver.name = pr->name; in pata_parport_register_driver()
593 error = driver_register(&pr->driver); in pata_parport_register_driver()
600 driver_unregister(&pr->driver); in pata_parport_register_driver()
605 pr_info("pata_parport: protocol %s registered\n", pr->name); in pata_parport_register_driver()
610 pi_init_one(parport, pr, -1, -1, -1); in pata_parport_register_driver()
621 int id = -1; in pata_parport_unregister_driver()
630 driver_unregister(&pr->driver); in pata_parport_unregister_driver()
638 int mode = -1, unit = -1, delay = -1; in new_device_store()
647 return -EINVAL; in new_device_store()
652 return -EINVAL; in new_device_store()
654 port_wanted = -1; in new_device_store()
661 return -EINVAL; in new_device_store()
671 if (port_num == port_wanted || port_wanted == -1) { in new_device_store()
676 return -ENODEV; in new_device_store()
690 return -ENODEV; in new_device_store()
699 struct pi_adapter *pi = host->private_data; in pi_remove_one()
705 /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ in pi_remove_one()
716 return -ENODEV; in delete_device_store()
733 id = idr_alloc(&parport_list, port, port->number, port->number, in pata_parport_attach()
743 pi_init_one(port, pr, -1, -1, -1); in pata_parport_attach()
751 struct pi_adapter *pi = host->private_data; in pi_remove_port()
753 if (pi->pardev->port == p) in pi_remove_port()
763 idr_remove(&parport_list, port->number); in pata_parport_detach()