2 # Copyright (c) 2003 Marcel Moolenaar
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/param.h>
29 #include <sys/systm.h>
31 #include <sys/mutex.h>
33 #include <machine/bus.h>
34 #include <dev/uart/uart.h>
35 #include <dev/uart/uart_bus.h>
37 # The UART hardware interface. The core UART code is hardware independent.
38 # The details of the hardware are abstracted by the UART hardware interface.
42 # attach() - attach hardware.
43 # This method is called when the device is being attached. All resources
44 # have been allocated. The transmit and receive buffers exist, but no
45 # high-level (ie tty) initialization has been done yet.
46 # The intend of this method is to setup the hardware for normal operation.
48 struct uart_softc *this;
51 # detach() - detach hardware.
52 # This method is called when a device is being detached from its bus. It
53 # is the first action performed, so even the high-level (ie tty) interface
54 # is still operational.
55 # The intend of this method is to disable the hardware.
57 struct uart_softc *this;
60 # flush() - flush FIFOs.
61 # This method is called to flush the transmitter and/or the receiver as
62 # specified by the what argument. Characters are expected to be lost.
64 struct uart_softc *this;
68 # getsig() - get line and modem signals.
69 # This method retrieves the DTE and DCE signals and their corresponding
70 # delta bits. The delta bits include those corresponding to DTE signals
71 # when they were changed by a call to setsig. The delta bits maintained
72 # by the hardware driver are cleared as a side-effect. A second call to
73 # this function will not have any delta bits set, unless there was a
74 # change in the signals in the mean time.
76 struct uart_softc *this;
79 # ioctl() - get or set miscellaneous parameters.
80 # This method is the bitbucket method. It can (and will) be used when there's
81 # something we need to set or get for which a new method is overkill. It's
82 # used for example to set HW or SW flow-control.
84 struct uart_softc *this;
89 # ipend() - query UART for pending interrupts.
90 # When an interrupt is signalled, the handler will call this method to find
91 # out which of the interrupt sources needs attention. The handler will use
92 # this information to dispatch service routines that deal with each of the
93 # interrupt sources. An advantage of this approach is that it allows multi-
94 # port drivers (like puc(4)) to query multiple devices concurrently and
95 # service them on an interrupt priority basis. If the hardware cannot provide
96 # the information reliably, it is free to service the interrupt and return 0,
97 # meaning that no attention is required.
99 struct uart_softc *this;
102 # param() - set communication parameters.
103 # This method is called to change the communication parameters.
105 struct uart_softc *this;
112 # probe() - detect hardware.
113 # This method is called as part of the bus probe to make sure the
114 # hardware exists. This function should also set the device description
115 # to something that represents the hardware.
117 struct uart_softc *this;
120 # receive() - move data from the receive FIFO to the receive buffer.
121 # This method is called to move received data to the receive buffer and
122 # additionally should make sure the receive interrupt should be cleared.
124 struct uart_softc *this;
127 # setsig() - set line and modem signals.
128 # This method allows changing DTE signals. The DTE delta bits indicate which
129 # signals are to be changed and the DTE bits themselves indicate whether to
130 # set or clear the signals. A subsequent call to getsig will return with the
131 # DTE delta bits set of those DTE signals that did change by this method.
133 struct uart_softc *this;
137 # transmit() - move data from the transmit buffer to the transmit FIFO.
138 # This method is responsible for writing the Tx buffer to the UART and
139 # additionally should make sure that a transmit interrupt is generated
140 # when transmission is complete.
141 METHOD int transmit {
142 struct uart_softc *this;