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/module.h>
19 #include <linux/parport.h>
20 #include <linux/delay.h>
21 #include <linux/sched.h>
22 #include <asm/uaccess.h>
24 #undef DEBUG /* undef me for production */
26 #ifdef CONFIG_LP_CONSOLE
27 #undef DEBUG /* Don't want a garbled console */
31 #define DPRINTK(stuff...) printk (stuff)
33 #define DPRINTK(stuff...)
37 * One-way data transfer functions. *
40 /* Compatibility mode. */
41 size_t parport_ieee1284_write_compat (struct parport
*port
,
42 const void *buffer
, size_t len
,
47 const unsigned char *addr
= buffer
;
49 struct pardevice
*dev
= port
->physport
->cad
;
50 unsigned char ctl
= (PARPORT_CONTROL_SELECT
51 | PARPORT_CONTROL_INIT
);
53 if (port
->irq
!= PARPORT_IRQ_NONE
) {
54 parport_enable_irq (port
);
58 port
->physport
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
59 parport_write_control (port
, ctl
);
60 parport_data_forward (port
);
62 unsigned long expire
= jiffies
+ dev
->timeout
;
63 long wait
= (HZ
+ 99) / 100;
64 unsigned char mask
= (PARPORT_STATUS_ERROR
65 | PARPORT_STATUS_BUSY
);
66 unsigned char val
= (PARPORT_STATUS_ERROR
67 | PARPORT_STATUS_BUSY
);
69 /* Wait until the peripheral's ready */
71 /* Is the peripheral ready yet? */
72 if (!parport_wait_peripheral (port
, mask
, val
))
76 /* Is the peripheral upset? */
77 if ((parport_read_status (port
) &
78 (PARPORT_STATUS_PAPEROUT
|
79 PARPORT_STATUS_SELECT
|
80 PARPORT_STATUS_ERROR
))
81 != (PARPORT_STATUS_SELECT
|
82 PARPORT_STATUS_ERROR
))
83 /* If nFault is asserted (i.e. no
84 * error) and PAPEROUT and SELECT are
85 * just red herrings, give the driver
86 * a chance to check it's happy with
87 * that before continuing. */
90 /* Have we run out of time? */
91 if (!time_before (jiffies
, expire
))
94 /* Yield the port for a while. If this is the
95 first time around the loop, don't let go of
96 the port. This way, we find out if we have
97 our interrupt handler called. */
98 if (count
&& no_irq
) {
99 parport_release (dev
);
100 __set_current_state (TASK_INTERRUPTIBLE
);
101 schedule_timeout (wait
);
102 parport_claim_or_block (dev
);
105 /* We must have the device claimed here */
106 parport_wait_event (port
, wait
);
108 /* Is there a signal pending? */
109 if (signal_pending (current
))
112 /* Wait longer next time. */
114 } while (time_before (jiffies
, expire
));
116 if (signal_pending (current
))
119 DPRINTK (KERN_DEBUG
"%s: Timed out\n", port
->name
);
123 /* Write the character to the data lines. */
125 parport_write_data (port
, byte
);
129 parport_write_control (port
, ctl
| PARPORT_CONTROL_STROBE
);
130 udelay (1); /* strobe */
132 parport_write_control (port
, ctl
);
133 udelay (1); /* hold */
135 /* Assume the peripheral received it. */
138 /* Let another process run if it needs to. */
139 if (time_before (jiffies
, expire
))
140 if (!parport_yield_blocking (dev
)
145 port
->physport
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
151 size_t parport_ieee1284_read_nibble (struct parport
*port
,
152 void *buffer
, size_t len
,
155 #ifndef CONFIG_PARPORT_1284
158 unsigned char *buf
= buffer
;
160 unsigned char byte
= 0;
162 len
*= 2; /* in nibbles */
163 for (i
=0; i
< len
; i
++) {
164 unsigned char nibble
;
166 /* Does the error line indicate end of data? */
167 if (((i
& 1) == 0) &&
168 (parport_read_status(port
) & PARPORT_STATUS_ERROR
)) {
169 port
->physport
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
171 "%s: No more nibble data (%d bytes)\n",
174 /* Go to reverse idle phase. */
175 parport_frob_control (port
,
176 PARPORT_CONTROL_AUTOFD
,
177 PARPORT_CONTROL_AUTOFD
);
178 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
182 /* Event 7: Set nAutoFd low. */
183 parport_frob_control (port
,
184 PARPORT_CONTROL_AUTOFD
,
185 PARPORT_CONTROL_AUTOFD
);
187 /* Event 9: nAck goes low. */
188 port
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
189 if (parport_wait_peripheral (port
,
190 PARPORT_STATUS_ACK
, 0)) {
191 /* Timeout -- no more data? */
193 "%s: Nibble timeout at event 9 (%d bytes)\n",
195 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
201 nibble
= parport_read_status (port
) >> 3;
203 if ((nibble
& 0x10) == 0)
207 /* Event 10: Set nAutoFd high. */
208 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
210 /* Event 11: nAck goes high. */
211 if (parport_wait_peripheral (port
,
213 PARPORT_STATUS_ACK
)) {
214 /* Timeout -- no more data? */
216 "%s: Nibble timeout at event 11\n",
229 i
/= 2; /* i is now in bytes */
232 /* Read the last nibble without checking data avail. */
233 port
= port
->physport
;
234 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
)
235 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
237 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DAVAIL
;
241 #endif /* IEEE1284 support */
245 size_t parport_ieee1284_read_byte (struct parport
*port
,
246 void *buffer
, size_t len
,
249 #ifndef CONFIG_PARPORT_1284
252 unsigned char *buf
= buffer
;
255 for (count
= 0; count
< len
; count
++) {
258 /* Data available? */
259 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
) {
260 port
->physport
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
262 "%s: No more byte data (%Zd bytes)\n",
265 /* Go to reverse idle phase. */
266 parport_frob_control (port
,
267 PARPORT_CONTROL_AUTOFD
,
268 PARPORT_CONTROL_AUTOFD
);
269 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
273 /* Event 14: Place data bus in high impedance state. */
274 parport_data_reverse (port
);
276 /* Event 7: Set nAutoFd low. */
277 parport_frob_control (port
,
278 PARPORT_CONTROL_AUTOFD
,
279 PARPORT_CONTROL_AUTOFD
);
281 /* Event 9: nAck goes low. */
282 port
->physport
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
283 if (parport_wait_peripheral (port
,
286 /* Timeout -- no more data? */
287 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
,
289 DPRINTK (KERN_DEBUG
"%s: Byte timeout at event 9\n",
294 byte
= parport_read_data (port
);
297 /* Event 10: Set nAutoFd high */
298 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
300 /* Event 11: nAck goes high. */
301 if (parport_wait_peripheral (port
,
303 PARPORT_STATUS_ACK
)) {
304 /* Timeout -- no more data? */
305 DPRINTK (KERN_DEBUG
"%s: Byte timeout at event 11\n",
310 /* Event 16: Set nStrobe low. */
311 parport_frob_control (port
,
312 PARPORT_CONTROL_STROBE
,
313 PARPORT_CONTROL_STROBE
);
316 /* Event 17: Set nStrobe high. */
317 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
321 /* Read the last byte without checking data avail. */
322 port
= port
->physport
;
323 if (parport_read_status (port
) & PARPORT_STATUS_ERROR
)
324 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DNA
;
326 port
->ieee1284
.phase
= IEEE1284_PH_HBUSY_DAVAIL
;
330 #endif /* IEEE1284 support */
337 #ifdef CONFIG_PARPORT_1284
340 int ecp_forward_to_reverse (struct parport
*port
)
344 /* Event 38: Set nAutoFd low */
345 parport_frob_control (port
,
346 PARPORT_CONTROL_AUTOFD
,
347 PARPORT_CONTROL_AUTOFD
);
348 parport_data_reverse (port
);
351 /* Event 39: Set nInit low to initiate bus reversal */
352 parport_frob_control (port
,
353 PARPORT_CONTROL_INIT
,
356 /* Event 40: PError goes low */
357 retval
= parport_wait_peripheral (port
,
358 PARPORT_STATUS_PAPEROUT
, 0);
361 DPRINTK (KERN_DEBUG
"%s: ECP direction: reverse\n",
363 port
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
365 DPRINTK (KERN_DEBUG
"%s: ECP direction: failed to reverse\n",
367 port
->ieee1284
.phase
= IEEE1284_PH_ECP_DIR_UNKNOWN
;
374 int ecp_reverse_to_forward (struct parport
*port
)
378 /* Event 47: Set nInit high */
379 parport_frob_control (port
,
381 | PARPORT_CONTROL_AUTOFD
,
383 | PARPORT_CONTROL_AUTOFD
);
385 /* Event 49: PError goes high */
386 retval
= parport_wait_peripheral (port
,
387 PARPORT_STATUS_PAPEROUT
,
388 PARPORT_STATUS_PAPEROUT
);
391 parport_data_forward (port
);
392 DPRINTK (KERN_DEBUG
"%s: ECP direction: forward\n",
394 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
397 "%s: ECP direction: failed to switch forward\n",
399 port
->ieee1284
.phase
= IEEE1284_PH_ECP_DIR_UNKNOWN
;
406 #endif /* IEEE1284 support */
408 /* ECP mode, forward channel, data. */
409 size_t parport_ieee1284_ecp_write_data (struct parport
*port
,
410 const void *buffer
, size_t len
,
413 #ifndef CONFIG_PARPORT_1284
416 const unsigned char *buf
= buffer
;
420 port
= port
->physport
;
422 if (port
->ieee1284
.phase
!= IEEE1284_PH_FWD_IDLE
)
423 if (ecp_reverse_to_forward (port
))
426 port
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
428 /* HostAck high (data, not command) */
429 parport_frob_control (port
,
430 PARPORT_CONTROL_AUTOFD
431 | PARPORT_CONTROL_STROBE
432 | PARPORT_CONTROL_INIT
,
433 PARPORT_CONTROL_INIT
);
434 for (written
= 0; written
< len
; written
++, buf
++) {
435 unsigned long expire
= jiffies
+ port
->cad
->timeout
;
440 parport_write_data (port
, byte
);
441 parport_frob_control (port
, PARPORT_CONTROL_STROBE
,
442 PARPORT_CONTROL_STROBE
);
444 for (retry
= 0; retry
< 100; retry
++) {
445 if (!parport_wait_peripheral (port
,
446 PARPORT_STATUS_BUSY
, 0))
449 if (signal_pending (current
)) {
450 parport_frob_control (port
,
451 PARPORT_CONTROL_STROBE
,
457 /* Time for Host Transfer Recovery (page 41 of IEEE1284) */
458 DPRINTK (KERN_DEBUG
"%s: ECP transfer stalled!\n", port
->name
);
460 parport_frob_control (port
, PARPORT_CONTROL_INIT
,
461 PARPORT_CONTROL_INIT
);
463 if (parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
) {
465 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
469 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
471 if (!(parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
))
474 DPRINTK (KERN_DEBUG
"%s: Host transfer recovered\n",
477 if (time_after_eq (jiffies
, expire
)) break;
480 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
482 if (parport_wait_peripheral (port
,
484 PARPORT_STATUS_BUSY
))
485 /* Peripheral hasn't accepted the data. */
489 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
492 #endif /* IEEE1284 support */
495 /* ECP mode, reverse channel, data. */
496 size_t parport_ieee1284_ecp_read_data (struct parport
*port
,
497 void *buffer
, size_t len
, int flags
)
499 #ifndef CONFIG_PARPORT_1284
502 struct pardevice
*dev
= port
->cad
;
503 unsigned char *buf
= buffer
;
504 int rle_count
= 0; /* shut gcc up */
509 port
= port
->physport
;
511 if (port
->ieee1284
.phase
!= IEEE1284_PH_REV_IDLE
)
512 if (ecp_forward_to_reverse (port
))
515 port
->ieee1284
.phase
= IEEE1284_PH_REV_DATA
;
517 /* Set HostAck low to start accepting data. */
518 ctl
= parport_read_control (port
);
519 ctl
&= ~(PARPORT_CONTROL_STROBE
| PARPORT_CONTROL_INIT
|
520 PARPORT_CONTROL_AUTOFD
);
521 parport_write_control (port
,
522 ctl
| PARPORT_CONTROL_AUTOFD
);
523 while (count
< len
) {
524 unsigned long expire
= jiffies
+ dev
->timeout
;
528 /* Event 43: Peripheral sets nAck low. It can take as
530 while (parport_wait_peripheral (port
, PARPORT_STATUS_ACK
, 0)) {
531 /* The peripheral hasn't given us data in
532 35ms. If we have data to give back to the
533 caller, do it now. */
537 /* If we've used up all the time we were allowed,
538 give up altogether. */
539 if (!time_before (jiffies
, expire
))
542 /* Yield the port for a while. */
543 if (count
&& dev
->port
->irq
!= PARPORT_IRQ_NONE
) {
544 parport_release (dev
);
545 __set_current_state (TASK_INTERRUPTIBLE
);
546 schedule_timeout ((HZ
+ 24) / 25);
547 parport_claim_or_block (dev
);
550 /* We must have the device claimed here. */
551 parport_wait_event (port
, (HZ
+ 24) / 25);
553 /* Is there a signal pending? */
554 if (signal_pending (current
))
558 /* Is this a command? */
560 /* The last byte was a run-length count, so
561 this can't be as well. */
564 command
= (parport_read_status (port
) &
565 PARPORT_STATUS_BUSY
) ? 1 : 0;
568 byte
= parport_read_data (port
);
570 /* If this is a channel command, rather than an RLE
571 command or a normal data byte, don't accept it. */
574 DPRINTK (KERN_DEBUG
"%s: stopping short at "
575 "channel command (%02x)\n",
579 else if (port
->ieee1284
.mode
!= IEEE1284_MODE_ECPRLE
)
580 DPRINTK (KERN_DEBUG
"%s: device illegally "
581 "using RLE; accepting anyway\n",
584 rle_count
= byte
+ 1;
586 /* Are we allowed to read that many bytes? */
587 if (rle_count
> (len
- count
)) {
588 DPRINTK (KERN_DEBUG
"%s: leaving %d RLE bytes "
589 "for next time\n", port
->name
,
597 /* Event 44: Set HostAck high, acknowledging handshake. */
598 parport_write_control (port
, ctl
);
600 /* Event 45: The peripheral has 35ms to set nAck high. */
601 if (parport_wait_peripheral (port
, PARPORT_STATUS_ACK
,
602 PARPORT_STATUS_ACK
)) {
603 /* It's gone wrong. Return what data we have
605 DPRINTK (KERN_DEBUG
"ECP read timed out at 45\n");
609 "%s: command ignored (%02x)\n",
615 /* Event 46: Set HostAck low and accept the data. */
616 parport_write_control (port
,
617 ctl
| PARPORT_CONTROL_AUTOFD
);
619 /* If we just read a run-length count, fetch the data. */
623 /* If this is the byte after a run-length count, decompress. */
626 memset (buf
, byte
, rle_count
);
629 DPRINTK (KERN_DEBUG
"%s: decompressed to %d bytes\n",
630 port
->name
, rle_count
);
632 /* Normal data byte. */
639 port
->ieee1284
.phase
= IEEE1284_PH_REV_IDLE
;
641 #endif /* IEEE1284 support */
644 /* ECP mode, forward channel, commands. */
645 size_t parport_ieee1284_ecp_write_addr (struct parport
*port
,
646 const void *buffer
, size_t len
,
649 #ifndef CONFIG_PARPORT_1284
652 const unsigned char *buf
= buffer
;
656 port
= port
->physport
;
658 if (port
->ieee1284
.phase
!= IEEE1284_PH_FWD_IDLE
)
659 if (ecp_reverse_to_forward (port
))
662 port
->ieee1284
.phase
= IEEE1284_PH_FWD_DATA
;
664 /* HostAck low (command, not data) */
665 parport_frob_control (port
,
666 PARPORT_CONTROL_AUTOFD
667 | PARPORT_CONTROL_STROBE
668 | PARPORT_CONTROL_INIT
,
669 PARPORT_CONTROL_AUTOFD
670 | PARPORT_CONTROL_INIT
);
671 for (written
= 0; written
< len
; written
++, buf
++) {
672 unsigned long expire
= jiffies
+ port
->cad
->timeout
;
677 parport_write_data (port
, byte
);
678 parport_frob_control (port
, PARPORT_CONTROL_STROBE
,
679 PARPORT_CONTROL_STROBE
);
681 for (retry
= 0; retry
< 100; retry
++) {
682 if (!parport_wait_peripheral (port
,
683 PARPORT_STATUS_BUSY
, 0))
686 if (signal_pending (current
)) {
687 parport_frob_control (port
,
688 PARPORT_CONTROL_STROBE
,
694 /* Time for Host Transfer Recovery (page 41 of IEEE1284) */
695 DPRINTK (KERN_DEBUG
"%s: ECP transfer stalled!\n", port
->name
);
697 parport_frob_control (port
, PARPORT_CONTROL_INIT
,
698 PARPORT_CONTROL_INIT
);
700 if (parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
) {
702 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
706 parport_frob_control (port
, PARPORT_CONTROL_INIT
, 0);
708 if (!(parport_read_status (port
) & PARPORT_STATUS_PAPEROUT
))
711 DPRINTK (KERN_DEBUG
"%s: Host transfer recovered\n",
714 if (time_after_eq (jiffies
, expire
)) break;
717 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
719 if (parport_wait_peripheral (port
,
721 PARPORT_STATUS_BUSY
))
722 /* Peripheral hasn't accepted the data. */
726 port
->ieee1284
.phase
= IEEE1284_PH_FWD_IDLE
;
729 #endif /* IEEE1284 support */
736 /* EPP mode, forward channel, data. */
737 size_t parport_ieee1284_epp_write_data (struct parport
*port
,
738 const void *buffer
, size_t len
,
741 unsigned char *bp
= (unsigned char *) buffer
;
744 /* set EPP idle state (just to make sure) with strobe low */
745 parport_frob_control (port
,
746 PARPORT_CONTROL_STROBE
|
747 PARPORT_CONTROL_AUTOFD
|
748 PARPORT_CONTROL_SELECT
|
749 PARPORT_CONTROL_INIT
,
750 PARPORT_CONTROL_STROBE
|
751 PARPORT_CONTROL_INIT
);
752 port
->ops
->data_forward (port
);
753 for (; len
> 0; len
--, bp
++) {
754 /* Event 62: Write data and set autofd low */
755 parport_write_data (port
, *bp
);
756 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
,
757 PARPORT_CONTROL_AUTOFD
);
759 /* Event 58: wait for busy (nWait) to go high */
760 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
, 0, 10))
763 /* Event 63: set nAutoFd (nDStrb) high */
764 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
766 /* Event 60: wait for busy (nWait) to go low */
767 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
768 PARPORT_STATUS_BUSY
, 5))
774 /* Event 61: set strobe (nWrite) high */
775 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
780 /* EPP mode, reverse channel, data. */
781 size_t parport_ieee1284_epp_read_data (struct parport
*port
,
782 void *buffer
, size_t len
,
785 unsigned char *bp
= (unsigned char *) buffer
;
788 /* set EPP idle state (just to make sure) with strobe high */
789 parport_frob_control (port
,
790 PARPORT_CONTROL_STROBE
|
791 PARPORT_CONTROL_AUTOFD
|
792 PARPORT_CONTROL_SELECT
|
793 PARPORT_CONTROL_INIT
,
794 PARPORT_CONTROL_INIT
);
795 port
->ops
->data_reverse (port
);
796 for (; len
> 0; len
--, bp
++) {
797 /* Event 67: set nAutoFd (nDStrb) low */
798 parport_frob_control (port
,
799 PARPORT_CONTROL_AUTOFD
,
800 PARPORT_CONTROL_AUTOFD
);
801 /* Event 58: wait for Busy to go high */
802 if (parport_wait_peripheral (port
, PARPORT_STATUS_BUSY
, 0)) {
806 *bp
= parport_read_data (port
);
808 /* Event 63: set nAutoFd (nDStrb) high */
809 parport_frob_control (port
, PARPORT_CONTROL_AUTOFD
, 0);
811 /* Event 60: wait for Busy to go low */
812 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
813 PARPORT_STATUS_BUSY
, 5)) {
819 port
->ops
->data_forward (port
);
824 /* EPP mode, forward channel, addresses. */
825 size_t parport_ieee1284_epp_write_addr (struct parport
*port
,
826 const void *buffer
, size_t len
,
829 unsigned char *bp
= (unsigned char *) buffer
;
832 /* set EPP idle state (just to make sure) with strobe low */
833 parport_frob_control (port
,
834 PARPORT_CONTROL_STROBE
|
835 PARPORT_CONTROL_AUTOFD
|
836 PARPORT_CONTROL_SELECT
|
837 PARPORT_CONTROL_INIT
,
838 PARPORT_CONTROL_STROBE
|
839 PARPORT_CONTROL_INIT
);
840 port
->ops
->data_forward (port
);
841 for (; len
> 0; len
--, bp
++) {
842 /* Event 56: Write data and set nAStrb low. */
843 parport_write_data (port
, *bp
);
844 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
845 PARPORT_CONTROL_SELECT
);
847 /* Event 58: wait for busy (nWait) to go high */
848 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
, 0, 10))
851 /* Event 59: set nAStrb high */
852 parport_frob_control (port
, PARPORT_CONTROL_SELECT
, 0);
854 /* Event 60: wait for busy (nWait) to go low */
855 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
856 PARPORT_STATUS_BUSY
, 5))
862 /* Event 61: set strobe (nWrite) high */
863 parport_frob_control (port
, PARPORT_CONTROL_STROBE
, 0);
868 /* EPP mode, reverse channel, addresses. */
869 size_t parport_ieee1284_epp_read_addr (struct parport
*port
,
870 void *buffer
, size_t len
,
873 unsigned char *bp
= (unsigned char *) buffer
;
876 /* Set EPP idle state (just to make sure) with strobe high */
877 parport_frob_control (port
,
878 PARPORT_CONTROL_STROBE
|
879 PARPORT_CONTROL_AUTOFD
|
880 PARPORT_CONTROL_SELECT
|
881 PARPORT_CONTROL_INIT
,
882 PARPORT_CONTROL_INIT
);
883 port
->ops
->data_reverse (port
);
884 for (; len
> 0; len
--, bp
++) {
885 /* Event 64: set nSelectIn (nAStrb) low */
886 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
887 PARPORT_CONTROL_SELECT
);
889 /* Event 58: wait for Busy to go high */
890 if (parport_wait_peripheral (port
, PARPORT_STATUS_BUSY
, 0)) {
894 *bp
= parport_read_data (port
);
896 /* Event 59: set nSelectIn (nAStrb) high */
897 parport_frob_control (port
, PARPORT_CONTROL_SELECT
,
898 PARPORT_CONTROL_SELECT
);
900 /* Event 60: wait for Busy to go low */
901 if (parport_poll_peripheral (port
, PARPORT_STATUS_BUSY
,
902 PARPORT_STATUS_BUSY
, 5))
907 port
->ops
->data_forward (port
);
912 EXPORT_SYMBOL(parport_ieee1284_ecp_write_data
);
913 EXPORT_SYMBOL(parport_ieee1284_ecp_read_data
);
914 EXPORT_SYMBOL(parport_ieee1284_ecp_write_addr
);
915 EXPORT_SYMBOL(parport_ieee1284_write_compat
);
916 EXPORT_SYMBOL(parport_ieee1284_read_nibble
);
917 EXPORT_SYMBOL(parport_ieee1284_read_byte
);
918 EXPORT_SYMBOL(parport_ieee1284_epp_write_data
);
919 EXPORT_SYMBOL(parport_ieee1284_epp_read_data
);
920 EXPORT_SYMBOL(parport_ieee1284_epp_write_addr
);
921 EXPORT_SYMBOL(parport_ieee1284_epp_read_addr
);