2 * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $NetBSD: usb/uvscom.c,v 1.1 2002/03/19 15:08:42 augustss Exp $
27 * $FreeBSD: src/sys/dev/usb/uvscom.c,v 1.19 2003/11/16 12:26:10 akiyama Exp $
28 * $DragonFly: src/sys/dev/usbmisc/uvscom/uvscom.c,v 1.20 2008/01/16 12:24:31 matthias Exp $
32 * uvscom: SUNTAC Slipper U VS-10U driver.
33 * Slipper U is a PC card to USB converter for data communication card
34 * adapter. It supports DDI Pocket's Air H" C@rd, C@rd H" 64, NTT's P-in,
35 * P-in m@ater and various data communication card adapters.
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/malloc.h>
42 #include <sys/fcntl.h>
47 #include <sys/select.h>
50 #include <sys/sysctl.h>
52 #include <bus/usb/usb.h>
53 #include <bus/usb/usbcdc.h>
55 #include <bus/usb/usbdi.h>
56 #include <bus/usb/usbdi_util.h>
57 #include <bus/usb/usb_quirks.h>
59 #include "../ucom/ucomvar.h"
62 static int uvscomdebug = 0;
63 SYSCTL_NODE(_hw_usb, OID_AUTO, uvscom, CTLFLAG_RW, 0, "USB uvscom");
64 SYSCTL_INT(_hw_usb_uvscom, OID_AUTO, debug, CTLFLAG_RW,
65 &uvscomdebug, 0, "uvscom debug level");
67 #define DPRINTFN(n, x) do { \
68 if (uvscomdebug > (n)) \
72 #define DPRINTFN(n, x)
74 #define DPRINTF(x) DPRINTFN(0, x)
76 #define UVSCOM_MODVER 1 /* module version */
78 #define UVSCOM_CONFIG_INDEX 0
79 #define UVSCOM_IFACE_INDEX 0
81 #define UVSCOM_INTR_INTERVAL 100 /* mS */
83 #define UVSCOM_UNIT_WAIT 5
86 #define UVSCOM_SET_SPEED 0x10
87 #define UVSCOM_LINE_CTL 0x11
88 #define UVSCOM_SET_PARAM 0x12
89 #define UVSCOM_READ_STATUS 0xd0
90 #define UVSCOM_SHUTDOWN 0xe0
92 /* UVSCOM_SET_SPEED parameters */
93 #define UVSCOM_SPEED_150BPS 0x00
94 #define UVSCOM_SPEED_300BPS 0x01
95 #define UVSCOM_SPEED_600BPS 0x02
96 #define UVSCOM_SPEED_1200BPS 0x03
97 #define UVSCOM_SPEED_2400BPS 0x04
98 #define UVSCOM_SPEED_4800BPS 0x05
99 #define UVSCOM_SPEED_9600BPS 0x06
100 #define UVSCOM_SPEED_19200BPS 0x07
101 #define UVSCOM_SPEED_38400BPS 0x08
102 #define UVSCOM_SPEED_57600BPS 0x09
103 #define UVSCOM_SPEED_115200BPS 0x0a
105 /* UVSCOM_LINE_CTL parameters */
106 #define UVSCOM_BREAK 0x40
107 #define UVSCOM_RTS 0x02
108 #define UVSCOM_DTR 0x01
109 #define UVSCOM_LINE_INIT 0x08
111 /* UVSCOM_SET_PARAM parameters */
112 #define UVSCOM_DATA_MASK 0x03
113 #define UVSCOM_DATA_BIT_8 0x03
114 #define UVSCOM_DATA_BIT_7 0x02
115 #define UVSCOM_DATA_BIT_6 0x01
116 #define UVSCOM_DATA_BIT_5 0x00
118 #define UVSCOM_STOP_MASK 0x04
119 #define UVSCOM_STOP_BIT_2 0x04
120 #define UVSCOM_STOP_BIT_1 0x00
122 #define UVSCOM_PARITY_MASK 0x18
123 #define UVSCOM_PARITY_EVEN 0x18
125 #define UVSCOM_PARITY_UNK 0x10
127 #define UVSCOM_PARITY_ODD 0x08
128 #define UVSCOM_PARITY_NONE 0x00
131 #define UVSCOM_TXRDY 0x04
132 #define UVSCOM_RXRDY 0x01
134 #define UVSCOM_DCD 0x08
135 #define UVSCOM_NOCARD 0x04
136 #define UVSCOM_DSR 0x02
137 #define UVSCOM_CTS 0x01
138 #define UVSCOM_USTAT_MASK (UVSCOM_NOCARD | UVSCOM_DSR | UVSCOM_CTS)
140 struct uvscom_softc {
141 struct ucom_softc sc_ucom;
143 int sc_iface_number;/* interface number */
145 usbd_interface_handle sc_intr_iface; /* interrupt interface */
146 int sc_intr_number; /* interrupt number */
147 usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */
148 u_char *sc_intr_buf; /* interrupt buffer */
151 u_char sc_dtr; /* current DTR state */
152 u_char sc_rts; /* current RTS state */
154 u_char sc_lsr; /* Local status register */
155 u_char sc_msr; /* uvscom status register */
157 uint16_t sc_lcr; /* Line control */
158 u_char sc_usr; /* unit status */
162 * These are the maximum number of bytes transferred per frame.
163 * The output buffer size cannot be increased due to the size encoding.
165 #define UVSCOMIBUFSIZE 512
166 #define UVSCOMOBUFSIZE 64
168 static usbd_status uvscom_shutdown(struct uvscom_softc *);
169 static usbd_status uvscom_reset(struct uvscom_softc *);
170 static usbd_status uvscom_set_line_coding(struct uvscom_softc *,
172 static usbd_status uvscom_set_line(struct uvscom_softc *, uint16_t);
173 static usbd_status uvscom_set_crtscts(struct uvscom_softc *);
174 static void uvscom_get_status(void *, int, u_char *, u_char *);
175 static void uvscom_dtr(struct uvscom_softc *, int);
176 static void uvscom_rts(struct uvscom_softc *, int);
177 static void uvscom_break(struct uvscom_softc *, int);
179 static void uvscom_set(void *, int, int, int);
180 static void uvscom_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
182 static int uvscom_ioctl(void *, int, u_long, caddr_t, int, struct thread *);
184 static int uvscom_param(void *, int, struct termios *);
185 static int uvscom_open(void *, int);
186 static void uvscom_close(void *, int);
188 struct ucom_callback uvscom_callback = {
192 NULL, /* uvscom_ioctl, TODO */
199 static const struct usb_devno uvscom_devs [] = {
200 { USB_DEVICE(0x05db, 0x0003) }, /* SUNTAC U-Cable type D2 */
201 { USB_DEVICE(0x05db, 0x0005) }, /* SUNTAC U-Cable type P1 */
202 { USB_DEVICE(0x05db, 0x0009) }, /* SUNTAC Slipper U */
203 { USB_DEVICE(0x05db, 0x000a) }, /* SUNTAC Ir-Trinity */
204 { USB_DEVICE(0x05db, 0x0011) }, /* SUNTAC U-Cable type */
207 static device_probe_t uvscom_match;
208 static device_attach_t uvscom_attach;
209 static device_detach_t uvscom_detach;
211 static device_method_t uvscom_methods[] = {
212 /* Device interface */
213 DEVMETHOD(device_probe, uvscom_match),
214 DEVMETHOD(device_attach, uvscom_attach),
215 DEVMETHOD(device_detach, uvscom_detach),
219 static driver_t uvscom_driver = {
222 sizeof (struct uvscom_softc)
225 DRIVER_MODULE(uvscom, uhub, uvscom_driver, ucom_devclass, usbd_driver_load, 0);
226 MODULE_DEPEND(uvscom, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
227 MODULE_VERSION(uvscom, UVSCOM_MODVER);
230 uvscom_match(device_t self)
232 struct usb_attach_arg *uaa = device_get_ivars(self);
234 if (uaa->iface != NULL)
235 return (UMATCH_NONE);
237 return (usb_lookup(uvscom_devs, uaa->vendor, uaa->product) != NULL ?
238 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
242 uvscom_attach(device_t self)
244 struct uvscom_softc *sc = device_get_softc(self);
245 struct usb_attach_arg *uaa = device_get_ivars(self);
246 usbd_device_handle dev = uaa->device;
247 struct ucom_softc *ucom;
248 usb_config_descriptor_t *cdesc;
249 usb_interface_descriptor_t *id;
250 usb_endpoint_descriptor_t *ed;
257 bzero(sc, sizeof (struct uvscom_softc));
261 ucom->sc_iface = uaa->iface;
263 devname = device_get_nameunit(ucom->sc_dev);
265 DPRINTF(("uvscom attach: sc = %p\n", sc));
267 /* initialize endpoints */
268 ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
269 sc->sc_intr_number = -1;
270 sc->sc_intr_pipe = NULL;
272 /* Move the device into the configured state. */
273 err = usbd_set_config_index(dev, UVSCOM_CONFIG_INDEX, 1);
275 kprintf("%s: failed to set configuration, err=%s\n",
276 devname, usbd_errstr(err));
280 /* get the config descriptor */
281 cdesc = usbd_get_config_descriptor(ucom->sc_udev);
284 kprintf("%s: failed to get configuration descriptor\n",
285 device_get_nameunit(ucom->sc_dev));
289 /* get the common interface */
290 err = usbd_device2interface_handle(dev, UVSCOM_IFACE_INDEX,
293 kprintf("%s: failed to get interface, err=%s\n",
294 devname, usbd_errstr(err));
298 id = usbd_get_interface_descriptor(ucom->sc_iface);
299 sc->sc_iface_number = id->bInterfaceNumber;
302 for (i = 0; i < id->bNumEndpoints; i++) {
303 ed = usbd_interface2endpoint_descriptor(ucom->sc_iface, i);
305 kprintf("%s: no endpoint descriptor for %d\n",
306 device_get_nameunit(ucom->sc_dev), i);
310 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
311 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
312 ucom->sc_bulkin_no = ed->bEndpointAddress;
313 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
314 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
315 ucom->sc_bulkout_no = ed->bEndpointAddress;
316 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
317 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
318 sc->sc_intr_number = ed->bEndpointAddress;
319 sc->sc_isize = UGETW(ed->wMaxPacketSize);
323 if (ucom->sc_bulkin_no == -1) {
324 kprintf("%s: Could not find data bulk in\n",
325 device_get_nameunit(ucom->sc_dev));
328 if (ucom->sc_bulkout_no == -1) {
329 kprintf("%s: Could not find data bulk out\n",
330 device_get_nameunit(ucom->sc_dev));
333 if (sc->sc_intr_number == -1) {
334 kprintf("%s: Could not find interrupt in\n",
335 device_get_nameunit(ucom->sc_dev));
339 sc->sc_dtr = sc->sc_rts = 0;
340 sc->sc_lcr = UVSCOM_LINE_INIT;
342 ucom->sc_parent = sc;
343 ucom->sc_portno = UCOM_UNK_PORTNO;
344 /* bulkin, bulkout set above */
345 ucom->sc_ibufsize = UVSCOMIBUFSIZE;
346 ucom->sc_obufsize = UVSCOMOBUFSIZE;
347 ucom->sc_ibufsizepad = UVSCOMIBUFSIZE;
348 ucom->sc_opkthdrlen = 0;
349 ucom->sc_callback = &uvscom_callback;
351 err = uvscom_reset(sc);
354 kprintf("%s: reset failed, %s\n", device_get_nameunit(ucom->sc_dev),
359 DPRINTF(("uvscom: in = 0x%x out = 0x%x intr = 0x%x\n",
360 ucom->sc_bulkin_no, ucom->sc_bulkout_no, sc->sc_intr_number));
362 ucom_attach(&sc->sc_ucom);
372 uvscom_detach(device_t self)
374 struct uvscom_softc *sc = device_get_softc(self);
377 DPRINTF(("uvscom_detach: sc = %p\n", sc));
379 sc->sc_ucom.sc_dying = 1;
381 if (sc->sc_intr_pipe != NULL) {
382 usbd_abort_pipe(sc->sc_intr_pipe);
383 usbd_close_pipe(sc->sc_intr_pipe);
384 kfree(sc->sc_intr_buf, M_USBDEV);
385 sc->sc_intr_pipe = NULL;
388 rv = ucom_detach(&sc->sc_ucom);
394 uvscom_readstat(struct uvscom_softc *sc)
396 usb_device_request_t req;
400 DPRINTF(("%s: send readstat\n", device_get_nameunit(sc->sc_ucom.sc_dev)));
402 req.bmRequestType = UT_READ_VENDOR_DEVICE;
403 req.bRequest = UVSCOM_READ_STATUS;
404 USETW(req.wValue, 0);
405 USETW(req.wIndex, 0);
406 USETW(req.wLength, 2);
408 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, &r);
410 kprintf("%s: uvscom_readstat: %s\n",
411 device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err));
415 DPRINTF(("%s: uvscom_readstat: r = %d\n",
416 device_get_nameunit(sc->sc_ucom.sc_dev), r));
418 return (USBD_NORMAL_COMPLETION);
422 uvscom_shutdown(struct uvscom_softc *sc)
424 usb_device_request_t req;
427 DPRINTF(("%s: send shutdown\n", device_get_nameunit(sc->sc_ucom.sc_dev)));
429 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
430 req.bRequest = UVSCOM_SHUTDOWN;
431 USETW(req.wValue, 0);
432 USETW(req.wIndex, 0);
433 USETW(req.wLength, 0);
435 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
437 kprintf("%s: uvscom_shutdown: %s\n",
438 device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err));
442 return (USBD_NORMAL_COMPLETION);
446 uvscom_reset(struct uvscom_softc *sc)
448 DPRINTF(("%s: uvscom_reset\n", device_get_nameunit(sc->sc_ucom.sc_dev)));
450 return (USBD_NORMAL_COMPLETION);
454 uvscom_set_crtscts(struct uvscom_softc *sc)
456 DPRINTF(("%s: uvscom_set_crtscts\n", device_get_nameunit(sc->sc_ucom.sc_dev)));
458 return (USBD_NORMAL_COMPLETION);
462 uvscom_set_line(struct uvscom_softc *sc, uint16_t line)
464 usb_device_request_t req;
467 DPRINTF(("%s: uvscom_set_line: %04x\n",
468 device_get_nameunit(sc->sc_ucom.sc_dev), line));
470 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
471 req.bRequest = UVSCOM_LINE_CTL;
472 USETW(req.wValue, line);
473 USETW(req.wIndex, 0);
474 USETW(req.wLength, 0);
476 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
478 kprintf("%s: uvscom_set_line: %s\n",
479 device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err));
483 return (USBD_NORMAL_COMPLETION);
487 uvscom_set_line_coding(struct uvscom_softc *sc, uint16_t lsp, uint16_t ls)
489 usb_device_request_t req;
492 DPRINTF(("%s: uvscom_set_line_coding: %02x %02x\n",
493 device_get_nameunit(sc->sc_ucom.sc_dev), lsp, ls));
495 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
496 req.bRequest = UVSCOM_SET_SPEED;
497 USETW(req.wValue, lsp);
498 USETW(req.wIndex, 0);
499 USETW(req.wLength, 0);
501 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
503 kprintf("%s: uvscom_set_line_coding: %s\n",
504 device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err));
508 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
509 req.bRequest = UVSCOM_SET_PARAM;
510 USETW(req.wValue, ls);
511 USETW(req.wIndex, 0);
512 USETW(req.wLength, 0);
514 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
516 kprintf("%s: uvscom_set_line_coding: %s\n",
517 device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err));
521 return (USBD_NORMAL_COMPLETION);
525 uvscom_dtr(struct uvscom_softc *sc, int onoff)
527 DPRINTF(("%s: uvscom_dtr: onoff = %d\n",
528 device_get_nameunit(sc->sc_ucom.sc_dev), onoff));
530 if (sc->sc_dtr == onoff)
531 return; /* no change */
536 SET(sc->sc_lcr, UVSCOM_DTR);
538 CLR(sc->sc_lcr, UVSCOM_DTR);
540 uvscom_set_line(sc, sc->sc_lcr);
544 uvscom_rts(struct uvscom_softc *sc, int onoff)
546 DPRINTF(("%s: uvscom_rts: onoff = %d\n",
547 device_get_nameunit(sc->sc_ucom.sc_dev), onoff));
549 if (sc->sc_rts == onoff)
550 return; /* no change */
555 SET(sc->sc_lcr, UVSCOM_RTS);
557 CLR(sc->sc_lcr, UVSCOM_RTS);
559 uvscom_set_line(sc, sc->sc_lcr);
563 uvscom_break(struct uvscom_softc *sc, int onoff)
565 DPRINTF(("%s: uvscom_break: onoff = %d\n",
566 device_get_nameunit(sc->sc_ucom.sc_dev), onoff));
569 uvscom_set_line(sc, SET(sc->sc_lcr, UVSCOM_BREAK));
573 uvscom_set(void *addr, int portno, int reg, int onoff)
575 struct uvscom_softc *sc = addr;
579 uvscom_dtr(sc, onoff);
582 uvscom_rts(sc, onoff);
585 uvscom_break(sc, onoff);
593 uvscom_param(void *addr, int portno, struct termios *t)
595 struct uvscom_softc *sc = addr;
600 DPRINTF(("%s: uvscom_param: sc = %p\n",
601 device_get_nameunit(sc->sc_ucom.sc_dev), sc));
605 switch (t->c_ospeed) {
607 lsp = UVSCOM_SPEED_150BPS;
610 lsp = UVSCOM_SPEED_300BPS;
613 lsp = UVSCOM_SPEED_600BPS;
616 lsp = UVSCOM_SPEED_1200BPS;
619 lsp = UVSCOM_SPEED_2400BPS;
622 lsp = UVSCOM_SPEED_4800BPS;
625 lsp = UVSCOM_SPEED_9600BPS;
628 lsp = UVSCOM_SPEED_19200BPS;
631 lsp = UVSCOM_SPEED_38400BPS;
634 lsp = UVSCOM_SPEED_57600BPS;
637 lsp = UVSCOM_SPEED_115200BPS;
643 if (ISSET(t->c_cflag, CSTOPB))
644 SET(ls, UVSCOM_STOP_BIT_2);
646 SET(ls, UVSCOM_STOP_BIT_1);
648 if (ISSET(t->c_cflag, PARENB)) {
649 if (ISSET(t->c_cflag, PARODD))
650 SET(ls, UVSCOM_PARITY_ODD);
652 SET(ls, UVSCOM_PARITY_EVEN);
654 SET(ls, UVSCOM_PARITY_NONE);
656 switch (ISSET(t->c_cflag, CSIZE)) {
658 SET(ls, UVSCOM_DATA_BIT_5);
661 SET(ls, UVSCOM_DATA_BIT_6);
664 SET(ls, UVSCOM_DATA_BIT_7);
667 SET(ls, UVSCOM_DATA_BIT_8);
673 err = uvscom_set_line_coding(sc, lsp, ls);
677 if (ISSET(t->c_cflag, CRTSCTS)) {
678 err = uvscom_set_crtscts(sc);
687 uvscom_open(void *addr, int portno)
689 struct uvscom_softc *sc = addr;
693 if (sc->sc_ucom.sc_dying)
696 DPRINTF(("uvscom_open: sc = %p\n", sc));
698 if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
699 DPRINTF(("uvscom_open: open interrupt pipe.\n"));
701 sc->sc_usr = 0; /* clear unit status */
703 err = uvscom_readstat(sc);
705 DPRINTF(("%s: uvscom_open: readstat faild\n",
706 device_get_nameunit(sc->sc_ucom.sc_dev)));
710 sc->sc_intr_buf = kmalloc(sc->sc_isize, M_USBDEV, M_WAITOK);
711 err = usbd_open_pipe_intr(sc->sc_ucom.sc_iface,
719 UVSCOM_INTR_INTERVAL);
721 kprintf("%s: cannot open interrupt pipe (addr %d)\n",
722 device_get_nameunit(sc->sc_ucom.sc_dev),
727 DPRINTF(("uvscom_open: did not open interrupt pipe.\n"));
730 if ((sc->sc_usr & UVSCOM_USTAT_MASK) == 0) {
731 /* unit is not ready */
733 for (i = UVSCOM_UNIT_WAIT; i > 0; --i) {
734 tsleep(&err, 0, "uvsop", hz); /* XXX */
735 if (ISSET(sc->sc_usr, UVSCOM_USTAT_MASK))
739 DPRINTF(("%s: unit is not ready\n",
740 device_get_nameunit(sc->sc_ucom.sc_dev)));
744 /* check PC card was inserted */
745 if (ISSET(sc->sc_usr, UVSCOM_NOCARD)) {
746 DPRINTF(("%s: no card\n",
747 device_get_nameunit(sc->sc_ucom.sc_dev)));
756 uvscom_close(void *addr, int portno)
758 struct uvscom_softc *sc = addr;
761 if (sc->sc_ucom.sc_dying)
764 DPRINTF(("uvscom_close: close\n"));
768 if (sc->sc_intr_pipe != NULL) {
769 err = usbd_abort_pipe(sc->sc_intr_pipe);
771 kprintf("%s: abort interrupt pipe failed: %s\n",
772 device_get_nameunit(sc->sc_ucom.sc_dev),
774 err = usbd_close_pipe(sc->sc_intr_pipe);
776 kprintf("%s: close interrupt pipe failed: %s\n",
777 device_get_nameunit(sc->sc_ucom.sc_dev),
779 kfree(sc->sc_intr_buf, M_USBDEV);
780 sc->sc_intr_pipe = NULL;
785 uvscom_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
787 struct uvscom_softc *sc = priv;
788 u_char *buf = sc->sc_intr_buf;
791 if (sc->sc_ucom.sc_dying)
794 if (status != USBD_NORMAL_COMPLETION) {
795 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
798 kprintf("%s: uvscom_intr: abnormal status: %s\n",
799 device_get_nameunit(sc->sc_ucom.sc_dev),
800 usbd_errstr(status));
801 usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
805 DPRINTFN(2, ("%s: uvscom status = %02x %02x\n",
806 device_get_nameunit(sc->sc_ucom.sc_dev), buf[0], buf[1]));
808 sc->sc_lsr = sc->sc_msr = 0;
812 if (ISSET(pstatus, UVSCOM_TXRDY))
813 SET(sc->sc_lsr, ULSR_TXRDY);
814 if (ISSET(pstatus, UVSCOM_RXRDY))
815 SET(sc->sc_lsr, ULSR_RXRDY);
818 if (ISSET(pstatus, UVSCOM_CTS))
819 SET(sc->sc_msr, UMSR_CTS);
820 if (ISSET(pstatus, UVSCOM_DSR))
821 SET(sc->sc_msr, UMSR_DSR);
822 if (ISSET(pstatus, UVSCOM_DCD))
823 SET(sc->sc_msr, UMSR_DCD);
825 ucom_status_change(&sc->sc_ucom);
829 uvscom_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
831 struct uvscom_softc *sc = addr;
841 uvscom_ioctl(void *addr, int portno, u_long cmd, caddr_t data, int flag,
844 struct uvscom_softc *sc = addr;
847 if (sc->sc_ucom.sc_dying)
850 DPRINTF(("uvscom_ioctl: cmd = 0x%08lx\n", cmd));
859 DPRINTF(("uvscom_ioctl: unknown\n"));