Documentation/driver-api/parport-lowlevel.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

Parallel Port Low-level Driver API

병렬 포트 드라이버 등록·공유·IEEE 1284 협상과 SPP/EPP/ECP 저수준 연산을 다루는 전문 번역입니다.

Source pathDocumentation/driver-api/parport-lowlevel.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

parport-lowlevel.rst:1-1832

이 문서는 Linux `parport` 공유 계층의 전체 저수준 계약을 설명합니다. 장치 드라이버는 포트 알림과 `pardevice`를 등록하고, claim·release·yield로 소유권을 조정한 뒤 IEEE 1284 모드를 협상해 전송합니다. 포트 드라이버는 `struct parport_operations`에 레지스터, IRQ, 방향, EPP·ECP·기본 block 전송을 구현합니다.

안전한 호출 순서는 수명 확보, 포트 claim, mode와 timeout 설정, 전송, release입니다. 특히 양수 반환이 성공 후 대기 또는 timeout을 뜻하는 API, `-EAGAIN` 뒤 소유권 재확보, 0-jiffy의 non-blocking 규칙, EPP fast timeout과 ECP FIFO 조건을 구분해야 합니다.

문서 구성
원문 줄주제핵심 계약
1-356개요와 드라이버 등록동적 attach/detach, mode는 조언 정보
357-669장치와 소유권콜백 수명, claim/release/yield
670-1144전역 전송 API대기, 협상, ID·검색, timeout
1145-1468SPP와 포트 제어data/status/control, IRQ, 방향
1469-1732EPP·ECPfast timeout, data/address, FIFO
1733-1832기본 block 전송nibble, byte, compatibility

