Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
parport.h File Reference
#include <linux/jiffies.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/irqreturn.h>
#include <linux/semaphore.h>
#include <asm/ptrace.h>
#include <uapi/linux/parport.h>
#include <linux/parport_pc.h>

Go to the source code of this file.

Data Structures

struct  pc_parport_state
 
struct  ax_parport_state
 
struct  amiga_parport_state
 
struct  ax88796_parport_state
 
struct  ip32_parport_state
 
struct  parport_state
 
struct  parport_operations
 
struct  parport_device_info
 
struct  pardevice
 
struct  ieee1284_info
 
struct  parport
 
struct  parport_driver
 

Macros

#define PARPORT_DEVPROC_REGISTERED   0
 
#define DEFAULT_SPIN_TIME   500 /* us */
 
#define PARPORT_DEV_TRAN   0 /* WARNING !! DEPRECATED !! */
 
#define PARPORT_DEV_LURK   (1<<0) /* WARNING !! DEPRECATED !! */
 
#define PARPORT_DEV_EXCL   (1<<1) /* Need exclusive access. */
 
#define PARPORT_FLAG_EXCL   (1<<1) /* EXCL driver registered. */
 
#define PARPORT_INACTIVITY_O_NONBLOCK   1
 
#define parport_write_data(p, x)   parport_pc_write_data(p,x)
 
#define parport_read_data(p)   parport_pc_read_data(p)
 
#define parport_write_control(p, x)   parport_pc_write_control(p,x)
 
#define parport_read_control(p)   parport_pc_read_control(p)
 
#define parport_frob_control(p, m, v)   parport_pc_frob_control(p,m,v)
 
#define parport_read_status(p)   parport_pc_read_status(p)
 
#define parport_enable_irq(p)   parport_pc_enable_irq(p)
 
#define parport_disable_irq(p)   parport_pc_disable_irq(p)
 
#define parport_data_forward(p)   parport_pc_data_forward(p)
 
#define parport_data_reverse(p)   parport_pc_data_reverse(p)
 

Enumerations

enum  ieee1284_phase {
  IEEE1284_PH_FWD_DATA, IEEE1284_PH_FWD_IDLE, IEEE1284_PH_TERMINATE, IEEE1284_PH_NEGOTIATION,
  IEEE1284_PH_HBUSY_DNA, IEEE1284_PH_REV_IDLE, IEEE1284_PH_HBUSY_DAVAIL, IEEE1284_PH_REV_DATA,
  IEEE1284_PH_ECP_SETUP, IEEE1284_PH_ECP_FWD_TO_REV, IEEE1284_PH_ECP_REV_TO_FWD, IEEE1284_PH_ECP_DIR_UNKNOWN
}
 

Functions

struct parportparport_register_port (unsigned long base, int irq, int dma, struct parport_operations *ops)
 
void parport_announce_port (struct parport *port)
 
void parport_remove_port (struct parport *port)
 
int parport_register_driver (struct parport_driver *)
 
void parport_unregister_driver (struct parport_driver *)
 
struct parportparport_find_number (int)
 
struct parportparport_find_base (unsigned long)
 
irqreturn_t parport_irq_handler (int irq, void *dev_id)
 
struct parportparport_get_port (struct parport *)
 
void parport_put_port (struct parport *)
 
struct pardeviceparport_register_device (struct parport *port, const char *name, int(*pf)(void *), void(*kf)(void *), void(*irq_func)(void *), int flags, void *handle)
 
void parport_unregister_device (struct pardevice *dev)
 
int parport_claim (struct pardevice *dev)
 
int parport_claim_or_block (struct pardevice *dev)
 
void parport_release (struct pardevice *dev)
 
void parport_ieee1284_interrupt (void *)
 
int parport_negotiate (struct parport *, int mode)
 
ssize_t parport_write (struct parport *, const void *buf, size_t len)
 
ssize_t parport_read (struct parport *, void *buf, size_t len)
 
long parport_set_timeout (struct pardevice *, long inactivity)
 
int parport_wait_event (struct parport *, long timeout)
 
int parport_wait_peripheral (struct parport *port, unsigned char mask, unsigned char val)
 
int parport_poll_peripheral (struct parport *port, unsigned char mask, unsigned char val, int usec)
 
size_t parport_ieee1284_write_compat (struct parport *, const void *, size_t, int)
 
