Parport

Theparport code provides parallel-port support under Linux. Thisincludes the ability to share one port between multiple devicedrivers.

You can pass parameters to theparport code to override its automaticdetection of your hardware. This is particularly useful if you wantto use IRQs, since in general these can’t be autoprobed successfully.By default IRQs are not used even if theycan be probed. This isbecause there are a lot of people using the same IRQ for theirparallel port and a sound card or network card.

Theparport code is split into two parts: generic (which deals withport-sharing) and architecture-dependent (which deals with actuallyusing the port).

Parport as modules

If you load theparport` code as a module, say:

# insmod parport

to load the genericparport code. You then must load thearchitecture-dependent code with (for example):

# insmod parport_pc io=0x3bc,0x378,0x278 irq=none,7,auto

to tell theparport code that you want three PC-style ports, one at0x3bc with no IRQ, one at 0x378 using IRQ 7, and one at 0x278 with anauto-detected IRQ. Currently, PC-style (parport_pc), Sunbpp,Amiga, Atari, and MFC3 hardware is supported.

PCI parallel I/O card support comes fromparport_pc. Base I/Oaddresses should not be specified for supported PCI cards since theyare automatically detected.

modprobe

If you use modprobe , you will find it useful to add lines as below to aconfiguration file in /etc/modprobe.d/ directory:

alias parport_lowlevel parport_pcoptions parport_pc io=0x378,0x278 irq=7,auto

modprobe will loadparport_pc (with the optionsio=0x378,0x278irq=7,auto)whenever a parallel port device driver (such aslp) is loaded.

Note that these are example lines only! You shouldn’t in general needto specify any options toparport_pc in order to be able to use aparallel port.

Parport probe [optional]

In 2.2 kernels there was a module calledparport_probe, which was usedfor collecting IEEE 1284 device ID information. This has now beenenhanced and now lives with the IEEE 1284 support. When a parallelport is detected, the devices that are connected to it are analysed,and information is logged like this:

parport0: Printer, BJC-210 (Canon)

The probe information is available from files in/proc/sys/dev/parport/.

Parport linked into the kernel statically

If you compile theparport code into the kernel, then you can usekernel boot parameters to get the same effect. Add something like thefollowing to your LILO command line:

parport=0x3bc parport=0x378,7 parport=0x278,auto,nofifo

You can have manyparport=... statements, one for each port you wantto add. Addingparport=0 to the kernel command-line will disableparport support entirely. Addingparport=auto to the kernelcommand-line will makeparport use any IRQ lines or DMA channels thatit auto-detects.

Files in /proc

If you have configured the/proc filesystem into your kernel, you willsee a new directory entry:/proc/sys/dev/parport. In there will be adirectory entry for each parallel port for which parport isconfigured. In each of those directories are a collection of filesdescribing that parallel port.

The/proc/sys/dev/parport directory tree looks like:

parport|-- default|   |-- spintime|   `-- timeslice|-- parport0|   |-- autoprobe|   |-- autoprobe0|   |-- autoprobe1|   |-- autoprobe2|   |-- autoprobe3|   |-- devices|   |   |-- active|   |   `-- lp|   |       `-- timeslice|   |-- base-addr|   |-- irq|   |-- dma|   |-- modes|   `-- spintime`-- parport1|-- autoprobe|-- autoprobe0|-- autoprobe1|-- autoprobe2|-- autoprobe3|-- devices|   |-- active|   `-- ppa|       `-- timeslice|-- base-addr|-- irq|-- dma|-- modes`-- spintime
FileContents
devices/activeA list of the device drivers using that port. A “+”will appear by the name of the device currently usingthe port (it might not appear against any). Thestring “none” means that there are no device driversusing that port.
base-addrParallel port’s base address, or addresses if the porthas more than one in which case they are separatedwith tabs. These values might not have any sensiblemeaning for some ports.
irqParallel port’s IRQ, or -1 if none is being used.
dmaParallel port’s DMA channel, or -1 if none is beingused.
modes

Parallel port’s hardware modes, comma-separated,meaning:

  • PCSPP
    PC-style SPP registers are available.
  • TRISTATE
    Port is bidirectional.
  • COMPAT
    Hardware acceleration for printers isavailable and will be used.
  • EPP
    Hardware acceleration for EPP protocolis available and will be used.
  • ECP
    Hardware acceleration for ECP protocolis available and will be used.
  • DMA
    DMA is available and will be used.

Note that the current implementation will only takeadvantage of COMPAT and ECP modes if it has an IRQline to use.

autoprobeAny IEEE-1284 device ID information that has beenacquired from the (non-IEEE 1284.3) device.
autoprobe[0-3]IEEE 1284 device ID information retrieved fromdaisy-chain devices that conform to IEEE 1284.3.
spintimeThe number of microseconds to busy-loop while waitingfor the peripheral to respond. You might find thatadjusting this improves performance, depending on yourperipherals. This is a port-wide setting, i.e. itapplies to all devices on a particular port.
timesliceThe number of milliseconds that a device driver isallowed to keep a port claimed for. This is advisory,and driver can ignore it if it must.
default/*The defaults for spintime and timeslice. When a newport is registered, it picks up the default spintime.When a new device is registered, it picks up thedefault timeslice.

Device drivers

Once the parport code is initialised, you can attach device drivers tospecific ports. Normally this happens automatically; if the lp driveris loaded it will create one lp device for each port found. You canoverride this, though, by using parameters either when you load the lpdriver:

# insmod lp parport=0,2

or on the LILO command line:

lp=parport0 lp=parport2

Both the above examples would inform lp that you want/dev/lp0 to bethe first parallel port, and /dev/lp1 to be thethird parallel port,with no lp device associated with the second port (parport1). Notethat this is different to the way older kernels worked; there used tobe a static association between the I/O port address and the devicename, so/dev/lp0 was always the port at 0x3bc. This is no longer thecase - if you only have one port, it will default to being/dev/lp0,regardless of base address.

Also:

  • If you selected the IEEE 1284 support at compile time, you can saylp=auto on the kernel command line, and lp will create devicesonly for those ports that seem to have printers attached.
  • If you give PLIP thetimid parameter, either withplip=timid onthe command line, or withinsmodpliptimid=1 when using modules,it will avoid any ports that seem to be in use by other devices.
  • IRQ autoprobing works only for a few port types at the moment.

Reporting printer problems with parport

If you are having problems printing, please go through these steps totry to narrow down where the problem area is.

When reporting problems with parport, really you need to give all ofthe messages thatparport_pc spits out when it initialises. There areseveral code paths:

  • polling
  • interrupt-driven, protocol in software
  • interrupt-driven, protocol in hardware using PIO
  • interrupt-driven, protocol in hardware using DMA

The kernel messages thatparport_pc logs give an indication of whichcode path is being used. (They could be a lot better actually..)

For normal printer protocol, having IEEE 1284 modes enabled or notshould not make a difference.

To turn off the ‘protocol in hardware’ code paths, disableCONFIG_PARPORT_PC_FIFO. Note that when they are enabled they are notnecessarilyused; it depends on whether the hardware is available,enabled by the BIOS, and detected by the driver.

So, to start with, disableCONFIG_PARPORT_PC_FIFO, and loadparport_pcwithirq=none. See if printing works then. It really should,because this is the simplest code path.

If that works fine, try withio=0x378irq=7 (adjust for yourhardware), to make it use interrupt-driven in-software protocol.

Ifthat works fine, then one of the hardware modes isn’t workingright. EnableCONFIG_FIFO (no, it isn’t a module option,and yes, it should be), set the port to ECP mode in the BIOS and notethe DMA channel, and try with:

io=0x378 irq=7 dma=none (for PIO)io=0x378 irq=7 dma=3 (for DMA)

philb@gnu.orgtim@cyberelk.net