상위 장치 API와 하위 포트 연산의 경계를 따라 읽으면 구현 책임이 선명해집니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ===============================
2 PARPORT interface documentation
3 ===============================
4
5 :Time-stamp: <2000-02-24 13:30:20 twaugh>
6
7 Described here are the following functions:
8
9 Global functions::
10 parport_register_driver
11 parport_unregister_driver
12 parport_enumerate
13 parport_register_device
14 parport_unregister_device
15 parport_claim
16 parport_claim_or_block
17 parport_release
18 parport_yield
19 parport_yield_blocking
20 parport_wait_peripheral
21 parport_poll_peripheral
22 parport_wait_event
23 parport_negotiate
24 parport_read
25 parport_write
26 parport_open
27 parport_close
28 parport_device_id
29 parport_device_coords
30 parport_find_class
31 parport_find_device
32 parport_set_timeout
33
34 Port functions (can be overridden by low-level drivers):
35
36 SPP::
37 port->ops->read_data
38 port->ops->write_data
39 port->ops->read_status
40 port->ops->read_control
41 port->ops->write_control
42 port->ops->frob_control
43 port->ops->enable_irq
44 port->ops->disable_irq
45 port->ops->data_forward
46 port->ops->data_reverse
47
48 EPP::
49 port->ops->epp_write_data
50 port->ops->epp_read_data
51 port->ops->epp_write_addr
52 port->ops->epp_read_addr
53
54 ECP::
55 port->ops->ecp_write_data
56 port->ops->ecp_read_data
57 port->ops->ecp_write_addr
58
59 Other::
60 port->ops->nibble_read_data
61 port->ops->byte_read_data
62 port->ops->compat_write_data
63
64 The parport subsystem comprises ``parport`` (the core port-sharing
65 code), and a variety of low-level drivers that actually do the port
66 accesses. Each low-level driver handles a particular style of port
67 (PC, Amiga, and so on).
68
69 The parport interface to the device driver author can be broken down
70 into global functions and port functions.
71
72 The global functions are mostly for communicating between the device
73 driver and the parport subsystem: acquiring a list of available ports,
74 claiming a port for exclusive use, and so on. They also include
75 ``generic`` functions for doing standard things that will work on any
76 IEEE 1284-capable architecture.
77
78 The port functions are provided by the low-level drivers, although the
79 core parport module provides generic ``defaults`` for some routines.
80 The port functions can be split into three groups: SPP, EPP, and ECP.
81
82 SPP (Standard Parallel Port) functions modify so-called ``SPP``
83 registers: data, status, and control. The hardware may not actually
84 have registers exactly like that, but the PC does and this interface is
85 modelled after common PC implementations. Other low-level drivers may
86 be able to emulate most of the functionality.
87
88 EPP (Enhanced Parallel Port) functions are provided for reading and
89 writing in IEEE 1284 EPP mode, and ECP (Extended Capabilities Port)
90 functions are used for IEEE 1284 ECP mode. (What about BECP? Does
91 anyone care?)
92
93 Hardware assistance for EPP and/or ECP transfers may or may not be
94 available, and if it is available it may or may not be used. If
95 hardware is not used, the transfer will be software-driven. In order
96 to cope with peripherals that only tenuously support IEEE 1284, a
97 low-level driver specific function is provided, for altering 'fudge
98 factors'.
99
100 Global functions
101 ================
102
103 parport_register_driver - register a device driver with parport
104 ---------------------------------------------------------------
105
106 SYNOPSIS
107 ^^^^^^^^
108
109 ::
110
111 #include <linux/parport.h>
112
113 struct parport_driver {
114 const char *name;
115 void (*attach) (struct parport *);
116 void (*detach) (struct parport *);
117 struct parport_driver *next;
118 };
119 int parport_register_driver (struct parport_driver *driver);
120
121 DESCRIPTION
122 ^^^^^^^^^^^
123
124 In order to be notified about parallel ports when they are detected,
125 parport_register_driver should be called. Your driver will
126 immediately be notified of all ports that have already been detected,
127 and of each new port as low-level drivers are loaded.
128
129 A ``struct parport_driver`` contains the textual name of your driver,
130 a pointer to a function to handle new ports, and a pointer to a
131 function to handle ports going away due to a low-level driver
132 unloading. Ports will only be detached if they are not being used
133 (i.e. there are no devices registered on them).
134
135 The visible parts of the ``struct parport *`` argument given to
136 attach/detach are::
137
138 struct parport
139 {
140 struct parport *next; /* next parport in list */
141 const char *name; /* port's name */
142 unsigned int modes; /* bitfield of hardware modes */
143 struct parport_device_info probe_info;
144 /* IEEE1284 info */
145 int number; /* parport index */
146 struct parport_operations *ops;
147 ...
148 };
149
150 There are other members of the structure, but they should not be
151 touched.
152
153 The ``modes`` member summarises the capabilities of the underlying
154 hardware. It consists of flags which may be bitwise-ored together:
155
156 ============================= ===============================================
157 PARPORT_MODE_PCSPP IBM PC registers are available,
158 i.e. functions that act on data,
159 control and status registers are
160 probably writing directly to the
161 hardware.
162 PARPORT_MODE_TRISTATE The data drivers may be turned off.
163 This allows the data lines to be used
164 for reverse (peripheral to host)
165 transfers.
166 PARPORT_MODE_COMPAT The hardware can assist with
167 compatibility-mode (printer)
168 transfers, i.e. compat_write_block.
169 PARPORT_MODE_EPP The hardware can assist with EPP
170 transfers.
171 PARPORT_MODE_ECP The hardware can assist with ECP
172 transfers.
173 PARPORT_MODE_DMA The hardware can use DMA, so you might
174 want to pass ISA DMA-able memory
175 (i.e. memory allocated using the
176 GFP_DMA flag with kmalloc) to the
177 low-level driver in order to take
178 advantage of it.
179 ============================= ===============================================
180
181 There may be other flags in ``modes`` as well.
182
183 The contents of ``modes`` is advisory only. For example, if the
184 hardware is capable of DMA, and PARPORT_MODE_DMA is in ``modes``, it
185 doesn't necessarily mean that DMA will always be used when possible.
186 Similarly, hardware that is capable of assisting ECP transfers won't
187 necessarily be used.
188
189 RETURN VALUE
190 ^^^^^^^^^^^^
191
192 Zero on success, otherwise an error code.
193
194 ERRORS
195 ^^^^^^
196
197 None. (Can it fail? Why return int?)
198
199 EXAMPLE
200 ^^^^^^^
201
202 ::
203
204 static void lp_attach (struct parport *port)
205 {
206 ...
207 private = kmalloc (...);
208 dev[count++] = parport_register_device (...);
209 ...
210 }
211
212 static void lp_detach (struct parport *port)
213 {
214 ...
215 }
216
217 static struct parport_driver lp_driver = {
218 "lp",
219 lp_attach,
220 lp_detach,
221 NULL /* always put NULL here */
222 };
223
224 int lp_init (void)
225 {
226 ...
227 if (parport_register_driver (&lp_driver)) {
228 /* Failed; nothing we can do. */
229 return -EIO;
230 }
231 ...
232 }
233
234
235 SEE ALSO
236 ^^^^^^^^
237
238 parport_unregister_driver, parport_register_device, parport_enumerate
239
240
241
242 parport_unregister_driver - tell parport to forget about this driver
243 --------------------------------------------------------------------
244
245 SYNOPSIS
246 ^^^^^^^^
247
248 ::
249
250 #include <linux/parport.h>
251
252 struct parport_driver {
253 const char *name;
254 void (*attach) (struct parport *);
255 void (*detach) (struct parport *);
256 struct parport_driver *next;
257 };
258 void parport_unregister_driver (struct parport_driver *driver);
259
260 DESCRIPTION
261 ^^^^^^^^^^^
262
263 This tells parport not to notify the device driver of new ports or of
264 ports going away. Registered devices belonging to that driver are NOT
265 unregistered: parport_unregister_device must be used for each one.
266
267 EXAMPLE
268 ^^^^^^^
269
270 ::
271
272 void cleanup_module (void)
273 {
274 ...
275 /* Stop notifications. */
276 parport_unregister_driver (&lp_driver);
277
278 /* Unregister devices. */
279 for (i = 0; i < NUM_DEVS; i++)
280 parport_unregister_device (dev[i]);
281 ...
282 }
283
284 SEE ALSO
285 ^^^^^^^^
286
287 parport_register_driver, parport_enumerate
288
289
290
291 parport_enumerate - retrieve a list of parallel ports (DEPRECATED)
292 ------------------------------------------------------------------
293
294 SYNOPSIS
295 ^^^^^^^^
296
297 ::
298
299 #include <linux/parport.h>
300
301 struct parport *parport_enumerate (void);
302
303 DESCRIPTION
304 ^^^^^^^^^^^
305
306 Retrieve the first of a list of valid parallel ports for this machine.
307 Successive parallel ports can be found using the ``struct parport
308 *next`` element of the ``struct parport *`` that is returned. If ``next``
309 is NULL, there are no more parallel ports in the list. The number of
310 ports in the list will not exceed PARPORT_MAX.
311
312 RETURN VALUE
313 ^^^^^^^^^^^^
314
315 A ``struct parport *`` describing a valid parallel port for the machine,
316 or NULL if there are none.
317
318 ERRORS
319 ^^^^^^
320
321 This function can return NULL to indicate that there are no parallel
322 ports to use.
323
324 EXAMPLE
325 ^^^^^^^
326
327 ::
328
329 int detect_device (void)
330 {
331 struct parport *port;
332
333 for (port = parport_enumerate ();
334 port != NULL;
335 port = port->next) {
336 /* Try to detect a device on the port... */
337 ...
338 }
339 }
340
341 ...
342 }
343
344 NOTES
345 ^^^^^
346
347 parport_enumerate is deprecated; parport_register_driver should be
348 used instead.
349
350 SEE ALSO
351 ^^^^^^^^
352
353 parport_register_driver, parport_unregister_driver
354
355
356
357 parport_register_device - register to use a port
358 ------------------------------------------------
359
360 SYNOPSIS
361 ^^^^^^^^
362
363 ::
364
365 #include <linux/parport.h>
366
367 typedef int (*preempt_func) (void *handle);
368 typedef void (*wakeup_func) (void *handle);
369 typedef int (*irq_func) (int irq, void *handle, struct pt_regs *);
370
371 struct pardevice *parport_register_device(struct parport *port,
372 const char *name,
373 preempt_func preempt,
374 wakeup_func wakeup,
375 irq_func irq,
376 int flags,
377 void *handle);
378
379 DESCRIPTION
380 ^^^^^^^^^^^
381
382 Use this function to register your device driver on a parallel port
383 (``port``). Once you have done that, you will be able to use
384 parport_claim and parport_release in order to use the port.
385
386 The (``name``) argument is the name of the device that appears in /proc
387 filesystem. The string must be valid for the whole lifetime of the
388 device (until parport_unregister_device is called).
389
390 This function will register three callbacks into your driver:
391 ``preempt``, ``wakeup`` and ``irq``. Each of these may be NULL in order to
392 indicate that you do not want a callback.
393
394 When the ``preempt`` function is called, it is because another driver
395 wishes to use the parallel port. The ``preempt`` function should return
396 non-zero if the parallel port cannot be released yet -- if zero is
397 returned, the port is lost to another driver and the port must be
398 re-claimed before use.
399
400 The ``wakeup`` function is called once another driver has released the
401 port and no other driver has yet claimed it. You can claim the
402 parallel port from within the ``wakeup`` function (in which case the
403 claim is guaranteed to succeed), or choose not to if you don't need it
404 now.
405
406 If an interrupt occurs on the parallel port your driver has claimed,
407 the ``irq`` function will be called. (Write something about shared
408 interrupts here.)
409
410 The ``handle`` is a pointer to driver-specific data, and is passed to
411 the callback functions.
412
413 ``flags`` may be a bitwise combination of the following flags:
414
415 ===================== =================================================
416 Flag Meaning
417 ===================== =================================================
418 PARPORT_DEV_EXCL The device cannot share the parallel port at all.
419 Use this only when absolutely necessary.
420 ===================== =================================================
421
422 The typedefs are not actually defined -- they are only shown in order
423 to make the function prototype more readable.
424
425 The visible parts of the returned ``struct pardevice`` are::
426
427 struct pardevice {
428 struct parport *port; /* Associated port */
429 void *private; /* Device driver's 'handle' */
430 ...
431 };
432
433 RETURN VALUE
434 ^^^^^^^^^^^^
435
436 A ``struct pardevice *``: a handle to the registered parallel port
437 device that can be used for parport_claim, parport_release, etc.
438
439 ERRORS
440 ^^^^^^
441
442 A return value of NULL indicates that there was a problem registering
443 a device on that port.
444
445 EXAMPLE
446 ^^^^^^^
447
448 ::
449
450 static int preempt (void *handle)
451 {
452 if (busy_right_now)
453 return 1;
454
455 must_reclaim_port = 1;
456 return 0;
457 }
458
459 static void wakeup (void *handle)
460 {
461 struct toaster *private = handle;
462 struct pardevice *dev = private->dev;
463 if (!dev) return; /* avoid races */
464
465 if (want_port)
466 parport_claim (dev);
467 }
468
469 static int toaster_detect (struct toaster *private, struct parport *port)
470 {
471 private->dev = parport_register_device (port, "toaster", preempt,
472 wakeup, NULL, 0,
473 private);
474 if (!private->dev)
475 /* Couldn't register with parport. */
476 return -EIO;
477
478 must_reclaim_port = 0;
479 busy_right_now = 1;
480 parport_claim_or_block (private->dev);
481 ...
482 /* Don't need the port while the toaster warms up. */
483 busy_right_now = 0;
484 ...
485 busy_right_now = 1;
486 if (must_reclaim_port) {
487 parport_claim_or_block (private->dev);
488 must_reclaim_port = 0;
489 }
490 ...
491 }
492
493 SEE ALSO
494 ^^^^^^^^
495
496 parport_unregister_device, parport_claim
497
498
499
500 parport_unregister_device - finish using a port
501 -----------------------------------------------
502
503 SYNPOPSIS
504
505 ::
506
507 #include <linux/parport.h>
508
509 void parport_unregister_device (struct pardevice *dev);
510
511 DESCRIPTION
512 ^^^^^^^^^^^
513
514 This function is the opposite of parport_register_device. After using
515 parport_unregister_device, ``dev`` is no longer a valid device handle.
516
517 You should not unregister a device that is currently claimed, although
518 if you do it will be released automatically.
519
520 EXAMPLE
521 ^^^^^^^
522
523 ::
524
525 ...
526 kfree (dev->private); /* before we lose the pointer */
527 parport_unregister_device (dev);
528 ...
529
530 SEE ALSO
531 ^^^^^^^^
532
533
534 parport_unregister_driver
535
536 parport_claim, parport_claim_or_block - claim the parallel port for a device
537 ----------------------------------------------------------------------------
538
539 SYNOPSIS
540 ^^^^^^^^
541
542 ::
543
544 #include <linux/parport.h>
545
546 int parport_claim (struct pardevice *dev);
547 int parport_claim_or_block (struct pardevice *dev);
548
549 DESCRIPTION
550 ^^^^^^^^^^^
551
552 These functions attempt to gain control of the parallel port on which
553 ``dev`` is registered. ``parport_claim`` does not block, but
554 ``parport_claim_or_block`` may do. (Put something here about blocking
555 interruptibly or non-interruptibly.)
556
557 You should not try to claim a port that you have already claimed.
558
559 RETURN VALUE
560 ^^^^^^^^^^^^
561
562 A return value of zero indicates that the port was successfully
563 claimed, and the caller now has possession of the parallel port.
564
565 If ``parport_claim_or_block`` blocks before returning successfully, the
566 return value is positive.
567
568 ERRORS
569 ^^^^^^
570
571 ========== ==========================================================
572 -EAGAIN The port is unavailable at the moment, but another attempt
573 to claim it may succeed.
574 ========== ==========================================================
575
576 SEE ALSO
577 ^^^^^^^^
578
579
580 parport_release
581
582 parport_release - release the parallel port
583 -------------------------------------------
584
585 SYNOPSIS
586 ^^^^^^^^
587
588 ::
589
590 #include <linux/parport.h>
591
592 void parport_release (struct pardevice *dev);
593
594 DESCRIPTION
595 ^^^^^^^^^^^
596
597 Once a parallel port device has been claimed, it can be released using
598 ``parport_release``. It cannot fail, but you should not release a
599 device that you do not have possession of.
600
601 EXAMPLE
602 ^^^^^^^
603
604 ::
605
606 static size_t write (struct pardevice *dev, const void *buf,
607 size_t len)
608 {
609 ...
610 written = dev->port->ops->write_ecp_data (dev->port, buf,
611 len);
612 parport_release (dev);
613 ...
614 }
615
616
617 SEE ALSO
618 ^^^^^^^^
619
620 change_mode, parport_claim, parport_claim_or_block, parport_yield
621
622
623
624 parport_yield, parport_yield_blocking - temporarily release a parallel port
625 ---------------------------------------------------------------------------
626
627 SYNOPSIS
628 ^^^^^^^^
629
630 ::
631
632 #include <linux/parport.h>
633
634 int parport_yield (struct pardevice *dev)
635 int parport_yield_blocking (struct pardevice *dev);
636
637 DESCRIPTION
638 ^^^^^^^^^^^
639
640 When a driver has control of a parallel port, it may allow another
641 driver to temporarily ``borrow`` it. ``parport_yield`` does not block;
642 ``parport_yield_blocking`` may do.
643
644 RETURN VALUE
645 ^^^^^^^^^^^^
646
647 A return value of zero indicates that the caller still owns the port
648 and the call did not block.
649
650 A positive return value from ``parport_yield_blocking`` indicates that
651 the caller still owns the port and the call blocked.
652
653 A return value of -EAGAIN indicates that the caller no longer owns the
654 port, and it must be re-claimed before use.
655
656 ERRORS
657 ^^^^^^
658
659 ========= ==========================================================
660 -EAGAIN Ownership of the parallel port was given away.
661 ========= ==========================================================
662
663 SEE ALSO
664 ^^^^^^^^
665
666 parport_release
667
668
669
670 parport_wait_peripheral - wait for status lines, up to 35ms
671 -----------------------------------------------------------
672
673 SYNOPSIS
674 ^^^^^^^^
675
676 ::
677
678 #include <linux/parport.h>
679
680 int parport_wait_peripheral (struct parport *port,
681 unsigned char mask,
682 unsigned char val);
683
684 DESCRIPTION
685 ^^^^^^^^^^^
686
687 Wait for the status lines in mask to match the values in val.
688
689 RETURN VALUE
690 ^^^^^^^^^^^^
691
692 ======== ==========================================================
693 -EINTR a signal is pending
694 0 the status lines in mask have values in val
695 1 timed out while waiting (35ms elapsed)
696 ======== ==========================================================
697
698 SEE ALSO
699 ^^^^^^^^
700
701 parport_poll_peripheral
702
703
704
705 parport_poll_peripheral - wait for status lines, in usec
706 --------------------------------------------------------
707
708 SYNOPSIS
709 ^^^^^^^^
710
711 ::
712
713 #include <linux/parport.h>
714
715 int parport_poll_peripheral (struct parport *port,
716 unsigned char mask,
717 unsigned char val,
718 int usec);
719
720 DESCRIPTION
721 ^^^^^^^^^^^
722
723 Wait for the status lines in mask to match the values in val.
724
725 RETURN VALUE
726 ^^^^^^^^^^^^
727
728 ======== ==========================================================
729 -EINTR a signal is pending
730 0 the status lines in mask have values in val
731 1 timed out while waiting (usec microseconds have elapsed)
732 ======== ==========================================================
733
734 SEE ALSO
735 ^^^^^^^^
736
737 parport_wait_peripheral
738
739
740
741 parport_wait_event - wait for an event on a port
742 ------------------------------------------------
743
744 SYNOPSIS
745 ^^^^^^^^
746
747 ::
748
749 #include <linux/parport.h>
750
751 int parport_wait_event (struct parport *port, signed long timeout)
752
753 DESCRIPTION
754 ^^^^^^^^^^^
755
756 Wait for an event (e.g. interrupt) on a port. The timeout is in
757 jiffies.
758
759 RETURN VALUE
760 ^^^^^^^^^^^^
761
762 ======= ==========================================================
763 0 success
764 <0 error (exit as soon as possible)
765 >0 timed out
766 ======= ==========================================================
767
768 parport_negotiate - perform IEEE 1284 negotiation
769 -------------------------------------------------
770
771 SYNOPSIS
772 ^^^^^^^^
773
774 ::
775
776 #include <linux/parport.h>
777
778 int parport_negotiate (struct parport *, int mode);
779
780 DESCRIPTION
781 ^^^^^^^^^^^
782
783 Perform IEEE 1284 negotiation.
784
785 RETURN VALUE
786 ^^^^^^^^^^^^
787
788 ======= ==========================================================
789 0 handshake OK; IEEE 1284 peripheral and mode available
790 -1 handshake failed; peripheral not compliant (or none present)
791 1 handshake OK; IEEE 1284 peripheral present but mode not
792 available
793 ======= ==========================================================
794
795 SEE ALSO
796 ^^^^^^^^
797
798 parport_read, parport_write
799
800
801
802 parport_read - read data from device
803 ------------------------------------
804
805 SYNOPSIS
806 ^^^^^^^^
807
808 ::
809
810 #include <linux/parport.h>
811
812 ssize_t parport_read (struct parport *, void *buf, size_t len);
813
814 DESCRIPTION
815 ^^^^^^^^^^^
816
817 Read data from device in current IEEE 1284 transfer mode. This only
818 works for modes that support reverse data transfer.
819
820 RETURN VALUE
821 ^^^^^^^^^^^^
822
823 If negative, an error code; otherwise the number of bytes transferred.
824
825 SEE ALSO
826 ^^^^^^^^
827
828 parport_write, parport_negotiate
829
830
831
832 parport_write - write data to device
833 ------------------------------------
834
835 SYNOPSIS
836 ^^^^^^^^
837
838 ::
839
840 #include <linux/parport.h>
841
842 ssize_t parport_write (struct parport *, const void *buf, size_t len);
843
844 DESCRIPTION
845 ^^^^^^^^^^^
846
847 Write data to device in current IEEE 1284 transfer mode. This only
848 works for modes that support forward data transfer.
849
850 RETURN VALUE
851 ^^^^^^^^^^^^
852
853 If negative, an error code; otherwise the number of bytes transferred.
854
855 SEE ALSO
856 ^^^^^^^^
857
858 parport_read, parport_negotiate
859
860
861
862 parport_open - register device for particular device number
863 -----------------------------------------------------------
864
865 SYNOPSIS
866 ^^^^^^^^
867
868 ::
869
870 #include <linux/parport.h>
871
872 struct pardevice *parport_open (int devnum, const char *name,
873 int (*pf) (void *),
874 void (*kf) (void *),
875 void (*irqf) (int, void *,
876 struct pt_regs *),
877 int flags, void *handle);
878
879 DESCRIPTION
880 ^^^^^^^^^^^
881
882 This is like parport_register_device but takes a device number instead
883 of a pointer to a struct parport.
884
885 RETURN VALUE
886 ^^^^^^^^^^^^
887
888 See parport_register_device. If no device is associated with devnum,
889 NULL is returned.
890
891 SEE ALSO
892 ^^^^^^^^
893
894 parport_register_device
895
896
897
898 parport_close - unregister device for particular device number
899 --------------------------------------------------------------
900
901 SYNOPSIS
902 ^^^^^^^^
903
904 ::
905
906 #include <linux/parport.h>
907
908 void parport_close (struct pardevice *dev);
909
910 DESCRIPTION
911 ^^^^^^^^^^^
912
913 This is the equivalent of parport_unregister_device for parport_open.
914
915 SEE ALSO
916 ^^^^^^^^
917
918 parport_unregister_device, parport_open
919
920
921
922 parport_device_id - obtain IEEE 1284 Device ID
923 ----------------------------------------------
924
925 SYNOPSIS
926 ^^^^^^^^
927
928 ::
929
930 #include <linux/parport.h>
931
932 ssize_t parport_device_id (int devnum, char *buffer, size_t len);
933
934 DESCRIPTION
935 ^^^^^^^^^^^
936
937 Obtains the IEEE 1284 Device ID associated with a given device.
938
939 RETURN VALUE
940 ^^^^^^^^^^^^
941
942 If negative, an error code; otherwise, the number of bytes of buffer
943 that contain the device ID. The format of the device ID is as
944 follows::
945
946 [length][ID]
947
948 The first two bytes indicate the inclusive length of the entire Device
949 ID, and are in big-endian order. The ID is a sequence of pairs of the
950 form::
951
952 key:value;
953
954 NOTES
955 ^^^^^
956
957 Many devices have ill-formed IEEE 1284 Device IDs.
958
959 SEE ALSO
960 ^^^^^^^^
961
962 parport_find_class, parport_find_device
963
964
965
966 parport_device_coords - convert device number to device coordinates
967 -------------------------------------------------------------------
968
969 SYNOPSIS
970 ^^^^^^^^
971
972 ::
973
974 #include <linux/parport.h>
975
976 int parport_device_coords (int devnum, int *parport, int *mux,
977 int *daisy);
978
979 DESCRIPTION
980 ^^^^^^^^^^^
981
982 Convert between device number (zero-based) and device coordinates
983 (port, multiplexor, daisy chain address).
984
985 RETURN VALUE
986 ^^^^^^^^^^^^
987
988 Zero on success, in which case the coordinates are (``*parport``, ``*mux``,
989 ``*daisy``).
990
991 SEE ALSO
992 ^^^^^^^^
993
994 parport_open, parport_device_id
995
996
997
998 parport_find_class - find a device by its class
999 -----------------------------------------------
1001 SYNOPSIS
1002 ^^^^^^^^
1004 ::
1006 #include <linux/parport.h>
1008 typedef enum {
1009 PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */
1010 PARPORT_CLASS_PRINTER,
1011 PARPORT_CLASS_MODEM,
1012 PARPORT_CLASS_NET,
1013 PARPORT_CLASS_HDC, /* Hard disk controller */
1014 PARPORT_CLASS_PCMCIA,
1015 PARPORT_CLASS_MEDIA, /* Multimedia device */
1016 PARPORT_CLASS_FDC, /* Floppy disk controller */
1017 PARPORT_CLASS_PORTS,
1018 PARPORT_CLASS_SCANNER,
1019 PARPORT_CLASS_DIGCAM,
1020 PARPORT_CLASS_OTHER, /* Anything else */
1021 PARPORT_CLASS_UNSPEC, /* No CLS field in ID */
1022 PARPORT_CLASS_SCSIADAPTER
1023 } parport_device_class;
1025 int parport_find_class (parport_device_class cls, int from);
1027 DESCRIPTION
1028 ^^^^^^^^^^^
1030 Find a device by class. The search starts from device number from+1.
1032 RETURN VALUE
1033 ^^^^^^^^^^^^
1035 The device number of the next device in that class, or -1 if no such
1036 device exists.
1038 NOTES
1039 ^^^^^
1041 Example usage::
1043 int devnum = -1;
1044 while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
1045 struct pardevice *dev = parport_open (devnum, ...);
1046 ...
1047 }
1049 SEE ALSO
1050 ^^^^^^^^
1052 parport_find_device, parport_open, parport_device_id
1056 parport_find_device - find a device by its class
1057 ------------------------------------------------
1059 SYNOPSIS
1060 ^^^^^^^^
1062 ::
1064 #include <linux/parport.h>
1066 int parport_find_device (const char *mfg, const char *mdl, int from);
1068 DESCRIPTION
1069 ^^^^^^^^^^^
1071 Find a device by vendor and model. The search starts from device
1072 number from+1.
1074 RETURN VALUE
1075 ^^^^^^^^^^^^
1077 The device number of the next device matching the specifications, or
1078 -1 if no such device exists.
1080 NOTES
1081 ^^^^^
1083 Example usage::
1085 int devnum = -1;
1086 while ((devnum = parport_find_device ("IOMEGA", "ZIP+", devnum)) != -1) {
1087 struct pardevice *dev = parport_open (devnum, ...);
1088 ...
1089 }
1091 SEE ALSO
1092 ^^^^^^^^
1094 parport_find_class, parport_open, parport_device_id
1098 parport_set_timeout - set the inactivity timeout
1099 ------------------------------------------------
1101 SYNOPSIS
1102 ^^^^^^^^
1104 ::
1106 #include <linux/parport.h>
1108 long parport_set_timeout (struct pardevice *dev, long inactivity);
1110 DESCRIPTION
1111 ^^^^^^^^^^^
1113 Set the inactivity timeout, in jiffies, for a registered device. The
1114 previous timeout is returned.
1116 RETURN VALUE
1117 ^^^^^^^^^^^^
1119 The previous timeout, in jiffies.
1121 NOTES
1122 ^^^^^
1124 Some of the port->ops functions for a parport may take time, owing to
1125 delays at the peripheral. After the peripheral has not responded for
1126 ``inactivity`` jiffies, a timeout will occur and the blocking function
1127 will return.
1129 A timeout of 0 jiffies is a special case: the function must do as much
1130 as it can without blocking or leaving the hardware in an unknown
1131 state. If port operations are performed from within an interrupt
1132 handler, for instance, a timeout of 0 jiffies should be used.
1134 Once set for a registered device, the timeout will remain at the set
1135 value until set again.
1137 SEE ALSO
1138 ^^^^^^^^
1140 port->ops->xxx_read/write_yyy
1145 PORT FUNCTIONS
1146 ==============
1148 The functions in the port->ops structure (struct parport_operations)
1149 are provided by the low-level driver responsible for that port.
1151 port->ops->read_data - read the data register
1152 ---------------------------------------------
1154 SYNOPSIS
1155 ^^^^^^^^
1157 ::
1159 #include <linux/parport.h>
1161 struct parport_operations {
1162 ...
1163 unsigned char (*read_data) (struct parport *port);
1164 ...
1165 };
1167 DESCRIPTION
1168 ^^^^^^^^^^^
1170 If port->modes contains the PARPORT_MODE_TRISTATE flag and the
1171 PARPORT_CONTROL_DIRECTION bit in the control register is set, this
1172 returns the value on the data pins. If port->modes contains the
1173 PARPORT_MODE_TRISTATE flag and the PARPORT_CONTROL_DIRECTION bit is
1174 not set, the return value _may_ be the last value written to the data
1175 register. Otherwise the return value is undefined.
1177 SEE ALSO
1178 ^^^^^^^^
1180 write_data, read_status, write_control
1184 port->ops->write_data - write the data register
1185 -----------------------------------------------
1187 SYNOPSIS
1188 ^^^^^^^^
1190 ::
1192 #include <linux/parport.h>
1194 struct parport_operations {
1195 ...
1196 void (*write_data) (struct parport *port, unsigned char d);
1197 ...
1198 };
1200 DESCRIPTION
1201 ^^^^^^^^^^^
1203 Writes to the data register. May have side-effects (a STROBE pulse,
1204 for instance).
1206 SEE ALSO
1207 ^^^^^^^^
1209 read_data, read_status, write_control
1213 port->ops->read_status - read the status register
1214 -------------------------------------------------
1216 SYNOPSIS
1217 ^^^^^^^^
1219 ::
1221 #include <linux/parport.h>
1223 struct parport_operations {
1224 ...
1225 unsigned char (*read_status) (struct parport *port);
1226 ...
1227 };
1229 DESCRIPTION
1230 ^^^^^^^^^^^
1232 Reads from the status register. This is a bitmask:
1234 - PARPORT_STATUS_ERROR (printer fault, "nFault")
1235 - PARPORT_STATUS_SELECT (on-line, "Select")
1236 - PARPORT_STATUS_PAPEROUT (no paper, "PError")
1237 - PARPORT_STATUS_ACK (handshake, "nAck")
1238 - PARPORT_STATUS_BUSY (busy, "Busy")
1240 There may be other bits set.
1242 SEE ALSO
1243 ^^^^^^^^
1245 read_data, write_data, write_control
1249 port->ops->read_control - read the control register
1250 ---------------------------------------------------
1252 SYNOPSIS
1253 ^^^^^^^^
1255 ::
1257 #include <linux/parport.h>
1259 struct parport_operations {
1260 ...
1261 unsigned char (*read_control) (struct parport *port);
1262 ...
1263 };
1265 DESCRIPTION
1266 ^^^^^^^^^^^
1268 Returns the last value written to the control register (either from
1269 write_control or frob_control). No port access is performed.
1271 SEE ALSO
1272 ^^^^^^^^
1274 read_data, write_data, read_status, write_control
1278 port->ops->write_control - write the control register
1279 -----------------------------------------------------
1281 SYNOPSIS
1282 ^^^^^^^^
1284 ::
1286 #include <linux/parport.h>
1288 struct parport_operations {
1289 ...
1290 void (*write_control) (struct parport *port, unsigned char s);
1291 ...
1292 };
1294 DESCRIPTION
1295 ^^^^^^^^^^^
1297 Writes to the control register. This is a bitmask::
1299 _______
1300 - PARPORT_CONTROL_STROBE (nStrobe)
1301 _______
1302 - PARPORT_CONTROL_AUTOFD (nAutoFd)
1303 _____
1304 - PARPORT_CONTROL_INIT (nInit)
1305 _________
1306 - PARPORT_CONTROL_SELECT (nSelectIn)
1308 SEE ALSO
1309 ^^^^^^^^
1311 read_data, write_data, read_status, frob_control
1315 port->ops->frob_control - write control register bits
1316 -----------------------------------------------------
1318 SYNOPSIS
1319 ^^^^^^^^
1321 ::
1323 #include <linux/parport.h>
1325 struct parport_operations {
1326 ...
1327 unsigned char (*frob_control) (struct parport *port,
1328 unsigned char mask,
1329 unsigned char val);
1330 ...
1331 };
1333 DESCRIPTION
1334 ^^^^^^^^^^^
1336 This is equivalent to reading from the control register, masking out
1337 the bits in mask, exclusive-or'ing with the bits in val, and writing
1338 the result to the control register.
1340 As some ports don't allow reads from the control port, a software copy
1341 of its contents is maintained, so frob_control is in fact only one
1342 port access.
1344 SEE ALSO
1345 ^^^^^^^^
1347 read_data, write_data, read_status, write_control
1351 port->ops->enable_irq - enable interrupt generation
1352 ---------------------------------------------------
1354 SYNOPSIS
1355 ^^^^^^^^
1357 ::
1359 #include <linux/parport.h>
1361 struct parport_operations {
1362 ...
1363 void (*enable_irq) (struct parport *port);
1364 ...
1365 };
1367 DESCRIPTION
1368 ^^^^^^^^^^^
1370 The parallel port hardware is instructed to generate interrupts at
1371 appropriate moments, although those moments are
1372 architecture-specific. For the PC architecture, interrupts are
1373 commonly generated on the rising edge of nAck.
1375 SEE ALSO
1376 ^^^^^^^^
1378 disable_irq
1382 port->ops->disable_irq - disable interrupt generation
1383 -----------------------------------------------------
1385 SYNOPSIS
1386 ^^^^^^^^
1388 ::
1390 #include <linux/parport.h>
1392 struct parport_operations {
1393 ...
1394 void (*disable_irq) (struct parport *port);
1395 ...
1396 };
1398 DESCRIPTION
1399 ^^^^^^^^^^^
1401 The parallel port hardware is instructed not to generate interrupts.
1402 The interrupt itself is not masked.
1404 SEE ALSO
1405 ^^^^^^^^
1407 enable_irq
1411 port->ops->data_forward - enable data drivers
1412 ---------------------------------------------
1414 SYNOPSIS
1415 ^^^^^^^^
1417 ::
1419 #include <linux/parport.h>
1421 struct parport_operations {
1422 ...
1423 void (*data_forward) (struct parport *port);
1424 ...
1425 };
1427 DESCRIPTION
1428 ^^^^^^^^^^^
1430 Enables the data line drivers, for 8-bit host-to-peripheral
1431 communications.
1433 SEE ALSO
1434 ^^^^^^^^
1436 data_reverse
1440 port->ops->data_reverse - tristate the buffer
1441 ---------------------------------------------
1443 SYNOPSIS
1444 ^^^^^^^^
1446 ::
1448 #include <linux/parport.h>
1450 struct parport_operations {
1451 ...
1452 void (*data_reverse) (struct parport *port);
1453 ...
1454 };
1456 DESCRIPTION
1457 ^^^^^^^^^^^
1459 Places the data bus in a high impedance state, if port->modes has the
1460 PARPORT_MODE_TRISTATE bit set.
1462 SEE ALSO
1463 ^^^^^^^^
1465 data_forward
1469 port->ops->epp_write_data - write EPP data
1470 ------------------------------------------
1472 SYNOPSIS
1473 ^^^^^^^^
1475 ::
1477 #include <linux/parport.h>
1479 struct parport_operations {
1480 ...
1481 size_t (*epp_write_data) (struct parport *port, const void *buf,
1482 size_t len, int flags);
1483 ...
1484 };
1486 DESCRIPTION
1487 ^^^^^^^^^^^
1489 Writes data in EPP mode, and returns the number of bytes written.
1491 The ``flags`` parameter may be one or more of the following,
1492 bitwise-or'ed together:
1494 ======================= =================================================
1495 PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
1496 32-bit registers. However, if a transfer
1497 times out, the return value may be unreliable.
1498 ======================= =================================================
1500 SEE ALSO
1501 ^^^^^^^^
1503 epp_read_data, epp_write_addr, epp_read_addr
1507 port->ops->epp_read_data - read EPP data
1508 ----------------------------------------
1510 SYNOPSIS
1511 ^^^^^^^^
1513 ::
1515 #include <linux/parport.h>
1517 struct parport_operations {
1518 ...
1519 size_t (*epp_read_data) (struct parport *port, void *buf,
1520 size_t len, int flags);
1521 ...
1522 };
1524 DESCRIPTION
1525 ^^^^^^^^^^^
1527 Reads data in EPP mode, and returns the number of bytes read.
1529 The ``flags`` parameter may be one or more of the following,
1530 bitwise-or'ed together:
1532 ======================= =================================================
1533 PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
1534 32-bit registers. However, if a transfer
1535 times out, the return value may be unreliable.
1536 ======================= =================================================
1538 SEE ALSO
1539 ^^^^^^^^
1541 epp_write_data, epp_write_addr, epp_read_addr
1545 port->ops->epp_write_addr - write EPP address
1546 ---------------------------------------------
1548 SYNOPSIS
1549 ^^^^^^^^
1551 ::
1553 #include <linux/parport.h>
1555 struct parport_operations {
1556 ...
1557 size_t (*epp_write_addr) (struct parport *port,
1558 const void *buf, size_t len, int flags);
1559 ...
1560 };
1562 DESCRIPTION
1563 ^^^^^^^^^^^
1565 Writes EPP addresses (8 bits each), and returns the number written.
1567 The ``flags`` parameter may be one or more of the following,
1568 bitwise-or'ed together:
1570 ======================= =================================================
1571 PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
1572 32-bit registers. However, if a transfer
1573 times out, the return value may be unreliable.
1574 ======================= =================================================
1576 (Does PARPORT_EPP_FAST make sense for this function?)
1578 SEE ALSO
1579 ^^^^^^^^
1581 epp_write_data, epp_read_data, epp_read_addr
1585 port->ops->epp_read_addr - read EPP address
1586 -------------------------------------------
1588 SYNOPSIS
1589 ^^^^^^^^
1591 ::
1593 #include <linux/parport.h>
1595 struct parport_operations {
1596 ...
1597 size_t (*epp_read_addr) (struct parport *port, void *buf,
1598 size_t len, int flags);
1599 ...
1600 };
1602 DESCRIPTION
1603 ^^^^^^^^^^^
1605 Reads EPP addresses (8 bits each), and returns the number read.
1607 The ``flags`` parameter may be one or more of the following,
1608 bitwise-or'ed together:
1610 ======================= =================================================
1611 PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
1612 32-bit registers. However, if a transfer
1613 times out, the return value may be unreliable.
1614 ======================= =================================================
1616 (Does PARPORT_EPP_FAST make sense for this function?)
1618 SEE ALSO
1619 ^^^^^^^^
1621 epp_write_data, epp_read_data, epp_write_addr
1625 port->ops->ecp_write_data - write a block of ECP data
1626 -----------------------------------------------------
1628 SYNOPSIS
1629 ^^^^^^^^
1631 ::
1633 #include <linux/parport.h>
1635 struct parport_operations {
1636 ...
1637 size_t (*ecp_write_data) (struct parport *port,
1638 const void *buf, size_t len, int flags);
1639 ...
1640 };
1642 DESCRIPTION
1643 ^^^^^^^^^^^
1645 Writes a block of ECP data. The ``flags`` parameter is ignored.
1647 RETURN VALUE
1648 ^^^^^^^^^^^^
1650 The number of bytes written.
1652 SEE ALSO
1653 ^^^^^^^^
1655 ecp_read_data, ecp_write_addr
1659 port->ops->ecp_read_data - read a block of ECP data
1660 ---------------------------------------------------
1662 SYNOPSIS
1663 ^^^^^^^^
1665 ::
1667 #include <linux/parport.h>
1669 struct parport_operations {
1670 ...
1671 size_t (*ecp_read_data) (struct parport *port,
1672 void *buf, size_t len, int flags);
1673 ...
1674 };
1676 DESCRIPTION
1677 ^^^^^^^^^^^
1679 Reads a block of ECP data. The ``flags`` parameter is ignored.
1681 RETURN VALUE
1682 ^^^^^^^^^^^^
1684 The number of bytes read. NB. There may be more unread data in a
1685 FIFO. Is there a way of stunning the FIFO to prevent this?
1687 SEE ALSO
1688 ^^^^^^^^
1690 ecp_write_block, ecp_write_addr
1694 port->ops->ecp_write_addr - write a block of ECP addresses
1695 ----------------------------------------------------------
1697 SYNOPSIS
1698 ^^^^^^^^
1700 ::
1702 #include <linux/parport.h>
1704 struct parport_operations {
1705 ...
1706 size_t (*ecp_write_addr) (struct parport *port,
1707 const void *buf, size_t len, int flags);
1708 ...
1709 };
1711 DESCRIPTION
1712 ^^^^^^^^^^^
1714 Writes a block of ECP addresses. The ``flags`` parameter is ignored.
1716 RETURN VALUE
1717 ^^^^^^^^^^^^
1719 The number of bytes written.
1721 NOTES
1722 ^^^^^
1724 This may use a FIFO, and if so shall not return until the FIFO is empty.
1726 SEE ALSO
1727 ^^^^^^^^
1729 ecp_read_data, ecp_write_data
1733 port->ops->nibble_read_data - read a block of data in nibble mode
1734 -----------------------------------------------------------------
1736 SYNOPSIS
1737 ^^^^^^^^
1739 ::
1741 #include <linux/parport.h>
1743 struct parport_operations {
1744 ...
1745 size_t (*nibble_read_data) (struct parport *port,
1746 void *buf, size_t len, int flags);
1747 ...
1748 };
1750 DESCRIPTION
1751 ^^^^^^^^^^^
1753 Reads a block of data in nibble mode. The ``flags`` parameter is ignored.
1755 RETURN VALUE
1756 ^^^^^^^^^^^^
1758 The number of whole bytes read.
1760 SEE ALSO
1761 ^^^^^^^^
1763 byte_read_data, compat_write_data
1767 port->ops->byte_read_data - read a block of data in byte mode
1768 -------------------------------------------------------------
1770 SYNOPSIS
1771 ^^^^^^^^
1773 ::
1775 #include <linux/parport.h>
1777 struct parport_operations {
1778 ...
1779 size_t (*byte_read_data) (struct parport *port,
1780 void *buf, size_t len, int flags);
1781 ...
1782 };
1784 DESCRIPTION
1785 ^^^^^^^^^^^
1787 Reads a block of data in byte mode. The ``flags`` parameter is ignored.
1789 RETURN VALUE
1790 ^^^^^^^^^^^^
1792 The number of bytes read.
1794 SEE ALSO
1795 ^^^^^^^^
1797 nibble_read_data, compat_write_data
1801 port->ops->compat_write_data - write a block of data in compatibility mode
1802 --------------------------------------------------------------------------
1804 SYNOPSIS
1805 ^^^^^^^^
1807 ::
1809 #include <linux/parport.h>
1811 struct parport_operations {
1812 ...
1813 size_t (*compat_write_data) (struct parport *port,
1814 const void *buf, size_t len, int flags);
1815 ...
1816 };
1818 DESCRIPTION
1819 ^^^^^^^^^^^
1821 Writes a block of data in compatibility mode. The ``flags`` parameter
1822 is ignored.
1824 RETURN VALUE
1825 ^^^^^^^^^^^^
1827 The number of bytes written.
1829 SEE ALSO
1830 ^^^^^^^^
1832 nibble_read_data, byte_read_data

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

