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