size_t parport_ieee1284_read_nibble (struct parport *, void *, size_t, int)
 
size_t parport_ieee1284_read_byte (struct parport *, void *, size_t, int)
 
size_t parport_ieee1284_ecp_read_data (struct parport *, void *, size_t, int)
 
size_t parport_ieee1284_ecp_write_data (struct parport *, const void *, size_t, int)
 
size_t parport_ieee1284_ecp_write_addr (struct parport *, const void *, size_t, int)
 
size_t parport_ieee1284_epp_write_data (struct parport *, const void *, size_t, int)
 
size_t parport_ieee1284_epp_read_data (struct parport *, void *, size_t, int)
 
size_t parport_ieee1284_epp_write_addr (struct parport *, const void *, size_t, int)
 
size_t parport_ieee1284_epp_read_addr (struct parport *, void *, size_t, int)
 
int parport_daisy_init (struct parport *port)
 
void parport_daisy_fini (struct parport *port)
 
struct pardeviceparport_open (int devnum, const char *name)
 
void parport_close (struct pardevice *dev)
 
ssize_t parport_device_id (int devnum, char *buffer, size_t len)
 
void parport_daisy_deselect_all (struct parport *port)
 
int parport_daisy_select (struct parport *port, int daisy, int mode)
 
int parport_proc_register (struct parport *pp)
 
int parport_proc_unregister (struct parport *pp)
 
int parport_device_proc_register (struct pardevice *device)
 
int parport_device_proc_unregister (struct pardevice *device)
 

Variables

unsigned long parport_default_timeslice
 
int parport_default_spintime
 

Macro Definition Documentation

#define DEFAULT_SPIN_TIME   500 /* us */

Definition at line 248 of file parport.h.

#define parport_data_forward (   p)    parport_pc_data_forward(p)

Definition at line 459 of file parport.h.

#define parport_data_reverse (   p)    parport_pc_data_reverse(p)

Definition at line 460 of file parport.h.

#define PARPORT_DEV_EXCL   (1<<1) /* Need exclusive access. */

Definition at line 378 of file parport.h.

#define PARPORT_DEV_LURK   (1<<0) /* WARNING !! DEPRECATED !! */

Definition at line 377 of file parport.h.

#define PARPORT_DEV_TRAN   0 /* WARNING !! DEPRECATED !! */

Definition at line 376 of file parport.h.

#define PARPORT_DEVPROC_REGISTERED   0

Definition at line 241 of file parport.h.

#define parport_disable_irq (   p)    parport_pc_disable_irq(p)

Definition at line 458 of file parport.h.

#define parport_enable_irq (   p)    parport_pc_enable_irq(p)

Definition at line 457 of file parport.h.

#define PARPORT_FLAG_EXCL   (1<<1) /* EXCL driver registered. */

Definition at line 380 of file parport.h.

#define parport_frob_control (   p,
  m,
  v 
)    parport_pc_frob_control(p,m,v)

Definition at line 455 of file parport.h.

#define PARPORT_INACTIVITY_O_NONBLOCK   1

Definition at line 388 of file parport.h.

#define parport_read_control (   p)    parport_pc_read_control(p)

Definition at line 454 of file parport.h.

#define parport_read_data (   p)    parport_pc_read_data(p)

Definition at line 452 of file parport.h.

#define parport_read_status (   p)    parport_pc_read_status(p)

Definition at line 456 of file parport.h.

#define parport_write_control (   p,
  x 
)    parport_pc_write_control(p,x)

Definition at line 453 of file parport.h.

#define parport_write_data (   p,
  x 
)    parport_pc_write_data(p,x)

Definition at line 451 of file parport.h.

Enumeration Type Documentation

Enumerator:
IEEE1284_PH_FWD_DATA 
IEEE1284_PH_FWD_IDLE 
IEEE1284_PH_TERMINATE 
IEEE1284_PH_NEGOTIATION 
IEEE1284_PH_HBUSY_DNA 
IEEE1284_PH_REV_IDLE 
IEEE1284_PH_HBUSY_DAVAIL 
IEEE1284_PH_REV_DATA 
IEEE1284_PH_ECP_SETUP 
IEEE1284_PH_ECP_FWD_TO_REV 
IEEE1284_PH_ECP_REV_TO_FWD 
IEEE1284_PH_ECP_DIR_UNKNOWN 

