umct.c revision 1.32.24.17 1 /* $NetBSD: umct.c,v 1.32.24.17 2016/07/09 20:25:16 skrll Exp $ */
2 /*
3 * Copyright (c) 2001 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /*
32 * MCT USB-RS232 Interface Controller
33 * http://www.mct.com.tw/prod/rs232.html
34 * http://www.dlink.com/products/usb/dsbs25
35 */
36
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: umct.c,v 1.32.24.17 2016/07/09 20:25:16 skrll Exp $");
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/ioctl.h>
44 #include <sys/conf.h>
45 #include <sys/tty.h>
46 #include <sys/file.h>
47 #include <sys/select.h>
48 #include <sys/proc.h>
49 #include <sys/vnode.h>
50 #include <sys/device.h>
51 #include <sys/poll.h>
52
53 #include <dev/usb/usb.h>
54 #include <dev/usb/usbcdc.h>
55
56 #include <dev/usb/usbdi.h>
57 #include <dev/usb/usbdi_util.h>
58 #include <dev/usb/usbdevs.h>
59 #include <dev/usb/usb_quirks.h>
60
61 #include <dev/usb/ucomvar.h>
62 #include <dev/usb/umct.h>
63
64 #ifdef UMCT_DEBUG
65 #define DPRINTFN(n, x) if (umctdebug > (n)) printf x
66 int umctdebug = 0;
67 #else
68 #define DPRINTFN(n, x)
69 #endif
70 #define DPRINTF(x) DPRINTFN(0, x)
71
72 #define UMCT_CONFIG_INDEX 0
73 #define UMCT_IFACE_INDEX 0
74
75 struct umct_softc {
76 device_t sc_dev; /* base device */
77 struct usbd_device *sc_udev; /* USB device */
78 struct usbd_interface *sc_iface; /* interface */
79 int sc_iface_number; /* interface number */
80 uint16_t sc_product;
81
82 int sc_inendpt; /* data in endpoint */
83 struct usbd_pipe *sc_inpipe; /* data in pipe */
84 u_char *sc_inbuf; /* interrupt buffer */
85
86 int sc_intr_number; /* interrupt number */
87 struct usbd_pipe *sc_intr_pipe; /* interrupt pipe */
88 u_char *sc_intr_buf; /* interrupt buffer */
89 int sc_isize;
90
91 usb_cdc_line_state_t sc_line_state; /* current line state */
92 u_char sc_dtr; /* current DTR state */
93 u_char sc_rts; /* current RTS state */
94 u_char sc_break; /* set break */
95
96 u_char sc_status;
97
98 device_t sc_subdev; /* ucom device */
99
100 u_char sc_dying; /* disconnecting */
101
102 u_char sc_lsr; /* Local status register */
103 u_char sc_msr; /* umct status register */
104
105 u_int last_lcr; /* keep lcr register */
106 };
107
108 /*
109 * These are the maximum number of bytes transferred per frame.
110 * The output buffer size cannot be increased due to the size encoding.
111 */
112 #define UMCTIBUFSIZE 256
113 #define UMCTOBUFSIZE 256
114
115 Static void umct_init(struct umct_softc *);
116 Static void umct_set_baudrate(struct umct_softc *, u_int);
117 Static void umct_set_lcr(struct umct_softc *, u_int);
118 Static void umct_intr(struct usbd_xfer *, void *, usbd_status);
119
120 Static void umct_rxintr(struct usbd_xfer *, void *, usbd_status);
121
122 Static void umct_set(void *, int, int, int);
123 Static void umct_dtr(struct umct_softc *, int);
124 Static void umct_rts(struct umct_softc *, int);
125 Static void umct_break(struct umct_softc *, int);
126 Static void umct_set_line_state(struct umct_softc *);
127 Static void umct_get_status(void *, int, u_char *, u_char *);
128 Static int umct_param(void *, int, struct termios *);
129 Static int umct_open(void *, int);
130 Static void umct_close(void *, int);
131
132 struct ucom_methods umct_methods = {
133 .ucom_get_status = umct_get_status,
134 .ucom_set = umct_set,
135 .ucom_param = umct_param,
136 .ucom_ioctl = NULL,
137 .ucom_open = umct_open,
138 .ucom_close = umct_close,
139 .ucom_read = NULL,
140 .ucom_write = NULL,
141 };
142
143 static const struct usb_devno umct_devs[] = {
144 /* MCT USB-232 Interface Products */
145 { USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232 },
146 /* Sitecom USB-232 Products */
147 { USB_VENDOR_MCT, USB_PRODUCT_MCT_SITECOM_USB232 },
148 /* D-Link DU-H3SP USB BAY Hub Products */
149 { USB_VENDOR_MCT, USB_PRODUCT_MCT_DU_H3SP_USB232 },
150 /* BELKIN F5U109 */
151 { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U109 },
152 };
153 #define umct_lookup(v, p) usb_lookup(umct_devs, v, p)
154
155 int umct_match(device_t, cfdata_t, void *);
156 void umct_attach(device_t, device_t, void *);
157 void umct_childdet(device_t, device_t);
158 int umct_detach(device_t, int);
159 int umct_activate(device_t, enum devact);
160 extern struct cfdriver umct_cd;
161 CFATTACH_DECL2_NEW(umct, sizeof(struct umct_softc), umct_match,
162 umct_attach, umct_detach, umct_activate, NULL, umct_childdet);
163
164 int
165 umct_match(device_t parent, cfdata_t match, void *aux)
166 {
167 struct usb_attach_arg *uaa = aux;
168
169 return umct_lookup(uaa->uaa_vendor, uaa->uaa_product) != NULL ?
170 UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
171 }
172
173 void
174 umct_attach(device_t parent, device_t self, void *aux)
175 {
176 struct umct_softc *sc = device_private(self);
177 struct usb_attach_arg *uaa = aux;
178 struct usbd_device *dev = uaa->uaa_device;
179 usb_config_descriptor_t *cdesc;
180 usb_interface_descriptor_t *id;
181 usb_endpoint_descriptor_t *ed;
182
183 char *devinfop;
184 usbd_status err;
185 int i;
186 struct ucom_attach_args ucaa;
187
188 sc->sc_dev = self;
189
190 aprint_naive("\n");
191 aprint_normal("\n");
192
193 devinfop = usbd_devinfo_alloc(dev, 0);
194 aprint_normal_dev(self, "%s\n", devinfop);
195 usbd_devinfo_free(devinfop);
196
197 sc->sc_udev = dev;
198 sc->sc_product = uaa->uaa_product;
199
200 DPRINTF(("\n\numct attach: sc=%p\n", sc));
201
202 /* initialize endpoints */
203 ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1;
204 sc->sc_intr_number = -1;
205 sc->sc_intr_pipe = NULL;
206
207 /* Move the device into the configured state. */
208 err = usbd_set_config_index(dev, UMCT_CONFIG_INDEX, 1);
209 if (err) {
210 aprint_error_dev(self, "failed to set configuration, err=%s\n",
211 usbd_errstr(err));
212 sc->sc_dying = 1;
213 return;
214 }
215
216 /* get the config descriptor */
217 cdesc = usbd_get_config_descriptor(sc->sc_udev);
218
219 if (cdesc == NULL) {
220 aprint_error_dev(self,
221 "failed to get configuration descriptor\n");
222 sc->sc_dying = 1;
223 return;
224 }
225
226 /* get the interface */
227 err = usbd_device2interface_handle(dev, UMCT_IFACE_INDEX,
228 &sc->sc_iface);
229 if (err) {
230 aprint_error_dev(self, "failed to get interface, err=%s\n",
231 usbd_errstr(err));
232 sc->sc_dying = 1;
233 return;
234 }
235
236 /* Find the bulk{in,out} and interrupt endpoints */
237
238 id = usbd_get_interface_descriptor(sc->sc_iface);
239 sc->sc_iface_number = id->bInterfaceNumber;
240
241 for (i = 0; i < id->bNumEndpoints; i++) {
242 ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
243 if (ed == NULL) {
244 aprint_error_dev(self,
245 "no endpoint descriptor for %d\n", i);
246 sc->sc_dying = 1;
247 return;
248 }
249
250 /*
251 * Input is done via an interrupt endpoint, so we handle
252 * the pipe and pass RX characters up to ucom. Since
253 * we can't rely on the endpoint descriptor order, we'll
254 * check the wMaxPacketSize field to differentiate.
255 */
256 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
257 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT &&
258 UGETW(ed->wMaxPacketSize) != 0x2) {
259 sc->sc_inendpt = ed->bEndpointAddress;
260 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
261 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
262 ucaa.ucaa_bulkout = ed->bEndpointAddress;
263 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
264 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
265 sc->sc_intr_number = ed->bEndpointAddress;
266 sc->sc_isize = UGETW(ed->wMaxPacketSize);
267 }
268 }
269
270 if (sc->sc_inendpt == -1) {
271 aprint_error_dev(self, "Could not find data in\n");
272 sc->sc_dying = 1;
273 return;
274 }
275
276 if (ucaa.ucaa_bulkout == -1) {
277 aprint_error_dev(self, "Could not find data bulk out\n");
278 sc->sc_dying = 1;
279 return;
280 }
281
282 if (sc->sc_intr_number == -1) {
283 aprint_error_dev(self, "Could not find interrupt in\n");
284 sc->sc_dying = 1;
285 return;
286 }
287
288 sc->sc_dtr = sc->sc_rts = 0;
289 ucaa.ucaa_portno = UCOM_UNK_PORTNO;
290 /* ucaa_bulkin, ucaa_bulkout set above */
291 ucaa.ucaa_ibufsize = UMCTIBUFSIZE;
292 if (sc->sc_product == USB_PRODUCT_MCT_SITECOM_USB232)
293 ucaa.ucaa_obufsize = 16; /* device is broken */
294 else
295 ucaa.ucaa_obufsize = UMCTOBUFSIZE;
296 ucaa.ucaa_ibufsizepad = UMCTIBUFSIZE;
297 ucaa.ucaa_opkthdrlen = 0;
298 ucaa.ucaa_device = dev;
299 ucaa.ucaa_iface = sc->sc_iface;
300 ucaa.ucaa_methods = &umct_methods;
301 ucaa.ucaa_arg = sc;
302 ucaa.ucaa_info = NULL;
303
304 umct_init(sc);
305
306 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
307
308 DPRINTF(("umct: in=0x%x out=0x%x intr=0x%x\n",
309 ucaa.ucaa_bulkin, ucaa.ucaa_bulkout, sc->sc_intr_number));
310 sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &ucaa,
311 ucomprint, ucomsubmatch);
312
313 return;
314 }
315
316 void
317 umct_childdet(device_t self, device_t child)
318 {
319 struct umct_softc *sc = device_private(self);
320
321 KASSERT(sc->sc_subdev == child);
322 sc->sc_subdev = NULL;
323 }
324
325 int
326 umct_detach(device_t self, int flags)
327 {
328 struct umct_softc *sc = device_private(self);
329 int rv = 0;
330
331 DPRINTF(("umct_detach: sc=%p flags=%d\n", sc, flags));
332
333 if (sc->sc_intr_pipe != NULL) {
334 usbd_abort_pipe(sc->sc_intr_pipe);
335 usbd_close_pipe(sc->sc_intr_pipe);
336 kmem_free(sc->sc_intr_buf, sc->sc_isize);
337 sc->sc_intr_pipe = NULL;
338 }
339
340 sc->sc_dying = 1;
341 if (sc->sc_subdev != NULL)
342 rv = config_detach(sc->sc_subdev, flags);
343
344 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
345
346 return rv;
347 }
348
349 int
350 umct_activate(device_t self, enum devact act)
351 {
352 struct umct_softc *sc = device_private(self);
353
354 switch (act) {
355 case DVACT_DEACTIVATE:
356 sc->sc_dying = 1;
357 return 0;
358 default:
359 return EOPNOTSUPP;
360 }
361 }
362
363 void
364 umct_set_line_state(struct umct_softc *sc)
365 {
366 usb_device_request_t req;
367 uByte ls;
368
369 ls = (sc->sc_dtr ? MCR_DTR : 0) |
370 (sc->sc_rts ? MCR_RTS : 0);
371
372 DPRINTF(("umct_set_line_state: DTR=%d,RTS=%d,ls=%02x\n",
373 sc->sc_dtr, sc->sc_rts, ls));
374
375 req.bmRequestType = UMCT_SET_REQUEST;
376 req.bRequest = REQ_SET_MCR;
377 USETW(req.wValue, 0);
378 USETW(req.wIndex, sc->sc_iface_number);
379 USETW(req.wLength, LENGTH_SET_MCR);
380
381 (void)usbd_do_request(sc->sc_udev, &req, &ls);
382 }
383
384 void
385 umct_set(void *addr, int portno, int reg, int onoff)
386 {
387 struct umct_softc *sc = addr;
388
389 switch (reg) {
390 case UCOM_SET_DTR:
391 umct_dtr(sc, onoff);
392 break;
393 case UCOM_SET_RTS:
394 umct_rts(sc, onoff);
395 break;
396 case UCOM_SET_BREAK:
397 umct_break(sc, onoff);
398 break;
399 default:
400 break;
401 }
402 }
403
404 void
405 umct_dtr(struct umct_softc *sc, int onoff)
406 {
407
408 DPRINTF(("umct_dtr: onoff=%d\n", onoff));
409
410 if (sc->sc_dtr == onoff)
411 return;
412 sc->sc_dtr = onoff;
413
414 umct_set_line_state(sc);
415 }
416
417 void
418 umct_rts(struct umct_softc *sc, int onoff)
419 {
420 DPRINTF(("umct_rts: onoff=%d\n", onoff));
421
422 if (sc->sc_rts == onoff)
423 return;
424 sc->sc_rts = onoff;
425
426 umct_set_line_state(sc);
427 }
428
429 void
430 umct_break(struct umct_softc *sc, int onoff)
431 {
432 DPRINTF(("umct_break: onoff=%d\n", onoff));
433
434 umct_set_lcr(sc, onoff ? sc->last_lcr | LCR_SET_BREAK :
435 sc->last_lcr);
436 }
437
438 void
439 umct_set_lcr(struct umct_softc *sc, u_int data)
440 {
441 usb_device_request_t req;
442 uByte adata;
443
444 adata = data;
445 req.bmRequestType = UMCT_SET_REQUEST;
446 req.bRequest = REQ_SET_LCR;
447 USETW(req.wValue, 0);
448 USETW(req.wIndex, sc->sc_iface_number);
449 USETW(req.wLength, LENGTH_SET_LCR);
450
451 (void)usbd_do_request(sc->sc_udev, &req, &adata); /* XXX should check */
452 }
453
454 void
455 umct_set_baudrate(struct umct_softc *sc, u_int rate)
456 {
457 usb_device_request_t req;
458 uDWord arate;
459 u_int val;
460
461 if (sc->sc_product == USB_PRODUCT_MCT_SITECOM_USB232 ||
462 sc->sc_product == USB_PRODUCT_BELKIN_F5U109) {
463 switch (rate) {
464 case 300: val = 0x01; break;
465 case 600: val = 0x02; break;
466 case 1200: val = 0x03; break;
467 case 2400: val = 0x04; break;
468 case 4800: val = 0x06; break;
469 case 9600: val = 0x08; break;
470 case 19200: val = 0x09; break;
471 case 38400: val = 0x0a; break;
472 case 57600: val = 0x0b; break;
473 case 115200: val = 0x0c; break;
474 default: val = -1; break;
475 }
476 } else {
477 val = UMCT_BAUD_RATE(rate);
478 }
479 USETDW(arate, val);
480
481 req.bmRequestType = UMCT_SET_REQUEST;
482 req.bRequest = REQ_SET_BAUD_RATE;
483 USETW(req.wValue, 0);
484 USETW(req.wIndex, sc->sc_iface_number);
485 USETW(req.wLength, LENGTH_BAUD_RATE);
486
487 (void)usbd_do_request(sc->sc_udev, &req, arate); /* XXX should check */
488 }
489
490 void
491 umct_init(struct umct_softc *sc)
492 {
493 umct_set_baudrate(sc, 9600);
494 umct_set_lcr(sc, LCR_DATA_BITS_8 | LCR_PARITY_NONE | LCR_STOP_BITS_1);
495 }
496
497 int
498 umct_param(void *addr, int portno, struct termios *t)
499 {
500 struct umct_softc *sc = addr;
501 u_int data = 0;
502
503 DPRINTF(("umct_param: sc=%p\n", sc));
504
505 DPRINTF(("umct_param: BAUDRATE=%d\n", t->c_ospeed));
506
507 if (ISSET(t->c_cflag, CSTOPB))
508 data |= LCR_STOP_BITS_2;
509 else
510 data |= LCR_STOP_BITS_1;
511 if (ISSET(t->c_cflag, PARENB)) {
512 if (ISSET(t->c_cflag, PARODD))
513 data |= LCR_PARITY_ODD;
514 else
515 data |= LCR_PARITY_EVEN;
516 } else
517 data |= LCR_PARITY_NONE;
518 switch (ISSET(t->c_cflag, CSIZE)) {
519 case CS5:
520 data |= LCR_DATA_BITS_5;
521 break;
522 case CS6:
523 data |= LCR_DATA_BITS_6;
524 break;
525 case CS7:
526 data |= LCR_DATA_BITS_7;
527 break;
528 case CS8:
529 data |= LCR_DATA_BITS_8;
530 break;
531 }
532
533 umct_set_baudrate(sc, t->c_ospeed);
534
535 sc->last_lcr = data;
536 umct_set_lcr(sc, data);
537
538 return 0;
539 }
540
541 int
542 umct_open(void *addr, int portno)
543 {
544 struct umct_softc *sc = addr;
545 int err, lcr_data;
546
547 if (sc->sc_dying)
548 return EIO;
549
550 DPRINTF(("umct_open: sc=%p\n", sc));
551
552 /* initialize LCR */
553 lcr_data = LCR_DATA_BITS_8 | LCR_PARITY_NONE |
554 LCR_STOP_BITS_1;
555 umct_set_lcr(sc, lcr_data);
556
557 if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
558 sc->sc_status = 0; /* clear status bit */
559 sc->sc_intr_buf = kmem_alloc(sc->sc_isize, KM_SLEEP);
560 err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_intr_number,
561 USBD_SHORT_XFER_OK, &sc->sc_intr_pipe, sc,
562 sc->sc_intr_buf, sc->sc_isize,
563 umct_intr, USBD_DEFAULT_INTERVAL);
564 if (err) {
565 DPRINTF(("%s: cannot open interrupt pipe (%d)\n",
566 device_xname(sc->sc_dev), sc->sc_intr_number));
567 return EIO;
568 }
569 }
570 if (sc->sc_inendpt != -1 && sc->sc_inpipe == NULL) {
571 sc->sc_inbuf = kmem_alloc(UMCTIBUFSIZE, KM_SLEEP);
572 err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_inendpt,
573 USBD_SHORT_XFER_OK, &sc->sc_inpipe, sc, sc->sc_inbuf,
574 UMCTIBUFSIZE, umct_rxintr, USBD_DEFAULT_INTERVAL);
575 if (err) {
576 DPRINTF(("%s: cannot open rx interrupt pipe (%d)\n",
577 device_xname(sc->sc_dev), sc->sc_inendpt));
578 return EIO;
579 }
580 }
581
582 return 0;
583 }
584
585 void
586 umct_close(void *addr, int portno)
587 {
588 struct umct_softc *sc = addr;
589 int err;
590
591 if (sc->sc_dying)
592 return;
593
594 DPRINTF(("umct_close: close\n"));
595
596 if (sc->sc_intr_pipe != NULL) {
597 err = usbd_abort_pipe(sc->sc_intr_pipe);
598 if (err)
599 printf("%s: abort interrupt pipe failed: %s\n",
600 device_xname(sc->sc_dev), usbd_errstr(err));
601 err = usbd_close_pipe(sc->sc_intr_pipe);
602 if (err)
603 printf("%s: close interrupt pipe failed: %s\n",
604 device_xname(sc->sc_dev), usbd_errstr(err));
605 kmem_free(sc->sc_intr_buf, sc->sc_isize);
606 sc->sc_intr_pipe = NULL;
607 }
608 if (sc->sc_inpipe != NULL) {
609 err = usbd_abort_pipe(sc->sc_inpipe);
610 if (err)
611 printf("%s: abort rx interrupt pipe failed: %s\n",
612 device_xname(sc->sc_dev), usbd_errstr(err));
613 err = usbd_close_pipe(sc->sc_inpipe);
614 if (err)
615 printf("%s: close rx interrupt pipe failed: %s\n",
616 device_xname(sc->sc_dev), usbd_errstr(err));
617 kmem_free(sc->sc_inbuf, UMCTIBUFSIZE);
618 sc->sc_inpipe = NULL;
619 }
620 }
621
622 void
623 umct_rxintr(struct usbd_xfer *xfer, void *priv, usbd_status status)
624 {
625 struct umct_softc *sc = priv;
626
627 if (sc->sc_dying)
628 return;
629
630 ucomreadcb(xfer, device_private(sc->sc_subdev), status);
631 }
632
633 void
634 umct_intr(struct usbd_xfer *xfer, void *priv, usbd_status status)
635 {
636 struct umct_softc *sc = priv;
637 u_char *tbuf = sc->sc_intr_buf;
638 u_char mstatus;
639
640 if (sc->sc_dying)
641 return;
642
643 if (status != USBD_NORMAL_COMPLETION) {
644 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
645 return;
646
647 DPRINTF(("%s: abnormal status: %s\n", device_xname(sc->sc_dev),
648 usbd_errstr(status)));
649 usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
650 return;
651 }
652
653 DPRINTF(("%s: umct status = MSR:%02x, LSR:%02x\n",
654 device_xname(sc->sc_dev), tbuf[0],tbuf[1]));
655
656 sc->sc_lsr = sc->sc_msr = 0;
657 mstatus = tbuf[0];
658 if (ISSET(mstatus, MSR_DSR))
659 sc->sc_msr |= UMSR_DSR;
660 if (ISSET(mstatus, MSR_DCD))
661 sc->sc_msr |= UMSR_DCD;
662 ucom_status_change(device_private(sc->sc_subdev));
663 }
664
665 void
666 umct_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
667 {
668 struct umct_softc *sc = addr;
669
670 DPRINTF(("umct_get_status:\n"));
671
672 if (lsr != NULL)
673 *lsr = sc->sc_lsr;
674 if (msr != NULL)
675 *msr = sc->sc_msr;
676 }
677