병렬 포트 저수준 드라이버 API의 구성

1-99

이 문서는 Linux 병렬 포트 공유 계층인 `parport`가 제공하는 저수준 API를 설명합니다. 병렬 포트를 사용하는 장치 드라이버는 전역 함수로 포트와 장치를 등록하고 소유권을 조정하며, 실제 레지스터 접근과 IEEE 1284 전송은 포트별 저수준 드라이버가 채운 `struct parport_operations`, 즉 `port->ops`를 통해 수행합니다.

전역 함수에는 드라이버·장치 등록과 해제, 포트 claim·release·yield, 상태선 대기, IEEE 1284 협상과 읽기·쓰기, 장치 번호 탐색, inactivity timeout 설정이 포함됩니다. 포트 함수에는 SPP 레지스터 접근, IRQ 제어, 데이터 버스 방향 전환, EPP·ECP·nibble·byte·compatibility 전송이 포함됩니다.

`parport` 코어는 여러 장치 드라이버가 한 병렬 포트를 공유하도록 중재합니다. 저수준 포트 드라이버는 가능한 경우 하드웨어 EPP/ECP 기능을 제공하고, 그렇지 않으면 SPP 레지스터 연산을 조합해 소프트웨어 방식으로 해당 전송을 에뮬레이션할 수 있습니다.

