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