Definition at line 163 of file parport.h.

Function Documentation

void parport_announce_port ( struct parport port)

parport_announce_port - tell device drivers about a parallel port : parallel port to announce

After a port driver has registered a parallel port with parport_register_port, and performed any necessary initialisation or adjustments, it should call parport_announce_port() in order to notify all device drivers that have called parport_register_driver(). Their attach() functions will be called, with as the parameter.

Definition at line 359 of file share.c.

int parport_claim ( struct pardevice dev)

parport_claim - claim access to a parallel port device : pointer to structure representing a device on the port

This function will not block and so can be used from interrupt context. If parport_claim() succeeds in claiming access to the port it returns zero and the port is available to use. It may fail (returning non-zero) if the port is in use by another driver and that driver is not willing to relinquish control of the port.

Definition at line 773 of file share.c.

int parport_claim_or_block ( struct pardevice dev)

parport_claim_or_block - claim access to a parallel port device : pointer to structure representing a device on the port

This behaves like parport_claim(), but will block if necessary to wait for the port to be free. A return value of 1 indicates that it slept; 0 means that it succeeded without needing to sleep. A negative error code indicates failure.

Definition at line 883 of file share.c.

void parport_close ( struct pardevice dev)

parport_close - close a device opened with parport_open() : device to close

This is to parport_open() as parport_unregister_device() is to parport_register_device().

Definition at line 265 of file daisy.c.

void parport_daisy_deselect_all ( struct parport port)

Definition at line 348 of file daisy.c.

void parport_daisy_fini ( struct parport port)

Definition at line 175 of file daisy.c.

int parport_daisy_init ( struct parport port)

Definition at line 92 of file daisy.c.

int parport_daisy_select ( struct parport port,
int  daisy,
int  mode 
)

Definition at line 353 of file daisy.c.

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

Definition at line 256 of file probe.c.

int parport_device_proc_register ( struct pardevice device)

Definition at line 589 of file procfs.c.

int parport_device_proc_unregister ( struct pardevice device)

Definition at line 594 of file procfs.c.

struct parport* parport_find_base ( unsigned long  base)
read

parport_find_base - find a parallel port by base address : base I/O address

This returns the parallel port with the specified base address, or NULL if there is none.

There is an implicit parport_get_port() done already; to throw away the reference to the port that parport_find_base() gives you, use parport_put_port().

Definition at line 743 of file share.c.

struct parport* parport_find_number ( int  number)
read

parport_find_number - find a parallel port by number : parallel port number

This returns the parallel port with the specified number, or NULL if there is none.

There is an implicit parport_get_port() done already; to throw away the reference to the port that parport_find_number() gives you, use parport_put_port().

Definition at line 713 of file share.c.

struct parport* parport_get_port ( struct parport port)
read

parport_get_port - increment a port's reference count : the port

This ensures that a struct parport pointer remains valid until the matching parport_put_port() call.

Definition at line 224 of file share.c.

size_t parport_ieee1284_ecp_read_data ( struct parport ,
void ,
size_t  ,
int   
)

Definition at line 490 of file ieee1284_ops.c.

size_t parport_ieee1284_ecp_write_addr ( struct parport ,
const void ,
size_t  ,
int   
)

Definition at line 638 of file ieee1284_ops.c.

size_t parport_ieee1284_ecp_write_data ( struct parport ,
const void ,
size_t  ,
int   
)

Definition at line 403 of file ieee1284_ops.c.

size_t parport_ieee1284_epp_read_addr ( struct parport ,
void ,
size_t  ,
int   
)

Definition at line 862 of file ieee1284_ops.c.

size_t parport_ieee1284_epp_read_data ( struct parport ,
void ,
size_t  ,
int   
)

Definition at line 774 of file ieee1284_ops.c.

size_t parport_ieee1284_epp_write_addr ( struct parport ,
const void ,
size_t  ,
int   
)

Definition at line 818 of file ieee1284_ops.c.

size_t parport_ieee1284_epp_write_data ( struct parport ,
const void ,
size_t  ,
int   
)

Definition at line 730 of file ieee1284_ops.c.

void parport_ieee1284_interrupt ( void )

Definition at line 574 of file ieee1284.c.

size_t parport_ieee1284_read_byte ( struct parport ,
void ,
size_t  ,
int   
)

