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