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