이후 절의 함수 이름, C 형식, 상수, 구조체 필드와 source path는 원문 표기를 유지합니다. 호출자는 먼저 포트와 장치의 수명 및 소유권을 확보한 뒤, 지원 모드와 timeout 조건에 맞는 전송 연산을 선택해야 합니다.

parport 저수준 계층
Parallel-port device driverGlobal parport functionsClaim and IEEE 1284 state`struct parport_operations`SPP / EPP / ECP hardware
Driver registrationAttach and detach callbacksRegistered `pardevice``port->ops` transferPeripheral

장치 드라이버 요청이 공유 계층의 중재를 거쳐 포트별 하드웨어 연산으로 내려갑니다.

===============================
PARPORT interface documentation
===============================

:Time-stamp: <2000-02-24 13:30:20 twaugh>

Described here are the following functions:

Global functions::
  parport_register_driver
  parport_unregister_driver
  parport_enumerate
  parport_register_device
  parport_unregister_device
  parport_claim
  parport_claim_or_block
  parport_release
  parport_yield
  parport_yield_blocking
  parport_wait_peripheral
  parport_poll_peripheral
  parport_wait_event
  parport_negotiate
  parport_read
  parport_write
  parport_open
  parport_close
  parport_device_id
  parport_device_coords
  parport_find_class
  parport_find_device
  parport_set_timeout

Port functions (can be overridden by low-level drivers):

  SPP::
    port->ops->read_data
    port->ops->write_data
    port->ops->read_status
    port->ops->read_control
    port->ops->write_control
    port->ops->frob_control
    port->ops->enable_irq
    port->ops->disable_irq
    port->ops->data_forward
    port->ops->data_reverse

  EPP::
    port->ops->epp_write_data
    port->ops->epp_read_data
    port->ops->epp_write_addr
    port->ops->epp_read_addr

  ECP::
    port->ops->ecp_write_data
    port->ops->ecp_read_data
    port->ops->ecp_write_addr

  Other::
    port->ops->nibble_read_data
    port->ops->byte_read_data
    port->ops->compat_write_data

The parport subsystem comprises ``parport`` (the core port-sharing
code), and a variety of low-level drivers that actually do the port
accesses.  Each low-level driver handles a particular style of port
(PC, Amiga, and so on).

The parport interface to the device driver author can be broken down
into global functions and port functions.

The global functions are mostly for communicating between the device
driver and the parport subsystem: acquiring a list of available ports,
claiming a port for exclusive use, and so on.  They also include
``generic`` functions for doing standard things that will work on any
IEEE 1284-capable architecture.

The port functions are provided by the low-level drivers, although the
core parport module provides generic ``defaults`` for some routines.
The port functions can be split into three groups: SPP, EPP, and ECP.

SPP (Standard Parallel Port) functions modify so-called ``SPP``
registers: data, status, and control.  The hardware may not actually
have registers exactly like that, but the PC does and this interface is
modelled after common PC implementations.  Other low-level drivers may
be able to emulate most of the functionality.

EPP (Enhanced Parallel Port) functions are provided for reading and
writing in IEEE 1284 EPP mode, and ECP (Extended Capabilities Port)
functions are used for IEEE 1284 ECP mode. (What about BECP? Does
anyone care?)

Hardware assistance for EPP and/or ECP transfers may or may not be
available, and if it is available it may or may not be used.  If
hardware is not used, the transfer will be software-driven.  In order
to cope with peripherals that only tenuously support IEEE 1284, a
low-level driver specific function is provided, for altering 'fudge
factors'.

`parport_register_driver()`와 포트 발견

100-241

`parport_register_driver()`는 병렬 포트 장치 드라이버를 parport 코어에 등록합니다. 등록이 끝나면 이미 존재하는 모든 포트에 대해 드라이버의 `attach` 콜백이 즉시 호출되고, 이후 새 포트가 등록될 때도 같은 알림을 받습니다. 포트를 담당하던 저수준 드라이버가 제거될 때에는 해당 포트에 등록된 장치가 없는 경우 `detach` 콜백이 호출됩니다.

드라이버가 볼 수 있는 `struct parport`의 주요 필드는 연결 리스트의 `next`, 포트 `name`, 지원 능력을 나타내는 `modes`, probe 정보 배열 `probe_info`, 포트 `number`, 하위 연산 집합 `ops`입니다. `modes`는 `PARPORT_MODE_PCSPP`, `PARPORT_MODE_TRISTATE`, `PARPORT_MODE_COMPAT`, `PARPORT_MODE_EPP`, `PARPORT_MODE_ECP`, `PARPORT_MODE_DMA`의 비트 조합입니다.

모드 플래그는 조언 정보일 뿐입니다. 예를 들어 `PARPORT_MODE_ECP`가 없더라도 드라이버가 `port->ops->ecp_write_data()`를 호출하면 parport 코어가 소프트웨어 ECP 전송을 시도할 수 있습니다. 따라서 하드웨어 가속 가능 여부와 API 사용 가능 여부를 동일하게 취급해서는 안 됩니다.

