xref: /freebsd/share/man/man4/ppbus.4 (revision 2b8331622f0b212cf3bb4fc4914a501e5321d506)
1.\" Copyright (c) 1998, 1999 Nicolas Souchu
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd March 1, 1998
28.Dt PPBUS 4
29.Os
30.Sh NAME
31.Nm ppbus
32.Nd Parallel Port Bus system
33.Sh SYNOPSIS
34.Cd "device ppbus"
35.Pp
36.Cd "device lpt"
37.Cd "device plip"
38.Cd "device ppi"
39.Cd "device pps"
40.Cd "device lpbb"
41.Sh DESCRIPTION
42The
43.Em ppbus
44system provides a uniform, modular and architecture-independent
45system for the implementation of drivers to control various parallel devices,
46and to utilize different parallel port chipsets.
47.Sh DEVICE DRIVERS
48In order to write new drivers or port existing drivers, the ppbus system
49provides the following facilities:
50.Bl -bullet -offset indent
51.It
52architecture-independent macros or functions to access parallel ports
53.It
54mechanism to allow various devices to share the same parallel port
55.It
56a user interface named
57.Xr ppi 4
58that allows parallel port access from outside the kernel without conflicting
59with kernel-in drivers.
60.El
61.Ss Developing new drivers
62The ppbus system has been designed to support the development of standard
63and non-standard software:
64.Pp
65.Bl -column "Driver" -compact
66.It Em Driver Ta Em Description
67.It Sy ppi Ta "Parallel port interface for general I/O"
68.It Sy pps Ta "Pulse per second Timing Interface"
69.It Sy lpbb Ta "Philips official parallel port I2C bit-banging interface"
70.El
71.Ss Porting existing drivers
72Another approach to the ppbus system is to port existing drivers.
73Various drivers have already been ported:
74.Pp
75.Bl -column "Driver" -compact
76.It Em Driver Ta Em Description
77.It Sy lpt Ta "lpt printer driver"
78.It Sy plip Ta "lp parallel network interface driver"
79.El
80.Pp
81ppbus should let you port any other software even from other operating systems
82that provide similar services.
83.Sh PARALLEL PORT CHIPSETS
84Parallel port chipset support is provided by
85.Xr ppc 4 .
86.Pp
87The ppbus system provides functions and macros to allocate a new
88parallel port bus, then initialize it and upper peripheral device drivers.
89.Pp
90ppc makes chipset detection and initialization and then calls ppbus attach
91functions to initialize the ppbus system.
92.Sh PARALLEL PORT MODEL
93The logical parallel port model chosen for the ppbus system is the PC's
94parallel port model.
95Consequently, for the i386 implementation of ppbus,
96most of the services provided by ppc are macros for inb()
97and outb() calls.
98But, for another architecture, accesses to one of our logical
99registers (data, status, control...) may require more than one I/O access.
100.Ss Description
101The parallel port may operate in the following modes:
102.Bl -bullet -offset indent
103.It
104compatible mode, also called Centronics mode
105.It
106bidirectional 8/4-bits mode, also called NIBBLE mode
107.It
108byte mode, also called PS/2 mode
109.It
110Extended Capability Port mode, ECP
111.It
112Enhanced Parallel Port mode, EPP
113.It
114mixed ECP+EPP or ECP+PS/2 modes
115.El
116.Ss Compatible mode
117This mode defines the protocol used by most PCs to transfer data to a printer.
118In this mode, data is placed on the port's data lines, the printer status is
119checked for no errors and that it is not busy, and then a data Strobe is
120generated by the software to clock the data to the printer.
121.Pp
122Many I/O controllers have implemented a mode that uses a FIFO buffer to
123transfer data with the Compatibility mode protocol.
124This mode is referred to as
125"Fast Centronics" or "Parallel Port FIFO mode".
126.Ss Bidirectional mode
127The NIBBLE mode is the most common way to get reverse channel data from a
128printer or peripheral.
129Combined with the standard host to printer mode, it
130provides a complete bidirectional channel.
131.Pp
132In this mode, outputs are 8-bits long.
133Inputs are accomplished by reading
1344 of the 8 bits of the status register.
135.Ss Byte mode
136In this mode, the data register is used either for outputs and inputs.
137Then,
138any transfer is 8-bits long.
139.Ss Extended Capability Port mode
140The ECP protocol was proposed as an advanced mode for communication with
141printer and scanner type peripherals.
142Like the EPP protocol, ECP mode provides
143for a high performance bidirectional communication path between the host
144adapter and the peripheral.
145.Pp
146ECP protocol features include:
147.Bl -item -offset indent
148.It
149Run_Length_Encoding (RLE) data compression for host adapters
150.It
151FIFOs for both the forward and reverse channels
152.It
153DMA as well as programmed I/O for the host register interface.
154.El
155.Ss Enhanced Parallel Port mode
156The EPP protocol was originally developed as a means to provide a high
157performance parallel port link that would still be compatible with the
158standard parallel port.
159.Pp
160The EPP mode has two types of cycle: address and data.
161What makes the
162difference at hardware level is the strobe of the byte placed on the data
163lines.
164Data are strobed with nAutofeed, addresses are strobed with
165nSelectin signals.
166.Pp
167A particularity of the ISA implementation of the EPP protocol is that an
168EPP cycle fits in an ISA cycle.
169In this fashion, parallel port peripherals can
170operate at close to the same performance levels as an equivalent ISA plug-in
171card.
172.Pp
173At software level, you may implement the protocol you wish, using data and
174address cycles as you want.
175This is for the IEEE1284 compatible part.
176Then,
177peripheral vendors may implement protocol handshake with the following
178status lines: PError, nFault and Select.
179Try to know how these lines toggle
180with your peripheral, allowing the peripheral to request more data, stop the
181transfer and so on.
182.Pp
183At any time, the peripheral may interrupt the host with the nAck signal without
184disturbing the current transfer.
185.Ss Mixed modes
186Some manufacturers, like SMC, have implemented chipsets that support mixed
187modes.
188With such chipsets, mode switching is available at any time by
189accessing the extended control register.
190.Sh IEEE1284-1994 Standard
191.Ss Background
192This standard is also named "IEEE Standard Signaling Method for a
193Bidirectional Parallel Peripheral Interface for Personal Computers".
194It
195defines a signaling method for asynchronous, fully interlocked, bidirectional
196parallel communications between hosts and printers or other peripherals.
197It
198also specifies a format for a peripheral identification string and a method of
199returning this string to the host outside of the bidirectional data stream.
200.Pp
201This standard is architecture independent and only specifies dialog handshake
202at signal level.
203One should refer to architecture specific documentation in
204order to manipulate machine dependent registers, mapped memory or other
205methods to control these signals.
206.Pp
207The IEEE1284 protocol is fully oriented with all supported parallel port
208modes.
209The computer acts as master and the peripheral as slave.
210.Pp
211Any transfer is defined as a finite state automaton.
212It allows software to
213properly manage the fully interlocked scheme of the signaling method.
214The compatible mode is supported "as is" without any negotiation because it
215is compatible.
216Any other mode must be firstly negotiated by the host to check
217it is supported by the peripheral, then to enter one of the forward idle
218states.
219.Pp
220At any time, the slave may want to send data to the host.
221This is only
222possible from forward idle states (nibble, byte, ecp...).
223So, the
224host must have previously negotiated to permit the peripheral to
225request transfer.
226Interrupt lines may be dedicated to the requesting signals
227to prevent time consuming polling methods.
228.Pp
229But peripheral requests are only a hint to the master host.
230If the host
231accepts the transfer, it must firstly negotiate the reverse mode and then
232starts the transfer.
233At any time during reverse transfer, the host may
234terminate the transfer or the slave may drive wires to signal that no more
235data is available.
236.Ss Implementation
237IEEE1284 Standard support has been implemented at the top of the ppbus system
238as a set of procedures that perform high level functions like negotiation,
239termination, transfer in any mode without bothering you with low level
240characteristics of the standard.
241.Pp
242IEEE1284 interacts with the ppbus system as little as possible.
243That means
244you still have to request the ppbus when you want to access it, the negotiate
245function does not do it for you.
246And of course, release it later.
247.Sh ARCHITECTURE
248.Ss adapter, ppbus and device layers
249First, there is the
250.Em adapter
251layer, the lowest of the ppbus system.
252It provides
253chipset abstraction throw a set of low level functions that maps the logical
254model to the underlying hardware.
255.Pp
256Secondly, there is the
257.Em ppbus
258layer that provides functions to:
259.Bl -enum -offset indent
260.It
261share the parallel port bus among the daisy-chain like connected devices
262.It
263manage devices linked to ppbus
264.It
265propose an arch-independent interface to access the hardware layer.
266.El
267.Pp
268Finally, the
269.Em device
270layer gathers the parallel peripheral device drivers.
271.Ss Parallel modes management
272We have to differentiate operating modes at various ppbus system layers.
273Actually, ppbus and adapter operating modes on one hands and for each
274one, current and available modes are separated.
275.Pp
276With this level of abstraction a particular chipset may commute from any
277native mode to any other mode emulated with extended modes without
278disturbing upper layers.
279For example, most chipsets support NIBBLE mode as
280native and emulated with ECP and/or EPP.
281.Pp
282This architecture should support IEEE1284-1994 modes.
283.Sh FEATURES
284.Ss The boot process
285The boot process starts with the probe stage of the
286.Xr ppc 4
287driver during ISA bus (PC architecture) initialization.
288During attachment of
289the ppc driver, a new ppbus structure is allocated, then probe and attachment
290for this new bus node are called.
291.Pp
292ppbus attachment tries to detect any PnP parallel peripheral (according to
293.%T "Plug and Play Parallel Port Devices"
294draft from (c)1993-4 Microsoft Corporation)
295then probes and attaches known device drivers.
296.Pp
297During probe, device drivers are supposed to request the ppbus and try to
298set their operating mode.
299This mode will be saved in the context structure and
300returned each time the driver requests the ppbus.
301.Ss Bus allocation and interrupts
302ppbus allocation is mandatory not to corrupt I/O of other devices.
303Another
304usage of ppbus allocation is to reserve the port and receive incoming
305interrupts.
306.Pp
307High level interrupt handlers are connected to the ppbus system thanks to the
308newbus
309.Fn BUS_SETUP_INTR
310and
311.Fn BUS_TEARDOWN_INTR
312functions.
313But, in order to attach a handler, drivers must
314own the bus.
315Consequently, a ppbus request is mandatory in order to call the above
316functions (see existing drivers for more info).
317Note that the interrupt handler
318is automatically released when the ppbus is released.
319.Ss Microsequences
320.Em Microsequences
321is a general purpose mechanism to allow fast low-level
322manipulation of the parallel port.
323Microsequences may be used to do either
324standard (in IEEE1284 modes) or non-standard transfers.
325The philosophy of
326microsequences is to avoid the overhead of the ppbus layer and do most of
327the job at adapter level.
328.Pp
329A microsequence is an array of opcodes and parameters.
330Each opcode codes an
331operation (opcodes are described in
332.Xr microseq 9 ) .
333Standard I/O operations are implemented at ppbus level whereas basic I/O
334operations and microseq language are coded at adapter level for efficiency.
335.Sh SEE ALSO
336.Xr lpt 4 ,
337.Xr plip 4 ,
338.Xr ppc 4 ,
339.Xr ppi 4
340.Sh HISTORY
341The
342.Nm
343manual page first appeared in
344.Fx 3.0 .
345.Sh AUTHORS
346This
347manual page was written by
348.An Nicolas Souchu .
349