parport-lowlevel.txt 37.1 KB
Newer Older
1
===============================
Linus Torvalds's avatar
Linus Torvalds committed
2
PARPORT interface documentation
3
===============================
Linus Torvalds's avatar
Linus Torvalds committed
4

5
:Time-stamp: <2000-02-24 13:30:20 twaugh>
Linus Torvalds's avatar
Linus Torvalds committed
6 7 8

Described here are the following functions:

9
Global functions::
Linus Torvalds's avatar
Linus Torvalds committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  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):
35 36

  SPP::
Linus Torvalds's avatar
Linus Torvalds committed
37 38 39 40 41 42 43 44 45 46 47
    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

48
  EPP::
Linus Torvalds's avatar
Linus Torvalds committed
49 50 51 52 53
    port->ops->epp_write_data
    port->ops->epp_read_data
    port->ops->epp_write_addr
    port->ops->epp_read_addr

54
  ECP::
Linus Torvalds's avatar
Linus Torvalds committed
55 56 57 58
    port->ops->ecp_write_data
    port->ops->ecp_read_data
    port->ops->ecp_write_addr

59
  Other::
Linus Torvalds's avatar
Linus Torvalds committed
60 61 62 63
    port->ops->nibble_read_data
    port->ops->byte_read_data
    port->ops->compat_write_data

64
The parport subsystem comprises ``parport`` (the core port-sharing
Linus Torvalds's avatar
Linus Torvalds committed
65 66 67 68 69 70 71 72 73 74
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
75
``generic`` functions for doing standard things that will work on any
Linus Torvalds's avatar
Linus Torvalds committed
76 77 78
IEEE 1284-capable architecture.

The port functions are provided by the low-level drivers, although the
79
core parport module provides generic ``defaults`` for some routines.
Linus Torvalds's avatar
Linus Torvalds committed
80 81
The port functions can be split into three groups: SPP, EPP, and ECP.

82
SPP (Standard Parallel Port) functions modify so-called ``SPP``
Linus Torvalds's avatar
Linus Torvalds committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
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'.

100 101
Global functions
================
Linus Torvalds's avatar
Linus Torvalds committed
102 103

parport_register_driver - register a device driver with parport
104
---------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
105 106

SYNOPSIS
107 108 109
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
110

111
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
112

113 114 115 116 117 118 119
	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);
Linus Torvalds's avatar
Linus Torvalds committed
120 121

DESCRIPTION
122
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
123 124 125 126 127 128

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.

129
A ``struct parport_driver`` contains the textual name of your driver,
Linus Torvalds's avatar
Linus Torvalds committed
130 131 132 133 134
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).

135 136 137 138 139 140 141 142 143 144 145 146 147 148
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;
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
149 150 151 152

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

153
The ``modes`` member summarises the capabilities of the underlying
Linus Torvalds's avatar
Linus Torvalds committed
154 155
hardware.  It consists of flags which may be bitwise-ored together:

156
  ============================= ===============================================
Linus Torvalds's avatar
Linus Torvalds committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
  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.
179
  ============================= ===============================================
Linus Torvalds's avatar
Linus Torvalds committed
180

181
There may be other flags in ``modes`` as well.
Linus Torvalds's avatar
Linus Torvalds committed
182

183 184
The contents of ``modes`` is advisory only.  For example, if the
hardware is capable of DMA, and PARPORT_MODE_DMA is in ``modes``, it
Linus Torvalds's avatar
Linus Torvalds committed
185 186 187 188 189
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
190
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
191 192 193 194

Zero on success, otherwise an error code.

ERRORS
195
^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
196 197 198 199

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

EXAMPLE
200
^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
201

202
::
Linus Torvalds's avatar
Linus Torvalds committed
203

204 205 206 207 208 209 210
	static void lp_attach (struct parport *port)
	{
		...
		private = kmalloc (...);
		dev[count++] = parport_register_device (...);
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
211

212 213 214 215
	static void lp_detach (struct parport *port)
	{
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
216

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
	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;
		}
		...
Linus Torvalds's avatar
Linus Torvalds committed
232
	}