등록이 성공하면 0을 반환하고, 실패하면 음수 오류 코드를 반환합니다. 원문은 현재 예상되는 오류가 없다고 덧붙입니다. 예제의 `lp` 드라이버는 `attach`와 `detach`를 제공하는 `parport_driver`를 정적으로 만들고 `module_init()`에서 등록합니다.

`struct parport` 관찰 지점
필드·플래그의미드라이버 판단
`name`, `number`포트 식별 정보로그와 장치 연결에 사용
`probe_info`최대 5개 daisy-chain 장치 정보탐색 결과 참조
`PARPORT_MODE_PCSPP`PC형 SPP 레지스터기본 레지스터 접근
`PARPORT_MODE_TRISTATE`데이터 라인 3상태 가능역방향 byte 전송 판단
`PARPORT_MODE_EPP/ECP`하드웨어 EPP/ECP 지원가속 경로 선택
`PARPORT_MODE_DMA`DMA 가능전송 구현 최적화
`ops`저수준 연산 테이블실제 포트 접근

Global functions
================

parport_register_driver - register a device driver with parport
---------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_driver {
                const char *name;
                void (*attach) (struct parport *);
                void (*detach) (struct parport *);
                struct parport_driver *next;
        };
        int parport_register_driver (struct parport_driver *driver);

DESCRIPTION
^^^^^^^^^^^

In order to be notified about parallel ports when they are detected,
parport_register_driver should be called.  Your driver will
immediately be notified of all ports that have already been detected,
and of each new port as low-level drivers are loaded.

A ``struct parport_driver`` contains the textual name of your driver,
a pointer to a function to handle new ports, and a pointer to a
function to handle ports going away due to a low-level driver
unloading.  Ports will only be detached if they are not being used
(i.e. there are no devices registered on them).

The visible parts of the ``struct parport *`` argument given to
attach/detach are::

        struct parport
        {
                struct parport *next; /* next parport in list */
                const char *name;     /* port's name */
                unsigned int modes;   /* bitfield of hardware modes */
                struct parport_device_info probe_info;
                                /* IEEE1284 info */
                int number;           /* parport index */
                struct parport_operations *ops;
                ...
        };

There are other members of the structure, but they should not be
touched.

The ``modes`` member summarises the capabilities of the underlying
hardware.  It consists of flags which may be bitwise-ored together:

  ============================= ===============================================
  PARPORT_MODE_PCSPP                IBM PC registers are available,
                                i.e. functions that act on data,
                                control and status registers are
                                probably writing directly to the
                                hardware.
  PARPORT_MODE_TRISTATE                The data drivers may be turned off.
                                This allows the data lines to be used
                                for reverse (peripheral to host)
                                transfers.
  PARPORT_MODE_COMPAT                The hardware can assist with
                                compatibility-mode (printer)
                                transfers, i.e. compat_write_block.
  PARPORT_MODE_EPP                The hardware can assist with EPP
                                transfers.
  PARPORT_MODE_ECP                The hardware can assist with ECP
                                transfers.
  PARPORT_MODE_DMA                The hardware can use DMA, so you might
                                want to pass ISA DMA-able memory
                                (i.e. memory allocated using the
                                GFP_DMA flag with kmalloc) to the
                                low-level driver in order to take
                                advantage of it.
  ============================= ===============================================

There may be other flags in ``modes`` as well.

The contents of ``modes`` is advisory only.  For example, if the
hardware is capable of DMA, and PARPORT_MODE_DMA is in ``modes``, it
doesn't necessarily mean that DMA will always be used when possible.
Similarly, hardware that is capable of assisting ECP transfers won't
necessarily be used.

RETURN VALUE
^^^^^^^^^^^^

Zero on success, otherwise an error code.

ERRORS
^^^^^^

None. (Can it fail? Why return int?)

EXAMPLE
^^^^^^^

::

        static void lp_attach (struct parport *port)
        {
                ...
                private = kmalloc (...);
                dev[count++] = parport_register_device (...);
                ...
        }

        static void lp_detach (struct parport *port)
        {
                ...
        }

        static struct parport_driver lp_driver = {
                "lp",
                lp_attach,
                lp_detach,
                NULL /* always put NULL here */
        };

        int lp_init (void)
        {
                ...
                if (parport_register_driver (&lp_driver)) {
                        /* Failed; nothing we can do. */
                        return -EIO;
                }
                ...
        }


SEE ALSO
^^^^^^^^

parport_unregister_driver, parport_register_device, parport_enumerate


`parport_unregister_driver()`와 폐기된 열거 방식

242-356

`parport_unregister_driver()`는 앞서 `parport_register_driver()`로 등록한 드라이버를 parport 코어에서 제거합니다. 이 호출 이후에는 포트가 추가되거나 제거되어도 `attach`·`detach` 알림을 더 이상 받지 않습니다.

이 함수는 드라이버가 등록해 둔 `struct pardevice`를 대신 해제하지 않습니다. 각 장치 등록은 드라이버가 직접 추적하여 `parport_unregister_device()`로 정리해야 하며, 드라이버 등록 해제와 장치 수명 종료를 같은 작업으로 간주하면 안 됩니다.

`parport_enumerate()`는 등록된 병렬 포트 연결 리스트의 첫 항목을 반환하는 오래된 인터페이스입니다. 리스트는 `PARPORT_MAX`개까지 이어지며 마지막 항목의 `next`는 `NULL`입니다. 포트가 없으면 함수 자체가 `NULL`을 반환합니다.

직접 열거는 폐기됐습니다. 포트가 나중에 추가·제거되는 동적 환경을 빠뜨리지 않도록 새 코드는 `parport_register_driver()`와 `attach`·`detach` 콜백을 사용해야 합니다.

드라이버 수명 관리
작업효과남는 책임
`parport_register_driver()`기존·신규 포트 알림 시작콜백에서 장치 등록
`parport_unregister_driver()`포트 알림 중단기존 `pardevice` 별도 해제
`parport_enumerate()`현재 연결 리스트 반환폐기됨, 동적 변경 추적 불가

parport_unregister_driver - tell parport to forget about this driver
--------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_driver {
                const char *name;
                void (*attach) (struct parport *);
                void (*detach) (struct parport *);
                struct parport_driver *next;
        };
        void parport_unregister_driver (struct parport_driver *driver);

DESCRIPTION
^^^^^^^^^^^

This tells parport not to notify the device driver of new ports or of
ports going away.  Registered devices belonging to that driver are NOT
unregistered: parport_unregister_device must be used for each one.

EXAMPLE
^^^^^^^

::

        void cleanup_module (void)
        {
                ...
                /* Stop notifications. */
                parport_unregister_driver (&lp_driver);

                /* Unregister devices. */
                for (i = 0; i < NUM_DEVS; i++)
                        parport_unregister_device (dev[i]);
                ...
        }

SEE ALSO
^^^^^^^^

parport_register_driver, parport_enumerate



parport_enumerate - retrieve a list of parallel ports (DEPRECATED)
------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport *parport_enumerate (void);

DESCRIPTION
^^^^^^^^^^^

Retrieve the first of a list of valid parallel ports for this machine.
Successive parallel ports can be found using the ``struct parport
*next`` element of the ``struct parport *`` that is returned.  If ``next``
is NULL, there are no more parallel ports in the list.  The number of
ports in the list will not exceed PARPORT_MAX.

RETURN VALUE
^^^^^^^^^^^^

A ``struct parport *`` describing a valid parallel port for the machine,
or NULL if there are none.

ERRORS
^^^^^^

This function can return NULL to indicate that there are no parallel
ports to use.

EXAMPLE
^^^^^^^

::

        int detect_device (void)
        {
                struct parport *port;

                for (port = parport_enumerate ();
                port != NULL;
                port = port->next) {
                        /* Try to detect a device on the port... */
                        ...
                }
                }

                ...
        }

NOTES
^^^^^

parport_enumerate is deprecated; parport_register_driver should be
used instead.

SEE ALSO
^^^^^^^^

parport_register_driver, parport_unregister_driver


`parport_register_device()`와 장치 콜백 수명

357-535

`parport_register_device()`는 특정 `struct parport`에 장치 드라이버 인스턴스를 등록합니다. 인자는 포트, 장치 이름, `preempt`·`wakeup`·`irq` 콜백, flags, 콜백에 돌려줄 `handle`입니다. 필요하지 않은 콜백은 `NULL`로 둘 수 있습니다.

`preempt` 콜백은 다른 드라이버가 포트를 요구할 때 현재 소유자가 포트를 양보할 수 있는지 묻습니다. 0을 반환하면 포트 소유권을 잃으며, non-zero를 반환하면 현재 작업 때문에 양보할 수 없다는 뜻입니다. 콜백이 0을 반환한 뒤에는 포트를 사용하기 전에 다시 claim해야 합니다.

`wakeup` 콜백은 포트가 사용 가능해졌을 때 호출됩니다. 이 콜백 안에서 `parport_claim()`을 호출하면 성공이 보장됩니다. `irq` 콜백은 포트 인터럽트가 발생했을 때 호출되며, `handle`은 세 콜백 모두에 드라이버의 사적 상태를 전달합니다.

`flags`에 `PARPORT_DEV_EXCL`을 지정하면 해당 포트에 다른 장치를 등록할 수 없는 독점 장치를 요청합니다. 성공 시 유효한 `struct pardevice *`를 반환하고 실패하면 `NULL`을 반환합니다. 원문의 toaster 예제는 콜백과 사적 구조체를 연결한 뒤 반환된 장치 핸들을 저장합니다.

`parport_unregister_device()`는 등록된 장치를 제거하고 전달된 핸들을 즉시 무효화합니다. claim한 장치를 해제하는 것은 올바른 사용법이 아니지만, 코어는 방어적으로 포트를 자동 release합니다. 호출 뒤에는 `dev`를 다시 참조해서는 안 됩니다.

`pardevice` 등록과 콜백
`parport_register_device()`Store name, flags and handle`parport_claim()`Use port`parport_unregister_device()`
Another driver requests port`preempt(handle)`0: ownership lost`wakeup(handle)` when freeClaim again
Port interrupt`irq(handle)`Device-specific handler

공유 포트 중재 시 콜백이 소유권과 인터럽트 전달을 조정합니다.

parport_register_device - register to use a port
------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        typedef int (*preempt_func) (void *handle);
        typedef void (*wakeup_func) (void *handle);
        typedef int (*irq_func) (int irq, void *handle, struct pt_regs *);

        struct pardevice *parport_register_device(struct parport *port,
                                                  const char *name,
                                                  preempt_func preempt,
                                                  wakeup_func wakeup,
                                                  irq_func irq,
                                                  int flags,
                                                  void *handle);

DESCRIPTION
^^^^^^^^^^^

Use this function to register your device driver on a parallel port
(``port``).  Once you have done that, you will be able to use
parport_claim and parport_release in order to use the port.

The (``name``) argument is the name of the device that appears in /proc
filesystem. The string must be valid for the whole lifetime of the
device (until parport_unregister_device is called).

This function will register three callbacks into your driver:
``preempt``, ``wakeup`` and ``irq``.  Each of these may be NULL in order to
indicate that you do not want a callback.

When the ``preempt`` function is called, it is because another driver
wishes to use the parallel port.  The ``preempt`` function should return
non-zero if the parallel port cannot be released yet -- if zero is
returned, the port is lost to another driver and the port must be
re-claimed before use.

The ``wakeup`` function is called once another driver has released the
port and no other driver has yet claimed it.  You can claim the
parallel port from within the ``wakeup`` function (in which case the
claim is guaranteed to succeed), or choose not to if you don't need it
now.

If an interrupt occurs on the parallel port your driver has claimed,
the ``irq`` function will be called. (Write something about shared
interrupts here.)

The ``handle`` is a pointer to driver-specific data, and is passed to
the callback functions.

``flags`` may be a bitwise combination of the following flags:

  ===================== =================================================
        Flag            Meaning
  ===================== =================================================
  PARPORT_DEV_EXCL        The device cannot share the parallel port at all.
                        Use this only when absolutely necessary.
  ===================== =================================================

The typedefs are not actually defined -- they are only shown in order
to make the function prototype more readable.

The visible parts of the returned ``struct pardevice`` are::

        struct pardevice {
                struct parport *port;        /* Associated port */
                void *private;                /* Device driver's 'handle' */
                ...
        };

RETURN VALUE
^^^^^^^^^^^^

A ``struct pardevice *``: a handle to the registered parallel port
device that can be used for parport_claim, parport_release, etc.

ERRORS
^^^^^^

A return value of NULL indicates that there was a problem registering
a device on that port.

EXAMPLE
^^^^^^^

::

        static int preempt (void *handle)
        {
                if (busy_right_now)
                        return 1;

                must_reclaim_port = 1;
                return 0;
        }

        static void wakeup (void *handle)
        {
                struct toaster *private = handle;
                struct pardevice *dev = private->dev;
                if (!dev) return; /* avoid races */

                if (want_port)
                        parport_claim (dev);
        }

        static int toaster_detect (struct toaster *private, struct parport *port)
        {
                private->dev = parport_register_device (port, "toaster", preempt,
                                                        wakeup, NULL, 0,
                                                        private);
                if (!private->dev)
                        /* Couldn't register with parport. */
                        return -EIO;

                must_reclaim_port = 0;
                busy_right_now = 1;
                parport_claim_or_block (private->dev);
                ...
                /* Don't need the port while the toaster warms up. */
                busy_right_now = 0;
                ...
                busy_right_now = 1;
                if (must_reclaim_port) {
                        parport_claim_or_block (private->dev);
                        must_reclaim_port = 0;
                }
                ...
        }