Definition at line 240 of file ieee1284_ops.c.

size_t parport_ieee1284_read_nibble ( struct parport ,
void ,
size_t  ,
int   
)

Definition at line 149 of file ieee1284_ops.c.

size_t parport_ieee1284_write_compat ( struct parport ,
const void ,
size_t  ,
int   
)

Definition at line 40 of file ieee1284_ops.c.

irqreturn_t parport_irq_handler ( int  irq,
void dev_id 
)

Definition at line 1005 of file share.c.

int parport_negotiate ( struct parport port,
int  mode 
)

parport_negotiate - negotiate an IEEE 1284 mode : port to use : mode to negotiate to

Use this to negotiate to a particular IEEE 1284 transfer mode. The parameter should be one of the constants in parport.h starting IEEE1284_MODE_xxx.

The return value is 0 if the peripheral has accepted the negotiation to the mode specified, -1 if the peripheral is not IEEE 1284 compliant (or not present), or 1 if the peripheral has rejected the negotiation.

Definition at line 334 of file ieee1284.c.

struct pardevice* parport_open ( int  devnum,
const char name 
)
read

Definition at line 213 of file daisy.c.

int parport_poll_peripheral ( struct parport port,
unsigned char  mask,
unsigned char  result,
int  usec 
)

parport_poll_peripheral - poll status lines : port to watch : status lines to watch

Returns
: desired values of chosen status lines : timeout

This function busy-waits until the masked status lines have the desired values, or until the timeout period elapses. The and

Returns
parameters are bitmasks, with the bits defined by the constants in parport.h: PARPORT_STATUS_BUSY, and so on.

This function does not call schedule(); instead it busy-waits using udelay(). It currently has a resolution of 5usec.

If the status lines take on the desired values before the timeout period elapses, parport_poll_peripheral() returns zero immediately. A return value greater than zero indicates a timeout. An error code (less than zero) indicates an error, most likely a signal that arrived, and the caller should finish what it is doing as soon as possible.

Definition at line 120 of file ieee1284.c.

int parport_proc_register ( struct parport pp)

Definition at line 579 of file procfs.c.

int parport_proc_unregister ( struct parport pp)

Definition at line 584 of file procfs.c.

void parport_put_port ( struct parport port)

parport_put_port - decrement a port's reference count : the port

This should be called once for each call to parport_get_port(), once the port is no longer needed.

Definition at line 238 of file share.c.

ssize_t parport_read ( struct parport port,
void buffer,
size_t  len 
)

parport_read - read a block of data from a parallel port : port to read from : data buffer (in kernel space) : number of bytes of data to transfer

This will read up to bytes of to the port specified, using the IEEE 1284 transfer mode most recently negotiated to (using parport_negotiate()), as long as that mode supports reverse transfers (peripheral to host).

It is the caller's responsibility to ensure that the first bytes of are available to write to.

This function returns the number of bytes transferred (if zero or positive), or else an error code.

Definition at line 700 of file ieee1284.c.

struct pardevice* parport_register_device ( struct parport port,
const char name,
int(*)(void *)  pf,
void(*)(void *)  kf,
void(*)(void *)  irq_func,
int  flags,
void handle 
)
read

Definition at line 525 of file share.c.

int parport_register_driver ( struct parport_driver drv)

parport_register_driver - register a parallel port device driver : structure describing the driver

This can be called by a parallel port device driver in order to receive notifications about ports being found in the system, as well as ports no longer available.

The structure is allocated by the caller and must not be deallocated until after calling parport_unregister_driver().

The driver's attach() function may block. The port that attach() is given will be valid for the duration of the callback, but if the driver wants to take a copy of the pointer it must call parport_get_port() to do so. Calling parport_register_device() on that port will do this for you.

The driver's detach() function may block. The port that detach() is given will be valid for the duration of the callback, but if the driver wants to take a copy of the pointer it must call parport_get_port() to do so.

Returns 0 on success. Currently it always succeeds.

Definition at line 154 of file share.c.

struct parport* parport_register_port ( unsigned long  base,
int  irq,
int  dma,
struct parport_operations ops 
)
read

parport_register_port - register a parallel port : base I/O address : IRQ line : DMA channel : pointer to the port driver's port operations structure