233

Linus Torvalds's avatar
Linus Torvalds committed
234 235

SEE ALSO
236
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
237 238

parport_unregister_driver, parport_register_device, parport_enumerate
239 240 241



Linus Torvalds's avatar
Linus Torvalds committed
242
parport_unregister_driver - tell parport to forget about this driver
243
--------------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
244 245

SYNOPSIS
246
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
247

248
::
Linus Torvalds's avatar
Linus Torvalds committed
249

250 251 252 253 254 255 256 257 258
	#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);
Linus Torvalds's avatar
Linus Torvalds committed
259 260

DESCRIPTION
261
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
262 263 264 265 266 267

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
268
^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
269

270
::
Linus Torvalds's avatar
Linus Torvalds committed
271

272 273 274 275 276 277 278 279 280 281 282
	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]);
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
283 284

SEE ALSO
285
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
286 287

parport_register_driver, parport_enumerate
288 289 290



Linus Torvalds's avatar
Linus Torvalds committed
291
parport_enumerate - retrieve a list of parallel ports (DEPRECATED)
292
------------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
293 294

SYNOPSIS
295
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
296

297
::
Linus Torvalds's avatar
Linus Torvalds committed
298

299 300 301
	#include <linux/parport.h>

	struct parport *parport_enumerate (void);
Linus Torvalds's avatar
Linus Torvalds committed
302 303

DESCRIPTION
304
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
305 306

Retrieve the first of a list of valid parallel ports for this machine.
307 308
Successive parallel ports can be found using the ``struct parport
*next`` element of the ``struct parport *`` that is returned.  If ``next``
Linus Torvalds's avatar
Linus Torvalds committed
309 310 311 312
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
313
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
314

315
A ``struct parport *`` describing a valid parallel port for the machine,
Linus Torvalds's avatar
Linus Torvalds committed
316 317 318
or NULL if there are none.

ERRORS
319
^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
320 321 322 323 324

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

EXAMPLE
325 326 327
^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
328

329 330 331 332 333 334 335 336 337 338 339
	int detect_device (void)
	{
		struct parport *port;

		for (port = parport_enumerate ();
		port != NULL;
		port = port->next) {
			/* Try to detect a device on the port... */
			...
		}
		}
Linus Torvalds's avatar
Linus Torvalds committed
340 341 342 343 344

		...
	}

NOTES
345
^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
346 347 348 349 350

parport_enumerate is deprecated; parport_register_driver should be
used instead.

SEE ALSO
351
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
352 353

parport_register_driver, parport_unregister_driver
354 355 356



Linus Torvalds's avatar
Linus Torvalds committed
357
parport_register_device - register to use a port
358
------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
359 360

SYNOPSIS
361
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
362

363
::
Linus Torvalds's avatar
Linus Torvalds committed
364

365
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
366

367 368 369 370 371 372 373 374 375 376 377
	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);
Linus Torvalds's avatar
Linus Torvalds committed
378 379

DESCRIPTION
380
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
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
Linus Torvalds's avatar
Linus Torvalds committed
384 385
parport_claim and parport_release in order to use the port.

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

Linus Torvalds's avatar
Linus Torvalds committed
390
This function will register three callbacks into your driver:
391
``preempt``, ``wakeup`` and ``irq``.  Each of these may be NULL in order to
Linus Torvalds's avatar
Linus Torvalds committed
392 393
indicate that you do not want a callback.

394 395
When the ``preempt`` function is called, it is because another driver
wishes to use the parallel port.  The ``preempt`` function should return
Linus Torvalds's avatar
Linus Torvalds committed
396 397 398 399
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.

400
The ``wakeup`` function is called once another driver has released the
Linus Torvalds's avatar
Linus Torvalds committed
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
Linus Torvalds's avatar
Linus Torvalds committed
403 404 405 406
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,
407
the ``irq`` function will be called. (Write something about shared
Linus Torvalds's avatar
Linus Torvalds committed
408 409
interrupts here.)