SEE ALSO
^^^^^^^^

parport_unregister_device, parport_claim



parport_unregister_device - finish using a port
-----------------------------------------------

SYNPOPSIS

::

        #include <linux/parport.h>

        void parport_unregister_device (struct pardevice *dev);

DESCRIPTION
^^^^^^^^^^^

This function is the opposite of parport_register_device.  After using
parport_unregister_device, ``dev`` is no longer a valid device handle.

You should not unregister a device that is currently claimed, although
if you do it will be released automatically.

EXAMPLE
^^^^^^^

::

        ...
        kfree (dev->private); /* before we lose the pointer */
        parport_unregister_device (dev);
        ...

SEE ALSO
^^^^^^^^


parport_unregister_driver

포트 claim, release와 일시 양보

536-669

`parport_claim()`은 등록된 장치가 병렬 포트를 즉시 소유하도록 시도합니다. 성공하면 0, 다른 장치가 점유 중이면 `-EAGAIN`을 반환합니다. `parport_claim_or_block()`은 포트가 비어날 때까지 잠들 수 있으며, 즉시 얻으면 0, 기다렸다가 얻으면 양수, 기다릴 수 없거나 실패하면 `-EAGAIN`을 반환합니다.

포트를 claim한 동안에만 장치가 포트 연산을 수행해야 합니다. 작업을 마치면 `parport_release()`로 소유권을 반환합니다. 예제처럼 ECP 데이터를 쓴 뒤 release하면 대기 중인 다른 장치가 포트를 사용할 수 있습니다. 관련 모드 전환과 claim 상태를 일관되게 유지해야 합니다.

`parport_yield()`와 `parport_yield_blocking()`은 현재 소유자가 다른 드라이버에 포트를 잠시 빌려주도록 합니다. 전자는 block하지 않고 후자는 block할 수 있습니다. 반환값 0은 호출자가 계속 포트를 소유하며 block하지 않았다는 뜻이고, blocking 버전의 양수는 기다렸지만 다시 소유권을 확보했다는 뜻입니다.

yield 계열이 `-EAGAIN`을 반환하면 소유권이 실제로 다른 장치에 넘어간 것입니다. 이 상태에서는 포트를 건드리지 말고 `parport_claim()` 또는 `parport_claim_or_block()`으로 다시 확보해야 합니다.

포트 소유권 반환값
API반환값호출 뒤 상태
`parport_claim()``0`즉시 소유
`parport_claim()``-EAGAIN`소유하지 않음
`parport_claim_or_block()``> 0`기다린 뒤 소유
`parport_release()``void`소유권 반환
`parport_yield_blocking()``0` 또는 `> 0`계속 소유
yield 계열`-EAGAIN`소유권을 잃음, 재claim 필요

parport_claim, parport_claim_or_block - claim the parallel port for a device
----------------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_claim (struct pardevice *dev);
        int parport_claim_or_block (struct pardevice *dev);

DESCRIPTION
^^^^^^^^^^^

These functions attempt to gain control of the parallel port on which
``dev`` is registered.  ``parport_claim`` does not block, but
``parport_claim_or_block`` may do. (Put something here about blocking
interruptibly or non-interruptibly.)

You should not try to claim a port that you have already claimed.

RETURN VALUE
^^^^^^^^^^^^

A return value of zero indicates that the port was successfully
claimed, and the caller now has possession of the parallel port.

If ``parport_claim_or_block`` blocks before returning successfully, the
return value is positive.

ERRORS
^^^^^^

========== ==========================================================
  -EAGAIN  The port is unavailable at the moment, but another attempt
           to claim it may succeed.
========== ==========================================================

SEE ALSO
^^^^^^^^


parport_release

parport_release - release the parallel port
-------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        void parport_release (struct pardevice *dev);

DESCRIPTION
^^^^^^^^^^^

Once a parallel port device has been claimed, it can be released using
``parport_release``.  It cannot fail, but you should not release a
device that you do not have possession of.

EXAMPLE
^^^^^^^

::

        static size_t write (struct pardevice *dev, const void *buf,
                        size_t len)
        {
                ...
                written = dev->port->ops->write_ecp_data (dev->port, buf,
                                                        len);
                parport_release (dev);
                ...
        }


SEE ALSO
^^^^^^^^

change_mode, parport_claim, parport_claim_or_block, parport_yield



parport_yield, parport_yield_blocking - temporarily release a parallel port
---------------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_yield (struct pardevice *dev)
        int parport_yield_blocking (struct pardevice *dev);

DESCRIPTION
^^^^^^^^^^^

When a driver has control of a parallel port, it may allow another
driver to temporarily ``borrow`` it.  ``parport_yield`` does not block;
``parport_yield_blocking`` may do.

RETURN VALUE
^^^^^^^^^^^^

A return value of zero indicates that the caller still owns the port
and the call did not block.

A positive return value from ``parport_yield_blocking`` indicates that
the caller still owns the port and the call blocked.

A return value of -EAGAIN indicates that the caller no longer owns the
port, and it must be re-claimed before use.

ERRORS
^^^^^^

========= ==========================================================
  -EAGAIN  Ownership of the parallel port was given away.
========= ==========================================================

SEE ALSO
^^^^^^^^

parport_release


상태선 대기, 이벤트와 IEEE 1284 협상

670-801

`parport_wait_peripheral()`은 status register에서 `mask`로 고른 선들이 `val`의 값과 일치할 때까지 최대 35ms 기다립니다. signal이 pending이면 `-EINTR`, 조건이 맞으면 0, 35ms가 지나면 1을 반환합니다.

`parport_poll_peripheral()`은 같은 조건을 `usec` 마이크로초 동안 polling합니다. 반환 규약도 `-EINTR`, 0, 1로 같지만 timeout 길이를 호출자가 정합니다. 이 두 함수의 양수 1은 errno가 아니라 시간 초과를 뜻합니다.

`parport_wait_event()`는 인터럽트 같은 포트 이벤트를 `timeout` jiffies 동안 기다립니다. 0은 성공, 음수는 가능한 한 빨리 종료해야 하는 오류, 양수는 timeout입니다.

`parport_negotiate()`는 지정한 `mode`로 IEEE 1284 협상을 수행합니다. 0은 handshake가 성공했고 주변장치와 모드가 모두 사용 가능함을 뜻합니다. -1은 handshake 실패로, 장치가 IEEE 1284 호환이 아니거나 아예 없을 수 있습니다. 1은 IEEE 1284 장치는 확인됐지만 요청한 모드는 사용할 수 없다는 뜻입니다.

대기와 협상 결과
API성공시간 초과·대체 결과중단·실패
`parport_wait_peripheral()``0``1` = 35ms 경과`-EINTR`
`parport_poll_peripheral()``0``1` = `usec` 경과`-EINTR`
`parport_wait_event()``0``> 0``< 0`
`parport_negotiate()``0``1` = 모드 불가`-1` = handshake 실패

parport_wait_peripheral - wait for status lines, up to 35ms
-----------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_wait_peripheral (struct parport *port,
                                     unsigned char mask,
                                     unsigned char val);

DESCRIPTION
^^^^^^^^^^^

Wait for the status lines in mask to match the values in val.

RETURN VALUE
^^^^^^^^^^^^

======== ==========================================================
 -EINTR  a signal is pending
      0  the status lines in mask have values in val
      1  timed out while waiting (35ms elapsed)
======== ==========================================================

SEE ALSO
^^^^^^^^

parport_poll_peripheral



parport_poll_peripheral - wait for status lines, in usec
--------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_poll_peripheral (struct parport *port,
                                     unsigned char mask,
                                     unsigned char val,
                                     int usec);

DESCRIPTION
^^^^^^^^^^^

Wait for the status lines in mask to match the values in val.

RETURN VALUE
^^^^^^^^^^^^

======== ==========================================================
 -EINTR  a signal is pending
      0  the status lines in mask have values in val
      1  timed out while waiting (usec microseconds have elapsed)
======== ==========================================================

SEE ALSO
^^^^^^^^

parport_wait_peripheral



parport_wait_event - wait for an event on a port
------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_wait_event (struct parport *port, signed long timeout)

DESCRIPTION
^^^^^^^^^^^

Wait for an event (e.g. interrupt) on a port.  The timeout is in
jiffies.

RETURN VALUE
^^^^^^^^^^^^

======= ==========================================================
      0  success
     <0  error (exit as soon as possible)
     >0  timed out
======= ==========================================================

parport_negotiate - perform IEEE 1284 negotiation
-------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_negotiate (struct parport *, int mode);

DESCRIPTION
^^^^^^^^^^^

Perform IEEE 1284 negotiation.

RETURN VALUE
^^^^^^^^^^^^

======= ==========================================================
     0  handshake OK; IEEE 1284 peripheral and mode available
    -1  handshake failed; peripheral not compliant (or none present)
     1  handshake OK; IEEE 1284 peripheral present but mode not
        available
======= ==========================================================

SEE ALSO
^^^^^^^^

parport_read, parport_write


현재 모드 전송과 장치 번호 기반 열기

802-921

`parport_read()`는 현재 IEEE 1284 전송 모드로 장치에서 `buf`에 최대 `len` 바이트를 읽습니다. 역방향 데이터 전송을 지원하는 모드에서만 동작합니다. 음수는 오류 코드이고, 0 이상의 값은 실제 전송한 바이트 수입니다.

`parport_write()`는 현재 IEEE 1284 전송 모드로 `buf`의 데이터를 장치에 씁니다. 순방향 데이터 전송을 지원하는 모드에서만 동작하며, 반환 규약은 `parport_read()`와 같습니다. 두 함수 모두 먼저 `parport_negotiate()`로 알맞은 모드를 선택한 상태에서 사용해야 합니다.

`parport_open()`은 `struct parport *` 대신 0부터 시작하는 장치 번호 `devnum`을 받아 장치를 등록한다는 점을 제외하면 `parport_register_device()`와 같습니다. 지정한 번호에 대응하는 장치가 없거나 등록에 실패하면 `NULL`을 반환합니다.

`parport_close()`는 `parport_open()`으로 얻은 장치를 닫는 짝 함수이며, 장치 등록 방식의 `parport_unregister_device()`에 해당합니다. 열린 핸들의 수명과 claim 상태를 정리한 뒤 호출해야 합니다.

번호 기반 IEEE 1284 전송
`devnum``parport_open()``parport_negotiate(mode)``parport_read()` / `parport_write()``parport_close()`

장치 번호를 핸들로 바꾸고 모드를 협상한 뒤 전송하고 닫습니다.

parport_read - read data from device
------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        ssize_t parport_read (struct parport *, void *buf, size_t len);

DESCRIPTION
^^^^^^^^^^^

Read data from device in current IEEE 1284 transfer mode.  This only
works for modes that support reverse data transfer.

RETURN VALUE
^^^^^^^^^^^^

If negative, an error code; otherwise the number of bytes transferred.

SEE ALSO
^^^^^^^^

parport_write, parport_negotiate



parport_write - write data to device
------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        ssize_t parport_write (struct parport *, const void *buf, size_t len);

DESCRIPTION
^^^^^^^^^^^

Write data to device in current IEEE 1284 transfer mode.  This only
works for modes that support forward data transfer.

RETURN VALUE
^^^^^^^^^^^^

If negative, an error code; otherwise the number of bytes transferred.

SEE ALSO
^^^^^^^^

parport_read, parport_negotiate



parport_open - register device for particular device number
-----------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct pardevice *parport_open (int devnum, const char *name,
                                        int (*pf) (void *),
                                        void (*kf) (void *),
                                        void (*irqf) (int, void *,
                                                      struct pt_regs *),
                                        int flags, void *handle);

DESCRIPTION
^^^^^^^^^^^

This is like parport_register_device but takes a device number instead
of a pointer to a struct parport.

RETURN VALUE
^^^^^^^^^^^^

See parport_register_device.  If no device is associated with devnum,
NULL is returned.

SEE ALSO
^^^^^^^^

parport_register_device



parport_close - unregister device for particular device number
--------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        void parport_close (struct pardevice *dev);

DESCRIPTION
^^^^^^^^^^^

This is the equivalent of parport_unregister_device for parport_open.

SEE ALSO
^^^^^^^^

parport_unregister_device, parport_open


IEEE 1284 Device ID, 좌표와 class 검색

922-1055

`parport_device_id()`는 장치 번호 `devnum`에 연결된 IEEE 1284 Device ID를 `buffer`에 가져옵니다. 음수는 오류이고, 0 이상의 반환값은 buffer에서 Device ID가 차지하는 바이트 수입니다.

Device ID 형식은 `[length][ID]`입니다. 첫 두 바이트는 전체 Device ID를 포함하는 길이를 big-endian으로 담으며, 뒤의 ID는 `key:value;` 쌍의 연속입니다. 실제 장치에는 형식이 잘못된 Device ID가 많으므로 파서는 누락·오류를 견고하게 처리해야 합니다.

