1 /* $Id: parport_ieee1284.c,v 1.4 1997/10/19 21:37:21 philip Exp $
2 * IEEE-1284 implementation for parport.
4 * Authors: Phil Blundell <philb@gnu.org>
5 * Carsten Gross <carsten@sol.wohnheim.uni-ulm.de>
6 * Jose Renau <renau@acm.org>
7 * Tim Waugh <tim@cyberelk.demon.co.uk> (largely rewritten)
9 * This file is responsible for IEEE 1284 negotiation, and for handing
10 * read/write requests to low-level drivers.
12 * Any part of this program may be used in documents licensed under
13 * the GNU Free Documentation License, Version 1.1 or any later version
14 * published by the Free Software Foundation.
16 * Various hacks, Fred Barnes <frmb2@ukc.ac.uk>, 04/2000
19 #include <linux/module.h>
20 #include <linux/threads.h>
21 #include <linux/parport.h>
22 #include <linux/delay.h>
23 #include <linux/kernel.h>
24 #include <linux/interrupt.h>
25 #include <linux/timer.h>
26 #include <linux/sched.h>
28 #undef DEBUG /* undef me for production */
30 #ifdef CONFIG_LP_CONSOLE
31 #undef DEBUG /* Don't want a garbled console */
35 #define DPRINTK(stuff...) printk (stuff)
37 #define DPRINTK(stuff...)
40 /* Make parport_wait_peripheral wake up.
41 * It will be useful to call this from an interrupt handler. */
42 static void parport_ieee1284_wakeup (struct parport
*port
)
44 up (&port
->physport
->ieee1284
.irq
);
47 static struct parport
*port_from_cookie
[PARPORT_MAX
];
48 static void timeout_waiting_on_port (unsigned long cookie
)
50 parport_ieee1284_wakeup (port_from_cookie
[cookie
% PARPORT_MAX
]);
54 * parport_wait_event - wait for an event on a parallel port
55 * @port: port to wait on
56 * @timeout: time to wait (in jiffies)
58 * This function waits for up to @timeout jiffies for an
59 * interrupt to occur on a parallel port. If the port timeout is
60 * set to zero, it returns immediately.
62 * If an interrupt occurs before the timeout period elapses, this
63 * function returns zero immediately. If it times out, it returns
64 * one. An error code less than zero indicates an error (most
65 * likely a pending signal), and the calling code should finish
66 * what it's doing as soon as it can.
69 int parport_wait_event (struct parport
*port
, signed long timeout
)
72 struct timer_list timer
;
74 if (!port
->physport
->cad
->timeout
)
75 /* Zero timeout is special, and we can't down() the
80 timer
.expires
= jiffies
+ timeout
;
81 timer
.function
= timeout_waiting_on_port
;
82 port_from_cookie
[port
->number
% PARPORT_MAX
] = port
;
83 timer
.data
= port
->number
;
86 ret
= down_interruptible (&port
->physport
->ieee1284
.irq
);
87 if (!del_timer (&timer
) && !ret
)
95 * parport_poll_peripheral - poll status lines
96 * @port: port to watch
97 * @mask: status lines to watch
98 * @result: desired values of chosen status lines
101 * This function busy-waits until the masked status lines have
102 * the desired values, or until the timeout period elapses. The
103 * @mask and @result parameters are bitmasks, with the bits
104 * defined by the constants in parport.h: %PARPORT_STATUS_BUSY,
107 * This function does not call schedule(); instead it busy-waits
108 * using udelay(). It currently has a resolution of 5usec.
110 * If the status lines take on the desired values before the
111 * timeout period elapses, parport_poll_peripheral() returns zero
112 * immediately. A return value greater than zero indicates
113 * a timeout. An error code (less than zero) indicates an error,
114 * most likely a signal that arrived, and the caller should
115 * finish what it is doing as soon as possible.
118 int parport_poll_peripheral(struct parport
*port
,
120 unsigned char result
,
123 /* Zero return code is success, >0 is timeout. */
124 int count
= usec
/ 5 + 2;
126 unsigned char status
;
127 for (i
= 0; i
< count
; i
++) {
128 status
= parport_read_status (port
);
129 if ((status
& mask
) == result
)
131 if (signal_pending (current
))
143 * parport_wait_peripheral - wait for status lines to change in 35ms
144 * @port: port to watch
145 * @mask: status lines to watch
146 * @result: desired values of chosen status lines
148 * This function waits until the masked status lines have the
149 * desired values, or until 35ms have elapsed (see IEEE 1284-1994
150 * page 24 to 25 for why this value in particular is hardcoded).
151 * The @mask and @result parameters are bitmasks, with the bits
152 * defined by the constants in parport.h: %PARPORT_STATUS_BUSY,
155 * The port is polled quickly to start off with, in anticipation
156 * of a fast response from the peripheral. This fast polling
157 * time is configurable (using /proc), and defaults to 500usec.
158 * If the timeout for this port (see parport_set_timeout()) is
159 * zero, the fast polling time is 35ms, and this function does
160 * not call schedule().
162 * If the timeout for this port is non-zero, after the fast
163 * polling fails it uses parport_wait_event() to wait for up to
164 * 10ms, waking up if an interrupt occurs.
167 int parport_wait_peripheral(struct parport
*port
,
169 unsigned char result
)
173 unsigned long deadline
;
174 unsigned char status
;
176 usec
= port
->physport
->spintime
; /* usecs of fast polling */
177 if (!port
->physport
->cad
->timeout
)
178 /* A zero timeout is "special": busy wait for the
184 * This should be adjustable.
185 * How about making a note (in the device structure) of how long
186 * it takes, so we know for next time?
188 ret
= parport_poll_peripheral (port
, mask
, result
, usec
);
192 if (!port
->physport
->cad
->timeout
)
193 /* We may be in an interrupt handler, so we can't poll
197 /* 40ms of slow polling. */
198 deadline
= jiffies
+ msecs_to_jiffies(40);
199 while (time_before (jiffies
, deadline
)) {
202 if (signal_pending (current
))
205 /* Wait for 10ms (or until an interrupt occurs if
206 * the handler is set) */
207 if ((ret
= parport_wait_event (port
, msecs_to_jiffies(10))) < 0)
210 status
= parport_read_status (port
);
211 if ((status
& mask
) == result
)
215 /* parport_wait_event didn't time out, but the
216 * peripheral wasn't actually ready either.
217 * Wait for another 10ms. */
218 schedule_timeout_interruptible(msecs_to_jiffies(10));
225 #ifdef CONFIG_PARPORT_1284
226 /* Terminate a negotiated mode. */
227 static void parport_ieee1284_terminate (struct parport
*port
)
230 port
= port
->physport
;
232 /* EPP terminates differently. */
233 switch (port
->ieee1284
.mode
) {
234 case IEEE1284_MODE_EPP
:
235 case IEEE1284_MODE_EPPSL
:
236 case IEEE1284_MODE_EPPSWE
:
237 /* Terminate from EPP mode. */
239 /* Event 68: Set nInit low */
240 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
243 /* Event 69: Set nInit high, nSelectIn low */
244 parport_frob_control (port
,
245 PARPORT_CONTROL_SELECT
246 | PARPORT_CONTROL_INIT
,
247 PARPORT_CONTROL_SELECT
248 | PARPORT_CONTROL_INIT
);
251 case IEEE1284_MODE_ECP
:
252 case IEEE1284_MODE_ECPRLE
:
253 case IEEE1284_MODE_ECPSWE
:
254 /* In ECP we can only terminate from fwd idle phase. */
255 if (port
->ieee1284
.phase
!= IEEE1284_PH_FWD_IDLE
) {
256 /* Event 47: Set nInit high */
257 parport_frob_control (port
,
259 | PARPORT_CONTROL_AUTOFD
,
261 | PARPORT_CONTROL_AUTOFD
);
263 /* Event 49: PError goes high */
264 r
= parport_wait_peripheral (port
,
265 PARPORT_STATUS_PAPEROUT
,
266 PARPORT_STATUS_PAPEROUT
);
268 DPRINTK (KERN_INFO
"%s: Timeout at event 49\n",
271 parport_data_forward (port
);
272 DPRINTK (KERN_DEBUG
"%s: ECP direction: forward\n",
274 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
280 /* Terminate from all other modes. */
282 /* Event 22: Set nSelectIn low, nAutoFd high */
283 parport_frob_control (port
,
284 PARPORT_CONTROL_SELECT
285 | PARPORT_CONTROL_AUTOFD
,
286 PARPORT_CONTROL_SELECT
);
288 /* Event 24: nAck goes low */
289 r
= parport_wait_peripheral (port
, PARPORT_STATUS_ACK
, 0);
291 DPRINTK (KERN_INFO
"%s: Timeout at event 24\n",
294 /* Event 25: Set nAutoFd low */
295 parport_frob_control (port
,
296 PARPORT_CONTROL_AUTOFD
,
297 PARPORT_CONTROL_AUTOFD
);
299 /* Event 27: nAck goes high */
300 r
= parport_wait_peripheral (port
,
304 DPRINTK (KERN_INFO
"%s: Timeout at event 27\n",
307 /* Event 29: Set nAutoFd high */
308 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
311 port
->ieee1284
.mode
= IEEE1284_MODE_COMPAT
;
312 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
314 DPRINTK (KERN_DEBUG
"%s: In compatibility (forward idle) mode\n",
317 #endif /* IEEE1284 support */
320 * parport_negotiate - negotiate an IEEE 1284 mode
322 * @mode: mode to negotiate to
324 * Use this to negotiate to a particular IEEE 1284 transfer mode.
325 * The @mode parameter should be one of the constants in
326 * parport.h starting %IEEE1284_MODE_xxx.
328 * The return value is 0 if the peripheral has accepted the
329 * negotiation to the mode specified, -1 if the peripheral is not
330 * IEEE 1284 compliant (or not present), or 1 if the peripheral
331 * has rejected the negotiation.
334 int parport_negotiate (struct parport
*port
, int mode
)
336 #ifndef CONFIG_PARPORT_1284
337 if (mode
== IEEE1284_MODE_COMPAT
)
339 printk (KERN_ERR
"parport: IEEE1284 not supported in this kernel\n");
342 int m
= mode
& ~IEEE1284_ADDR
;
346 port
= port
->physport
;
348 /* Is there anything to do? */
349 if (port
->ieee1284
.mode
== mode
)
352 /* Is the difference just an address-or-not bit? */
353 if ((port
->ieee1284
.mode
& ~IEEE1284_ADDR
) == (mode
& ~IEEE1284_ADDR
)){
354 port
->ieee1284
.mode
= mode
;
358 /* Go to compability forward idle mode */
359 if (port
->ieee1284
.mode
!= IEEE1284_MODE_COMPAT
)
360 parport_ieee1284_terminate (port
);
362 if (mode
== IEEE1284_MODE_COMPAT
)
363 /* Compatibility mode: no negotiation. */
367 case IEEE1284_MODE_ECPSWE
:
368 m
= IEEE1284_MODE_ECP
;
370 case IEEE1284_MODE_EPPSL
:
371 case IEEE1284_MODE_EPPSWE
:
372 m
= IEEE1284_MODE_EPP
;
374 case IEEE1284_MODE_BECP
:
375 return -ENOSYS
; /* FIXME (implement BECP) */
378 if (mode
& IEEE1284_EXT_LINK
)
379 m
= 1<<7; /* request extensibility link */
381 port
->ieee1284
.phase
= IEEE1284_PH_NEGOTIATION
;
383 /* Start off with nStrobe and nAutoFd high, and nSelectIn low */
384 parport_frob_control (port
,
385 PARPORT_CONTROL_STROBE
386 | PARPORT_CONTROL_AUTOFD
387 | PARPORT_CONTROL_SELECT
,
388 PARPORT_CONTROL_SELECT
);
391 /* Event 0: Set data */
392 parport_data_forward (port
);
393 parport_write_data (port
, m
);
394 udelay (400); /* Shouldn't need to wait this long. */
396 /* Event 1: Set nSelectIn high, nAutoFd low */
397 parport_frob_control (port
,
398 PARPORT_CONTROL_SELECT
399 | PARPORT_CONTROL_AUTOFD
,
400 PARPORT_CONTROL_AUTOFD
);
402 /* Event 2: PError, Select, nFault go high, nAck goes low */
403 if (parport_wait_peripheral (port
,
405 | PARPORT_STATUS_SELECT
406 | PARPORT_STATUS_PAPEROUT
407 | PARPORT_STATUS_ACK
,
409 | PARPORT_STATUS_SELECT
410 | PARPORT_STATUS_PAPEROUT
)) {
412 parport_frob_control (port
,
413 PARPORT_CONTROL_SELECT
414 | PARPORT_CONTROL_AUTOFD
,
415 PARPORT_CONTROL_SELECT
);
417 "%s: Peripheral not IEEE1284 compliant (0x%02X)\n",
418 port
->name
, parport_read_status (port
));
419 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
420 return -1; /* Not IEEE1284 compliant */
423 /* Event 3: Set nStrobe low */
424 parport_frob_control (port
,
425 PARPORT_CONTROL_STROBE
,
426 PARPORT_CONTROL_STROBE
);
428 /* Event 4: Set nStrobe and nAutoFd high */
430 parport_frob_control (port
,
431 PARPORT_CONTROL_STROBE
432 | PARPORT_CONTROL_AUTOFD
,
435 /* Event 6: nAck goes high */
436 if (parport_wait_peripheral (port
,
438 PARPORT_STATUS_ACK
)) {
439 /* This shouldn't really happen with a compliant device. */
441 "%s: Mode 0x%02x not supported? (0x%02x)\n",
442 port
->name
, mode
, port
->ops
->read_status (port
));
443 parport_ieee1284_terminate (port
);
447 xflag
= parport_read_status (port
) & PARPORT_STATUS_SELECT
;
449 /* xflag should be high for all modes other than nibble (0). */
450 if (mode
&& !xflag
) {
451 /* Mode not supported. */
452 DPRINTK (KERN_DEBUG
"%s: Mode 0x%02x rejected by peripheral\n",
454 parport_ieee1284_terminate (port
);
458 /* More to do if we've requested extensibility link. */
459 if (mode
& IEEE1284_EXT_LINK
) {
462 parport_write_data (port
, m
);
465 /* Event 51: Set nStrobe low */
466 parport_frob_control (port
,
467 PARPORT_CONTROL_STROBE
,
468 PARPORT_CONTROL_STROBE
);
470 /* Event 52: nAck goes low */
471 if (parport_wait_peripheral (port
, PARPORT_STATUS_ACK
, 0)) {
472 /* This peripheral is _very_ slow. */
474 "%s: Event 52 didn't happen\n",
476 parport_ieee1284_terminate (port
);
480 /* Event 53: Set nStrobe high */
481 parport_frob_control (port
,
482 PARPORT_CONTROL_STROBE
,
485 /* Event 55: nAck goes high */
486 if (parport_wait_peripheral (port
,
488 PARPORT_STATUS_ACK
)) {
489 /* This shouldn't really happen with a compliant
492 "%s: Mode 0x%02x not supported? (0x%02x)\n",
494 port
->ops
->read_status (port
));
495 parport_ieee1284_terminate (port
);
499 /* Event 54: Peripheral sets XFlag to reflect support */
500 xflag
= parport_read_status (port
) & PARPORT_STATUS_SELECT
;
502 /* xflag should be high. */
504 /* Extended mode not supported. */
505 DPRINTK (KERN_DEBUG
"%s: Extended mode 0x%02x not "
506 "supported\n", port
->name
, mode
);
507 parport_ieee1284_terminate (port
);
511 /* Any further setup is left to the caller. */
514 /* Mode is supported */
515 DPRINTK (KERN_DEBUG
"%s: In mode 0x%02x\n", port
->name
, mode
);
516 port
->ieee1284
.mode
= mode
;
518 /* But ECP is special */
519 if (!(mode
& IEEE1284_EXT_LINK
) && (m
& IEEE1284_MODE_ECP
)) {
520 port
->ieee1284
.phase
= IEEE1284_PH_ECP_SETUP
;
522 /* Event 30: Set nAutoFd low */
523 parport_frob_control (port
,
524 PARPORT_CONTROL_AUTOFD
,
525 PARPORT_CONTROL_AUTOFD
);
527 /* Event 31: PError goes high. */
528 r
= parport_wait_peripheral (port
,
529 PARPORT_STATUS_PAPEROUT
,
530 PARPORT_STATUS_PAPEROUT
);
532 DPRINTK (KERN_INFO
"%s: Timeout at event 31\n",
536 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
537 DPRINTK (KERN_DEBUG
"%s: ECP direction: forward\n",
539 } else switch (mode
) {
540 case IEEE1284_MODE_NIBBLE
:
541 case IEEE1284_MODE_BYTE
:
542 port
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
545 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
550 #endif /* IEEE1284 support */
553 /* Acknowledge that the peripheral has data available.
554 * Events 18-20, in order to get from Reverse Idle phase
555 * to Host Busy Data Available.
556 * This will most likely be called from an interrupt.
557 * Returns zero if data was available.
559 #ifdef CONFIG_PARPORT_1284
560 static int parport_ieee1284_ack_data_avail (struct parport
*port
)
562 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
)
563 /* Event 18 didn't happen. */
566 /* Event 20: nAutoFd goes high. */
567 port
->ops
->frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
568 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DAVAIL
;
571 #endif /* IEEE1284 support */
573 /* Handle an interrupt. */
574 void parport_ieee1284_interrupt (void *handle
)
576 struct parport
*port
= handle
;
577 parport_ieee1284_wakeup (port
);
579 #ifdef CONFIG_PARPORT_1284
580 if (port
->ieee1284
.phase
== IEEE1284_PH_REV_IDLE
) {
581 /* An interrupt in this phase means that data
582 * is now available. */
583 DPRINTK (KERN_DEBUG
"%s: Data available\n", port
->name
);
584 parport_ieee1284_ack_data_avail (port
);
586 #endif /* IEEE1284 support */
590 * parport_write - write a block of data to a parallel port
591 * @port: port to write to
592 * @buffer: data buffer (in kernel space)
593 * @len: number of bytes of data to transfer
595 * This will write up to @len bytes of @buffer to the port
596 * specified, using the IEEE 1284 transfer mode most recently
597 * negotiated to (using parport_negotiate()), as long as that
598 * mode supports forward transfers (host to peripheral).
600 * It is the caller's responsibility to ensure that the first
601 * @len bytes of @buffer are valid.
603 * This function returns the number of bytes transferred (if zero
604 * or positive), or else an error code.
607 ssize_t
parport_write (struct parport
*port
, const void *buffer
, size_t len
)
609 #ifndef CONFIG_PARPORT_1284
610 return port
->ops
->compat_write_data (port
, buffer
, len
, 0);
613 int mode
= port
->ieee1284
.mode
;
614 int addr
= mode
& IEEE1284_ADDR
;
615 size_t (*fn
) (struct parport
*, const void *, size_t, int);
617 /* Ignore the device-ID-request bit and the address bit. */
618 mode
&= ~(IEEE1284_DEVICEID
| IEEE1284_ADDR
);
620 /* Use the mode we're in. */
622 case IEEE1284_MODE_NIBBLE
:
623 case IEEE1284_MODE_BYTE
:
624 parport_negotiate (port
, IEEE1284_MODE_COMPAT
);
625 case IEEE1284_MODE_COMPAT
:
626 DPRINTK (KERN_DEBUG
"%s: Using compatibility mode\n",
628 fn
= port
->ops
->compat_write_data
;
631 case IEEE1284_MODE_EPP
:
632 DPRINTK (KERN_DEBUG
"%s: Using EPP mode\n", port
->name
);
634 fn
= port
->ops
->epp_write_addr
;
636 fn
= port
->ops
->epp_write_data
;
639 case IEEE1284_MODE_EPPSWE
:
640 DPRINTK (KERN_DEBUG
"%s: Using software-emulated EPP mode\n",
643 fn
= parport_ieee1284_epp_write_addr
;
645 fn
= parport_ieee1284_epp_write_data
;
648 case IEEE1284_MODE_ECP
:
649 case IEEE1284_MODE_ECPRLE
:
650 DPRINTK (KERN_DEBUG
"%s: Using ECP mode\n", port
->name
);
652 fn
= port
->ops
->ecp_write_addr
;
654 fn
= port
->ops
->ecp_write_data
;
658 case IEEE1284_MODE_ECPSWE
:
659 DPRINTK (KERN_DEBUG
"%s: Using software-emulated ECP mode\n",
661 /* The caller has specified that it must be emulated,
662 * even if we have ECP hardware! */
664 fn
= parport_ieee1284_ecp_write_addr
;
666 fn
= parport_ieee1284_ecp_write_data
;
671 DPRINTK (KERN_DEBUG
"%s: Unknown mode 0x%02x\n", port
->name
,
672 port
->ieee1284
.mode
);
676 retval
= (*fn
) (port
, buffer
, len
, 0);
677 DPRINTK (KERN_DEBUG
"%s: wrote %d/%d bytes\n", port
->name
, retval
, len
);
679 #endif /* IEEE1284 support */
683 * parport_read - read a block of data from a parallel port
684 * @port: port to read from
685 * @buffer: data buffer (in kernel space)
686 * @len: number of bytes of data to transfer
688 * This will read up to @len bytes of @buffer to the port
689 * specified, using the IEEE 1284 transfer mode most recently
690 * negotiated to (using parport_negotiate()), as long as that
691 * mode supports reverse transfers (peripheral to host).
693 * It is the caller's responsibility to ensure that the first
694 * @len bytes of @buffer are available to write to.
696 * This function returns the number of bytes transferred (if zero
697 * or positive), or else an error code.
700 ssize_t
parport_read (struct parport
*port
, void *buffer
, size_t len
)
702 #ifndef CONFIG_PARPORT_1284
703 printk (KERN_ERR
"parport: IEEE1284 not supported in this kernel\n");
706 int mode
= port
->physport
->ieee1284
.mode
;
707 int addr
= mode
& IEEE1284_ADDR
;
708 size_t (*fn
) (struct parport
*, void *, size_t, int);
710 /* Ignore the device-ID-request bit and the address bit. */
711 mode
&= ~(IEEE1284_DEVICEID
| IEEE1284_ADDR
);
713 /* Use the mode we're in. */
715 case IEEE1284_MODE_COMPAT
:
716 /* if we can tri-state use BYTE mode instead of NIBBLE mode,
717 * if that fails, revert to NIBBLE mode -- ought to store somewhere
718 * the device's ability to do BYTE mode reverse transfers, so we don't
719 * end up needlessly calling negotiate(BYTE) repeately.. (fb)
721 if ((port
->physport
->modes
& PARPORT_MODE_TRISTATE
) &&
722 !parport_negotiate (port
, IEEE1284_MODE_BYTE
)) {
723 /* got into BYTE mode OK */
724 DPRINTK (KERN_DEBUG
"%s: Using byte mode\n", port
->name
);
725 fn
= port
->ops
->byte_read_data
;
728 if (parport_negotiate (port
, IEEE1284_MODE_NIBBLE
)) {
731 /* fall through to NIBBLE */
732 case IEEE1284_MODE_NIBBLE
:
733 DPRINTK (KERN_DEBUG
"%s: Using nibble mode\n", port
->name
);
734 fn
= port
->ops
->nibble_read_data
;
737 case IEEE1284_MODE_BYTE
:
738 DPRINTK (KERN_DEBUG
"%s: Using byte mode\n", port
->name
);
739 fn
= port
->ops
->byte_read_data
;
742 case IEEE1284_MODE_EPP
:
743 DPRINTK (KERN_DEBUG
"%s: Using EPP mode\n", port
->name
);
745 fn
= port
->ops
->epp_read_addr
;
747 fn
= port
->ops
->epp_read_data
;
750 case IEEE1284_MODE_EPPSWE
:
751 DPRINTK (KERN_DEBUG
"%s: Using software-emulated EPP mode\n",
754 fn
= parport_ieee1284_epp_read_addr
;
756 fn
= parport_ieee1284_epp_read_data
;
759 case IEEE1284_MODE_ECP
:
760 case IEEE1284_MODE_ECPRLE
:
761 DPRINTK (KERN_DEBUG
"%s: Using ECP mode\n", port
->name
);
762 fn
= port
->ops
->ecp_read_data
;
765 case IEEE1284_MODE_ECPSWE
:
766 DPRINTK (KERN_DEBUG
"%s: Using software-emulated ECP mode\n",
768 fn
= parport_ieee1284_ecp_read_data
;
772 DPRINTK (KERN_DEBUG
"%s: Unknown mode 0x%02x\n", port
->name
,
773 port
->physport
->ieee1284
.mode
);
777 return (*fn
) (port
, buffer
, len
, 0);
778 #endif /* IEEE1284 support */
782 * parport_set_timeout - set the inactivity timeout for a device
783 * @dev: device on a port
784 * @inactivity: inactivity timeout (in jiffies)
786 * This sets the inactivity timeout for a particular device on a
787 * port. This affects functions like parport_wait_peripheral().
788 * The special value 0 means not to call schedule() while dealing
791 * The return value is the previous inactivity timeout.
793 * Any callers of parport_wait_event() for this device are woken
797 long parport_set_timeout (struct pardevice
*dev
, long inactivity
)
799 long int old
= dev
->timeout
;
801 dev
->timeout
= inactivity
;
803 if (dev
->port
->physport
->cad
== dev
)
804 parport_ieee1284_wakeup (dev
->port
);
809 /* Exported symbols for modules. */
811 EXPORT_SYMBOL(parport_negotiate
);
812 EXPORT_SYMBOL(parport_write
);
813 EXPORT_SYMBOL(parport_read
);
814 EXPORT_SYMBOL(parport_wait_peripheral
);
815 EXPORT_SYMBOL(parport_wait_event
);
816 EXPORT_SYMBOL(parport_set_timeout
);
817 EXPORT_SYMBOL(parport_ieee1284_interrupt
);