410
The ``handle`` is a pointer to driver-specific data, and is passed to
Linus Torvalds's avatar
Linus Torvalds committed
411 412
the callback functions.

413
``flags`` may be a bitwise combination of the following flags:
Linus Torvalds's avatar
Linus Torvalds committed
414

415
  ===================== =================================================
Linus Torvalds's avatar
Linus Torvalds committed
416
        Flag            Meaning
417
  ===================== =================================================
Linus Torvalds's avatar
Linus Torvalds committed
418 419
  PARPORT_DEV_EXCL	The device cannot share the parallel port at all.
			Use this only when absolutely necessary.
420
  ===================== =================================================
Linus Torvalds's avatar
Linus Torvalds committed
421 422 423 424

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

425
The visible parts of the returned ``struct pardevice`` are::
Linus Torvalds's avatar
Linus Torvalds committed
426

427 428 429 430 431
	struct pardevice {
		struct parport *port;	/* Associated port */
		void *private;		/* Device driver's 'handle' */
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
432 433

RETURN VALUE
434
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
435

436
A ``struct pardevice *``: a handle to the registered parallel port
Linus Torvalds's avatar
Linus Torvalds committed
437 438 439
device that can be used for parport_claim, parport_release, etc.

ERRORS
440
^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
441 442 443 444 445

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

EXAMPLE
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
^^^^^^^

::

	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;
Linus Torvalds's avatar
Linus Torvalds committed
477 478

		must_reclaim_port = 0;
479 480 481 482 483 484 485 486 487 488 489 490
		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;
		}
		...
Linus Torvalds's avatar
Linus Torvalds committed
491 492 493
	}

SEE ALSO
494
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
495 496

parport_unregister_device, parport_claim
497 498


Linus Torvalds's avatar
Linus Torvalds committed
499 500

parport_unregister_device - finish using a port
501
-----------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
502 503 504

SYNPOPSIS

505 506 507
::

	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
508

509
	void parport_unregister_device (struct pardevice *dev);
Linus Torvalds's avatar
Linus Torvalds committed
510 511

DESCRIPTION
512
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
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.
Linus Torvalds's avatar
Linus Torvalds committed
516 517 518 519 520

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

EXAMPLE
521 522 523
^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
524 525 526 527 528 529 530

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

SEE ALSO
531 532
^^^^^^^^

Linus Torvalds's avatar
Linus Torvalds committed
533 534 535 536

parport_unregister_driver

parport_claim, parport_claim_or_block - claim the parallel port for a device
537
----------------------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
538 539

SYNOPSIS
540 541 542
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
543

544
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
545

546 547
	int parport_claim (struct pardevice *dev);
	int parport_claim_or_block (struct pardevice *dev);
Linus Torvalds's avatar
Linus Torvalds committed
548 549

DESCRIPTION
550
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
551 552

These functions attempt to gain control of the parallel port on which
553 554
``dev`` is registered.  ``parport_claim`` does not block, but
``parport_claim_or_block`` may do. (Put something here about blocking
Linus Torvalds's avatar
Linus Torvalds committed
555 556 557 558 559
interruptibly or non-interruptibly.)

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

RETURN VALUE
560
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
561 562 563 564

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

565
If ``parport_claim_or_block`` blocks before returning successfully, the
Linus Torvalds's avatar
Linus Torvalds committed
566 567 568
return value is positive.

ERRORS
569
^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
570

571
========== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
572 573
  -EAGAIN  The port is unavailable at the moment, but another attempt
           to claim it may succeed.
574
========== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
575 576

SEE ALSO
577 578
^^^^^^^^

Linus Torvalds's avatar
Linus Torvalds committed
579 580 581 582

parport_release

parport_release - release the parallel port
583
-------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
584 585

SYNOPSIS
586 587 588
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
589

590
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
591

592
	void parport_release (struct pardevice *dev);
Linus Torvalds's avatar
Linus Torvalds committed
593 594

DESCRIPTION
595
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
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
Linus Torvalds's avatar
Linus Torvalds committed
599 600 601
device that you do not have possession of.