When a parallel port (lowlevel) driver finds a port that should be made available to parallel port device drivers, it should call parport_register_port(). The , , and parameters are for the convenience of port drivers, and for ports where they aren't meaningful needn't be set to anything special. They can be altered afterwards by adjusting the relevant members of the parport structure that is returned and represents the port. They should not be tampered with after calling parport_announce_port, however.

If there are parallel port device drivers in the system that have registered themselves using parport_register_driver(), they are not told about the port at this time; that is done by parport_announce_port().

The structure is allocated by the caller, and must not be deallocated before calling parport_remove_port().

If there is no memory to allocate a new parport structure, this function will return NULL.

Definition at line 276 of file share.c.

void parport_release ( struct pardevice dev)

parport_release - give up access to a parallel port device : pointer to structure representing parallel port device

This function cannot fail, but it should not be called without the port claimed. Similarly, if the port is already claimed you should not try claiming it again.

Definition at line 943 of file share.c.

void parport_remove_port ( struct parport port)

parport_remove_port - deregister a parallel port : parallel port to deregister

When a parallel port driver is forcibly unloaded, or a parallel port becomes inaccessible, the port driver must call this function in order to deal with device drivers that still want to use it.

The parport structure associated with the port has its operations structure replaced with one containing 'null' operations that return errors or just don't do anything.

Any drivers that have registered themselves using parport_register_driver() are notified that the port is no longer accessible by having their detach() routines called with as the parameter.

Definition at line 413 of file share.c.

long parport_set_timeout ( struct pardevice dev,
long  inactivity 
)

parport_set_timeout - set the inactivity timeout for a device : device on a port : inactivity timeout (in jiffies)

This sets the inactivity timeout for a particular device on a port. This affects functions like parport_wait_peripheral(). The special value 0 means not to call schedule() while dealing with this device.

The return value is the previous inactivity timeout.

Any callers of parport_wait_event() for this device are woken up.

Definition at line 797 of file ieee1284.c.

void parport_unregister_device ( struct pardevice dev)

parport_unregister_device - deregister a device on a parallel port : pointer to structure representing device

This undoes the effect of parport_register_device().

Definition at line 641 of file share.c.

void parport_unregister_driver ( struct parport_driver drv)

parport_unregister_driver - deregister a parallel port device driver : structure describing the driver that was given to parport_register_driver()

This should be called by a parallel port device driver that has registered itself using parport_register_driver() when it is about to be unloaded.

When it returns, the driver's attach() routine will no longer be called, and for each port that attach() was called for, the detach() routine will have been called.

All the driver's attach() and detach() calls are guaranteed to have finished by the time this function returns.

Definition at line 187 of file share.c.

int parport_wait_event ( struct parport ,
long  timeout 
)
int parport_wait_peripheral ( struct parport port,
unsigned char  mask,
unsigned char  result 
)

parport_wait_peripheral - wait for status lines to change in 35ms : port to watch : status lines to watch

Returns
: desired values of chosen status lines

This function waits until the masked status lines have the desired values, or until 35ms have elapsed (see IEEE 1284-1994 page 24 to 25 for why this value in particular is hardcoded). The and

Returns
parameters are bitmasks, with the bits defined by the constants in parport.h: PARPORT_STATUS_BUSY, and so on.

The port is polled quickly to start off with, in anticipation of a fast response from the peripheral. This fast polling time is configurable (using /proc), and defaults to 500usec. If the timeout for this port (see parport_set_timeout()) is zero, the fast polling time is 35ms, and this function does not call schedule().

If the timeout for this port is non-zero, after the fast polling fails it uses parport_wait_event() to wait for up to 10ms, waking up if an interrupt occurs.

Definition at line 169 of file ieee1284.c.

ssize_t parport_write ( struct parport port,
const void buffer,
size_t  len 
)

parport_write - write a block of data to a parallel port : port to write to : data buffer (in kernel space) : number of bytes of data to transfer

This will write up to bytes of to the port specified, using the IEEE 1284 transfer mode most recently negotiated to (using parport_negotiate()), as long as that mode supports forward transfers (host to peripheral).

It is the caller's responsibility to ensure that the first bytes of are valid.

This function returns the number of bytes transferred (if zero or positive), or else an error code.

Definition at line 607 of file ieee1284.c.

Variable Documentation

int parport_default_spintime

Definition at line 42 of file share.c.

unsigned long parport_default_timeslice

Definition at line 41 of file share.c.