xref: /netbsd-src/share/man/man4/ppbus.4 (revision f26c80959a4e1ab9f59442117d13e2badd98b280)
1.\" $NetBSD: ppbus.4,v 1.15 2009/08/19 23:17:25 wiz Exp $
2.\"
3.\" Copyright (c) 1998, 1999 Nicolas Souchu
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/share/man/man4/ppbus.4,v 1.14.2.5 2001/08/17 13:08:39 ru Exp $
28.\"
29.Dd August 19, 2009
30.Dt PPBUS 4
31.Os
32.Sh NAME
33.Nm ppbus
34.Nd Parallel Port Bus system with GPIO
35.Sh SYNOPSIS
36.Cd "ppbus* at atppc?"
37.Cd "options PPBUS_VERBOSE"
38.Cd "options PPBUS_DEBUG"
39.Cd "options DEBUG_1284"
40.Pp
41.Cd "gpio* at ppbus?"
42.Cd "lpt* at ppbus?"
43.Cd "plip* at ppbus?"
44.Cd "pps* at ppbus?"
45.\" Cd "lpbb* at ppbus?"
46.\" Cd "vpo* at ppbus?"
47.Sh DESCRIPTION
48The
49.Nm
50system provides a uniform, modular, and architecture-independent
51system for the implementation of drivers to control various parallel
52devices, and to use different parallel port chip sets.
53.Sh DEVICE DRIVERS
54In order to write new drivers or port existing drivers, the
55.Nm
56system provides the following facilities:
57.Bl -bullet -offset indent
58.It
59architecture-independent macros or functions to access parallel ports
60.It
61mechanism to allow various devices to share the same parallel port
62.It
63a
64.Xr gpio 4
65interface to access the individual pins
66.It
67a user interface named
68.Xr ppi 4
69that allows parallel port access from outside the kernel without
70conflicting with kernel-in drivers.
71.El
72.Ss Developing new drivers
73The
74.Nm
75system has been designed to support the development of standard
76and non-standard software:
77.Pp
78.Bl -column "Driver" -compact
79.It Em Driver Ta Em Description
80.\" It Sy vpo Ta "VPI0 parallel to Adaptec AIC-7110 SCSI controller driver" .
81It uses standard and non-standard parallel port accesses.
82.It Sy ppi Ta "Parallel port interface for general I/O"
83.It Sy pps Ta "Pulse per second Timing Interface"
84.\" It Sy lpbb Ta "Philips official parallel port I2C bit-banging interface"
85.El
86.Ss Porting existing drivers
87Another approach to the
88.Nm
89system is to port existing drivers.
90Various drivers have already been ported:
91.Pp
92.Bl -column "Driver" -compact
93.It Em Driver Ta Em Description
94.It Sy lpt Ta "lpt printer driver"
95.It Sy lp Ta "plip network interface driver"
96.El
97.Pp
98.Nm
99should let you port any other software even from other operating
100systems that provide similar services.
101.Sh PARALLEL PORT CHIP SETS
102Parallel port chip set support is provided by
103.Xr atppc 4 .
104.Pp
105The
106.Nm
107system provides functions and macros to request service from the
108.Nm
109including reads, writes, setting of parameters, and bus requests/releases.
110.Pp
111.Xr atppc 4
112detects chip set and capabilities and sets up interrupt handling.
113It makes
114methods available for use to the
115.Nm
116system.
117.Sh PARALLEL PORT MODEL
118The logical parallel port model chosen for the
119.Nm
120system is the AT
121parallel port model.
122Consequently, for the
123.Em atppc
124implementation of
125.Nm ,
126most of the services provided by
127.Nm
128will
129translate into I/O instructions on actual registers.
130However, other parallel port implementations may require more than
131one I/O instruction to do a single logical register operation on
132data, status and control virtual registers.
133.Ss Description
134The parallel port may operate in the following modes:
135.Bl -bullet -offset indent
136.It
137Compatible (Centronics -- the standard parallel port mode) mode,
138output byte
139.It
140Nibble mode, input 4-bits
141.It
142Byte (PS/2) mode, input byte
143.It
144Extended Capability Port (ECP) mode, bidirectional byte
145.It
146Enhanced Parallel Port (EPP) mode, bidirectional byte
147.El
148.Ss Compatible mode
149This mode defines the protocol used by most PCs to transfer data
150to a printer.
151In this mode, data is placed on the port's data lines, the printer
152status is checked for no errors and that it is not busy, and then
153a data Strobe is generated by the software to clock the data to
154the printer.
155.Pp
156Many I/O controllers have implemented a mode that uses a FIFO buffer
157to transfer data with the Compatibility mode protocol.
158This mode is referred to as
159.Dq Fast Centronics
160or
161.Dq Parallel Port FIFO mode .
162.Ss Nibble mode
163The Nibble mode is the most common way to get reverse channel data
164from a printer or peripheral.
165When combined with the standard host to printer mode, a bidirectional
166data channel is created.
167Inputs are accomplished by reading 4 of the 8 bits of the status
168register.
169.Ss Byte mode
170In this mode, the data register is used either for outputs and inputs.
171All transfers are 8-bits long.
172Channel direction must be negotiated when doing
173.Tn IEEE 1248
174compliant operations.
175.Ss Extended Capability Port mode
176The ECP protocol was proposed as an advanced mode for communication
177with printer and scanner type peripherals.
178Like the EPP protocol, ECP mode provides for a high performance
179bidirectional communication path between the host adapter and the
180peripheral.
181.Pp
182ECP protocol features include:
183.Bl -item -offset indent
184.It
185Run_Length_Encoding (RLE) data compression for host adapters (not
186supported in these drivers)
187.It
188FIFO's for both the forward and reverse channels
189.It
190DMA or programmed I/O for the host register interface.
191.El
192.Ss Enhanced Parallel Port mode
193The EPP protocol was originally developed as a means to provide a
194high performance parallel port link that would still be compatible
195with the standard parallel port.
196.Pp
197The EPP mode has two types of cycle: address and data.
198What makes the difference at hardware level is the strobe of the
199byte placed on the data lines.
200Data are strobed with nAutofeed, addresses are strobed with nSelectin
201signals.
202.Pp
203A particularity of the ISA implementation of the EPP protocol is
204that an EPP cycle fits in an ISA cycle.
205In this fashion, parallel port peripherals can operate at close to
206the same performance levels as an equivalent ISA plug-in card.
207.Pp
208At software level, you may implement the protocol you wish, using
209data and address cycles as you want.
210This is for the
211.Tn IEEE 1284
212compatible part.
213Peripheral vendors may implement protocol handshake with the
214following status lines: PError, nFault and Select.
215Try to know how these lines toggle with your peripheral, allowing
216the peripheral to request more data, stop the transfer and so on.
217.Pp
218At any time, the peripheral may interrupt the host with the nAck
219signal without disturbing the current transfer.
220.Ss Mixed modes
221Some manufacturers, like SMC, have implemented chip sets that
222support mixed modes.
223With such chip sets, mode switching is available at any time by
224accessing the extended control register.
225All ECP-capable chip sets can switch between standard, byte, fast
226centronics, and ECP modes.
227Some ECP chip sets also support switching to EPP mode.
228.Sh IEEE 1284 1994 Standard
229.Ss Background
230This standard is also named
231.Do
232IEEE Standard Signaling Method for a Bidirectional Parallel Peripheral
233Interface for Personal Computers
234.Dc .
235It defines a signaling method for asynchronous, fully interlocked,
236bidirectional parallel communications between hosts and printers
237or other peripherals.
238It also specifies a format for a peripheral identification string
239and a method of returning this string to the host.
240.Pp
241This standard is architecture independent and only specifies dialog
242handshake at signal level.
243One should refer to architecture specific documentation in order
244to manipulate machine dependent registers, mapped memory or other
245methods to control these signals.
246.Pp
247The
248.Tn IEEE 1284
249protocol is fully oriented with all supported parallel port modes.
250The computer acts as master and the peripheral as slave.
251.Pp
252Any transfer is defined as a finite state automate.
253It allows software to properly manage the fully interlocked scheme
254of the signaling method.
255The compatible mode is supported
256.Dq as is
257without any negotiation because it is the default, backward-compatible
258transfer mode.
259Any other mode must be firstly negotiated by the host to check it
260is supported by the peripheral, then to enter one of the forward
261idle states.
262.Pp
263At any time, the slave may want to send data to the host.
264The host must negotiate to permit the peripheral to complete the
265transfer.
266Interrupt lines may be dedicated to the requesting signals
267to prevent time consuming polling methods.
268.Pp
269If the host accepts the transfer, it must firstly negotiate the
270reverse mode and then start the transfer.
271At any time during reverse transfer, the host may terminate the
272transfer or the slave may drive wires to signal that no more data
273is available.
274.Ss Implementation
275.Tn IEEE 1284 Standard
276support has been implemented at the top of the
277.Nm
278system as a set of procedures that perform high level functions
279like negotiation, termination, transfer in any mode without bothering
280you with low level characteristics of the standard.
281.Pp
282.Tn IEEE 1284
283interacts with the
284.Nm
285system as little as possible.
286That means you still have to request the
287.Nm
288when you want to access it, and of course, release it when finished.
289.Sh ARCHITECTURE
290.Ss Chip set, ppbus and device layers
291First, there is the
292.Em chip set
293layer, the lowest of the
294.Nm
295system.
296It provides chip set abstraction through a set of low level functions
297that maps the logical model to the underlying hardware.
298.Pp
299Secondly, there is the
300.Em ppbus
301layer that provides functions to:
302.Bl -enum -offset indent
303.It
304share the parallel port bus among the daisy-chain like connected
305devices
306.It
307manage devices linked to
308.Nm
309.It
310propose an arch-independent interface to access the hardware layer.
311.El
312.Pp
313Finally, the
314.Em device
315layer represents the traditional device drivers such as
316.Xr lpt 4
317which now use an abstraction instead of real hardware.
318.Ss Parallel port mode management
319Operating modes are differentiated at various
320.Nm
321system layers.
322There is a difference between a
323.Em capability
324and a
325.Em mode .
326A chip set may have a combination of capabilities, but at any one
327time the
328.Nm
329system operates in a single mode.
330.Pp
331Nibble mode is a
332.Em virtual
333mode: the actual chip set would be in standard mode and the driver
334would change its behavior to drive the right lines on the parallel
335port.
336.Pp
337Each child device of
338.Nm
339must set its operating mode and other parameters whenever it requests
340and gets access to its parent
341.Nm .
342.Sh FEATURES
343.Ss The boot process
344.Nm
345attachment tries to detect any PnP parallel peripheral (according to
346.%T "Plug and Play Parallel Port Devices" draft from (c)1993-4
347.Tn Microsoft Corporation )
348then probes and attaches known device drivers.
349.Pp
350During probe, device drivers should request the
351.Nm
352and try to determine if the right capabilities are present in the
353system.
354.Ss Bus request and interrupts
355.Nm
356reservation via a bus request is mandatory not to corrupt I/O of
357other devices.
358For example, when the
359.Xr lpt 4
360device is opened, the bus will be
361.Dq allocated
362to the device driver and attempts to reserve the bus for another
363device will fail until the
364.Xr lpt 4
365driver releases the bus.
366.Pp
367Child devices can also register interrupt handlers to be called
368when a hardware interrupt occurs.
369In order to attach a handler, drivers must own the bus.
370Drivers should have interrupt handlers that check to see if the
371device still owns the bus when they are called and/or ensure that
372these handlers are removed whenever the device does not own the
373bus.
374.Ss Micro-sequences
375.Em Micro-sequences
376are a general purpose mechanism to allow fast low-level manipulation
377of the parallel port.
378Micro-sequences may be used to do either standard (in
379.Tn IEEE 1284
380modes) or non-standard transfers.
381The philosophy of micro-sequences is to avoid the overhead of the
382.Nm
383layer for a sequence of operations and do most of the job at the
384chip set level.
385.Pp
386A micro-sequence is an array of opcodes and parameters.
387Each opcode codes an operation (opcodes are described in
388.Xr microseq 9 ) .
389Standard I/O operations are implemented at ppbus level whereas
390basic I/O operations and microseq language are coded at adapter
391level for efficiency.
392.\" .Pp
393.\" As an example, the
394.\" .Xr vpo 4
395.\" driver uses micro-sequences to implement:
396.\" .Bl -bullet -offset indent
397.\" .It
398.\" a modified version of the Nibble transfer mode
399.\" .It
400.\" various I/O sequences to initialize, select and allocate the
401.\" peripheral
402.\" .El
403.Ss GPIO interface
404Pins 1 through 17 of the parallel port can be controlled through the
405.Xr gpio 4
406interface, pins 18 through 25 are hardwired to ground.
407Pins 10 through 13 and pin 15 are input pins, the others are output
408pins.
409Some of the pins are inverted by the hardware, the values read or
410written are adjusted accordingly.
411Note that the
412.Xr gpio 4
413interface starts at 0 when numbering pins.
414.Sh SEE ALSO
415.Xr atppc 4 ,
416.Xr gpio 4 ,
417.Xr lpt 4 ,
418.Xr plip 4 ,
419.Xr ppi 4 ,
420.\" Xr vpo 4 ,
421.Xr microseq 9
422.Sh HISTORY
423The
424.Nm
425system first appeared in
426.Fx 3.0 .
427.Sh AUTHORS
428This manual page is based on the
429.Fx
430.Nm ppbus
431manual page.
432The information has been updated for the
433.Nx
434port by Gary Thorpe.
435.Sh BUGS
436The
437.Nm
438framework is still experimental and not enabled by default yet.
439