EXAMPLE
602
^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
603

604 605 606 607 608 609 610 611 612 613 614
::

	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);
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
615 616 617


SEE ALSO
618
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
619 620

change_mode, parport_claim, parport_claim_or_block, parport_yield
621 622 623



Linus Torvalds's avatar
Linus Torvalds committed
624
parport_yield, parport_yield_blocking - temporarily release a parallel port
625
---------------------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
626 627

SYNOPSIS
628 629 630
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
631

632
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
633

634 635
	int parport_yield (struct pardevice *dev)
	int parport_yield_blocking (struct pardevice *dev);
Linus Torvalds's avatar
Linus Torvalds committed
636 637

DESCRIPTION
638
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
639 640

When a driver has control of a parallel port, it may allow another
641 642
driver to temporarily ``borrow`` it.  ``parport_yield`` does not block;
``parport_yield_blocking`` may do.
Linus Torvalds's avatar
Linus Torvalds committed
643 644

RETURN VALUE
645
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
646 647 648 649

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

650
A positive return value from ``parport_yield_blocking`` indicates that
Linus Torvalds's avatar
Linus Torvalds committed
651 652 653 654 655 656
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
657
^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
658

659
========= ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
660
  -EAGAIN  Ownership of the parallel port was given away.
661
========= ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
662 663

SEE ALSO
664
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
665 666

parport_release
667 668


Linus Torvalds's avatar
Linus Torvalds committed
669 670

parport_wait_peripheral - wait for status lines, up to 35ms
671
-----------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
672 673

SYNOPSIS
674 675 676
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
677

678
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
679

680 681 682
	int parport_wait_peripheral (struct parport *port,
				     unsigned char mask,
				     unsigned char val);
Linus Torvalds's avatar
Linus Torvalds committed
683 684

DESCRIPTION
685
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
686 687 688 689

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

RETURN VALUE
690
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
691

692
======== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
693 694 695
 -EINTR  a signal is pending
      0  the status lines in mask have values in val
      1  timed out while waiting (35ms elapsed)
696
======== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
697 698

SEE ALSO
699
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
700 701

parport_poll_peripheral
702 703


Linus Torvalds's avatar
Linus Torvalds committed
704 705

parport_poll_peripheral - wait for status lines, in usec
706
--------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
707 708

SYNOPSIS
709 710 711
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
712

713
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
714

715 716 717 718
	int parport_poll_peripheral (struct parport *port,
				     unsigned char mask,
				     unsigned char val,
				     int usec);
Linus Torvalds's avatar
Linus Torvalds committed
719 720

DESCRIPTION
721
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
722 723 724 725

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

RETURN VALUE
726
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
727

728
======== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
729 730 731
 -EINTR  a signal is pending
      0  the status lines in mask have values in val
      1  timed out while waiting (usec microseconds have elapsed)
732
======== ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
733 734

SEE ALSO
735
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
736 737

parport_wait_peripheral
738 739 740



Linus Torvalds's avatar
Linus Torvalds committed
741
parport_wait_event - wait for an event on a port
742
------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
743 744

SYNOPSIS
745
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
746

747
::
Linus Torvalds's avatar
Linus Torvalds committed
748

749 750 751
	#include <linux/parport.h>

	int parport_wait_event (struct parport *port, signed long timeout)
Linus Torvalds's avatar
Linus Torvalds committed
752 753

DESCRIPTION
754
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
755 756 757 758 759

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

RETURN VALUE
760
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
761

762
======= ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
763 764 765
      0  success
     <0  error (exit as soon as possible)
     >0  timed out
766 767
======= ==========================================================

Linus Torvalds's avatar
Linus Torvalds committed
768
parport_negotiate - perform IEEE 1284 negotiation
769
-------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
770 771

SYNOPSIS
772 773 774
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
775

776
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
777

778
	int parport_negotiate (struct parport *, int mode);
Linus Torvalds's avatar
Linus Torvalds committed
779 780

DESCRIPTION
781
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
782 783 784 785