`parport_device_coords()`는 0 기반 장치 번호를 `(port, multiplexor, daisy chain address)` 좌표로 변환합니다. 성공 시 0을 반환하며 결과는 `*parport`, `*mux`, `*daisy`에 기록됩니다.

`parport_find_class()`는 지정한 `parport_device_class`의 다음 장치를 찾습니다. 검색은 `from + 1`에서 시작하고, 찾으면 장치 번호, 없으면 -1을 반환합니다. class에는 `PARPORT_CLASS_LEGACY`, `PRINTER`, `MODEM`, `NET`, `HDC`, `PCMCIA`, `MEDIA`, `FDC`, `PORTS`, `SCANNER`, `DIGCAM`, `OTHER`, `UNSPEC`, `SCSIADAPTER`가 있습니다.

모든 digital camera를 순회하는 원문 예제처럼 첫 `from`을 -1로 두고, 반환된 번호를 다음 호출의 `from`으로 넘깁니다. 각 번호는 `parport_open()`으로 열 수 있습니다.

장치 식별 경로
입력API출력
`devnum``parport_device_id()`big-endian 길이 + `key:value;` ID
`devnum``parport_device_coords()``port`, `mux`, `daisy`
`class`, `from``parport_find_class()`다음 장치 번호 또는 `-1`
`PARPORT_CLASS_DIGCAM`반복 검색모든 digital camera

parport_device_id - obtain IEEE 1284 Device ID
----------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        ssize_t parport_device_id (int devnum, char *buffer, size_t len);

DESCRIPTION
^^^^^^^^^^^

Obtains the IEEE 1284 Device ID associated with a given device.

RETURN VALUE
^^^^^^^^^^^^

If negative, an error code; otherwise, the number of bytes of buffer
that contain the device ID.  The format of the device ID is as
follows::

        [length][ID]

The first two bytes indicate the inclusive length of the entire Device
ID, and are in big-endian order.  The ID is a sequence of pairs of the
form::

        key:value;

NOTES
^^^^^

Many devices have ill-formed IEEE 1284 Device IDs.

SEE ALSO
^^^^^^^^

parport_find_class, parport_find_device



parport_device_coords - convert device number to device coordinates
-------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_device_coords (int devnum, int *parport, int *mux,
                                   int *daisy);

DESCRIPTION
^^^^^^^^^^^

Convert between device number (zero-based) and device coordinates
(port, multiplexor, daisy chain address).

RETURN VALUE
^^^^^^^^^^^^

Zero on success, in which case the coordinates are (``*parport``, ``*mux``,
``*daisy``).

SEE ALSO
^^^^^^^^

parport_open, parport_device_id



parport_find_class - find a device by its class
-----------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        typedef enum {
                PARPORT_CLASS_LEGACY = 0,       /* Non-IEEE1284 device */
                PARPORT_CLASS_PRINTER,
                PARPORT_CLASS_MODEM,
                PARPORT_CLASS_NET,
                PARPORT_CLASS_HDC,              /* Hard disk controller */
                PARPORT_CLASS_PCMCIA,
                PARPORT_CLASS_MEDIA,            /* Multimedia device */
                PARPORT_CLASS_FDC,              /* Floppy disk controller */
                PARPORT_CLASS_PORTS,
                PARPORT_CLASS_SCANNER,
                PARPORT_CLASS_DIGCAM,
                PARPORT_CLASS_OTHER,            /* Anything else */
                PARPORT_CLASS_UNSPEC,           /* No CLS field in ID */
                PARPORT_CLASS_SCSIADAPTER
        } parport_device_class;

        int parport_find_class (parport_device_class cls, int from);

DESCRIPTION
^^^^^^^^^^^

Find a device by class.  The search starts from device number from+1.

RETURN VALUE
^^^^^^^^^^^^

The device number of the next device in that class, or -1 if no such
device exists.

NOTES
^^^^^

Example usage::

        int devnum = -1;
        while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
                struct pardevice *dev = parport_open (devnum, ...);
                ...
        }

SEE ALSO
^^^^^^^^

parport_find_device, parport_open, parport_device_id


제조사·모델 검색과 inactivity timeout

1056-1144

`parport_find_device()`는 IEEE 1284 Device ID의 제조사 `mfg`와 모델 `mdl`이 일치하는 장치를 찾습니다. 검색은 `from + 1`에서 시작하며, 다음 일치 장치 번호를 반환하거나 더 없으면 -1을 반환합니다. 원문은 `IOMEGA`, `ZIP+`를 반복 검색해 각각 `parport_open()`하는 예를 보입니다.

`parport_set_timeout()`은 등록된 장치의 inactivity timeout을 jiffies 단위로 설정하고 이전 값을 반환합니다. 설정은 다시 바꿀 때까지 장치에 유지됩니다.

일부 `port->ops->xxx_read/write_yyy` 전송은 주변장치 응답 지연 때문에 오래 걸릴 수 있습니다. 주변장치가 `inactivity` jiffies 동안 응답하지 않으면 timeout이 발생하고 blocking 함수가 반환합니다.

0 jiffies는 특별합니다. 연산은 block하지 않고 하드웨어를 알 수 없는 상태에 남기지 않는 범위에서 가능한 만큼만 수행해야 합니다. 인터럽트 handler 안에서 포트 연산을 수행해야 한다면 timeout을 0으로 설정해야 합니다.

검색과 timeout 규칙
항목규칙실무 의미
검색 시작`from + 1``from = -1`로 첫 장치부터 순회
검색 종료`-1`더 이상 일치 장치 없음
일반 timeout`inactivity` jiffies무응답 blocking 전송 중단
IRQ 문맥`0` jiffiesblock 금지, 하드웨어 상태 보존
반환값이전 timeout임시 변경 후 복원 가능

parport_find_device - find a device by its class
------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        int parport_find_device (const char *mfg, const char *mdl, int from);

DESCRIPTION
^^^^^^^^^^^

Find a device by vendor and model.  The search starts from device
number from+1.

RETURN VALUE
^^^^^^^^^^^^

The device number of the next device matching the specifications, or
-1 if no such device exists.

NOTES
^^^^^

Example usage::

        int devnum = -1;
        while ((devnum = parport_find_device ("IOMEGA", "ZIP+", devnum)) != -1) {
                struct pardevice *dev = parport_open (devnum, ...);
                ...
        }

SEE ALSO
^^^^^^^^

parport_find_class, parport_open, parport_device_id



parport_set_timeout - set the inactivity timeout
------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        long parport_set_timeout (struct pardevice *dev, long inactivity);

DESCRIPTION
^^^^^^^^^^^

Set the inactivity timeout, in jiffies, for a registered device.  The
previous timeout is returned.

RETURN VALUE
^^^^^^^^^^^^

The previous timeout, in jiffies.

NOTES
^^^^^

Some of the port->ops functions for a parport may take time, owing to
delays at the peripheral.  After the peripheral has not responded for
``inactivity`` jiffies, a timeout will occur and the blocking function
will return.

A timeout of 0 jiffies is a special case: the function must do as much
as it can without blocking or leaving the hardware in an unknown
state.  If port operations are performed from within an interrupt
handler, for instance, a timeout of 0 jiffies should be used.

Once set for a registered device, the timeout will remain at the set
value until set again.

SEE ALSO
^^^^^^^^

port->ops->xxx_read/write_yyy



기본 data·status register 연산

1145-1248

이 절부터의 함수는 포트를 담당하는 저수준 드라이버가 `struct parport_operations`에 구현합니다. 상위 parport 코어와 장치 드라이버는 이 `port->ops` 테이블을 통해 아키텍처별 레지스터나 하드웨어 엔진을 사용합니다.

`port->ops->read_data()`는 조건에 따라 데이터 핀 또는 마지막 출력값을 읽습니다. `port->modes`에 `PARPORT_MODE_TRISTATE`가 있고 control register의 `PARPORT_CONTROL_DIRECTION` 비트가 설정돼 있으면 데이터 핀 값을 반환합니다. TRISTATE는 지원하지만 방향 비트가 꺼져 있으면 마지막으로 data register에 쓴 값일 수 있으며, 그 밖의 경우 반환값은 정의되지 않습니다.

`port->ops->write_data()`는 data register에 바이트를 씁니다. 구현에 따라 STROBE pulse 같은 부수 효과가 생길 수 있으므로 단순 메모리 저장처럼 취급해서는 안 됩니다.

`port->ops->read_status()`는 status register 비트마스크를 반환합니다. 표준 비트는 `PARPORT_STATUS_ERROR`(printer fault, `nFault`), `PARPORT_STATUS_SELECT`(on-line, `Select`), `PARPORT_STATUS_PAPEROUT`(no paper, `PError`), `PARPORT_STATUS_ACK`(handshake, `nAck`), `PARPORT_STATUS_BUSY`(busy, `Busy`)이며 다른 비트도 함께 설정될 수 있습니다.

SPP 기본 레지스터
연산조건·비트결과·주의
`read_data`TRISTATE + DIRECTION실제 data pins
`read_data`TRISTATE, 순방향마지막 write 값일 수 있음
`write_data`data register writeSTROBE 등 부수 효과 가능
`read_status``ERROR/SELECT/PAPEROUT/ACK/BUSY`추가 비트도 허용

PORT FUNCTIONS
==============

The functions in the port->ops structure (struct parport_operations)
are provided by the low-level driver responsible for that port.

port->ops->read_data - read the data register
---------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                unsigned char (*read_data) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

If port->modes contains the PARPORT_MODE_TRISTATE flag and the
PARPORT_CONTROL_DIRECTION bit in the control register is set, this
returns the value on the data pins.  If port->modes contains the
PARPORT_MODE_TRISTATE flag and the PARPORT_CONTROL_DIRECTION bit is
not set, the return value _may_ be the last value written to the data
register.  Otherwise the return value is undefined.

SEE ALSO
^^^^^^^^

write_data, read_status, write_control



port->ops->write_data - write the data register
-----------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*write_data) (struct parport *port, unsigned char d);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes to the data register.  May have side-effects (a STROBE pulse,
for instance).

SEE ALSO
^^^^^^^^

read_data, read_status, write_control



port->ops->read_status - read the status register
-------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                unsigned char (*read_status) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads from the status register.  This is a bitmask:

- PARPORT_STATUS_ERROR (printer fault, "nFault")
- PARPORT_STATUS_SELECT (on-line, "Select")
- PARPORT_STATUS_PAPEROUT (no paper, "PError")
- PARPORT_STATUS_ACK (handshake, "nAck")
- PARPORT_STATUS_BUSY (busy, "Busy")

There may be other bits set.

SEE ALSO
^^^^^^^^

read_data, write_data, write_control


control register 읽기·쓰기와 선택 비트 변경

1249-1350

`port->ops->read_control()`은 `write_control()` 또는 `frob_control()`이 마지막으로 기록한 control register 값을 반환합니다. 실제 포트 read는 수행하지 않으며, 저수준 드라이버가 유지하는 소프트웨어 사본을 읽습니다.

`port->ops->write_control()`은 control register 비트마스크를 기록합니다. 정의된 선은 `PARPORT_CONTROL_STROBE`(`nStrobe`), `PARPORT_CONTROL_AUTOFD`(`nAutoFd`), `PARPORT_CONTROL_INIT`(`nInit`), `PARPORT_CONTROL_SELECT`(`nSelectIn`)입니다. 신호 이름의 `n`과 원문의 윗줄 표시는 active-low 신호임을 나타냅니다.

`port->ops->frob_control()`은 현재 control 값에서 `mask` 비트를 대상으로 `val`과 exclusive-or한 결과를 다시 기록하는 선택적 갱신 연산입니다. 의미상 read-modify-write이지만 control port 읽기를 지원하지 않는 하드웨어를 위해 소프트웨어 사본을 사용하므로 실제 포트 접근은 한 번뿐입니다.

여러 control 선을 바꾸는 코드에서는 전체 값을 덮어쓸지 `frob_control()`로 특정 비트만 변경할지 명확히 선택해야 합니다. `read_control()`이 물리 핀을 샘플링하지 않는다는 점도 진단 코드에서 중요합니다.

Control 신호와 연산
항목의미접근 특성
`PARPORT_CONTROL_STROBE``nStrobe`active-low
`PARPORT_CONTROL_AUTOFD``nAutoFd`active-low
`PARPORT_CONTROL_INIT``nInit`active-low 표기 보존
`PARPORT_CONTROL_SELECT``nSelectIn`active-low
`read_control()`마지막 기록값포트 접근 없음
`frob_control(mask, val)`선택 비트 XOR 갱신포트 접근 1회

port->ops->read_control - read the control register
---------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                unsigned char (*read_control) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Returns the last value written to the control register (either from
write_control or frob_control).  No port access is performed.

SEE ALSO
^^^^^^^^

read_data, write_data, read_status, write_control



port->ops->write_control - write the control register
-----------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*write_control) (struct parport *port, unsigned char s);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes to the control register. This is a bitmask::

                                  _______
        - PARPORT_CONTROL_STROBE (nStrobe)
                                  _______
        - PARPORT_CONTROL_AUTOFD (nAutoFd)
                                _____
        - PARPORT_CONTROL_INIT (nInit)
                                  _________
        - PARPORT_CONTROL_SELECT (nSelectIn)

SEE ALSO
^^^^^^^^

read_data, write_data, read_status, frob_control



port->ops->frob_control - write control register bits
-----------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                unsigned char (*frob_control) (struct parport *port,
                                        unsigned char mask,
                                        unsigned char val);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

