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