Perform IEEE 1284 negotiation.

RETURN VALUE
786
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
787

788
======= ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
789 790 791 792
     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
793
======= ==========================================================
Linus Torvalds's avatar
Linus Torvalds committed
794 795

SEE ALSO
796
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
797 798

parport_read, parport_write
799 800 801



Linus Torvalds's avatar
Linus Torvalds committed
802
parport_read - read data from device
803
------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
804 805

SYNOPSIS
806 807 808
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
809

810
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
811

812
	ssize_t parport_read (struct parport *, void *buf, size_t len);
Linus Torvalds's avatar
Linus Torvalds committed
813 814

DESCRIPTION
815
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
816 817 818 819 820

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

RETURN VALUE
821
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
822 823 824 825

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

SEE ALSO
826
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
827 828

parport_write, parport_negotiate
829 830 831



Linus Torvalds's avatar
Linus Torvalds committed
832
parport_write - write data to device
833
------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
834 835

SYNOPSIS
836 837 838
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
839

840
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
841

842
	ssize_t parport_write (struct parport *, const void *buf, size_t len);
Linus Torvalds's avatar
Linus Torvalds committed
843 844

DESCRIPTION
845
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
846 847 848 849 850

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

RETURN VALUE
851
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
852 853 854 855

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

SEE ALSO
856
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
857 858

parport_read, parport_negotiate
859 860


Linus Torvalds's avatar
Linus Torvalds committed
861 862

parport_open - register device for particular device number
863
-----------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
864 865

SYNOPSIS
866
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
867

868
::
Linus Torvalds's avatar
Linus Torvalds committed
869

870 871 872 873 874 875 876 877
	#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);
Linus Torvalds's avatar
Linus Torvalds committed
878 879

DESCRIPTION
880
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
881 882 883 884 885

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

RETURN VALUE
886
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
887 888 889 890 891

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

SEE ALSO
892
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
893

894
parport_register_device
895 896 897



Linus Torvalds's avatar
Linus Torvalds committed
898
parport_close - unregister device for particular device number
899
--------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
900 901

SYNOPSIS
902 903 904
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
905

906
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
907

908
	void parport_close (struct pardevice *dev);
Linus Torvalds's avatar
Linus Torvalds committed
909 910

DESCRIPTION
911
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
912 913 914 915

This is the equivalent of parport_unregister_device for parport_open.

SEE ALSO
916
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
917 918

parport_unregister_device, parport_open
919 920 921



Linus Torvalds's avatar
Linus Torvalds committed
922
parport_device_id - obtain IEEE 1284 Device ID
923
----------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
924 925

SYNOPSIS
926 927 928
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
929

930
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
931

932
	ssize_t parport_device_id (int devnum, char *buffer, size_t len);
Linus Torvalds's avatar
Linus Torvalds committed
933 934

DESCRIPTION
935
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
936 937 938 939

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

RETURN VALUE
940
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
941 942 943

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
944
follows::
Linus Torvalds's avatar
Linus Torvalds committed
945

946
	[length][ID]
Linus Torvalds's avatar
Linus Torvalds committed
947 948 949

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
950
form::
Linus Torvalds's avatar
Linus Torvalds committed
951

952
	key:value;
Linus Torvalds's avatar
Linus Torvalds committed
953 954

NOTES
955
^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
956 957 958 959

Many devices have ill-formed IEEE 1284 Device IDs.

SEE ALSO
960
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
961

962
parport_find_class, parport_find_device
963 964 965



Linus Torvalds's avatar
Linus Torvalds committed
966
parport_device_coords - convert device number to device coordinates
967
-------------------------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
968 969

SYNOPSIS
970 971 972
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
973

974
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
975

976 977
	int parport_device_coords (int devnum, int *parport, int *mux,
				   int *daisy);
Linus Torvalds's avatar
Linus Torvalds committed
978 979

DESCRIPTION
980
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
981 982 983 984 985

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

RETURN VALUE
986
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
987

