xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/parport.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunParport
2*4882a593Smuzhiyun+++++++
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunThe ``parport`` code provides parallel-port support under Linux.  This
5*4882a593Smuzhiyunincludes the ability to share one port between multiple device
6*4882a593Smuzhiyundrivers.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunYou can pass parameters to the ``parport`` code to override its automatic
9*4882a593Smuzhiyundetection of your hardware.  This is particularly useful if you want
10*4882a593Smuzhiyunto use IRQs, since in general these can't be autoprobed successfully.
11*4882a593SmuzhiyunBy default IRQs are not used even if they **can** be probed.  This is
12*4882a593Smuzhiyunbecause there are a lot of people using the same IRQ for their
13*4882a593Smuzhiyunparallel port and a sound card or network card.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunThe ``parport`` code is split into two parts: generic (which deals with
16*4882a593Smuzhiyunport-sharing) and architecture-dependent (which deals with actually
17*4882a593Smuzhiyunusing the port).
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunParport as modules
21*4882a593Smuzhiyun==================
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunIf you load the `parport`` code as a module, say::
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun	# insmod parport
26*4882a593Smuzhiyun
27*4882a593Smuzhiyunto load the generic ``parport`` code.  You then must load the
28*4882a593Smuzhiyunarchitecture-dependent code with (for example)::
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun	# insmod parport_pc io=0x3bc,0x378,0x278 irq=none,7,auto
31*4882a593Smuzhiyun
32*4882a593Smuzhiyunto tell the ``parport`` code that you want three PC-style ports, one at
33*4882a593Smuzhiyun0x3bc with no IRQ, one at 0x378 using IRQ 7, and one at 0x278 with an
34*4882a593Smuzhiyunauto-detected IRQ.  Currently, PC-style (``parport_pc``), Sun ``bpp``,
35*4882a593SmuzhiyunAmiga, Atari, and MFC3 hardware is supported.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunPCI parallel I/O card support comes from ``parport_pc``.  Base I/O
38*4882a593Smuzhiyunaddresses should not be specified for supported PCI cards since they
39*4882a593Smuzhiyunare automatically detected.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun
42*4882a593Smuzhiyunmodprobe
43*4882a593Smuzhiyun--------
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunIf you use modprobe , you will find it useful to add lines as below to a
46*4882a593Smuzhiyunconfiguration file in /etc/modprobe.d/ directory::
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun	alias parport_lowlevel parport_pc
49*4882a593Smuzhiyun	options parport_pc io=0x378,0x278 irq=7,auto
50*4882a593Smuzhiyun
51*4882a593Smuzhiyunmodprobe will load ``parport_pc`` (with the options ``io=0x378,0x278 irq=7,auto``)
52*4882a593Smuzhiyunwhenever a parallel port device driver (such as ``lp``) is loaded.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunNote that these are example lines only!  You shouldn't in general need
55*4882a593Smuzhiyunto specify any options to ``parport_pc`` in order to be able to use a
56*4882a593Smuzhiyunparallel port.
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunParport probe [optional]
60*4882a593Smuzhiyun------------------------
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunIn 2.2 kernels there was a module called ``parport_probe``, which was used
63*4882a593Smuzhiyunfor collecting IEEE 1284 device ID information.  This has now been
64*4882a593Smuzhiyunenhanced and now lives with the IEEE 1284 support.  When a parallel
65*4882a593Smuzhiyunport is detected, the devices that are connected to it are analysed,
66*4882a593Smuzhiyunand information is logged like this::
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun	parport0: Printer, BJC-210 (Canon)
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunThe probe information is available from files in ``/proc/sys/dev/parport/``.
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunParport linked into the kernel statically
74*4882a593Smuzhiyun=========================================
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunIf you compile the ``parport`` code into the kernel, then you can use
77*4882a593Smuzhiyunkernel boot parameters to get the same effect.  Add something like the
78*4882a593Smuzhiyunfollowing to your LILO command line::
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun	parport=0x3bc parport=0x378,7 parport=0x278,auto,nofifo
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunYou can have many ``parport=...`` statements, one for each port you want
83*4882a593Smuzhiyunto add.  Adding ``parport=0`` to the kernel command-line will disable
84*4882a593Smuzhiyunparport support entirely.  Adding ``parport=auto`` to the kernel
85*4882a593Smuzhiyuncommand-line will make ``parport`` use any IRQ lines or DMA channels that
86*4882a593Smuzhiyunit auto-detects.
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunFiles in /proc
90*4882a593Smuzhiyun==============
91*4882a593Smuzhiyun
92*4882a593SmuzhiyunIf you have configured the ``/proc`` filesystem into your kernel, you will
93*4882a593Smuzhiyunsee a new directory entry: ``/proc/sys/dev/parport``.  In there will be a
94*4882a593Smuzhiyundirectory entry for each parallel port for which parport is
95*4882a593Smuzhiyunconfigured.  In each of those directories are a collection of files
96*4882a593Smuzhiyundescribing that parallel port.
97*4882a593Smuzhiyun
98*4882a593SmuzhiyunThe ``/proc/sys/dev/parport`` directory tree looks like::
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun	parport
101*4882a593Smuzhiyun	|-- default
102*4882a593Smuzhiyun	|   |-- spintime
103*4882a593Smuzhiyun	|   `-- timeslice
104*4882a593Smuzhiyun	|-- parport0
105*4882a593Smuzhiyun	|   |-- autoprobe
106*4882a593Smuzhiyun	|   |-- autoprobe0
107*4882a593Smuzhiyun	|   |-- autoprobe1
108*4882a593Smuzhiyun	|   |-- autoprobe2
109*4882a593Smuzhiyun	|   |-- autoprobe3
110*4882a593Smuzhiyun	|   |-- devices
111*4882a593Smuzhiyun	|   |   |-- active
112*4882a593Smuzhiyun	|   |   `-- lp
113*4882a593Smuzhiyun	|   |       `-- timeslice
114*4882a593Smuzhiyun	|   |-- base-addr
115*4882a593Smuzhiyun	|   |-- irq
116*4882a593Smuzhiyun	|   |-- dma
117*4882a593Smuzhiyun	|   |-- modes
118*4882a593Smuzhiyun	|   `-- spintime
119*4882a593Smuzhiyun	`-- parport1
120*4882a593Smuzhiyun	|-- autoprobe
121*4882a593Smuzhiyun	|-- autoprobe0
122*4882a593Smuzhiyun	|-- autoprobe1
123*4882a593Smuzhiyun	|-- autoprobe2
124*4882a593Smuzhiyun	|-- autoprobe3
125*4882a593Smuzhiyun	|-- devices
126*4882a593Smuzhiyun	|   |-- active
127*4882a593Smuzhiyun	|   `-- ppa
128*4882a593Smuzhiyun	|       `-- timeslice
129*4882a593Smuzhiyun	|-- base-addr
130*4882a593Smuzhiyun	|-- irq
131*4882a593Smuzhiyun	|-- dma
132*4882a593Smuzhiyun	|-- modes
133*4882a593Smuzhiyun	`-- spintime
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun.. tabularcolumns:: |p{4.0cm}|p{13.5cm}|
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun=======================	=======================================================
138*4882a593SmuzhiyunFile			Contents
139*4882a593Smuzhiyun=======================	=======================================================
140*4882a593Smuzhiyun``devices/active``	A list of the device drivers using that port.  A "+"
141*4882a593Smuzhiyun			will appear by the name of the device currently using
142*4882a593Smuzhiyun			the port (it might not appear against any).  The
143*4882a593Smuzhiyun			string "none" means that there are no device drivers
144*4882a593Smuzhiyun			using that port.
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun``base-addr``		Parallel port's base address, or addresses if the port
147*4882a593Smuzhiyun			has more than one in which case they are separated
148*4882a593Smuzhiyun			with tabs.  These values might not have any sensible
149*4882a593Smuzhiyun			meaning for some ports.
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun``irq``			Parallel port's IRQ, or -1 if none is being used.
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun``dma``			Parallel port's DMA channel, or -1 if none is being
154*4882a593Smuzhiyun			used.
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun``modes``		Parallel port's hardware modes, comma-separated,
157*4882a593Smuzhiyun			meaning:
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun			- PCSPP
160*4882a593Smuzhiyun				PC-style SPP registers are available.
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun			- TRISTATE
163*4882a593Smuzhiyun				Port is bidirectional.
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun			- COMPAT
166*4882a593Smuzhiyun				Hardware acceleration for printers is
167*4882a593Smuzhiyun				available and will be used.
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun			- EPP
170*4882a593Smuzhiyun				Hardware acceleration for EPP protocol
171*4882a593Smuzhiyun				is available and will be used.
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun			- ECP
174*4882a593Smuzhiyun				Hardware acceleration for ECP protocol
175*4882a593Smuzhiyun				is available and will be used.
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun			- DMA
178*4882a593Smuzhiyun				DMA is available and will be used.
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun			Note that the current implementation will only take
181*4882a593Smuzhiyun			advantage of COMPAT and ECP modes if it has an IRQ
182*4882a593Smuzhiyun			line to use.
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun``autoprobe``		Any IEEE-1284 device ID information that has been
185*4882a593Smuzhiyun			acquired from the (non-IEEE 1284.3) device.
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun``autoprobe[0-3]``	IEEE 1284 device ID information retrieved from
188*4882a593Smuzhiyun			daisy-chain devices that conform to IEEE 1284.3.
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun``spintime``		The number of microseconds to busy-loop while waiting
191*4882a593Smuzhiyun			for the peripheral to respond.  You might find that
192*4882a593Smuzhiyun			adjusting this improves performance, depending on your
193*4882a593Smuzhiyun			peripherals.  This is a port-wide setting, i.e. it
194*4882a593Smuzhiyun			applies to all devices on a particular port.
195*4882a593Smuzhiyun
196*4882a593Smuzhiyun``timeslice``		The number of milliseconds that a device driver is
197*4882a593Smuzhiyun			allowed to keep a port claimed for.  This is advisory,
198*4882a593Smuzhiyun			and driver can ignore it if it must.
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun``default/*``		The defaults for spintime and timeslice. When a new
201*4882a593Smuzhiyun			port is	registered, it picks up the default spintime.
202*4882a593Smuzhiyun			When a new device is registered, it picks up the
203*4882a593Smuzhiyun			default timeslice.
204*4882a593Smuzhiyun=======================	=======================================================
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunDevice drivers
207*4882a593Smuzhiyun==============
208*4882a593Smuzhiyun
209*4882a593SmuzhiyunOnce the parport code is initialised, you can attach device drivers to
210*4882a593Smuzhiyunspecific ports.  Normally this happens automatically; if the lp driver
211*4882a593Smuzhiyunis loaded it will create one lp device for each port found.  You can
212*4882a593Smuzhiyunoverride this, though, by using parameters either when you load the lp
213*4882a593Smuzhiyundriver::
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun	# insmod lp parport=0,2
216*4882a593Smuzhiyun
217*4882a593Smuzhiyunor on the LILO command line::
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun	lp=parport0 lp=parport2
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunBoth the above examples would inform lp that you want ``/dev/lp0`` to be
222*4882a593Smuzhiyunthe first parallel port, and /dev/lp1 to be the **third** parallel port,
223*4882a593Smuzhiyunwith no lp device associated with the second port (parport1).  Note
224*4882a593Smuzhiyunthat this is different to the way older kernels worked; there used to
225*4882a593Smuzhiyunbe a static association between the I/O port address and the device
226*4882a593Smuzhiyunname, so ``/dev/lp0`` was always the port at 0x3bc.  This is no longer the
227*4882a593Smuzhiyuncase - if you only have one port, it will default to being ``/dev/lp0``,
228*4882a593Smuzhiyunregardless of base address.
229*4882a593Smuzhiyun
230*4882a593SmuzhiyunAlso:
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun * If you selected the IEEE 1284 support at compile time, you can say
233*4882a593Smuzhiyun   ``lp=auto`` on the kernel command line, and lp will create devices
234*4882a593Smuzhiyun   only for those ports that seem to have printers attached.
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun * If you give PLIP the ``timid`` parameter, either with ``plip=timid`` on
237*4882a593Smuzhiyun   the command line, or with ``insmod plip timid=1`` when using modules,
238*4882a593Smuzhiyun   it will avoid any ports that seem to be in use by other devices.
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun * IRQ autoprobing works only for a few port types at the moment.
241*4882a593Smuzhiyun
242*4882a593SmuzhiyunReporting printer problems with parport
243*4882a593Smuzhiyun=======================================
244*4882a593Smuzhiyun
245*4882a593SmuzhiyunIf you are having problems printing, please go through these steps to
246*4882a593Smuzhiyuntry to narrow down where the problem area is.
247*4882a593Smuzhiyun
248*4882a593SmuzhiyunWhen reporting problems with parport, really you need to give all of
249*4882a593Smuzhiyunthe messages that ``parport_pc`` spits out when it initialises.  There are
250*4882a593Smuzhiyunseveral code paths:
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun- polling
253*4882a593Smuzhiyun- interrupt-driven, protocol in software
254*4882a593Smuzhiyun- interrupt-driven, protocol in hardware using PIO
255*4882a593Smuzhiyun- interrupt-driven, protocol in hardware using DMA
256*4882a593Smuzhiyun
257*4882a593SmuzhiyunThe kernel messages that ``parport_pc`` logs give an indication of which
258*4882a593Smuzhiyuncode path is being used. (They could be a lot better actually..)
259*4882a593Smuzhiyun
260*4882a593SmuzhiyunFor normal printer protocol, having IEEE 1284 modes enabled or not
261*4882a593Smuzhiyunshould not make a difference.
262*4882a593Smuzhiyun
263*4882a593SmuzhiyunTo turn off the 'protocol in hardware' code paths, disable
264*4882a593Smuzhiyun``CONFIG_PARPORT_PC_FIFO``.  Note that when they are enabled they are not
265*4882a593Smuzhiyunnecessarily **used**; it depends on whether the hardware is available,
266*4882a593Smuzhiyunenabled by the BIOS, and detected by the driver.
267*4882a593Smuzhiyun
268*4882a593SmuzhiyunSo, to start with, disable ``CONFIG_PARPORT_PC_FIFO``, and load ``parport_pc``
269*4882a593Smuzhiyunwith ``irq=none``. See if printing works then.  It really should,
270*4882a593Smuzhiyunbecause this is the simplest code path.
271*4882a593Smuzhiyun
272*4882a593SmuzhiyunIf that works fine, try with ``io=0x378 irq=7`` (adjust for your
273*4882a593Smuzhiyunhardware), to make it use interrupt-driven in-software protocol.
274*4882a593Smuzhiyun
275*4882a593SmuzhiyunIf **that** works fine, then one of the hardware modes isn't working
276*4882a593Smuzhiyunright.  Enable ``CONFIG_FIFO`` (no, it isn't a module option,
277*4882a593Smuzhiyunand yes, it should be), set the port to ECP mode in the BIOS and note
278*4882a593Smuzhiyunthe DMA channel, and try with::
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun    io=0x378 irq=7 dma=none (for PIO)
281*4882a593Smuzhiyun    io=0x378 irq=7 dma=3 (for DMA)
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun----------
284*4882a593Smuzhiyun
285*4882a593Smuzhiyunphilb@gnu.org
286*4882a593Smuzhiyuntim@cyberelk.net
287