This is equivalent to reading from the control register, masking out
the bits in mask, exclusive-or'ing with the bits in val, and writing
the result to the control register.

As some ports don't allow reads from the control port, a software copy
of its contents is maintained, so frob_control is in fact only one
port access.

SEE ALSO
^^^^^^^^

read_data, write_data, read_status, write_control


인터럽트와 데이터 버스 방향 제어

1351-1468

`port->ops->enable_irq()`는 아키텍처가 정한 적절한 시점에 병렬 포트 하드웨어가 인터럽트를 생성하도록 설정합니다. PC 아키텍처에서는 보통 `nAck`의 rising edge에서 인터럽트가 발생합니다.

`port->ops->disable_irq()`는 병렬 포트 하드웨어가 인터럽트를 생성하지 않도록 합니다. 이 연산은 인터럽트 자체를 mask하는 것이 아니라 포트의 발생 기능을 끄는 것입니다. IRQ controller 수준의 masking과 구분해야 합니다.

`port->ops->data_forward()`는 data line driver를 활성화하여 host에서 peripheral로 8-bit 통신을 수행하게 합니다. `port->ops->data_reverse()`는 `port->modes`에 `PARPORT_MODE_TRISTATE`가 있을 때 data bus를 high-impedance 상태로 두어 peripheral에서 host로 데이터를 받을 수 있게 합니다.

전송 방향을 바꿀 때에는 현재 모드와 주변장치 handshake를 함께 고려해야 합니다. TRISTATE 지원이 없는 포트에서 역방향 전환을 가정하면 안 됩니다.

IRQ와 양방향 data bus
`enable_irq()`Hardware event`nAck` rising edge on PCRegistered IRQ callback
Host-to-peripheral`data_forward()`8-bit driven bus
Peripheral-to-host`data_reverse()`TRISTATE high impedance

포트 하드웨어의 발생 제어와 data driver 방향을 서로 독립적으로 다룹니다.

port->ops->enable_irq - enable interrupt generation
---------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*enable_irq) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

The parallel port hardware is instructed to generate interrupts at
appropriate moments, although those moments are
architecture-specific.  For the PC architecture, interrupts are
commonly generated on the rising edge of nAck.

SEE ALSO
^^^^^^^^

disable_irq



port->ops->disable_irq - disable interrupt generation
-----------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*disable_irq) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

The parallel port hardware is instructed not to generate interrupts.
The interrupt itself is not masked.

SEE ALSO
^^^^^^^^

enable_irq



port->ops->data_forward - enable data drivers
---------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*data_forward) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Enables the data line drivers, for 8-bit host-to-peripheral
communications.

SEE ALSO
^^^^^^^^

data_reverse



port->ops->data_reverse - tristate the buffer
---------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                void (*data_reverse) (struct parport *port);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Places the data bus in a high impedance state, if port->modes has the
PARPORT_MODE_TRISTATE bit set.

SEE ALSO
^^^^^^^^

data_forward


EPP data 전송과 address 쓰기

1469-1584

`port->ops->epp_write_data()`는 EPP mode에서 `buf`의 `len` 바이트를 data cycle로 쓰고 실제 쓴 바이트 수를 반환합니다. `port->ops->epp_read_data()`는 EPP data cycle로 읽어 `buf`에 저장하고 실제 읽은 바이트 수를 반환합니다.

두 data 연산의 `flags`에는 `PARPORT_EPP_FAST`를 bitwise OR하여 지정할 수 있습니다. 일부 칩의 16-bit 또는 32-bit register를 이용해 빠르게 전송하지만, 전송이 timeout되면 반환한 바이트 수가 신뢰할 수 없을 수 있습니다.

`port->ops->epp_write_addr()`는 각 8-bit EPP address를 쓰고 처리한 address 수를 반환합니다. 이 함수에도 `PARPORT_EPP_FAST`가 정의돼 있지만, 원문은 address 연산에 fast flag가 의미가 있는지 의문을 그대로 남깁니다.

EPP data와 address cycle은 같은 byte buffer 형식을 사용하더라도 프로토콜에서 구별됩니다. 호출자는 peripheral의 register 선택에는 address 연산을, payload에는 data 연산을 사용해야 합니다.

EPP 전송 연산
연산cycle반환값`PARPORT_EPP_FAST`
`epp_write_data`Data write쓴 바이트 수16/32-bit 가속 가능
`epp_read_data`Data read읽은 바이트 수timeout 시 값 불확실
`epp_write_addr`8-bit address write쓴 address 수의미 여부가 원문에서 미확정

port->ops->epp_write_data - write EPP data
------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*epp_write_data) (struct parport *port, const void *buf,
                                        size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes data in EPP mode, and returns the number of bytes written.

The ``flags`` parameter may be one or more of the following,
bitwise-or'ed together:

======================= =================================================
PARPORT_EPP_FAST        Use fast transfers. Some chips provide 16-bit and
                        32-bit registers.  However, if a transfer
                        times out, the return value may be unreliable.
======================= =================================================

SEE ALSO
^^^^^^^^

epp_read_data, epp_write_addr, epp_read_addr



port->ops->epp_read_data - read EPP data
----------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*epp_read_data) (struct parport *port, void *buf,
                                        size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads data in EPP mode, and returns the number of bytes read.

The ``flags`` parameter may be one or more of the following,
bitwise-or'ed together:

======================= =================================================
PARPORT_EPP_FAST        Use fast transfers. Some chips provide 16-bit and
                        32-bit registers.  However, if a transfer
                        times out, the return value may be unreliable.
======================= =================================================

SEE ALSO
^^^^^^^^

epp_write_data, epp_write_addr, epp_read_addr



port->ops->epp_write_addr - write EPP address
---------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*epp_write_addr) (struct parport *port,
                                        const void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes EPP addresses (8 bits each), and returns the number written.

The ``flags`` parameter may be one or more of the following,
bitwise-or'ed together:

======================= =================================================
PARPORT_EPP_FAST        Use fast transfers. Some chips provide 16-bit and
                        32-bit registers.  However, if a transfer
                        times out, the return value may be unreliable.
======================= =================================================

(Does PARPORT_EPP_FAST make sense for this function?)

SEE ALSO
^^^^^^^^

epp_write_data, epp_read_data, epp_read_addr


EPP address 읽기

1585-1624

`port->ops->epp_read_addr()`는 EPP address cycle을 사용해 각각 8-bit인 address들을 `buf`에 읽습니다. 반환값은 실제로 읽은 address 수입니다.

`flags`는 bitwise OR한 옵션을 받으며 현재 문서화된 값은 `PARPORT_EPP_FAST`입니다. 일부 칩의 16-bit·32-bit register로 빠른 전송을 사용할 수 있지만 timeout이 발생하면 반환값이 신뢰할 수 없을 수 있습니다.

원문은 `epp_write_addr()`와 마찬가지로 address 읽기에서 `PARPORT_EPP_FAST`가 실제로 의미가 있는지 열린 질문으로 남깁니다. 저수준 드라이버 구현은 하드웨어 동작을 확인하고, 상위 호출자는 부분 전송과 불확실한 count를 고려해야 합니다.

`epp_read_addr()` 계약
항목내용
전송 단위8-bit EPP address
buffer`void *buf`, 최대 `len`개
반환읽은 address 수
Fast flag`PARPORT_EPP_FAST`
주의timeout 시 반환값 불확실, address fast 의미 미확정
관련 연산`epp_write_data`, `epp_read_data`, `epp_write_addr`

port->ops->epp_read_addr - read EPP address
-------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*epp_read_addr) (struct parport *port, void *buf,
                                        size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads EPP addresses (8 bits each), and returns the number read.

The ``flags`` parameter may be one or more of the following,
bitwise-or'ed together:

======================= =================================================
PARPORT_EPP_FAST        Use fast transfers. Some chips provide 16-bit and
                        32-bit registers.  However, if a transfer
                        times out, the return value may be unreliable.
======================= =================================================

(Does PARPORT_EPP_FAST make sense for this function?)

SEE ALSO
^^^^^^^^

epp_write_data, epp_read_data, epp_write_addr


ECP data와 address block 전송

1625-1732

`port->ops->ecp_write_data()`는 ECP data block을 쓰고 실제 쓴 바이트 수를 반환합니다. `port->ops->ecp_read_data()`는 ECP data block을 읽고 실제 읽은 바이트 수를 반환합니다. 두 함수 모두 `flags` 인자를 받지만 이 API에서는 무시합니다.

ECP read가 반환한 뒤에도 하드웨어 FIFO에 읽지 않은 데이터가 남아 있을 수 있습니다. 원문은 FIFO를 멈춰 이를 방지할 방법이 있는지 질문을 남깁니다. 따라서 반환 count만으로 peripheral과 FIFO가 완전히 비었다고 단정해서는 안 됩니다.

`port->ops->ecp_write_addr()`는 ECP address block을 쓰고 쓴 바이트 수를 반환하며 `flags`는 무시합니다. 구현이 FIFO를 사용한다면 FIFO가 완전히 빌 때까지 반환해서는 안 됩니다.

원문의 관련 항목에는 `ecp_write_block` 표기가 있지만 실제 이 절의 함수 이름은 `ecp_write_data`입니다. 번역에서는 원문 symbol을 보존하면서 구현자가 함수 포인터 이름을 혼동하지 않도록 구분합니다.

ECP FIFO 경계
`ecp_write_data()`Optional FIFOReturn written byte count
`ecp_read_data()`Read requested blockUnread FIFO data may remain
`ecp_write_addr()`Queue address blockWait until FIFO emptyReturn written byte count

Write-address는 FIFO drain을 보장하지만 read-data 뒤에는 잔여 데이터가 있을 수 있습니다.

port->ops->ecp_write_data - write a block of ECP data
-----------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*ecp_write_data) (struct parport *port,
                                        const void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes a block of ECP data.  The ``flags`` parameter is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of bytes written.

SEE ALSO
^^^^^^^^

ecp_read_data, ecp_write_addr



port->ops->ecp_read_data - read a block of ECP data
---------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*ecp_read_data) (struct parport *port,
                                        void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads a block of ECP data.  The ``flags`` parameter is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of bytes read.  NB. There may be more unread data in a
FIFO.  Is there a way of stunning the FIFO to prevent this?

SEE ALSO
^^^^^^^^

ecp_write_block, ecp_write_addr



port->ops->ecp_write_addr - write a block of ECP addresses
----------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*ecp_write_addr) (struct parport *port,
                                        const void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes a block of ECP addresses.  The ``flags`` parameter is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of bytes written.

NOTES
^^^^^

This may use a FIFO, and if so shall not return until the FIFO is empty.

SEE ALSO
^^^^^^^^

ecp_read_data, ecp_write_data


Nibble·byte·compatibility mode block 전송

1733-1832

`port->ops->nibble_read_data()`는 IEEE 1284 nibble mode로 data block을 읽습니다. 전송은 nibble 단위 프로토콜을 사용하지만 반환값은 완성된 전체 바이트 수이며 `flags`는 무시합니다.

`port->ops->byte_read_data()`는 byte mode로 data block을 읽고 실제 읽은 바이트 수를 반환합니다. 이 연산도 `flags`를 무시하며, 역방향 byte 전송에는 포트의 양방향 데이터 버스 지원이 필요합니다.

`port->ops->compat_write_data()`는 compatibility mode로 data block을 쓰고 실제 쓴 바이트 수를 반환합니다. `flags`는 무시됩니다. 이 세 함수는 EPP/ECP 하드웨어가 없어도 IEEE 1284의 기본 역방향·순방향 경로를 구성합니다.

모든 block 함수에서 요청 길이와 반환 count가 다를 수 있으므로 호출자는 부분 전송을 처리해야 합니다. mode를 협상하고 포트를 claim한 상태에서 알맞은 방향 연산을 선택해야 합니다.

기본 IEEE 1284 block 전송
연산방향·모드반환`flags`
`nibble_read_data`Peripheral-to-host, nibble완성된 전체 바이트 수무시
`byte_read_data`Peripheral-to-host, byte읽은 바이트 수무시
`compat_write_data`Host-to-peripheral, compatibility쓴 바이트 수무시

port->ops->nibble_read_data - read a block of data in nibble mode
-----------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*nibble_read_data) (struct parport *port,
                                        void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads a block of data in nibble mode.  The ``flags`` parameter is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of whole bytes read.

SEE ALSO
^^^^^^^^

byte_read_data, compat_write_data



port->ops->byte_read_data - read a block of data in byte mode
-------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*byte_read_data) (struct parport *port,
                                        void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Reads a block of data in byte mode.  The ``flags`` parameter is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of bytes read.

SEE ALSO
^^^^^^^^

nibble_read_data, compat_write_data



port->ops->compat_write_data - write a block of data in compatibility mode
--------------------------------------------------------------------------

SYNOPSIS
^^^^^^^^

::

        #include <linux/parport.h>

        struct parport_operations {
                ...
                size_t (*compat_write_data) (struct parport *port,
                                        const void *buf, size_t len, int flags);
                ...
        };

DESCRIPTION
^^^^^^^^^^^

Writes a block of data in compatibility mode.  The ``flags`` parameter
is ignored.

RETURN VALUE
^^^^^^^^^^^^

The number of bytes written.

SEE ALSO
^^^^^^^^

nibble_read_data, byte_read_data