988 989
Zero on success, in which case the coordinates are (``*parport``, ``*mux``,
``*daisy``).
Linus Torvalds's avatar
Linus Torvalds committed
990 991

SEE ALSO
992
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
993

994
parport_open, parport_device_id
995 996 997



Linus Torvalds's avatar
Linus Torvalds committed
998
parport_find_class - find a device by its class
999
-----------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1000 1001

SYNOPSIS
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
^^^^^^^^

::

	#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);
Linus Torvalds's avatar
Linus Torvalds committed
1026 1027

DESCRIPTION
1028
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1029 1030 1031 1032

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

RETURN VALUE
1033
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1034 1035 1036 1037 1038

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

NOTES
1039
^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1040

1041
Example usage::
Linus Torvalds's avatar
Linus Torvalds committed
1042

1043 1044 1045 1046 1047
	int devnum = -1;
	while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
		struct pardevice *dev = parport_open (devnum, ...);
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
1048 1049

SEE ALSO
1050
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1051 1052

parport_find_device, parport_open, parport_device_id
1053 1054 1055



Linus Torvalds's avatar
Linus Torvalds committed
1056
parport_find_device - find a device by its class
1057
------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1058 1059

SYNOPSIS
1060
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1061

1062
::
Linus Torvalds's avatar
Linus Torvalds committed
1063

1064 1065 1066
	#include <linux/parport.h>

	int parport_find_device (const char *mfg, const char *mdl, int from);
Linus Torvalds's avatar
Linus Torvalds committed
1067 1068

DESCRIPTION
1069
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1070 1071 1072 1073 1074

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

RETURN VALUE
1075
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1076 1077 1078 1079 1080

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

NOTES
1081
^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1082

1083
Example usage::
Linus Torvalds's avatar
Linus Torvalds committed
1084

1085 1086 1087 1088 1089
	int devnum = -1;
	while ((devnum = parport_find_device ("IOMEGA", "ZIP+", devnum)) != -1) {
		struct pardevice *dev = parport_open (devnum, ...);
		...
	}
Linus Torvalds's avatar
Linus Torvalds committed
1090 1091

SEE ALSO
1092
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1093 1094

parport_find_class, parport_open, parport_device_id
1095 1096


Linus Torvalds's avatar
Linus Torvalds committed
1097 1098

parport_set_timeout - set the inactivity timeout
1099
------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1100 1101

SYNOPSIS
1102 1103 1104
^^^^^^^^

::
Linus Torvalds's avatar
Linus Torvalds committed
1105

1106
	#include <linux/parport.h>
Linus Torvalds's avatar
Linus Torvalds committed
1107

1108
	long parport_set_timeout (struct pardevice *dev, long inactivity);
Linus Torvalds's avatar
Linus Torvalds committed
1109 1110

DESCRIPTION
1111
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1112 1113 1114 1115 1116

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

RETURN VALUE
1117
^^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1118 1119 1120 1121

The previous timeout, in jiffies.

NOTES
1122
^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1123 1124 1125

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
1126
``inactivity`` jiffies, a timeout will occur and the blocking function
Linus Torvalds's avatar
Linus Torvalds committed
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
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
1138
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1139 1140

port->ops->xxx_read/write_yyy
1141 1142 1143 1144




Linus Torvalds's avatar
Linus Torvalds committed
1145
PORT FUNCTIONS
1146
==============
Linus Torvalds's avatar
Linus Torvalds committed
1147 1148 1149 1150 1151

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
1152
---------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1153 1154

SYNOPSIS
1155
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1156

1157
::
Linus Torvalds's avatar
Linus Torvalds committed
1158

