1 /* IEEE-1284 operations for parport.
3 * This file is for generic IEEE 1284 operations. The idea is that
4 * they are used by the low-level drivers. If they have a special way
5 * of doing something, they can provide their own routines (and put
6 * the function pointers in port->ops); if not, they can just use these
9 * Note: Make no assumptions about hardware or architecture in this file!
11 * Author: Tim Waugh <tim@cyberelk.demon.co.uk>
12 * Fixed AUTOFD polarity in ecp_forward_to_reverse(). Fred Barnes, 1999
13 * Software emulated EPP fixes, Fred Barnes, 04/2001.
17 #include <linux/config.h>
18 #include <linux/parport.h>
19 #include <linux/delay.h>
20 #include <linux/sched.h>
21 #include <asm/uaccess.h>
23 #undef DEBUG /* undef me for production */
25 #ifdef CONFIG_LP_CONSOLE
26 #undef DEBUG /* Don't want a garbled console */
30 #define DPRINTK(stuff...) printk (stuff)
32 #define DPRINTK(stuff...)
36 * One-way data transfer functions. *
39 /* Compatibility mode. */
40 size_t parport_ieee1284_write_compat (struct parport
*port
,
41 const void *buffer
, size_t len
,
46 const unsigned char *addr
= buffer
;
48 struct pardevice
*dev
= port
->physport
->cad
;
49 unsigned char ctl
= (PARPORT_CONTROL_SELECT
50 | PARPORT_CONTROL_INIT
);
52 if (port
->irq
!= PARPORT_IRQ_NONE
) {
53 parport_enable_irq (port
);
57 port
->physport
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
58 parport_write_control (port
, ctl
);
59 parport_data_forward (port
);
61 unsigned long expire
= jiffies
+ dev
->timeout
;
62 long wait
= (HZ
+ 99) / 100;
63 unsigned char mask
= (PARPORT_STATUS_ERROR
64 | PARPORT_STATUS_BUSY
);
65 unsigned char val
= (PARPORT_STATUS_ERROR
66 | PARPORT_STATUS_BUSY
);
68 /* Wait until the peripheral's ready */
70 /* Is the peripheral ready yet? */
71 if (!parport_wait_peripheral (port
, mask
, val
))
75 /* Is the peripheral upset? */
76 if ((parport_read_status (port
) &
77 (PARPORT_STATUS_PAPEROUT
|
78 PARPORT_STATUS_SELECT
|
79 PARPORT_STATUS_ERROR
))
80 != (PARPORT_STATUS_SELECT
|
81 PARPORT_STATUS_ERROR
))
82 /* If nFault is asserted (i.e. no
83 * error) and PAPEROUT and SELECT are
84 * just red herrings, give the driver
85 * a chance to check it's happy with
86 * that before continuing. */
89 /* Have we run out of time? */
90 if (!time_before (jiffies
, expire
))
93 /* Yield the port for a while. If this is the
94 first time around the loop, don't let go of
95 the port. This way, we find out if we have
96 our interrupt handler called. */
97 if (count
&& no_irq
) {
98 parport_release (dev
);
99 __set_current_state (TASK_INTERRUPTIBLE
);
100 schedule_timeout (wait
);
101 parport_claim_or_block (dev
);
104 /* We must have the device claimed here */
105 parport_wait_event (port
, wait
);
107 /* Is there a signal pending? */
108 if (signal_pending (current
))
111 /* Wait longer next time. */
113 } while (time_before (jiffies
, expire
));
115 if (signal_pending (current
))
118 DPRINTK (KERN_DEBUG
"%s: Timed out\n", port
->name
);
122 /* Write the character to the data lines. */
124 parport_write_data (port
, byte
);
128 parport_write_control (port
, ctl
| PARPORT_CONTROL_STROBE
);
129 udelay (1); /* strobe */
131 parport_write_control (port
, ctl
);
132 udelay (1); /* hold */
134 /* Assume the peripheral received it. */
137 /* Let another process run if it needs to. */
138 if (time_before (jiffies
, expire
))
139 if (!parport_yield_blocking (dev
)
144 port
->physport
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
150 size_t parport_ieee1284_read_nibble (struct parport
*port
,
151 void *buffer
, size_t len
,
154 #ifndef CONFIG_PARPORT_1284
157 unsigned char *buf
= buffer
;
159 unsigned char byte
= 0;
161 len
*= 2; /* in nibbles */
162 for (i
=0; i
< len
; i
++) {
163 unsigned char nibble
;
165 /* Does the error line indicate end of data? */
166 if (((i
& 1) == 0) &&
167 (parport_read_status(port
) & PARPORT_STATUS_ERROR
)) {
168 port
->physport
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
170 "%s: No more nibble data (%d bytes)\n",
173 /* Go to reverse idle phase. */
174 parport_frob_control (port
,
175 PARPORT_CONTROL_AUTOFD
,
176 PARPORT_CONTROL_AUTOFD
);
177 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
181 /* Event 7: Set nAutoFd low. */
182 parport_frob_control (port
,
183 PARPORT_CONTROL_AUTOFD
,
184 PARPORT_CONTROL_AUTOFD
);
186 /* Event 9: nAck goes low. */
187 port
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
188 if (parport_wait_peripheral (port
,
189 PARPORT_STATUS_ACK
, 0)) {
190 /* Timeout -- no more data? */
192 "%s: Nibble timeout at event 9 (%d bytes)\n",
194 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
200 nibble
= parport_read_status (port
) >> 3;
202 if ((nibble
& 0x10) == 0)
206 /* Event 10: Set nAutoFd high. */
207 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
209 /* Event 11: nAck goes high. */
210 if (parport_wait_peripheral (port
,
212 PARPORT_STATUS_ACK
)) {
213 /* Timeout -- no more data? */
215 "%s: Nibble timeout at event 11\n",
228 i
/= 2; /* i is now in bytes */
231 /* Read the last nibble without checking data avail. */
232 port
= port
->physport
;
233 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
)
234 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
236 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DAVAIL
;
240 #endif /* IEEE1284 support */
244 size_t parport_ieee1284_read_byte (struct parport
*port
,
245 void *buffer
, size_t len
,
248 #ifndef CONFIG_PARPORT_1284
251 unsigned char *buf
= buffer
;
254 for (count
= 0; count
< len
; count
++) {
257 /* Data available? */
258 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
) {
259 port
->physport
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
261 "%s: No more byte data (%Zd bytes)\n",
264 /* Go to reverse idle phase. */
265 parport_frob_control (port
,
266 PARPORT_CONTROL_AUTOFD
,
267 PARPORT_CONTROL_AUTOFD
);
268 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
272 /* Event 14: Place data bus in high impedance state. */
273 parport_data_reverse (port
);
275 /* Event 7: Set nAutoFd low. */
276 parport_frob_control (port
,
277 PARPORT_CONTROL_AUTOFD
,
278 PARPORT_CONTROL_AUTOFD
);
280 /* Event 9: nAck goes low. */
281 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
282 if (parport_wait_peripheral (port
,
285 /* Timeout -- no more data? */
286 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
,
288 DPRINTK (KERN_DEBUG
"%s: Byte timeout at event 9\n",
293 byte
= parport_read_data (port
);
296 /* Event 10: Set nAutoFd high */
297 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
299 /* Event 11: nAck goes high. */
300 if (parport_wait_peripheral (port
,
302 PARPORT_STATUS_ACK
)) {
303 /* Timeout -- no more data? */
304 DPRINTK (KERN_DEBUG
"%s: Byte timeout at event 11\n",
309 /* Event 16: Set nStrobe low. */
310 parport_frob_control (port
,
311 PARPORT_CONTROL_STROBE
,
312 PARPORT_CONTROL_STROBE
);
315 /* Event 17: Set nStrobe high. */
316 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
320 /* Read the last byte without checking data avail. */
321 port
= port
->physport
;
322 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
)
323 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
325 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DAVAIL
;
329 #endif /* IEEE1284 support */
336 #ifdef CONFIG_PARPORT_1284
339 int ecp_forward_to_reverse (struct parport
*port
)
343 /* Event 38: Set nAutoFd low */
344 parport_frob_control (port
,
345 PARPORT_CONTROL_AUTOFD
,
346 PARPORT_CONTROL_AUTOFD
);
347 parport_data_reverse (port
);
350 /* Event 39: Set nInit low to initiate bus reversal */
351 parport_frob_control (port
,
352 PARPORT_CONTROL_INIT
,
355 /* Event 40: PError goes low */
356 retval
= parport_wait_peripheral (port
,
357 PARPORT_STATUS_PAPEROUT
, 0);
360 DPRINTK (KERN_DEBUG
"%s: ECP direction: reverse\n",
362 port
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
364 DPRINTK (KERN_DEBUG
"%s: ECP direction: failed to reverse\n",
366 port
->ieee1284
.phase
= IEEE1284_PH_ECP_DIR_UNKNOWN
;
373 int ecp_reverse_to_forward (struct parport
*port
)
377 /* Event 47: Set nInit high */
378 parport_frob_control (port
,
380 | PARPORT_CONTROL_AUTOFD
,
382 | PARPORT_CONTROL_AUTOFD
);
384 /* Event 49: PError goes high */
385 retval
= parport_wait_peripheral (port
,
386 PARPORT_STATUS_PAPEROUT
,
387 PARPORT_STATUS_PAPEROUT
);
390 parport_data_forward (port
);
391 DPRINTK (KERN_DEBUG
"%s: ECP direction: forward\n",
393 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
396 "%s: ECP direction: failed to switch forward\n",
398 port
->ieee1284
.phase
= IEEE1284_PH_ECP_DIR_UNKNOWN
;
405 #endif /* IEEE1284 support */
407 /* ECP mode, forward channel, data. */
408 size_t parport_ieee1284_ecp_write_data (struct parport
*port
,
409 const void *buffer
, size_t len
,
412 #ifndef CONFIG_PARPORT_1284
415 const unsigned char *buf
= buffer
;
419 port
= port
->physport
;
421 if (port
->ieee1284
.phase
!= IEEE1284_PH_FWD_IDLE
)
422 if (ecp_reverse_to_forward (port
))
425 port
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
427 /* HostAck high (data, not command) */
428 parport_frob_control (port
,
429 PARPORT_CONTROL_AUTOFD
430 | PARPORT_CONTROL_STROBE
431 | PARPORT_CONTROL_INIT
,
432 PARPORT_CONTROL_INIT
);
433 for (written
= 0; written
< len
; written
++, buf
++) {
434 unsigned long expire
= jiffies
+ port
->cad
->timeout
;
439 parport_write_data (port
, byte
);
440 parport_frob_control (port
, PARPORT_CONTROL_STROBE
,
441 PARPORT_CONTROL_STROBE
);
443 for (retry
= 0; retry
< 100; retry
++) {
444 if (!parport_wait_peripheral (port
,
445 PARPORT_STATUS_BUSY
, 0))
448 if (signal_pending (current
)) {
449 parport_frob_control (port
,
450 PARPORT_CONTROL_STROBE
,
456 /* Time for Host Transfer Recovery (page 41 of IEEE1284) */
457 DPRINTK (KERN_DEBUG
"%s: ECP transfer stalled!\n", port
->name
);
459 parport_frob_control (port
, PARPORT_CONTROL_INIT
,
460 PARPORT_CONTROL_INIT
);
462 if (parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
) {
464 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
468 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
470 if (!(parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
))
473 DPRINTK (KERN_DEBUG
"%s: Host transfer recovered\n",
476 if (time_after_eq (jiffies
, expire
)) break;
479 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
481 if (parport_wait_peripheral (port
,
483 PARPORT_STATUS_BUSY
))
484 /* Peripheral hasn't accepted the data. */
488 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
491 #endif /* IEEE1284 support */
494 /* ECP mode, reverse channel, data. */
495 size_t parport_ieee1284_ecp_read_data (struct parport
*port
,
496 void *buffer
, size_t len
, int flags
)
498 #ifndef CONFIG_PARPORT_1284
501 struct pardevice
*dev
= port
->cad
;
502 unsigned char *buf
= buffer
;
503 int rle_count
= 0; /* shut gcc up */
508 port
= port
->physport
;
510 if (port
->ieee1284
.phase
!= IEEE1284_PH_REV_IDLE
)
511 if (ecp_forward_to_reverse (port
))
514 port
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
516 /* Set HostAck low to start accepting data. */
517 ctl
= parport_read_control (port
);
518 ctl
&= ~(PARPORT_CONTROL_STROBE
| PARPORT_CONTROL_INIT
|
519 PARPORT_CONTROL_AUTOFD
);
520 parport_write_control (port
,
521 ctl
| PARPORT_CONTROL_AUTOFD
);
522 while (count
< len
) {
523 unsigned long expire
= jiffies
+ dev
->timeout
;
527 /* Event 43: Peripheral sets nAck low. It can take as
529 while (parport_wait_peripheral (port
, PARPORT_STATUS_ACK
, 0)) {
530 /* The peripheral hasn't given us data in
531 35ms. If we have data to give back to the
532 caller, do it now. */
536 /* If we've used up all the time we were allowed,
537 give up altogether. */
538 if (!time_before (jiffies
, expire
))
541 /* Yield the port for a while. */
542 if (count
&& dev
->port
->irq
!= PARPORT_IRQ_NONE
) {
543 parport_release (dev
);
544 __set_current_state (TASK_INTERRUPTIBLE
);
545 schedule_timeout ((HZ
+ 24) / 25);
546 parport_claim_or_block (dev
);
549 /* We must have the device claimed here. */
550 parport_wait_event (port
, (HZ
+ 24) / 25);
552 /* Is there a signal pending? */
553 if (signal_pending (current
))
557 /* Is this a command? */
559 /* The last byte was a run-length count, so
560 this can't be as well. */
563 command
= (parport_read_status (port
) &
564 PARPORT_STATUS_BUSY
) ? 1 : 0;
567 byte
= parport_read_data (port
);
569 /* If this is a channel command, rather than an RLE
570 command or a normal data byte, don't accept it. */
573 DPRINTK (KERN_DEBUG
"%s: stopping short at "
574 "channel command (%02x)\n",
578 else if (port
->ieee1284
.mode
!= IEEE1284_MODE_ECPRLE
)
579 DPRINTK (KERN_DEBUG
"%s: device illegally "
580 "using RLE; accepting anyway\n",
583 rle_count
= byte
+ 1;
585 /* Are we allowed to read that many bytes? */
586 if (rle_count
> (len
- count
)) {
587 DPRINTK (KERN_DEBUG
"%s: leaving %d RLE bytes "
588 "for next time\n", port
->name
,
596 /* Event 44: Set HostAck high, acknowledging handshake. */
597 parport_write_control (port
, ctl
);
599 /* Event 45: The peripheral has 35ms to set nAck high. */
600 if (parport_wait_peripheral (port
, PARPORT_STATUS_ACK
,
601 PARPORT_STATUS_ACK
)) {
602 /* It's gone wrong. Return what data we have
604 DPRINTK (KERN_DEBUG
"ECP read timed out at 45\n");
608 "%s: command ignored (%02x)\n",
614 /* Event 46: Set HostAck low and accept the data. */
615 parport_write_control (port
,
616 ctl
| PARPORT_CONTROL_AUTOFD
);
618 /* If we just read a run-length count, fetch the data. */
622 /* If this is the byte after a run-length count, decompress. */
625 memset (buf
, byte
, rle_count
);
628 DPRINTK (KERN_DEBUG
"%s: decompressed to %d bytes\n",
629 port
->name
, rle_count
);
631 /* Normal data byte. */
638 port
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
640 #endif /* IEEE1284 support */
643 /* ECP mode, forward channel, commands. */
644 size_t parport_ieee1284_ecp_write_addr (struct parport
*port
,
645 const void *buffer
, size_t len
,
648 #ifndef CONFIG_PARPORT_1284
651 const unsigned char *buf
= buffer
;
655 port
= port
->physport
;
657 if (port
->ieee1284
.phase
!= IEEE1284_PH_FWD_IDLE
)
658 if (ecp_reverse_to_forward (port
))
661 port
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
663 /* HostAck low (command, not data) */
664 parport_frob_control (port
,
665 PARPORT_CONTROL_AUTOFD
666 | PARPORT_CONTROL_STROBE
667 | PARPORT_CONTROL_INIT
,
668 PARPORT_CONTROL_AUTOFD
669 | PARPORT_CONTROL_INIT
);
670 for (written
= 0; written
< len
; written
++, buf
++) {
671 unsigned long expire
= jiffies
+ port
->cad
->timeout
;
676 parport_write_data (port
, byte
);
677 parport_frob_control (port
, PARPORT_CONTROL_STROBE
,
678 PARPORT_CONTROL_STROBE
);
680 for (retry
= 0; retry
< 100; retry
++) {
681 if (!parport_wait_peripheral (port
,
682 PARPORT_STATUS_BUSY
, 0))
685 if (signal_pending (current
)) {
686 parport_frob_control (port
,
687 PARPORT_CONTROL_STROBE
,
693 /* Time for Host Transfer Recovery (page 41 of IEEE1284) */
694 DPRINTK (KERN_DEBUG
"%s: ECP transfer stalled!\n", port
->name
);
696 parport_frob_control (port
, PARPORT_CONTROL_INIT
,
697 PARPORT_CONTROL_INIT
);
699 if (parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
) {
701 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
705 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
707 if (!(parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
))
710 DPRINTK (KERN_DEBUG
"%s: Host transfer recovered\n",
713 if (time_after_eq (jiffies
, expire
)) break;
716 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
718 if (parport_wait_peripheral (port
,
720 PARPORT_STATUS_BUSY
))
721 /* Peripheral hasn't accepted the data. */
725 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
728 #endif /* IEEE1284 support */
735 /* EPP mode, forward channel, data. */
736 size_t parport_ieee1284_epp_write_data (struct parport
*port
,
737 const void *buffer
, size_t len
,
740 unsigned char *bp
= (unsigned char *) buffer
;
743 /* set EPP idle state (just to make sure) with strobe low */
744 parport_frob_control (port
,
745 PARPORT_CONTROL_STROBE
|
746 PARPORT_CONTROL_AUTOFD
|
747 PARPORT_CONTROL_SELECT
|
748 PARPORT_CONTROL_INIT
,
749 PARPORT_CONTROL_STROBE
|
750 PARPORT_CONTROL_INIT
);
751 port
->ops
->data_forward (port
);
752 for (; len
> 0; len
--, bp
++) {
753 /* Event 62: Write data and set autofd low */
754 parport_write_data (port
, *bp
);
755 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
,
756 PARPORT_CONTROL_AUTOFD
);
758 /* Event 58: wait for busy (nWait) to go high */
759 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
, 0, 10))
762 /* Event 63: set nAutoFd (nDStrb) high */
763 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
765 /* Event 60: wait for busy (nWait) to go low */
766 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
767 PARPORT_STATUS_BUSY
, 5))
773 /* Event 61: set strobe (nWrite) high */
774 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
779 /* EPP mode, reverse channel, data. */
780 size_t parport_ieee1284_epp_read_data (struct parport
*port
,
781 void *buffer
, size_t len
,
784 unsigned char *bp
= (unsigned char *) buffer
;
787 /* set EPP idle state (just to make sure) with strobe high */
788 parport_frob_control (port
,
789 PARPORT_CONTROL_STROBE
|
790 PARPORT_CONTROL_AUTOFD
|
791 PARPORT_CONTROL_SELECT
|
792 PARPORT_CONTROL_INIT
,
793 PARPORT_CONTROL_INIT
);
794 port
->ops
->data_reverse (port
);
795 for (; len
> 0; len
--, bp
++) {
796 /* Event 67: set nAutoFd (nDStrb) low */
797 parport_frob_control (port
,
798 PARPORT_CONTROL_AUTOFD
,
799 PARPORT_CONTROL_AUTOFD
);
800 /* Event 58: wait for Busy to go high */
801 if (parport_wait_peripheral (port
, PARPORT_STATUS_BUSY
, 0)) {
805 *bp
= parport_read_data (port
);
807 /* Event 63: set nAutoFd (nDStrb) high */
808 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
810 /* Event 60: wait for Busy to go low */
811 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
812 PARPORT_STATUS_BUSY
, 5)) {
818 port
->ops
->data_forward (port
);
823 /* EPP mode, forward channel, addresses. */
824 size_t parport_ieee1284_epp_write_addr (struct parport
*port
,
825 const void *buffer
, size_t len
,
828 unsigned char *bp
= (unsigned char *) buffer
;
831 /* set EPP idle state (just to make sure) with strobe low */
832 parport_frob_control (port
,
833 PARPORT_CONTROL_STROBE
|
834 PARPORT_CONTROL_AUTOFD
|
835 PARPORT_CONTROL_SELECT
|
836 PARPORT_CONTROL_INIT
,
837 PARPORT_CONTROL_STROBE
|
838 PARPORT_CONTROL_INIT
);
839 port
->ops
->data_forward (port
);
840 for (; len
> 0; len
--, bp
++) {
841 /* Event 56: Write data and set nAStrb low. */
842 parport_write_data (port
, *bp
);
843 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
844 PARPORT_CONTROL_SELECT
);
846 /* Event 58: wait for busy (nWait) to go high */
847 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
, 0, 10))
850 /* Event 59: set nAStrb high */
851 parport_frob_control (port
, PARPORT_CONTROL_SELECT
, 0);
853 /* Event 60: wait for busy (nWait) to go low */
854 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
855 PARPORT_STATUS_BUSY
, 5))
861 /* Event 61: set strobe (nWrite) high */
862 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
867 /* EPP mode, reverse channel, addresses. */
868 size_t parport_ieee1284_epp_read_addr (struct parport
*port
,
869 void *buffer
, size_t len
,
872 unsigned char *bp
= (unsigned char *) buffer
;
875 /* Set EPP idle state (just to make sure) with strobe high */
876 parport_frob_control (port
,
877 PARPORT_CONTROL_STROBE
|
878 PARPORT_CONTROL_AUTOFD
|
879 PARPORT_CONTROL_SELECT
|
880 PARPORT_CONTROL_INIT
,
881 PARPORT_CONTROL_INIT
);
882 port
->ops
->data_reverse (port
);
883 for (; len
> 0; len
--, bp
++) {
884 /* Event 64: set nSelectIn (nAStrb) low */
885 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
886 PARPORT_CONTROL_SELECT
);
888 /* Event 58: wait for Busy to go high */
889 if (parport_wait_peripheral (port
, PARPORT_STATUS_BUSY
, 0)) {
893 *bp
= parport_read_data (port
);
895 /* Event 59: set nSelectIn (nAStrb) high */
896 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
897 PARPORT_CONTROL_SELECT
);
899 /* Event 60: wait for Busy to go low */
900 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
901 PARPORT_STATUS_BUSY
, 5))
906 port
->ops
->data_forward (port
);