Lines Matching refs:port
36 static void parport_ieee1284_wakeup (struct parport *port) in parport_ieee1284_wakeup() argument
38 up (&port->physport->ieee1284.irq); in parport_ieee1284_wakeup()
43 struct parport *port = from_timer(port, t, timer); in timeout_waiting_on_port() local
45 parport_ieee1284_wakeup (port); in timeout_waiting_on_port()
64 int parport_wait_event (struct parport *port, signed long timeout) in parport_wait_event() argument
68 if (!port->physport->cad->timeout) in parport_wait_event()
73 timer_setup(&port->timer, timeout_waiting_on_port, 0); in parport_wait_event()
74 mod_timer(&port->timer, jiffies + timeout); in parport_wait_event()
75 ret = down_interruptible (&port->physport->ieee1284.irq); in parport_wait_event()
76 if (!del_timer_sync(&port->timer) && !ret) in parport_wait_event()
107 int parport_poll_peripheral(struct parport *port, in parport_poll_peripheral() argument
117 status = parport_read_status (port); in parport_poll_peripheral()
156 int parport_wait_peripheral(struct parport *port, in parport_wait_peripheral() argument
165 usec = port->physport->spintime; /* usecs of fast polling */ in parport_wait_peripheral()
166 if (!port->physport->cad->timeout) in parport_wait_peripheral()
177 ret = parport_poll_peripheral (port, mask, result, usec); in parport_wait_peripheral()
181 if (!port->physport->cad->timeout) in parport_wait_peripheral()
194 if ((ret = parport_wait_event (port, msecs_to_jiffies(10))) < 0) in parport_wait_peripheral()
197 status = parport_read_status (port); in parport_wait_peripheral()
214 static void parport_ieee1284_terminate (struct parport *port) in parport_ieee1284_terminate() argument
217 port = port->physport; in parport_ieee1284_terminate()
220 switch (port->ieee1284.mode) { in parport_ieee1284_terminate()
227 parport_frob_control (port, PARPORT_CONTROL_INIT, 0); in parport_ieee1284_terminate()
231 parport_frob_control (port, in parport_ieee1284_terminate()
242 if (port->ieee1284.phase != IEEE1284_PH_FWD_IDLE) { in parport_ieee1284_terminate()
244 parport_frob_control (port, in parport_ieee1284_terminate()
251 r = parport_wait_peripheral (port, in parport_ieee1284_terminate()
256 port->name); in parport_ieee1284_terminate()
258 parport_data_forward (port); in parport_ieee1284_terminate()
259 pr_debug("%s: ECP direction: forward\n", port->name); in parport_ieee1284_terminate()
260 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_ieee1284_terminate()
269 parport_frob_control (port, in parport_ieee1284_terminate()
275 r = parport_wait_peripheral (port, PARPORT_STATUS_ACK, 0); in parport_ieee1284_terminate()
277 pr_debug("%s: Timeout at event 24\n", port->name); in parport_ieee1284_terminate()
280 parport_frob_control (port, in parport_ieee1284_terminate()
285 r = parport_wait_peripheral (port, in parport_ieee1284_terminate()
289 pr_debug("%s: Timeout at event 27\n", port->name); in parport_ieee1284_terminate()
292 parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); in parport_ieee1284_terminate()
295 port->ieee1284.mode = IEEE1284_MODE_COMPAT; in parport_ieee1284_terminate()
296 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_ieee1284_terminate()
298 pr_debug("%s: In compatibility (forward idle) mode\n", port->name); in parport_ieee1284_terminate()
317 int parport_negotiate (struct parport *port, int mode) in parport_negotiate() argument
329 port = port->physport; in parport_negotiate()
332 if (port->ieee1284.mode == mode) in parport_negotiate()
336 if ((port->ieee1284.mode & ~IEEE1284_ADDR) == (mode & ~IEEE1284_ADDR)){ in parport_negotiate()
337 port->ieee1284.mode = mode; in parport_negotiate()
342 if (port->ieee1284.mode != IEEE1284_MODE_COMPAT) in parport_negotiate()
343 parport_ieee1284_terminate (port); in parport_negotiate()
364 port->ieee1284.phase = IEEE1284_PH_NEGOTIATION; in parport_negotiate()
367 parport_frob_control (port, in parport_negotiate()
375 parport_data_forward (port); in parport_negotiate()
376 parport_write_data (port, m); in parport_negotiate()
380 parport_frob_control (port, in parport_negotiate()
386 if (parport_wait_peripheral (port, in parport_negotiate()
395 parport_frob_control (port, in parport_negotiate()
400 port->name, parport_read_status (port)); in parport_negotiate()
401 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_negotiate()
406 parport_frob_control (port, in parport_negotiate()
412 parport_frob_control (port, in parport_negotiate()
418 if (parport_wait_peripheral (port, in parport_negotiate()
423 port->name, mode, port->ops->read_status (port)); in parport_negotiate()
424 parport_ieee1284_terminate (port); in parport_negotiate()
428 xflag = parport_read_status (port) & PARPORT_STATUS_SELECT; in parport_negotiate()
434 port->name, mode); in parport_negotiate()
435 parport_ieee1284_terminate (port); in parport_negotiate()
443 parport_write_data (port, m); in parport_negotiate()
447 parport_frob_control (port, in parport_negotiate()
452 if (parport_wait_peripheral (port, PARPORT_STATUS_ACK, 0)) { in parport_negotiate()
454 pr_debug("%s: Event 52 didn't happen\n", port->name); in parport_negotiate()
455 parport_ieee1284_terminate (port); in parport_negotiate()
460 parport_frob_control (port, in parport_negotiate()
465 if (parport_wait_peripheral (port, in parport_negotiate()
471 port->name, mode, in parport_negotiate()
472 port->ops->read_status(port)); in parport_negotiate()
473 parport_ieee1284_terminate (port); in parport_negotiate()
478 xflag = parport_read_status (port) & PARPORT_STATUS_SELECT; in parport_negotiate()
484 port->name, mode); in parport_negotiate()
485 parport_ieee1284_terminate (port); in parport_negotiate()
493 pr_debug("%s: In mode 0x%02x\n", port->name, mode); in parport_negotiate()
494 port->ieee1284.mode = mode; in parport_negotiate()
498 port->ieee1284.phase = IEEE1284_PH_ECP_SETUP; in parport_negotiate()
501 parport_frob_control (port, in parport_negotiate()
506 r = parport_wait_peripheral (port, in parport_negotiate()
510 pr_debug("%s: Timeout at event 31\n", port->name); in parport_negotiate()
513 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_negotiate()
514 pr_debug("%s: ECP direction: forward\n", port->name); in parport_negotiate()
518 port->ieee1284.phase = IEEE1284_PH_REV_IDLE; in parport_negotiate()
521 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_negotiate()
536 static int parport_ieee1284_ack_data_avail (struct parport *port) in parport_ieee1284_ack_data_avail() argument
538 if (parport_read_status (port) & PARPORT_STATUS_ERROR) in parport_ieee1284_ack_data_avail()
543 port->ops->frob_control (port, PARPORT_CONTROL_AUTOFD, 0); in parport_ieee1284_ack_data_avail()
544 port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; in parport_ieee1284_ack_data_avail()
552 struct parport *port = handle; in parport_ieee1284_interrupt() local
553 parport_ieee1284_wakeup (port); in parport_ieee1284_interrupt()
556 if (port->ieee1284.phase == IEEE1284_PH_REV_IDLE) { in parport_ieee1284_interrupt()
559 pr_debug("%s: Data available\n", port->name); in parport_ieee1284_interrupt()
560 parport_ieee1284_ack_data_avail (port); in parport_ieee1284_interrupt()
583 ssize_t parport_write (struct parport *port, const void *buffer, size_t len) in parport_write() argument
586 return port->ops->compat_write_data (port, buffer, len, 0); in parport_write()
589 int mode = port->ieee1284.mode; in parport_write()
600 parport_negotiate (port, IEEE1284_MODE_COMPAT); in parport_write()
603 pr_debug("%s: Using compatibility mode\n", port->name); in parport_write()
604 fn = port->ops->compat_write_data; in parport_write()
608 pr_debug("%s: Using EPP mode\n", port->name); in parport_write()
610 fn = port->ops->epp_write_addr; in parport_write()
612 fn = port->ops->epp_write_data; in parport_write()
616 pr_debug("%s: Using software-emulated EPP mode\n", port->name); in parport_write()
625 pr_debug("%s: Using ECP mode\n", port->name); in parport_write()
627 fn = port->ops->ecp_write_addr; in parport_write()
629 fn = port->ops->ecp_write_data; in parport_write()
634 pr_debug("%s: Using software-emulated ECP mode\n", port->name); in parport_write()
646 port->name, port->ieee1284.mode); in parport_write()
650 retval = (*fn) (port, buffer, len, 0); in parport_write()
651 pr_debug("%s: wrote %zd/%zu bytes\n", port->name, retval, len); in parport_write()
674 ssize_t parport_read (struct parport *port, void *buffer, size_t len) in parport_read() argument
680 int mode = port->physport->ieee1284.mode; in parport_read()
695 if ((port->physport->modes & PARPORT_MODE_TRISTATE) && in parport_read()
696 !parport_negotiate (port, IEEE1284_MODE_BYTE)) { in parport_read()
698 pr_debug("%s: Using byte mode\n", port->name); in parport_read()
699 fn = port->ops->byte_read_data; in parport_read()
702 if (parport_negotiate (port, IEEE1284_MODE_NIBBLE)) { in parport_read()
707 pr_debug("%s: Using nibble mode\n", port->name); in parport_read()
708 fn = port->ops->nibble_read_data; in parport_read()
712 pr_debug("%s: Using byte mode\n", port->name); in parport_read()
713 fn = port->ops->byte_read_data; in parport_read()
717 pr_debug("%s: Using EPP mode\n", port->name); in parport_read()
719 fn = port->ops->epp_read_addr; in parport_read()
721 fn = port->ops->epp_read_data; in parport_read()
725 pr_debug("%s: Using software-emulated EPP mode\n", port->name); in parport_read()
734 pr_debug("%s: Using ECP mode\n", port->name); in parport_read()
735 fn = port->ops->ecp_read_data; in parport_read()
739 pr_debug("%s: Using software-emulated ECP mode\n", port->name); in parport_read()
745 port->name, port->physport->ieee1284.mode); in parport_read()
749 return (*fn) (port, buffer, len, 0); in parport_read()
775 if (dev->port->physport->cad == dev) in parport_set_timeout()
776 parport_ieee1284_wakeup (dev->port); in parport_set_timeout()