1159 1160 1161 1162 1163 1164 1165
	#include <linux/parport.h>

	struct parport_operations {
		...
		unsigned char (*read_data) (struct parport *port);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1166 1167

DESCRIPTION
1168
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1169 1170 1171 1172 1173 1174 1175 1176 1177

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
1178
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1179 1180

write_data, read_status, write_control
1181 1182


Linus Torvalds's avatar
Linus Torvalds committed
1183 1184

port->ops->write_data - write the data register
1185
-----------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1186 1187

SYNOPSIS
1188
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1189

1190
::
Linus Torvalds's avatar
Linus Torvalds committed
1191

1192 1193 1194 1195 1196 1197 1198
	#include <linux/parport.h>

	struct parport_operations {
		...
		void (*write_data) (struct parport *port, unsigned char d);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1199 1200

DESCRIPTION
1201
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1202 1203 1204 1205 1206

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

SEE ALSO
1207
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1208 1209

read_data, read_status, write_control
1210 1211


Linus Torvalds's avatar
Linus Torvalds committed
1212 1213

port->ops->read_status - read the status register
1214
-------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1215 1216

SYNOPSIS
1217
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1218

1219
::
Linus Torvalds's avatar
Linus Torvalds committed
1220

1221 1222 1223 1224 1225 1226 1227
	#include <linux/parport.h>

	struct parport_operations {
		...
		unsigned char (*read_status) (struct parport *port);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1228 1229

DESCRIPTION
1230
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242

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
1243
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1244 1245

read_data, write_data, write_control
1246 1247


Linus Torvalds's avatar
Linus Torvalds committed
1248 1249

port->ops->read_control - read the control register
1250
---------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1251 1252

SYNOPSIS
1253
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1254

1255
::
Linus Torvalds's avatar
Linus Torvalds committed
1256

1257 1258 1259 1260 1261 1262 1263
	#include <linux/parport.h>

	struct parport_operations {
		...
		unsigned char (*read_control) (struct parport *port);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1264 1265

DESCRIPTION
1266
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1267 1268 1269 1270 1271

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

SEE ALSO
1272
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1273 1274

read_data, write_data, read_status, write_control
1275 1276


Linus Torvalds's avatar
Linus Torvalds committed
1277 1278

port->ops->write_control - write the control register
1279
-----------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1280 1281

SYNOPSIS
1282
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1283

1284
::
Linus Torvalds's avatar
Linus Torvalds committed
1285

1286 1287 1288 1289 1290 1291 1292
	#include <linux/parport.h>

	struct parport_operations {
		...
		void (*write_control) (struct parport *port, unsigned char s);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1293 1294

DESCRIPTION
1295
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1296

1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
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)
Linus Torvalds's avatar
Linus Torvalds committed
1307 1308

SEE ALSO
1309
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1310 1311

read_data, write_data, read_status, frob_control
1312 1313


Linus Torvalds's avatar
Linus Torvalds committed
1314 1315

port->ops->frob_control - write control register bits
1316
-----------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1317 1318

SYNOPSIS
1319
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1320

1321
::
Linus Torvalds's avatar
Linus Torvalds committed
1322

1323 1324 1325 1326 1327 1328 1329 1330 1331
	#include <linux/parport.h>

	struct parport_operations {
		...
		unsigned char (*frob_control) (struct parport *port,
					unsigned char mask,
					unsigned char val);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1332 1333

DESCRIPTION
1334
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344

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
1345
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1346 1347

read_data, write_data, read_status, write_control
1348 1349


Linus Torvalds's avatar
Linus Torvalds committed
1350 1351

port->ops->enable_irq - enable interrupt generation
1352
---------------------------------------------------
Linus Torvalds's avatar
Linus Torvalds committed
1353 1354

SYNOPSIS
1355
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1356

1357
::
Linus Torvalds's avatar
Linus Torvalds committed
1358

1359 1360 1361 1362 1363 1364 1365
	#include <linux/parport.h>

	struct parport_operations {
		...
		void (*enable_irq) (struct parport *port);
		...
	};
Linus Torvalds's avatar
Linus Torvalds committed
1366 1367

DESCRIPTION
1368
^^^^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1369 1370 1371 1372 1373 1374 1375

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
1376
^^^^^^^^
Linus Torvalds's avatar
Linus Torvalds committed
1377 1378

disable_irq
1379 1380


Linus Torvalds's avatar
Linus Torvalds committed
1381 1382

port->ops->disable_irq - disable interrupt generation
1383
-----------------------------------------------------