1 /* $NetBSD: usb/uvscom.c,v 1.1 2002/03/19 15:08:42 augustss Exp $ */
3 * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
6 * Redistribution and use in source and binary forms, with or without
7 * 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 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
31 * uvscom: SUNTAC Slipper U VS-10U driver.
32 * Slipper U is a PC card to USB converter for data communication card
33 * adapter. It supports DDI Pocket's Air H" C@rd, C@rd H" 64, NTT's P-in,
34 * P-in m@ater and various data communication card adapters.
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/malloc.h>
41 #include <sys/fcntl.h>
45 #if defined(__FreeBSD__)
47 #include <sys/ioccom.h>
48 #if __FreeBSD_version >= 500014
49 #include <sys/selinfo.h>
51 #include <sys/select.h>
54 #include <sys/ioctl.h>
55 #include <sys/device.h>
58 #include <sys/vnode.h>
60 #include <sys/sysctl.h>
62 #include <dev/usb/usb.h>
63 #include <dev/usb/usbcdc.h>
65 #include <dev/usb/usbdi.h>
66 #include <dev/usb/usbdi_util.h>
67 #include <dev/usb/usbdevs.h>
68 #include <dev/usb/usb_quirks.h>
70 #include <dev/usb/ucomvar.h>
73 static int uvscomdebug = 0;
74 SYSCTL_NODE(_hw_usb, OID_AUTO, uvscom, CTLFLAG_RW, 0, "USB uvscom");
75 SYSCTL_INT(_hw_usb_uvscom, OID_AUTO, debug, CTLFLAG_RW,
76 &uvscomdebug, 0, "uvscom debug level");
78 #define DPRINTFN(n, x) do { \
79 if (uvscomdebug > (n)) \
83 #define DPRINTFN(n, x)
85 #define DPRINTF(x) DPRINTFN(0, x)
87 #define UVSCOM_MODVER 1 /* module version */
89 #define UVSCOM_CONFIG_INDEX 0
90 #define UVSCOM_IFACE_INDEX 0
92 #define UVSCOM_INTR_INTERVAL 100 /* mS */
94 #define UVSCOM_UNIT_WAIT 5
97 #define UVSCOM_SET_SPEED 0x10
98 #define UVSCOM_LINE_CTL 0x11
99 #define UVSCOM_SET_PARAM 0x12
100 #define UVSCOM_READ_STATUS 0xd0
101 #define UVSCOM_SHUTDOWN 0xe0
103 /* UVSCOM_SET_SPEED parameters */
104 #define UVSCOM_SPEED_150BPS 0x00
105 #define UVSCOM_SPEED_300BPS 0x01
106 #define UVSCOM_SPEED_600BPS 0x02
107 #define UVSCOM_SPEED_1200BPS 0x03
108 #define UVSCOM_SPEED_2400BPS 0x04
109 #define UVSCOM_SPEED_4800BPS 0x05
110 #define UVSCOM_SPEED_9600BPS 0x06
111 #define UVSCOM_SPEED_19200BPS 0x07
112 #define UVSCOM_SPEED_38400BPS 0x08
113 #define UVSCOM_SPEED_57600BPS 0x09
114 #define UVSCOM_SPEED_115200BPS 0x0a
116 /* UVSCOM_LINE_CTL parameters */
117 #define UVSCOM_BREAK 0x40
118 #define UVSCOM_RTS 0x02
119 #define UVSCOM_DTR 0x01
120 #define UVSCOM_LINE_INIT 0x08
122 /* UVSCOM_SET_PARAM parameters */
123 #define UVSCOM_DATA_MASK 0x03
124 #define UVSCOM_DATA_BIT_8 0x03
125 #define UVSCOM_DATA_BIT_7 0x02
126 #define UVSCOM_DATA_BIT_6 0x01
127 #define UVSCOM_DATA_BIT_5 0x00
129 #define UVSCOM_STOP_MASK 0x04
130 #define UVSCOM_STOP_BIT_2 0x04
131 #define UVSCOM_STOP_BIT_1 0x00
133 #define UVSCOM_PARITY_MASK 0x18
134 #define UVSCOM_PARITY_EVEN 0x18
136 #define UVSCOM_PARITY_UNK 0x10
138 #define UVSCOM_PARITY_ODD 0x08
139 #define UVSCOM_PARITY_NONE 0x00
142 #define UVSCOM_TXRDY 0x04
143 #define UVSCOM_RXRDY 0x01
145 #define UVSCOM_DCD 0x08
146 #define UVSCOM_NOCARD 0x04
147 #define UVSCOM_DSR 0x02
148 #define UVSCOM_CTS 0x01
149 #define UVSCOM_USTAT_MASK (UVSCOM_NOCARD | UVSCOM_DSR | UVSCOM_CTS)
151 struct uvscom_softc {
152 struct ucom_softc sc_ucom;
154 int sc_iface_number;/* interface number */
156 usbd_interface_handle sc_intr_iface; /* interrupt interface */
157 int sc_intr_number; /* interrupt number */
158 usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */
159 u_char *sc_intr_buf; /* interrupt buffer */
162 u_char sc_dtr; /* current DTR state */
163 u_char sc_rts; /* current RTS state */
165 u_char sc_lsr; /* Local status register */
166 u_char sc_msr; /* uvscom status register */
168 uint16_t sc_lcr; /* Line control */
169 u_char sc_usr; /* unit status */
173 * These are the maximum number of bytes transferred per frame.
174 * The output buffer size cannot be increased due to the size encoding.
176 #define UVSCOMIBUFSIZE 512
177 #define UVSCOMOBUFSIZE 64
179 Static usbd_status uvscom_shutdown(struct uvscom_softc *);
180 Static usbd_status uvscom_reset(struct uvscom_softc *);
181 Static usbd_status uvscom_set_line_coding(struct uvscom_softc *,
183 Static usbd_status uvscom_set_line(struct uvscom_softc *, uint16_t);
184 Static usbd_status uvscom_set_crtscts(struct uvscom_softc *);
185 Static void uvscom_get_status(void *, int, u_char *, u_char *);
186 Static void uvscom_dtr(struct uvscom_softc *, int);
187 Static void uvscom_rts(struct uvscom_softc *, int);
188 Static void uvscom_break(struct uvscom_softc *, int);
190 Static void uvscom_set(void *, int, int, int);
191 Static void uvscom_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
193 Static int uvscom_ioctl(void *, int, u_long, caddr_t, int, usb_proc_ptr);
195 Static int uvscom_param(void *, int, struct termios *);
196 Static int uvscom_open(void *, int);
197 Static void uvscom_close(void *, int);
199 struct ucom_callback uvscom_callback = {
203 NULL, /* uvscom_ioctl, TODO */
210 static const struct usb_devno uvscom_devs [] = {
211 /* SUNTAC U-Cable type P1 */
212 { USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_PS64P1 },
213 /* SUNTAC Slipper U */
214 { USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_VS10U },
216 #define uvscom_lookup(v, p) usb_lookup(uvscom_devs, v, p)
218 Static device_probe_t uvscom_match;
219 Static device_attach_t uvscom_attach;
220 Static device_detach_t uvscom_detach;
222 Static device_method_t uvscom_methods[] = {
223 /* Device interface */
224 DEVMETHOD(device_probe, uvscom_match),
225 DEVMETHOD(device_attach, uvscom_attach),
226 DEVMETHOD(device_detach, uvscom_detach),
230 Static driver_t uvscom_driver = {
233 sizeof (struct uvscom_softc)
236 DRIVER_MODULE(uvscom, uhub, uvscom_driver, ucom_devclass, usbd_driver_load, 0);
237 MODULE_DEPEND(uvscom, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
238 MODULE_VERSION(uvscom, UVSCOM_MODVER);
242 USB_MATCH_START(uvscom, uaa);
244 if (uaa->iface != NULL)
245 return (UMATCH_NONE);
247 return (uvscom_lookup(uaa->vendor, uaa->product) != NULL ?
248 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
253 USB_ATTACH_START(uvscom, sc, uaa);
254 usbd_device_handle dev = uaa->device;
255 struct ucom_softc *ucom;
256 usb_config_descriptor_t *cdesc;
257 usb_interface_descriptor_t *id;
258 usb_endpoint_descriptor_t *ed;
264 devinfo = malloc(1024, M_USBDEV, M_WAITOK);
267 bzero(sc, sizeof (struct uvscom_softc));
269 usbd_devinfo(dev, 0, devinfo);
270 /* USB_ATTACH_SETUP; */
272 device_set_desc_copy(self, devinfo);
273 /* USB_ATTACH_SETUP; */
276 ucom->sc_iface = uaa->iface;
278 devname = USBDEVNAME(ucom->sc_dev);
279 printf("%s: %s\n", devname, devinfo);
281 DPRINTF(("uvscom attach: sc = %p\n", sc));
283 /* initialize endpoints */
284 ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
285 sc->sc_intr_number = -1;
286 sc->sc_intr_pipe = NULL;
288 /* Move the device into the configured state. */
289 err = usbd_set_config_index(dev, UVSCOM_CONFIG_INDEX, 1);
291 printf("%s: failed to set configuration, err=%s\n",
292 devname, usbd_errstr(err));
296 /* get the config descriptor */
297 cdesc = usbd_get_config_descriptor(ucom->sc_udev);
300 printf("%s: failed to get configuration descriptor\n",
301 USBDEVNAME(ucom->sc_dev));
305 /* get the common interface */
306 err = usbd_device2interface_handle(dev, UVSCOM_IFACE_INDEX,
309 printf("%s: failed to get interface, err=%s\n",
310 devname, usbd_errstr(err));
314 id = usbd_get_interface_descriptor(ucom->sc_iface);
315 sc->sc_iface_number = id->bInterfaceNumber;
318 for (i = 0; i < id->bNumEndpoints; i++) {
319 ed = usbd_interface2endpoint_descriptor(ucom->sc_iface, i);
321 printf("%s: no endpoint descriptor for %d\n",
322 USBDEVNAME(ucom->sc_dev), i);
326 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
327 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
328 ucom->sc_bulkin_no = ed->bEndpointAddress;
329 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
330 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
331 ucom->sc_bulkout_no = ed->bEndpointAddress;
332 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
333 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
334 sc->sc_intr_number = ed->bEndpointAddress;
335 sc->sc_isize = UGETW(ed->wMaxPacketSize);
339 if (ucom->sc_bulkin_no == -1) {
340 printf("%s: Could not find data bulk in\n",
341 USBDEVNAME(ucom->sc_dev));
344 if (ucom->sc_bulkout_no == -1) {
345 printf("%s: Could not find data bulk out\n",
346 USBDEVNAME(ucom->sc_dev));
349 if (sc->sc_intr_number == -1) {
350 printf("%s: Could not find interrupt in\n",
351 USBDEVNAME(ucom->sc_dev));
355 sc->sc_dtr = sc->sc_rts = 0;
356 sc->sc_lcr = UVSCOM_LINE_INIT;
358 ucom->sc_parent = sc;
359 ucom->sc_portno = UCOM_UNK_PORTNO;
360 /* bulkin, bulkout set above */
361 ucom->sc_ibufsize = UVSCOMIBUFSIZE;
362 ucom->sc_obufsize = UVSCOMOBUFSIZE;
363 ucom->sc_ibufsizepad = UVSCOMIBUFSIZE;
364 ucom->sc_opkthdrlen = 0;
365 ucom->sc_callback = &uvscom_callback;
367 err = uvscom_reset(sc);
370 printf("%s: reset failed, %s\n", USBDEVNAME(ucom->sc_dev),
375 DPRINTF(("uvscom: in = 0x%x out = 0x%x intr = 0x%x\n",
376 ucom->sc_bulkin_no, ucom->sc_bulkout_no, sc->sc_intr_number));
378 ucom_attach(&sc->sc_ucom);
380 free(devinfo, M_USBDEV);
381 USB_ATTACH_SUCCESS_RETURN;
385 free(devinfo, M_USBDEV);
386 USB_ATTACH_ERROR_RETURN;
391 USB_DETACH_START(uvscom, sc);
394 DPRINTF(("uvscom_detach: sc = %p\n", sc));
396 sc->sc_ucom.sc_dying = 1;
398 if (sc->sc_intr_pipe != NULL) {
399 usbd_abort_pipe(sc->sc_intr_pipe);
400 usbd_close_pipe(sc->sc_intr_pipe);
401 free(sc->sc_intr_buf, M_USBDEV);
402 sc->sc_intr_pipe = NULL;
405 rv = ucom_detach(&sc->sc_ucom);
411 uvscom_readstat(struct uvscom_softc *sc)
413 usb_device_request_t req;
417 DPRINTF(("%s: send readstat\n", USBDEVNAME(sc->sc_ucom.sc_dev)));
419 req.bmRequestType = UT_READ_VENDOR_DEVICE;
420 req.bRequest = UVSCOM_READ_STATUS;
421 USETW(req.wValue, 0);
422 USETW(req.wIndex, 0);
423 USETW(req.wLength, 2);
425 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, &r);
427 printf("%s: uvscom_readstat: %s\n",
428 USBDEVNAME(sc->sc_ucom.sc_dev), usbd_errstr(err));
432 DPRINTF(("%s: uvscom_readstat: r = %d\n",
433 USBDEVNAME(sc->sc_ucom.sc_dev), r));
435 return (USBD_NORMAL_COMPLETION);
439 uvscom_shutdown(struct uvscom_softc *sc)
441 usb_device_request_t req;
444 DPRINTF(("%s: send shutdown\n", USBDEVNAME(sc->sc_ucom.sc_dev)));
446 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
447 req.bRequest = UVSCOM_SHUTDOWN;
448 USETW(req.wValue, 0);
449 USETW(req.wIndex, 0);
450 USETW(req.wLength, 0);
452 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
454 printf("%s: uvscom_shutdown: %s\n",
455 USBDEVNAME(sc->sc_ucom.sc_dev), usbd_errstr(err));
459 return (USBD_NORMAL_COMPLETION);
463 uvscom_reset(struct uvscom_softc *sc)
465 DPRINTF(("%s: uvscom_reset\n", USBDEVNAME(sc->sc_ucom.sc_dev)));
467 return (USBD_NORMAL_COMPLETION);
471 uvscom_set_crtscts(struct uvscom_softc *sc)
473 DPRINTF(("%s: uvscom_set_crtscts\n", USBDEVNAME(sc->sc_ucom.sc_dev)));
475 return (USBD_NORMAL_COMPLETION);
479 uvscom_set_line(struct uvscom_softc *sc, uint16_t line)
481 usb_device_request_t req;
484 DPRINTF(("%s: uvscom_set_line: %04x\n",
485 USBDEVNAME(sc->sc_ucom.sc_dev), line));
487 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
488 req.bRequest = UVSCOM_LINE_CTL;
489 USETW(req.wValue, line);
490 USETW(req.wIndex, 0);
491 USETW(req.wLength, 0);
493 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
495 printf("%s: uvscom_set_line: %s\n",
496 USBDEVNAME(sc->sc_ucom.sc_dev), usbd_errstr(err));
500 return (USBD_NORMAL_COMPLETION);
504 uvscom_set_line_coding(struct uvscom_softc *sc, uint16_t lsp, uint16_t ls)
506 usb_device_request_t req;
509 DPRINTF(("%s: uvscom_set_line_coding: %02x %02x\n",
510 USBDEVNAME(sc->sc_ucom.sc_dev), lsp, ls));
512 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
513 req.bRequest = UVSCOM_SET_SPEED;
514 USETW(req.wValue, lsp);
515 USETW(req.wIndex, 0);
516 USETW(req.wLength, 0);
518 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
520 printf("%s: uvscom_set_line_coding: %s\n",
521 USBDEVNAME(sc->sc_ucom.sc_dev), usbd_errstr(err));
525 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
526 req.bRequest = UVSCOM_SET_PARAM;
527 USETW(req.wValue, ls);
528 USETW(req.wIndex, 0);
529 USETW(req.wLength, 0);
531 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
533 printf("%s: uvscom_set_line_coding: %s\n",
534 USBDEVNAME(sc->sc_ucom.sc_dev), usbd_errstr(err));
538 return (USBD_NORMAL_COMPLETION);
542 uvscom_dtr(struct uvscom_softc *sc, int onoff)
544 DPRINTF(("%s: uvscom_dtr: onoff = %d\n",
545 USBDEVNAME(sc->sc_ucom.sc_dev), onoff));
547 if (sc->sc_dtr == onoff)
548 return; /* no change */
553 SET(sc->sc_lcr, UVSCOM_DTR);
555 CLR(sc->sc_lcr, UVSCOM_DTR);
557 uvscom_set_line(sc, sc->sc_lcr);
561 uvscom_rts(struct uvscom_softc *sc, int onoff)
563 DPRINTF(("%s: uvscom_rts: onoff = %d\n",
564 USBDEVNAME(sc->sc_ucom.sc_dev), onoff));
566 if (sc->sc_rts == onoff)
567 return; /* no change */
572 SET(sc->sc_lcr, UVSCOM_RTS);
574 CLR(sc->sc_lcr, UVSCOM_RTS);
576 uvscom_set_line(sc, sc->sc_lcr);
580 uvscom_break(struct uvscom_softc *sc, int onoff)
582 DPRINTF(("%s: uvscom_break: onoff = %d\n",
583 USBDEVNAME(sc->sc_ucom.sc_dev), onoff));
586 uvscom_set_line(sc, SET(sc->sc_lcr, UVSCOM_BREAK));
590 uvscom_set(void *addr, int portno, int reg, int onoff)
592 struct uvscom_softc *sc = addr;
596 uvscom_dtr(sc, onoff);
599 uvscom_rts(sc, onoff);
602 uvscom_break(sc, onoff);
610 uvscom_param(void *addr, int portno, struct termios *t)
612 struct uvscom_softc *sc = addr;
617 DPRINTF(("%s: uvscom_param: sc = %p\n",
618 USBDEVNAME(sc->sc_ucom.sc_dev), sc));
622 switch (t->c_ospeed) {
624 lsp = UVSCOM_SPEED_150BPS;
627 lsp = UVSCOM_SPEED_300BPS;
630 lsp = UVSCOM_SPEED_600BPS;
633 lsp = UVSCOM_SPEED_1200BPS;
636 lsp = UVSCOM_SPEED_2400BPS;
639 lsp = UVSCOM_SPEED_4800BPS;
642 lsp = UVSCOM_SPEED_9600BPS;
645 lsp = UVSCOM_SPEED_19200BPS;
648 lsp = UVSCOM_SPEED_38400BPS;
651 lsp = UVSCOM_SPEED_57600BPS;
654 lsp = UVSCOM_SPEED_115200BPS;
660 if (ISSET(t->c_cflag, CSTOPB))
661 SET(ls, UVSCOM_STOP_BIT_2);
663 SET(ls, UVSCOM_STOP_BIT_1);
665 if (ISSET(t->c_cflag, PARENB)) {
666 if (ISSET(t->c_cflag, PARODD))
667 SET(ls, UVSCOM_PARITY_ODD);
669 SET(ls, UVSCOM_PARITY_EVEN);
671 SET(ls, UVSCOM_PARITY_NONE);
673 switch (ISSET(t->c_cflag, CSIZE)) {
675 SET(ls, UVSCOM_DATA_BIT_5);
678 SET(ls, UVSCOM_DATA_BIT_6);
681 SET(ls, UVSCOM_DATA_BIT_7);
684 SET(ls, UVSCOM_DATA_BIT_8);
690 err = uvscom_set_line_coding(sc, lsp, ls);
694 if (ISSET(t->c_cflag, CRTSCTS)) {
695 err = uvscom_set_crtscts(sc);
704 uvscom_open(void *addr, int portno)
706 struct uvscom_softc *sc = addr;
710 if (sc->sc_ucom.sc_dying)
713 DPRINTF(("uvscom_open: sc = %p\n", sc));
715 if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
716 DPRINTF(("uvscom_open: open interrupt pipe.\n"));
718 sc->sc_usr = 0; /* clear unit status */
720 err = uvscom_readstat(sc);
722 DPRINTF(("%s: uvscom_open: readstat faild\n",
723 USBDEVNAME(sc->sc_ucom.sc_dev)));
727 sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
728 err = usbd_open_pipe_intr(sc->sc_ucom.sc_iface,
736 UVSCOM_INTR_INTERVAL);
738 printf("%s: cannot open interrupt pipe (addr %d)\n",
739 USBDEVNAME(sc->sc_ucom.sc_dev),
744 DPRINTF(("uvscom_open: did not open interrupt pipe.\n"));
747 if ((sc->sc_usr & UVSCOM_USTAT_MASK) == 0) {
748 /* unit is not ready */
750 for (i = UVSCOM_UNIT_WAIT; i > 0; --i) {
751 tsleep(&err, TTIPRI, "uvsop", hz); /* XXX */
752 if (ISSET(sc->sc_usr, UVSCOM_USTAT_MASK))
756 DPRINTF(("%s: unit is not ready\n",
757 USBDEVNAME(sc->sc_ucom.sc_dev)));
761 /* check PC card was inserted */
762 if (ISSET(sc->sc_usr, UVSCOM_NOCARD)) {
763 DPRINTF(("%s: no card\n",
764 USBDEVNAME(sc->sc_ucom.sc_dev)));
773 uvscom_close(void *addr, int portno)
775 struct uvscom_softc *sc = addr;
778 if (sc->sc_ucom.sc_dying)
781 DPRINTF(("uvscom_close: close\n"));
785 if (sc->sc_intr_pipe != NULL) {
786 err = usbd_abort_pipe(sc->sc_intr_pipe);
788 printf("%s: abort interrupt pipe failed: %s\n",
789 USBDEVNAME(sc->sc_ucom.sc_dev),
791 err = usbd_close_pipe(sc->sc_intr_pipe);
793 printf("%s: close interrupt pipe failed: %s\n",
794 USBDEVNAME(sc->sc_ucom.sc_dev),
796 free(sc->sc_intr_buf, M_USBDEV);
797 sc->sc_intr_pipe = NULL;
802 uvscom_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
804 struct uvscom_softc *sc = priv;
805 u_char *buf = sc->sc_intr_buf;
808 if (sc->sc_ucom.sc_dying)
811 if (status != USBD_NORMAL_COMPLETION) {
812 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
815 printf("%s: uvscom_intr: abnormal status: %s\n",
816 USBDEVNAME(sc->sc_ucom.sc_dev),
817 usbd_errstr(status));
818 usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
822 DPRINTFN(2, ("%s: uvscom status = %02x %02x\n",
823 USBDEVNAME(sc->sc_ucom.sc_dev), buf[0], buf[1]));
825 sc->sc_lsr = sc->sc_msr = 0;
829 if (ISSET(pstatus, UVSCOM_TXRDY))
830 SET(sc->sc_lsr, ULSR_TXRDY);
831 if (ISSET(pstatus, UVSCOM_RXRDY))
832 SET(sc->sc_lsr, ULSR_RXRDY);
835 if (ISSET(pstatus, UVSCOM_CTS))
836 SET(sc->sc_msr, UMSR_CTS);
837 if (ISSET(pstatus, UVSCOM_DSR))
838 SET(sc->sc_msr, UMSR_DSR);
839 if (ISSET(pstatus, UVSCOM_DCD))
840 SET(sc->sc_msr, UMSR_DCD);
842 ucom_status_change(&sc->sc_ucom);
846 uvscom_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
848 struct uvscom_softc *sc = addr;
858 uvscom_ioctl(void *addr, int portno, u_long cmd, caddr_t data, int flag,
861 struct uvscom_softc *sc = addr;
864 if (sc->sc_ucom.sc_dying)
867 DPRINTF(("uvscom_ioctl: cmd = 0x%08lx\n", cmd));
876 DPRINTF(("uvscom_ioctl: unknown\n"));