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