ubsa.c revision 1.2.2.3 1 1.2.2.3 nathanw /* $NetBSD: ubsa.c,v 1.2.2.3 2002/11/11 22:12:50 nathanw Exp $ */
2 1.2.2.2 nathanw /*-
3 1.2.2.2 nathanw * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
4 1.2.2.2 nathanw * All rights reserved.
5 1.2.2.2 nathanw *
6 1.2.2.2 nathanw * Redistribution and use in source and binary forms, with or without
7 1.2.2.2 nathanw * modification, are permitted provided that the following conditions
8 1.2.2.2 nathanw * are met:
9 1.2.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
10 1.2.2.2 nathanw * notice, this list of conditions and the following disclaimer.
11 1.2.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
12 1.2.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
13 1.2.2.2 nathanw * documentation and/or other materials provided with the distribution.
14 1.2.2.2 nathanw *
15 1.2.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.2.2.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.2.2.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.2.2.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.2.2.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.2.2.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.2.2.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.2.2.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.2.2.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.2.2.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.2.2.2 nathanw * SUCH DAMAGE.
26 1.2.2.2 nathanw */
27 1.2.2.2 nathanw /*
28 1.2.2.2 nathanw * Copyright (c) 2001 The NetBSD Foundation, Inc.
29 1.2.2.2 nathanw * All rights reserved.
30 1.2.2.2 nathanw *
31 1.2.2.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
32 1.2.2.2 nathanw * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
33 1.2.2.2 nathanw *
34 1.2.2.2 nathanw * Redistribution and use in source and binary forms, with or without
35 1.2.2.2 nathanw * modification, are permitted provided that the following conditions
36 1.2.2.2 nathanw * are met:
37 1.2.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
38 1.2.2.2 nathanw * notice, this list of conditions and the following disclaimer.
39 1.2.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
40 1.2.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
41 1.2.2.2 nathanw * documentation and/or other materials provided with the distribution.
42 1.2.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
43 1.2.2.2 nathanw * must display the following acknowledgement:
44 1.2.2.2 nathanw * This product includes software developed by the NetBSD
45 1.2.2.2 nathanw * Foundation, Inc. and its contributors.
46 1.2.2.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
47 1.2.2.2 nathanw * contributors may be used to endorse or promote products derived
48 1.2.2.2 nathanw * from this software without specific prior written permission.
49 1.2.2.2 nathanw *
50 1.2.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
51 1.2.2.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52 1.2.2.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 1.2.2.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
54 1.2.2.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55 1.2.2.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56 1.2.2.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 1.2.2.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 1.2.2.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 1.2.2.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60 1.2.2.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
61 1.2.2.2 nathanw */
62 1.2.2.2 nathanw
63 1.2.2.2 nathanw #include <sys/cdefs.h>
64 1.2.2.2 nathanw
65 1.2.2.2 nathanw #include <sys/param.h>
66 1.2.2.2 nathanw #include <sys/systm.h>
67 1.2.2.2 nathanw #include <sys/kernel.h>
68 1.2.2.2 nathanw #include <sys/malloc.h>
69 1.2.2.2 nathanw #ifdef __FreeBSD__
70 1.2.2.2 nathanw #include <sys/bus.h>
71 1.2.2.2 nathanw #endif
72 1.2.2.2 nathanw #include <sys/ioccom.h>
73 1.2.2.2 nathanw #include <sys/fcntl.h>
74 1.2.2.2 nathanw #include <sys/conf.h>
75 1.2.2.2 nathanw #include <sys/tty.h>
76 1.2.2.2 nathanw #include <sys/file.h>
77 1.2.2.2 nathanw #if __FreeBSD_version >= 500014
78 1.2.2.2 nathanw #include <sys/selinfo.h>
79 1.2.2.2 nathanw #else
80 1.2.2.2 nathanw #include <sys/select.h>
81 1.2.2.2 nathanw #endif
82 1.2.2.2 nathanw #include <sys/proc.h>
83 1.2.2.2 nathanw #include <sys/vnode.h>
84 1.2.2.2 nathanw #include <sys/poll.h>
85 1.2.2.2 nathanw #include <sys/sysctl.h>
86 1.2.2.2 nathanw
87 1.2.2.2 nathanw #include <dev/usb/usb.h>
88 1.2.2.2 nathanw #include <dev/usb/usbcdc.h>
89 1.2.2.2 nathanw
90 1.2.2.2 nathanw #include <dev/usb/usbdi.h>
91 1.2.2.2 nathanw #include <dev/usb/usbdi_util.h>
92 1.2.2.2 nathanw #include <dev/usb/usbdevs.h>
93 1.2.2.2 nathanw #include <dev/usb/usb_quirks.h>
94 1.2.2.2 nathanw
95 1.2.2.2 nathanw #include <dev/usb/ucomvar.h>
96 1.2.2.2 nathanw
97 1.2.2.2 nathanw #ifdef UBSA_DEBUG
98 1.2.2.2 nathanw Static int ubsadebug = 0;
99 1.2.2.2 nathanw #ifdef __FreeBSD__
100 1.2.2.2 nathanw SYSCTL_NODE(_hw_usb, OID_AUTO, ubsa, CTLFLAG_RW, 0, "USB ubsa");
101 1.2.2.2 nathanw SYSCTL_INT(_hw_usb_ubsa, OID_AUTO, debug, CTLFLAG_RW,
102 1.2.2.2 nathanw &ubsadebug, 0, "ubsa debug level");
103 1.2.2.2 nathanw #endif
104 1.2.2.2 nathanw
105 1.2.2.2 nathanw #define DPRINTFN(n, x) do { \
106 1.2.2.2 nathanw if (ubsadebug > (n)) \
107 1.2.2.2 nathanw logprintf x; \
108 1.2.2.2 nathanw } while (0)
109 1.2.2.2 nathanw #else
110 1.2.2.2 nathanw #define DPRINTFN(n, x)
111 1.2.2.2 nathanw #endif
112 1.2.2.2 nathanw #define DPRINTF(x) DPRINTFN(0, x)
113 1.2.2.2 nathanw
114 1.2.2.2 nathanw #define UBSA_MODVER 1 /* module version */
115 1.2.2.2 nathanw
116 1.2.2.2 nathanw #define UBSA_CONFIG_INDEX 1
117 1.2.2.2 nathanw #define UBSA_IFACE_INDEX 0
118 1.2.2.2 nathanw
119 1.2.2.2 nathanw #define UBSA_INTR_INTERVAL 100 /* ms */
120 1.2.2.2 nathanw
121 1.2.2.2 nathanw #define UBSA_SET_BAUDRATE 0x00
122 1.2.2.2 nathanw #define UBSA_SET_STOP_BITS 0x01
123 1.2.2.2 nathanw #define UBSA_SET_DATA_BITS 0x02
124 1.2.2.2 nathanw #define UBSA_SET_PARITY 0x03
125 1.2.2.2 nathanw #define UBSA_SET_DTR 0x0A
126 1.2.2.2 nathanw #define UBSA_SET_RTS 0x0B
127 1.2.2.2 nathanw #define UBSA_SET_BREAK 0x0C
128 1.2.2.2 nathanw #define UBSA_SET_FLOW_CTRL 0x10
129 1.2.2.2 nathanw
130 1.2.2.2 nathanw #define UBSA_PARITY_NONE 0x00
131 1.2.2.2 nathanw #define UBSA_PARITY_EVEN 0x01
132 1.2.2.2 nathanw #define UBSA_PARITY_ODD 0x02
133 1.2.2.2 nathanw #define UBSA_PARITY_MARK 0x03
134 1.2.2.2 nathanw #define UBSA_PARITY_SPACE 0x04
135 1.2.2.2 nathanw
136 1.2.2.2 nathanw #define UBSA_FLOW_NONE 0x0000
137 1.2.2.2 nathanw #define UBSA_FLOW_OCTS 0x0001
138 1.2.2.2 nathanw #define UBSA_FLOW_ODSR 0x0002
139 1.2.2.2 nathanw #define UBSA_FLOW_IDSR 0x0004
140 1.2.2.2 nathanw #define UBSA_FLOW_IDTR 0x0008
141 1.2.2.2 nathanw #define UBSA_FLOW_IRTS 0x0010
142 1.2.2.2 nathanw #define UBSA_FLOW_ORTS 0x0020
143 1.2.2.2 nathanw #define UBSA_FLOW_UNKNOWN 0x0040
144 1.2.2.2 nathanw #define UBSA_FLOW_OXON 0x0080
145 1.2.2.2 nathanw #define UBSA_FLOW_IXON 0x0100
146 1.2.2.2 nathanw
147 1.2.2.2 nathanw /* line status register */
148 1.2.2.2 nathanw #define UBSA_LSR_TSRE 0x40 /* Transmitter empty: byte sent */
149 1.2.2.2 nathanw #define UBSA_LSR_TXRDY 0x20 /* Transmitter buffer empty */
150 1.2.2.2 nathanw #define UBSA_LSR_BI 0x10 /* Break detected */
151 1.2.2.2 nathanw #define UBSA_LSR_FE 0x08 /* Framing error: bad stop bit */
152 1.2.2.2 nathanw #define UBSA_LSR_PE 0x04 /* Parity error */
153 1.2.2.2 nathanw #define UBSA_LSR_OE 0x02 /* Overrun, lost incoming byte */
154 1.2.2.2 nathanw #define UBSA_LSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
155 1.2.2.2 nathanw #define UBSA_LSR_RCV_MASK 0x1f /* Mask for incoming data or error */
156 1.2.2.2 nathanw
157 1.2.2.2 nathanw /* modem status register */
158 1.2.2.2 nathanw /* All deltas are from the last read of the MSR. */
159 1.2.2.2 nathanw #define UBSA_MSR_DCD 0x80 /* Current Data Carrier Detect */
160 1.2.2.2 nathanw #define UBSA_MSR_RI 0x40 /* Current Ring Indicator */
161 1.2.2.2 nathanw #define UBSA_MSR_DSR 0x20 /* Current Data Set Ready */
162 1.2.2.2 nathanw #define UBSA_MSR_CTS 0x10 /* Current Clear to Send */
163 1.2.2.2 nathanw #define UBSA_MSR_DDCD 0x08 /* DCD has changed state */
164 1.2.2.2 nathanw #define UBSA_MSR_TERI 0x04 /* RI has toggled low to high */
165 1.2.2.2 nathanw #define UBSA_MSR_DDSR 0x02 /* DSR has changed state */
166 1.2.2.2 nathanw #define UBSA_MSR_DCTS 0x01 /* CTS has changed state */
167 1.2.2.2 nathanw
168 1.2.2.2 nathanw struct ubsa_softc {
169 1.2.2.2 nathanw USBBASEDEVICE sc_dev; /* base device */
170 1.2.2.2 nathanw usbd_device_handle sc_udev; /* USB device */
171 1.2.2.2 nathanw usbd_interface_handle sc_iface; /* interface */
172 1.2.2.2 nathanw
173 1.2.2.2 nathanw int sc_iface_number; /* interface number */
174 1.2.2.2 nathanw
175 1.2.2.2 nathanw usbd_interface_handle sc_intr_iface; /* interrupt interface */
176 1.2.2.2 nathanw int sc_intr_number; /* interrupt number */
177 1.2.2.2 nathanw usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */
178 1.2.2.2 nathanw u_char *sc_intr_buf; /* interrupt buffer */
179 1.2.2.2 nathanw int sc_isize;
180 1.2.2.2 nathanw
181 1.2.2.2 nathanw u_char sc_dtr; /* current DTR state */
182 1.2.2.2 nathanw u_char sc_rts; /* current RTS state */
183 1.2.2.2 nathanw
184 1.2.2.2 nathanw u_char sc_lsr; /* Local status register */
185 1.2.2.2 nathanw u_char sc_msr; /* ubsa status register */
186 1.2.2.3 nathanw
187 1.2.2.2 nathanw device_ptr_t sc_subdev; /* ucom device */
188 1.2.2.2 nathanw
189 1.2.2.2 nathanw u_char sc_dying; /* disconnecting */
190 1.2.2.2 nathanw
191 1.2.2.2 nathanw };
192 1.2.2.2 nathanw
193 1.2.2.2 nathanw Static void ubsa_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
194 1.2.2.2 nathanw
195 1.2.2.2 nathanw Static void ubsa_get_status(void *, int, u_char *, u_char *);
196 1.2.2.2 nathanw Static void ubsa_set(void *, int, int, int);
197 1.2.2.2 nathanw Static int ubsa_param(void *, int, struct termios *);
198 1.2.2.2 nathanw Static int ubsa_open(void *, int);
199 1.2.2.2 nathanw Static void ubsa_close(void *, int);
200 1.2.2.2 nathanw
201 1.2.2.2 nathanw Static void ubsa_break(struct ubsa_softc *sc, int onoff);
202 1.2.2.2 nathanw Static int ubsa_request(struct ubsa_softc *, u_int8_t, u_int16_t);
203 1.2.2.2 nathanw Static void ubsa_dtr(struct ubsa_softc *, int);
204 1.2.2.2 nathanw Static void ubsa_rts(struct ubsa_softc *, int);
205 1.2.2.2 nathanw Static void ubsa_baudrate(struct ubsa_softc *, speed_t);
206 1.2.2.2 nathanw Static void ubsa_parity(struct ubsa_softc *, tcflag_t);
207 1.2.2.2 nathanw Static void ubsa_databits(struct ubsa_softc *, tcflag_t);
208 1.2.2.2 nathanw Static void ubsa_stopbits(struct ubsa_softc *, tcflag_t);
209 1.2.2.2 nathanw Static void ubsa_flow(struct ubsa_softc *, tcflag_t, tcflag_t);
210 1.2.2.2 nathanw
211 1.2.2.2 nathanw struct ucom_methods ubsa_methods = {
212 1.2.2.2 nathanw ubsa_get_status,
213 1.2.2.2 nathanw ubsa_set,
214 1.2.2.2 nathanw ubsa_param,
215 1.2.2.2 nathanw NULL,
216 1.2.2.2 nathanw ubsa_open,
217 1.2.2.2 nathanw ubsa_close,
218 1.2.2.2 nathanw NULL,
219 1.2.2.2 nathanw NULL
220 1.2.2.2 nathanw };
221 1.2.2.2 nathanw
222 1.2.2.2 nathanw Static const struct usb_devno ubsa_devs[] = {
223 1.2.2.2 nathanw /* BELKIN F5U103 */
224 1.2.2.2 nathanw { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U103 },
225 1.2.2.2 nathanw /* BELKIN F5U120 */
226 1.2.2.2 nathanw { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U120 },
227 1.2.2.2 nathanw /* GoHubs GO-COM232 */
228 1.2.2.2 nathanw { USB_VENDOR_ETEK, USB_PRODUCT_ETEK_1COM },
229 1.2.2.2 nathanw /* GoHubs GO-COM232 */
230 1.2.2.2 nathanw { USB_VENDOR_GOHUBS, USB_PRODUCT_GOHUBS_GOCOM232 },
231 1.2.2.2 nathanw /* Peracom */
232 1.2.2.2 nathanw { USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 },
233 1.2.2.2 nathanw };
234 1.2.2.2 nathanw #define ubsa_lookup(v, p) usb_lookup(ubsa_devs, v, p)
235 1.2.2.2 nathanw
236 1.2.2.2 nathanw USB_DECLARE_DRIVER(ubsa);
237 1.2.2.2 nathanw
238 1.2.2.2 nathanw USB_MATCH(ubsa)
239 1.2.2.2 nathanw {
240 1.2.2.2 nathanw USB_MATCH_START(ubsa, uaa);
241 1.2.2.2 nathanw
242 1.2.2.2 nathanw if (uaa->iface != NULL)
243 1.2.2.2 nathanw return (UMATCH_NONE);
244 1.2.2.2 nathanw
245 1.2.2.2 nathanw return (ubsa_lookup(uaa->vendor, uaa->product) != NULL ?
246 1.2.2.2 nathanw UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
247 1.2.2.2 nathanw }
248 1.2.2.2 nathanw
249 1.2.2.2 nathanw USB_ATTACH(ubsa)
250 1.2.2.2 nathanw {
251 1.2.2.2 nathanw USB_ATTACH_START(ubsa, sc, uaa);
252 1.2.2.2 nathanw usbd_device_handle dev = uaa->device;
253 1.2.2.2 nathanw usb_config_descriptor_t *cdesc;
254 1.2.2.2 nathanw usb_interface_descriptor_t *id;
255 1.2.2.2 nathanw usb_endpoint_descriptor_t *ed;
256 1.2.2.2 nathanw char devinfo[1024];
257 1.2.2.2 nathanw const char *devname = USBDEVNAME(sc->sc_dev);
258 1.2.2.2 nathanw usbd_status err;
259 1.2.2.2 nathanw struct ucom_attach_args uca;
260 1.2.2.2 nathanw int i;
261 1.2.2.2 nathanw
262 1.2.2.2 nathanw usbd_devinfo(dev, 0, devinfo);
263 1.2.2.2 nathanw USB_ATTACH_SETUP;
264 1.2.2.2 nathanw printf("%s: %s\n", devname, devinfo);
265 1.2.2.2 nathanw
266 1.2.2.2 nathanw sc->sc_udev = dev;
267 1.2.2.2 nathanw
268 1.2.2.2 nathanw /*
269 1.2.2.2 nathanw * initialize rts, dtr variables to something
270 1.2.2.3 nathanw * different from boolean 0, 1
271 1.2.2.2 nathanw */
272 1.2.2.2 nathanw sc->sc_dtr = -1;
273 1.2.2.2 nathanw sc->sc_rts = -1;
274 1.2.2.2 nathanw
275 1.2.2.2 nathanw printf("%s: %s\n", devname, devinfo);
276 1.2.2.2 nathanw
277 1.2.2.2 nathanw DPRINTF(("ubsa attach: sc = %p\n", sc));
278 1.2.2.2 nathanw
279 1.2.2.3 nathanw /* initialize endpoints */
280 1.2.2.2 nathanw uca.bulkin = uca.bulkout = -1;
281 1.2.2.2 nathanw sc->sc_intr_number = -1;
282 1.2.2.2 nathanw sc->sc_intr_pipe = NULL;
283 1.2.2.2 nathanw
284 1.2.2.2 nathanw /* Move the device into the configured state. */
285 1.2.2.2 nathanw err = usbd_set_config_index(dev, UBSA_CONFIG_INDEX, 1);
286 1.2.2.2 nathanw if (err) {
287 1.2.2.2 nathanw printf("%s: failed to set configuration: %s\n",
288 1.2.2.2 nathanw devname, usbd_errstr(err));
289 1.2.2.2 nathanw sc->sc_dying = 1;
290 1.2.2.2 nathanw goto error;
291 1.2.2.2 nathanw }
292 1.2.2.2 nathanw
293 1.2.2.2 nathanw /* get the config descriptor */
294 1.2.2.2 nathanw cdesc = usbd_get_config_descriptor(sc->sc_udev);
295 1.2.2.2 nathanw
296 1.2.2.2 nathanw if (cdesc == NULL) {
297 1.2.2.2 nathanw printf("%s: failed to get configuration descriptor\n",
298 1.2.2.2 nathanw devname);
299 1.2.2.2 nathanw sc->sc_dying = 1;
300 1.2.2.2 nathanw goto error;
301 1.2.2.2 nathanw }
302 1.2.2.2 nathanw
303 1.2.2.2 nathanw /* get the first interface */
304 1.2.2.2 nathanw err = usbd_device2interface_handle(dev, UBSA_IFACE_INDEX,
305 1.2.2.2 nathanw &sc->sc_iface);
306 1.2.2.2 nathanw if (err) {
307 1.2.2.2 nathanw printf("%s: failed to get interface: %s\n",
308 1.2.2.2 nathanw devname, usbd_errstr(err));
309 1.2.2.2 nathanw sc->sc_dying = 1;
310 1.2.2.2 nathanw goto error;
311 1.2.2.2 nathanw }
312 1.2.2.2 nathanw
313 1.2.2.2 nathanw /* Find the endpoints */
314 1.2.2.2 nathanw
315 1.2.2.2 nathanw id = usbd_get_interface_descriptor(sc->sc_iface);
316 1.2.2.2 nathanw sc->sc_iface_number = id->bInterfaceNumber;
317 1.2.2.2 nathanw
318 1.2.2.2 nathanw for (i = 0; i < id->bNumEndpoints; i++) {
319 1.2.2.2 nathanw ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
320 1.2.2.2 nathanw if (ed == NULL) {
321 1.2.2.2 nathanw printf("%s: no endpoint descriptor for %d\n",
322 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev), i);
323 1.2.2.2 nathanw sc->sc_dying = 1;
324 1.2.2.2 nathanw goto error;
325 1.2.2.2 nathanw }
326 1.2.2.2 nathanw
327 1.2.2.2 nathanw if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
328 1.2.2.2 nathanw UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
329 1.2.2.2 nathanw sc->sc_intr_number = ed->bEndpointAddress;
330 1.2.2.2 nathanw sc->sc_isize = UGETW(ed->wMaxPacketSize);
331 1.2.2.2 nathanw } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
332 1.2.2.2 nathanw UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
333 1.2.2.2 nathanw uca.bulkin = ed->bEndpointAddress;
334 1.2.2.2 nathanw uca.ibufsize = UGETW(ed->wMaxPacketSize);
335 1.2.2.2 nathanw } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
336 1.2.2.2 nathanw UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
337 1.2.2.2 nathanw uca.bulkout = ed->bEndpointAddress;
338 1.2.2.2 nathanw uca.obufsize = UGETW(ed->wMaxPacketSize);
339 1.2.2.2 nathanw }
340 1.2.2.2 nathanw }
341 1.2.2.2 nathanw
342 1.2.2.2 nathanw if (sc->sc_intr_number == -1) {
343 1.2.2.2 nathanw printf("%s: Could not find interrupt in\n", devname);
344 1.2.2.2 nathanw sc->sc_dying = 1;
345 1.2.2.2 nathanw goto error;
346 1.2.2.2 nathanw }
347 1.2.2.2 nathanw
348 1.2.2.2 nathanw if (uca.bulkin == -1) {
349 1.2.2.2 nathanw printf("%s: Could not find data bulk in\n", devname);
350 1.2.2.2 nathanw sc->sc_dying = 1;
351 1.2.2.2 nathanw goto error;
352 1.2.2.2 nathanw }
353 1.2.2.2 nathanw
354 1.2.2.2 nathanw if (uca.bulkout == -1) {
355 1.2.2.2 nathanw printf("%s: Could not find data bulk out\n", devname);
356 1.2.2.2 nathanw sc->sc_dying = 1;
357 1.2.2.2 nathanw goto error;
358 1.2.2.2 nathanw }
359 1.2.2.2 nathanw
360 1.2.2.2 nathanw uca.portno = UCOM_UNK_PORTNO;
361 1.2.2.2 nathanw /* bulkin, bulkout set above */
362 1.2.2.2 nathanw uca.ibufsizepad = uca.ibufsize;
363 1.2.2.2 nathanw uca.opkthdrlen = 0;
364 1.2.2.2 nathanw uca.device = dev;
365 1.2.2.2 nathanw uca.iface = sc->sc_iface;
366 1.2.2.2 nathanw uca.methods = &ubsa_methods;
367 1.2.2.2 nathanw uca.arg = sc;
368 1.2.2.2 nathanw uca.info = NULL;
369 1.2.2.2 nathanw
370 1.2.2.2 nathanw usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
371 1.2.2.2 nathanw USBDEV(sc->sc_dev));
372 1.2.2.2 nathanw
373 1.2.2.2 nathanw DPRINTF(("ubsa: in = 0x%x, out = 0x%x, intr = 0x%x\n",
374 1.2.2.2 nathanw uca.bulkin_no, uca.bulkout_no, sc->sc_intr_number));
375 1.2.2.2 nathanw
376 1.2.2.2 nathanw sc->sc_subdev = config_found_sm(self, &uca, ucomprint, ucomsubmatch);
377 1.2.2.2 nathanw
378 1.2.2.2 nathanw USB_ATTACH_SUCCESS_RETURN;
379 1.2.2.2 nathanw
380 1.2.2.2 nathanw error:
381 1.2.2.2 nathanw free(devinfo, M_USBDEV);
382 1.2.2.2 nathanw USB_ATTACH_ERROR_RETURN;
383 1.2.2.2 nathanw }
384 1.2.2.2 nathanw
385 1.2.2.2 nathanw USB_DETACH(ubsa)
386 1.2.2.2 nathanw {
387 1.2.2.2 nathanw USB_DETACH_START(ubsa, sc);
388 1.2.2.2 nathanw int rv;
389 1.2.2.2 nathanw
390 1.2.2.2 nathanw
391 1.2.2.2 nathanw DPRINTF(("ubsa_detach: sc = %p\n", sc));
392 1.2.2.2 nathanw
393 1.2.2.2 nathanw if (sc->sc_intr_pipe != NULL) {
394 1.2.2.2 nathanw usbd_abort_pipe(sc->sc_intr_pipe);
395 1.2.2.2 nathanw usbd_close_pipe(sc->sc_intr_pipe);
396 1.2.2.2 nathanw free(sc->sc_intr_buf, M_USBDEV);
397 1.2.2.2 nathanw sc->sc_intr_pipe = NULL;
398 1.2.2.2 nathanw }
399 1.2.2.2 nathanw
400 1.2.2.2 nathanw sc->sc_dying = 1;
401 1.2.2.2 nathanw if (sc->sc_subdev != NULL) {
402 1.2.2.2 nathanw rv = config_detach(sc->sc_subdev, flags);
403 1.2.2.2 nathanw sc->sc_subdev = NULL;
404 1.2.2.2 nathanw }
405 1.2.2.2 nathanw
406 1.2.2.2 nathanw usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
407 1.2.2.2 nathanw USBDEV(sc->sc_dev));
408 1.2.2.2 nathanw
409 1.2.2.2 nathanw return (rv);
410 1.2.2.2 nathanw }
411 1.2.2.2 nathanw
412 1.2.2.2 nathanw int
413 1.2.2.2 nathanw ubsa_activate(device_ptr_t self, enum devact act)
414 1.2.2.2 nathanw {
415 1.2.2.2 nathanw struct ubsa_softc *sc = (struct ubsa_softc *)self;
416 1.2.2.2 nathanw int rv = 0;
417 1.2.2.2 nathanw
418 1.2.2.2 nathanw switch (act) {
419 1.2.2.2 nathanw case DVACT_ACTIVATE:
420 1.2.2.2 nathanw return (EOPNOTSUPP);
421 1.2.2.2 nathanw
422 1.2.2.2 nathanw case DVACT_DEACTIVATE:
423 1.2.2.2 nathanw if (sc->sc_subdev != NULL)
424 1.2.2.2 nathanw rv = config_deactivate(sc->sc_subdev);
425 1.2.2.2 nathanw sc->sc_dying = 1;
426 1.2.2.2 nathanw break;
427 1.2.2.2 nathanw }
428 1.2.2.2 nathanw return (rv);
429 1.2.2.2 nathanw }
430 1.2.2.2 nathanw
431 1.2.2.2 nathanw Static int
432 1.2.2.2 nathanw ubsa_request(struct ubsa_softc *sc, u_int8_t request, u_int16_t value)
433 1.2.2.2 nathanw {
434 1.2.2.2 nathanw usb_device_request_t req;
435 1.2.2.2 nathanw usbd_status err;
436 1.2.2.2 nathanw
437 1.2.2.2 nathanw req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
438 1.2.2.2 nathanw req.bRequest = request;
439 1.2.2.2 nathanw USETW(req.wValue, value);
440 1.2.2.2 nathanw USETW(req.wIndex, sc->sc_iface_number);
441 1.2.2.2 nathanw USETW(req.wLength, 0);
442 1.2.2.2 nathanw
443 1.2.2.2 nathanw err = usbd_do_request(sc->sc_udev, &req, 0);
444 1.2.2.2 nathanw if (err)
445 1.2.2.2 nathanw printf("%s: ubsa_request: %s\n",
446 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev), usbd_errstr(err));
447 1.2.2.2 nathanw return (err);
448 1.2.2.2 nathanw }
449 1.2.2.2 nathanw
450 1.2.2.2 nathanw Static void
451 1.2.2.2 nathanw ubsa_dtr(struct ubsa_softc *sc, int onoff)
452 1.2.2.2 nathanw {
453 1.2.2.2 nathanw
454 1.2.2.2 nathanw DPRINTF(("ubsa_dtr: onoff = %d\n", onoff));
455 1.2.2.2 nathanw
456 1.2.2.2 nathanw if (sc->sc_dtr == onoff)
457 1.2.2.2 nathanw return;
458 1.2.2.2 nathanw sc->sc_dtr = onoff;
459 1.2.2.2 nathanw
460 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_DTR, onoff ? 1 : 0);
461 1.2.2.2 nathanw }
462 1.2.2.2 nathanw
463 1.2.2.2 nathanw Static void
464 1.2.2.2 nathanw ubsa_rts(struct ubsa_softc *sc, int onoff)
465 1.2.2.2 nathanw {
466 1.2.2.2 nathanw
467 1.2.2.2 nathanw DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
468 1.2.2.2 nathanw
469 1.2.2.2 nathanw if (sc->sc_rts == onoff)
470 1.2.2.2 nathanw return;
471 1.2.2.2 nathanw sc->sc_rts = onoff;
472 1.2.2.2 nathanw
473 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_RTS, onoff ? 1 : 0);
474 1.2.2.2 nathanw }
475 1.2.2.2 nathanw
476 1.2.2.2 nathanw Static void
477 1.2.2.2 nathanw ubsa_break(struct ubsa_softc *sc, int onoff)
478 1.2.2.2 nathanw {
479 1.2.2.2 nathanw
480 1.2.2.2 nathanw DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
481 1.2.2.2 nathanw
482 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_BREAK, onoff ? 1 : 0);
483 1.2.2.2 nathanw }
484 1.2.2.2 nathanw
485 1.2.2.2 nathanw Static void
486 1.2.2.2 nathanw ubsa_set(void *addr, int portno, int reg, int onoff)
487 1.2.2.2 nathanw {
488 1.2.2.2 nathanw struct ubsa_softc *sc;
489 1.2.2.2 nathanw
490 1.2.2.2 nathanw sc = addr;
491 1.2.2.2 nathanw switch (reg) {
492 1.2.2.2 nathanw case UCOM_SET_DTR:
493 1.2.2.2 nathanw ubsa_dtr(sc, onoff);
494 1.2.2.2 nathanw break;
495 1.2.2.2 nathanw case UCOM_SET_RTS:
496 1.2.2.2 nathanw ubsa_rts(sc, onoff);
497 1.2.2.2 nathanw break;
498 1.2.2.2 nathanw case UCOM_SET_BREAK:
499 1.2.2.2 nathanw ubsa_break(sc, onoff);
500 1.2.2.2 nathanw break;
501 1.2.2.2 nathanw default:
502 1.2.2.2 nathanw break;
503 1.2.2.2 nathanw }
504 1.2.2.2 nathanw }
505 1.2.2.2 nathanw
506 1.2.2.2 nathanw Static void
507 1.2.2.2 nathanw ubsa_baudrate(struct ubsa_softc *sc, speed_t speed)
508 1.2.2.2 nathanw {
509 1.2.2.2 nathanw u_int16_t value = 0;
510 1.2.2.3 nathanw
511 1.2.2.2 nathanw DPRINTF(("ubsa_baudrate: speed = %d\n", speed));
512 1.2.2.2 nathanw
513 1.2.2.2 nathanw switch(speed) {
514 1.2.2.2 nathanw case B0:
515 1.2.2.2 nathanw break;
516 1.2.2.2 nathanw case B300:
517 1.2.2.2 nathanw case B600:
518 1.2.2.2 nathanw case B1200:
519 1.2.2.2 nathanw case B2400:
520 1.2.2.2 nathanw case B4800:
521 1.2.2.2 nathanw case B9600:
522 1.2.2.2 nathanw case B19200:
523 1.2.2.2 nathanw case B38400:
524 1.2.2.2 nathanw case B57600:
525 1.2.2.2 nathanw case B115200:
526 1.2.2.3 nathanw case B230400:
527 1.2.2.2 nathanw value = B230400 / speed;
528 1.2.2.2 nathanw break;
529 1.2.2.3 nathanw default:
530 1.2.2.2 nathanw printf("%s: ubsa_param: unsupported baudrate, "
531 1.2.2.2 nathanw "forcing default of 9600\n",
532 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev));
533 1.2.2.2 nathanw value = B230400 / B9600;
534 1.2.2.2 nathanw break;
535 1.2.2.2 nathanw };
536 1.2.2.3 nathanw
537 1.2.2.2 nathanw if (speed == B0) {
538 1.2.2.2 nathanw ubsa_flow(sc, 0, 0);
539 1.2.2.2 nathanw ubsa_dtr(sc, 0);
540 1.2.2.2 nathanw ubsa_rts(sc, 0);
541 1.2.2.2 nathanw } else
542 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_BAUDRATE, value);
543 1.2.2.2 nathanw }
544 1.2.2.2 nathanw
545 1.2.2.2 nathanw Static void
546 1.2.2.2 nathanw ubsa_parity(struct ubsa_softc *sc, tcflag_t cflag)
547 1.2.2.2 nathanw {
548 1.2.2.2 nathanw int value;
549 1.2.2.2 nathanw
550 1.2.2.2 nathanw DPRINTF(("ubsa_parity: cflag = 0x%x\n", cflag));
551 1.2.2.2 nathanw
552 1.2.2.2 nathanw if (cflag & PARENB)
553 1.2.2.2 nathanw value = (cflag & PARODD) ? UBSA_PARITY_ODD : UBSA_PARITY_EVEN;
554 1.2.2.2 nathanw else
555 1.2.2.2 nathanw value = UBSA_PARITY_NONE;
556 1.2.2.2 nathanw
557 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_PARITY, value);
558 1.2.2.2 nathanw }
559 1.2.2.2 nathanw
560 1.2.2.2 nathanw Static void
561 1.2.2.2 nathanw ubsa_databits(struct ubsa_softc *sc, tcflag_t cflag)
562 1.2.2.2 nathanw {
563 1.2.2.2 nathanw int value;
564 1.2.2.2 nathanw
565 1.2.2.2 nathanw DPRINTF(("ubsa_databits: cflag = 0x%x\n", cflag));
566 1.2.2.2 nathanw
567 1.2.2.2 nathanw switch (cflag & CSIZE) {
568 1.2.2.2 nathanw case CS5: value = 0; break;
569 1.2.2.2 nathanw case CS6: value = 1; break;
570 1.2.2.2 nathanw case CS7: value = 2; break;
571 1.2.2.2 nathanw case CS8: value = 3; break;
572 1.2.2.3 nathanw default:
573 1.2.2.2 nathanw printf("%s: ubsa_param: unsupported databits requested, "
574 1.2.2.2 nathanw "forcing default of 8\n",
575 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev));
576 1.2.2.2 nathanw value = 3;
577 1.2.2.2 nathanw }
578 1.2.2.2 nathanw
579 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_DATA_BITS, value);
580 1.2.2.2 nathanw }
581 1.2.2.2 nathanw
582 1.2.2.2 nathanw Static void
583 1.2.2.2 nathanw ubsa_stopbits(struct ubsa_softc *sc, tcflag_t cflag)
584 1.2.2.2 nathanw {
585 1.2.2.2 nathanw int value;
586 1.2.2.2 nathanw
587 1.2.2.2 nathanw DPRINTF(("ubsa_stopbits: cflag = 0x%x\n", cflag));
588 1.2.2.2 nathanw
589 1.2.2.2 nathanw value = (cflag & CSTOPB) ? 1 : 0;
590 1.2.2.2 nathanw
591 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_STOP_BITS, value);
592 1.2.2.2 nathanw }
593 1.2.2.2 nathanw
594 1.2.2.2 nathanw Static void
595 1.2.2.2 nathanw ubsa_flow(struct ubsa_softc *sc, tcflag_t cflag, tcflag_t iflag)
596 1.2.2.2 nathanw {
597 1.2.2.2 nathanw int value;
598 1.2.2.3 nathanw
599 1.2.2.2 nathanw DPRINTF(("ubsa_flow: cflag = 0x%x, iflag = 0x%x\n", cflag, iflag));
600 1.2.2.2 nathanw
601 1.2.2.2 nathanw value = 0;
602 1.2.2.2 nathanw if (cflag & CRTSCTS)
603 1.2.2.2 nathanw value |= UBSA_FLOW_OCTS | UBSA_FLOW_IRTS;
604 1.2.2.2 nathanw if (iflag & (IXON|IXOFF))
605 1.2.2.2 nathanw value |= UBSA_FLOW_OXON | UBSA_FLOW_IXON;
606 1.2.2.2 nathanw
607 1.2.2.2 nathanw ubsa_request(sc, UBSA_SET_FLOW_CTRL, value);
608 1.2.2.2 nathanw }
609 1.2.2.2 nathanw
610 1.2.2.2 nathanw Static int
611 1.2.2.2 nathanw ubsa_param(void *addr, int portno, struct termios *ti)
612 1.2.2.2 nathanw {
613 1.2.2.3 nathanw struct ubsa_softc *sc = addr;
614 1.2.2.2 nathanw
615 1.2.2.2 nathanw DPRINTF(("ubsa_param: sc = %p\n", sc));
616 1.2.2.2 nathanw
617 1.2.2.2 nathanw ubsa_baudrate(sc, ti->c_ospeed);
618 1.2.2.2 nathanw ubsa_parity(sc, ti->c_cflag);
619 1.2.2.2 nathanw ubsa_databits(sc, ti->c_cflag);
620 1.2.2.2 nathanw ubsa_stopbits(sc, ti->c_cflag);
621 1.2.2.2 nathanw ubsa_flow(sc, ti->c_cflag, ti->c_iflag);
622 1.2.2.2 nathanw
623 1.2.2.2 nathanw return (0);
624 1.2.2.2 nathanw }
625 1.2.2.2 nathanw
626 1.2.2.2 nathanw Static int
627 1.2.2.2 nathanw ubsa_open(void *addr, int portno)
628 1.2.2.2 nathanw {
629 1.2.2.3 nathanw struct ubsa_softc *sc = addr;
630 1.2.2.2 nathanw int err;
631 1.2.2.3 nathanw
632 1.2.2.2 nathanw if (sc->sc_dying)
633 1.2.2.2 nathanw return (ENXIO);
634 1.2.2.2 nathanw
635 1.2.2.2 nathanw DPRINTF(("ubsa_open: sc = %p\n", sc));
636 1.2.2.2 nathanw
637 1.2.2.2 nathanw if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
638 1.2.2.2 nathanw sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
639 1.2.2.2 nathanw err = usbd_open_pipe_intr(sc->sc_intr_iface,
640 1.2.2.2 nathanw sc->sc_intr_number,
641 1.2.2.2 nathanw USBD_SHORT_XFER_OK,
642 1.2.2.2 nathanw &sc->sc_intr_pipe,
643 1.2.2.2 nathanw sc,
644 1.2.2.2 nathanw sc->sc_intr_buf,
645 1.2.2.2 nathanw sc->sc_isize,
646 1.2.2.2 nathanw ubsa_intr,
647 1.2.2.2 nathanw UBSA_INTR_INTERVAL);
648 1.2.2.2 nathanw if (err) {
649 1.2.2.2 nathanw printf("%s: cannot open interrupt pipe (addr %d)\n",
650 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev),
651 1.2.2.2 nathanw sc->sc_intr_number);
652 1.2.2.2 nathanw return (EIO);
653 1.2.2.2 nathanw }
654 1.2.2.2 nathanw }
655 1.2.2.2 nathanw
656 1.2.2.2 nathanw return (0);
657 1.2.2.2 nathanw }
658 1.2.2.2 nathanw
659 1.2.2.2 nathanw Static void
660 1.2.2.3 nathanw ubsa_close(void *addr, int portno)
661 1.2.2.2 nathanw {
662 1.2.2.3 nathanw struct ubsa_softc *sc = addr;
663 1.2.2.2 nathanw int err;
664 1.2.2.2 nathanw
665 1.2.2.2 nathanw if (sc->sc_dying)
666 1.2.2.2 nathanw return;
667 1.2.2.2 nathanw
668 1.2.2.2 nathanw DPRINTF(("ubsa_close: close\n"));
669 1.2.2.2 nathanw
670 1.2.2.2 nathanw if (sc->sc_intr_pipe != NULL) {
671 1.2.2.2 nathanw err = usbd_abort_pipe(sc->sc_intr_pipe);
672 1.2.2.2 nathanw if (err)
673 1.2.2.2 nathanw printf("%s: abort interrupt pipe failed: %s\n",
674 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev),
675 1.2.2.2 nathanw usbd_errstr(err));
676 1.2.2.2 nathanw err = usbd_close_pipe(sc->sc_intr_pipe);
677 1.2.2.2 nathanw if (err)
678 1.2.2.2 nathanw printf("%s: close interrupt pipe failed: %s\n",
679 1.2.2.2 nathanw USBDEVNAME(sc->sc_dev),
680 1.2.2.2 nathanw usbd_errstr(err));
681 1.2.2.2 nathanw free(sc->sc_intr_buf, M_USBDEV);
682 1.2.2.2 nathanw sc->sc_intr_pipe = NULL;
683 1.2.2.2 nathanw }
684 1.2.2.2 nathanw }
685 1.2.2.2 nathanw
686 1.2.2.2 nathanw Static void
687 1.2.2.2 nathanw ubsa_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
688 1.2.2.2 nathanw {
689 1.2.2.3 nathanw struct ubsa_softc *sc = priv;
690 1.2.2.2 nathanw u_char *buf;
691 1.2.2.2 nathanw
692 1.2.2.2 nathanw buf = sc->sc_intr_buf;
693 1.2.2.2 nathanw if (sc->sc_dying)
694 1.2.2.2 nathanw return;
695 1.2.2.2 nathanw
696 1.2.2.2 nathanw if (status != USBD_NORMAL_COMPLETION) {
697 1.2.2.2 nathanw if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
698 1.2.2.2 nathanw return;
699 1.2.2.2 nathanw
700 1.2.2.2 nathanw DPRINTF(("%s: ubsa_intr: abnormal status: %s\n",
701 1.2.2.2 nathanw USBDEVNAME(sc->sc_ucom.sc_dev),
702 1.2.2.2 nathanw usbd_errstr(status)));
703 1.2.2.2 nathanw usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
704 1.2.2.2 nathanw return;
705 1.2.2.2 nathanw }
706 1.2.2.2 nathanw
707 1.2.2.2 nathanw /* incidentally, Belkin adapter status bits match UART 16550 bits */
708 1.2.2.2 nathanw sc->sc_lsr = buf[2];
709 1.2.2.2 nathanw sc->sc_msr = buf[3];
710 1.2.2.2 nathanw
711 1.2.2.2 nathanw DPRINTF(("%s: ubsa lsr = 0x%02x, msr = 0x%02x\n",
712 1.2.2.2 nathanw USBDEVNAME(sc->sc_ucom.sc_dev), sc->sc_lsr, sc->sc_msr));
713 1.2.2.2 nathanw
714 1.2.2.2 nathanw ucom_status_change((struct ucom_softc *)sc->sc_subdev);
715 1.2.2.2 nathanw }
716 1.2.2.2 nathanw
717 1.2.2.2 nathanw Static void
718 1.2.2.2 nathanw ubsa_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
719 1.2.2.2 nathanw {
720 1.2.2.3 nathanw struct ubsa_softc *sc = addr;
721 1.2.2.2 nathanw
722 1.2.2.2 nathanw DPRINTF(("ubsa_get_status\n"));
723 1.2.2.2 nathanw
724 1.2.2.2 nathanw if (lsr != NULL)
725 1.2.2.2 nathanw *lsr = sc->sc_lsr;
726 1.2.2.2 nathanw if (msr != NULL)
727 1.2.2.2 nathanw *msr = sc->sc_msr;
728 1.2.2.2 nathanw }
729