FreeBSD kernel usb device Code
uplcom.c
Go to the documentation of this file.
1/* $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $ */
2
3#include <sys/cdefs.h>
4__FBSDID("$FreeBSD$");
5
6/*-
7 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD
8 *
9 * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34/*-
35 * Copyright (c) 2001 The NetBSD Foundation, Inc.
36 * All rights reserved.
37 *
38 * This code is derived from software contributed to The NetBSD Foundation
39 * by Ichiro FUKUHARA (ichiro@ichiro.org).
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
51 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
54 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60 * POSSIBILITY OF SUCH DAMAGE.
61 */
62
63/*
64 * This driver supports several USB-to-RS232 serial adapters driven by
65 * Prolific PL-2303, PL-2303X and probably PL-2303HX USB-to-RS232
66 * bridge chip. The adapters are sold under many different brand
67 * names.
68 *
69 * Datasheets are available at Prolific www site at
70 * http://www.prolific.com.tw. The datasheets don't contain full
71 * programming information for the chip.
72 *
73 * PL-2303HX is probably programmed the same as PL-2303X.
74 *
75 * There are several differences between PL-2303 and PL-2303(H)X.
76 * PL-2303(H)X can do higher bitrate in bulk mode, has _probably_
77 * different command for controlling CRTSCTS and needs special
78 * sequence of commands for initialization which aren't also
79 * documented in the datasheet.
80 */
81
82#include <sys/stdint.h>
83#include <sys/stddef.h>
84#include <sys/param.h>
85#include <sys/queue.h>
86#include <sys/types.h>
87#include <sys/systm.h>
88#include <sys/kernel.h>
89#include <sys/bus.h>
90#include <sys/module.h>
91#include <sys/lock.h>
92#include <sys/mutex.h>
93#include <sys/condvar.h>
94#include <sys/sysctl.h>
95#include <sys/sx.h>
96#include <sys/unistd.h>
97#include <sys/callout.h>
98#include <sys/malloc.h>
99#include <sys/priv.h>
100
101#include <dev/usb/usb.h>
102#include <dev/usb/usbdi.h>
103#include <dev/usb/usbdi_util.h>
104#include <dev/usb/usb_cdc.h>
105#include "usbdevs.h"
106
107#define USB_DEBUG_VAR uplcom_debug
108#include <dev/usb/usb_debug.h>
109#include <dev/usb/usb_process.h>
110
112
113#ifdef USB_DEBUG
114static int uplcom_debug = 0;
115
116static SYSCTL_NODE(_hw_usb, OID_AUTO, uplcom, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
117 "USB uplcom");
118SYSCTL_INT(_hw_usb_uplcom, OID_AUTO, debug, CTLFLAG_RWTUN,
119 &uplcom_debug, 0, "Debug level");
120#endif
121
122#define UPLCOM_MODVER 1 /* module version */
123
124#define UPLCOM_CONFIG_INDEX 0
125#define UPLCOM_IFACE_INDEX 0
126#define UPLCOM_SECOND_IFACE_INDEX 1
127
128#ifndef UPLCOM_INTR_INTERVAL
129#define UPLCOM_INTR_INTERVAL 0 /* default */
130#endif
131
132#define UPLCOM_BULK_BUF_SIZE 1024 /* bytes */
133
134#define UPLCOM_SET_REQUEST 0x01
135#define UPLCOM_SET_REQUEST_PL2303HXN 0x80
136#define UPLCOM_SET_CRTSCTS 0x41
137#define UPLCOM_SET_CRTSCTS_PL2303X 0x61
138#define UPLCOM_SET_CRTSCTS_PL2303HXN 0xFA
139#define UPLCOM_CLEAR_CRTSCTS_PL2303HXN 0xFF
140#define UPLCOM_CRTSCTS_REG_PL2303HXN 0x0A
141#define UPLCOM_STATUS_REG_PL2303HX 0x8080
142#define RSAQ_STATUS_CTS 0x80
143#define RSAQ_STATUS_OVERRUN_ERROR 0x40
144#define RSAQ_STATUS_PARITY_ERROR 0x20
145#define RSAQ_STATUS_FRAME_ERROR 0x10
146#define RSAQ_STATUS_RING 0x08
147#define RSAQ_STATUS_BREAK_ERROR 0x04
148#define RSAQ_STATUS_DSR 0x02
149#define RSAQ_STATUS_DCD 0x01
150
151#define TYPE_PL2303 0
152#define TYPE_PL2303HX 1
153#define TYPE_PL2303HXD 2
154#define TYPE_PL2303HXN 3
155
156#define UPLCOM_STATE_INDEX 8
157
158enum {
163};
164
168
171 struct mtx sc_mtx;
172
173 uint16_t sc_line;
174
175 uint8_t sc_lsr; /* local status register */
176 uint8_t sc_msr; /* uplcom status register */
177 uint8_t sc_chiptype; /* type of chip */
180 uint8_t sc_iface_index[2];
181};
182
183/* prototypes */
184
185static usb_error_t uplcom_reset(struct uplcom_softc *, struct usb_device *);
186static usb_error_t uplcom_pl2303_do(struct usb_device *, uint8_t, uint8_t,
187 uint16_t, uint16_t, uint16_t);
188static int uplcom_pl2303_init(struct usb_device *, uint8_t);
189static void uplcom_free(struct ucom_softc *);
190static void uplcom_cfg_set_dtr(struct ucom_softc *, uint8_t);
191static void uplcom_cfg_set_rts(struct ucom_softc *, uint8_t);
192static void uplcom_cfg_set_break(struct ucom_softc *, uint8_t);
193static int uplcom_pre_param(struct ucom_softc *, struct termios *);
194static void uplcom_cfg_param(struct ucom_softc *, struct termios *);
195static void uplcom_start_read(struct ucom_softc *);
196static void uplcom_stop_read(struct ucom_softc *);
197static void uplcom_start_write(struct ucom_softc *);
198static void uplcom_stop_write(struct ucom_softc *);
199static void uplcom_cfg_get_status(struct ucom_softc *, uint8_t *,
200 uint8_t *);
201static void uplcom_poll(struct ucom_softc *ucom);
202
203static device_probe_t uplcom_probe;
204static device_attach_t uplcom_attach;
205static device_detach_t uplcom_detach;
206static void uplcom_free_softc(struct uplcom_softc *);
207
211
214 .type = UE_BULK,
215 .endpoint = UE_ADDR_ANY,
216 .direction = UE_DIR_OUT,
217 .bufsize = UPLCOM_BULK_BUF_SIZE,
218 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
219 .callback = &uplcom_write_callback,
220 .if_index = 0,
221 },
222
224 .type = UE_BULK,
225 .endpoint = UE_ADDR_ANY,
226 .direction = UE_DIR_IN,
227 .bufsize = UPLCOM_BULK_BUF_SIZE,
228 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
229 .callback = &uplcom_read_callback,
230 .if_index = 0,
231 },
232
234 .type = UE_INTERRUPT,
235 .endpoint = UE_ADDR_ANY,
236 .direction = UE_DIR_IN,
237 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
238 .bufsize = 0, /* use wMaxPacketSize */
239 .callback = &uplcom_intr_callback,
240 .if_index = 1,
241 },
242};
243
246 .ucom_cfg_set_dtr = &uplcom_cfg_set_dtr,
247 .ucom_cfg_set_rts = &uplcom_cfg_set_rts,
248 .ucom_cfg_set_break = &uplcom_cfg_set_break,
249 .ucom_cfg_param = &uplcom_cfg_param,
250 .ucom_pre_param = &uplcom_pre_param,
251 .ucom_start_read = &uplcom_start_read,
252 .ucom_stop_read = &uplcom_stop_read,
253 .ucom_start_write = &uplcom_start_write,
254 .ucom_stop_write = &uplcom_stop_write,
255 .ucom_poll = &uplcom_poll,
256 .ucom_free = &uplcom_free,
257};
258
259#define UPLCOM_DEV(v,p) \
260 { USB_VENDOR(USB_VENDOR_##v), USB_PRODUCT(USB_PRODUCT_##v##_##p) }
261
263 UPLCOM_DEV(ACERP, S81), /* BenQ S81 phone */
264 UPLCOM_DEV(ADLINK, ND6530), /* ADLINK ND-6530 USB-Serial */
265 UPLCOM_DEV(ALCATEL, OT535), /* Alcatel One Touch 535/735 */
266 UPLCOM_DEV(ALCOR, AU9720), /* Alcor AU9720 USB 2.0-RS232 */
267 UPLCOM_DEV(ANCHOR, SERIAL), /* Anchor Serial adapter */
268 UPLCOM_DEV(ATEN, UC232A), /* PLANEX USB-RS232 URS-03 */
269 UPLCOM_DEV(ATEN, UC232B), /* Prolific USB-RS232 Controller D */
270 UPLCOM_DEV(BELKIN, F5U257), /* Belkin F5U257 USB to Serial */
271 UPLCOM_DEV(COREGA, CGUSBRS232R), /* Corega CG-USBRS232R */
272 UPLCOM_DEV(EPSON, CRESSI_EDY), /* Cressi Edy diving computer */
273 UPLCOM_DEV(EPSON, N2ITION3), /* Zeagle N2iTion3 diving computer */
274 UPLCOM_DEV(ELECOM, UCSGT), /* ELECOM UC-SGT Serial Adapter */
275 UPLCOM_DEV(ELECOM, UCSGT0), /* ELECOM UC-SGT Serial Adapter */
276 UPLCOM_DEV(HAL, IMR001), /* HAL Corporation Crossam2+USB */
277 UPLCOM_DEV(HP, LD220), /* HP LD220 POS Display */
278 UPLCOM_DEV(IODATA, USBRSAQ), /* I/O DATA USB-RSAQ */
279 UPLCOM_DEV(IODATA, USBRSAQ5), /* I/O DATA USB-RSAQ5 */
280 UPLCOM_DEV(ITEGNO, WM1080A), /* iTegno WM1080A GSM/GFPRS modem */
281 UPLCOM_DEV(ITEGNO, WM2080A), /* iTegno WM2080A CDMA modem */
282 UPLCOM_DEV(LEADTEK, 9531), /* Leadtek 9531 GPS */
283 UPLCOM_DEV(MICROSOFT, 700WX), /* Microsoft Palm 700WX */
284 UPLCOM_DEV(MOBILEACTION, MA620), /* Mobile Action MA-620 Infrared Adapter */
285 UPLCOM_DEV(NETINDEX, WS002IN), /* Willcom W-S002IN */
286 UPLCOM_DEV(NOKIA2, CA42), /* Nokia CA-42 cable */
287 UPLCOM_DEV(OTI, DKU5), /* OTI DKU-5 cable */
288 UPLCOM_DEV(PANASONIC, TYTP50P6S), /* Panasonic TY-TP50P6-S flat screen */
289 UPLCOM_DEV(PLX, CA42), /* PLX CA-42 clone cable */
290 UPLCOM_DEV(PROLIFIC, ALLTRONIX_GPRS), /* Alltronix ACM003U00 modem */
291 UPLCOM_DEV(PROLIFIC, ALDIGA_AL11U), /* AlDiga AL-11U modem */
292 UPLCOM_DEV(PROLIFIC, DCU11), /* DCU-11 Phone Cable */
293 UPLCOM_DEV(PROLIFIC, HCR331), /* HCR331 Card Reader */
294 UPLCOM_DEV(PROLIFIC, MICROMAX_610U), /* Micromax 610U modem */
295 UPLCOM_DEV(PROLIFIC, MOTOROLA), /* Motorola cable */
296 UPLCOM_DEV(PROLIFIC, PHAROS), /* Prolific Pharos */
297 UPLCOM_DEV(PROLIFIC, PL2303), /* Generic adapter */
298 UPLCOM_DEV(PROLIFIC, PL2303GC), /* Generic adapter (PL2303HXN, type GC) */
299 UPLCOM_DEV(PROLIFIC, PL2303GB), /* Generic adapter (PL2303HXN, type GB) */
300 UPLCOM_DEV(PROLIFIC, PL2303GT), /* Generic adapter (PL2303HXN, type GT) */
301 UPLCOM_DEV(PROLIFIC, PL2303GL), /* Generic adapter (PL2303HXN, type GL) */
302 UPLCOM_DEV(PROLIFIC, PL2303GE), /* Generic adapter (PL2303HXN, type GE) */
303 UPLCOM_DEV(PROLIFIC, PL2303GS), /* Generic adapter (PL2303HXN, type GS) */
304 UPLCOM_DEV(PROLIFIC, RSAQ2), /* I/O DATA USB-RSAQ2 */
305 UPLCOM_DEV(PROLIFIC, RSAQ3), /* I/O DATA USB-RSAQ3 */
306 UPLCOM_DEV(PROLIFIC, UIC_MSR206), /* UIC MSR206 Card Reader */
307 UPLCOM_DEV(PROLIFIC2, PL2303), /* Prolific adapter */
308 UPLCOM_DEV(RADIOSHACK, USBCABLE), /* Radio Shack USB Adapter */
309 UPLCOM_DEV(RATOC, REXUSB60), /* RATOC REX-USB60 */
310 UPLCOM_DEV(SAGEM, USBSERIAL), /* Sagem USB-Serial Controller */
311 UPLCOM_DEV(SAMSUNG, I330), /* Samsung I330 phone cradle */
312 UPLCOM_DEV(SANWA, KB_USB2), /* Sanwa KB-USB2 Multimeter cable */
313 UPLCOM_DEV(SIEMENS3, EF81), /* Siemens EF81 */
314 UPLCOM_DEV(SIEMENS3, SX1), /* Siemens SX1 */
315 UPLCOM_DEV(SIEMENS3, X65), /* Siemens X65 */
316 UPLCOM_DEV(SIEMENS3, X75), /* Siemens X75 */
317 UPLCOM_DEV(SITECOM, SERIAL), /* Sitecom USB to Serial */
318 UPLCOM_DEV(SMART, PL2303), /* SMART Technologies USB to Serial */
319 UPLCOM_DEV(SONY, QN3), /* Sony QN3 phone cable */
320 UPLCOM_DEV(SONYERICSSON, DATAPILOT), /* Sony Ericsson Datapilot */
321 UPLCOM_DEV(SONYERICSSON, DCU10), /* Sony Ericsson DCU-10 Cable */
322 UPLCOM_DEV(SOURCENEXT, KEIKAI8), /* SOURCENEXT KeikaiDenwa 8 */
323 UPLCOM_DEV(SOURCENEXT, KEIKAI8_CHG), /* SOURCENEXT KeikaiDenwa 8 with charger */
324 UPLCOM_DEV(SPEEDDRAGON, MS3303H), /* Speed Dragon USB-Serial */
325 UPLCOM_DEV(SYNTECH, CPT8001C), /* Syntech CPT-8001C Barcode scanner */
326 UPLCOM_DEV(TDK, UHA6400), /* TDK USB-PHS Adapter UHA6400 */
327 UPLCOM_DEV(TDK, UPA9664), /* TDK USB-PHS Adapter UPA9664 */
328 UPLCOM_DEV(TRIPPLITE, U209), /* Tripp-Lite U209-000-R USB to Serial */
329 UPLCOM_DEV(YCCABLE, PL2303), /* YC Cable USB-Serial */
330};
331#undef UPLCOM_DEV
332
333static device_method_t uplcom_methods[] = {
334 DEVMETHOD(device_probe, uplcom_probe),
335 DEVMETHOD(device_attach, uplcom_attach),
336 DEVMETHOD(device_detach, uplcom_detach),
337 DEVMETHOD_END
338};
339
340static devclass_t uplcom_devclass;
341
342static driver_t uplcom_driver = {
343 .name = "uplcom",
344 .methods = uplcom_methods,
345 .size = sizeof(struct uplcom_softc),
346};
347
349MODULE_DEPEND(uplcom, ucom, 1, 1, 1);
350MODULE_DEPEND(uplcom, usb, 1, 1, 1);
353
354static int
355uplcom_probe(device_t dev)
356{
357 struct usb_attach_arg *uaa = device_get_ivars(dev);
358
359 DPRINTFN(11, "\n");
360
361 if (uaa->usb_mode != USB_MODE_HOST) {
362 return (ENXIO);
363 }
365 return (ENXIO);
366 }
367 if (uaa->info.bIfaceIndex != UPLCOM_IFACE_INDEX) {
368 return (ENXIO);
369 }
370 return (usbd_lookup_id_by_uaa(uplcom_devs, sizeof(uplcom_devs), uaa));
371}
372
373static int
374uplcom_attach(device_t dev)
375{
376 struct usb_attach_arg *uaa = device_get_ivars(dev);
377 struct uplcom_softc *sc = device_get_softc(dev);
378 struct usb_interface *iface;
380 struct usb_device_descriptor *dd;
381 int error;
382
383 struct usb_device_request req;
384 usb_error_t err;
385 uint8_t buf[4];
386
387 DPRINTFN(11, "\n");
388
390 mtx_init(&sc->sc_mtx, "uplcom", NULL, MTX_DEF);
392
393 DPRINTF("sc = %p\n", sc);
394
395 sc->sc_udev = uaa->device;
396
398
399 switch (UGETW(dd->bcdDevice)) {
400 case 0x0300:
402 /* or TA, that is HX with external crystal */
403 break;
404 case 0x0400:
406 /* or EA, that is HXD with ESD protection */
407 /* or RA, that has internal voltage level converter that works only up to 1Mbaud (!) */
408 break;
409 case 0x0500:
411 /* in fact it's TB, that is HXD with external crystal */
412 break;
413 default:
414 /* NOTE: I have no info about the bcdDevice for the base PL2303 (up to 1.2Mbaud,
415 only fixed rates) and for PL2303SA (8-pin chip, up to 115200 baud */
416 /* Determine the chip type. This algorithm is taken from Linux. */
417 if (dd->bDeviceClass == 0x02)
419 else if (dd->bMaxPacketSize == 0x40)
421 else
423 break;
424 }
425
426 /*
427 * The new chip revision PL2303HXN is only compatible with the new
428 * UPLCOM_SET_REQUEST_PL2303HXN command. Issuing the old command
429 * UPLCOM_SET_REQUEST to the new chip raises an error. Thus, PL2303HX
430 * and PL2303HXN can be distinguished by issuing an old-style request
431 * (on a status register) to the new chip and checking the error.
432 */
433 if (sc->sc_chiptype == TYPE_PL2303HX) {
434 req.bmRequestType = UT_READ_VENDOR_DEVICE;
435 req.bRequest = UPLCOM_SET_REQUEST;
437 req.wIndex[0] = sc->sc_data_iface_no;
438 req.wIndex[1] = 0;
439 USETW(req.wLength, 1);
440 err = usbd_do_request(sc->sc_udev, NULL, &req, buf);
441 if (err)
443 }
444
445 switch (sc->sc_chiptype) {
446 case TYPE_PL2303:
447 DPRINTF("chiptype: 2303\n");
448 break;
449 case TYPE_PL2303HX:
450 DPRINTF("chiptype: 2303HX/TA\n");
451 break;
452 case TYPE_PL2303HXN:
453 DPRINTF("chiptype: 2303HXN\n");
454 break;
455 case TYPE_PL2303HXD:
456 DPRINTF("chiptype: 2303HXD/TB/RA/EA\n");
457 break;
458 default:
459 DPRINTF("chiptype: unknown %d\n", sc->sc_chiptype);
460 break;
461 }
462
463 /*
464 * USB-RSAQ1 has two interface
465 *
466 * USB-RSAQ1 | USB-RSAQ2
467 * -----------------+-----------------
468 * Interface 0 |Interface 0
469 * Interrupt(0x81) | Interrupt(0x81)
470 * -----------------+ BulkIN(0x02)
471 * Interface 1 | BulkOUT(0x83)
472 * BulkIN(0x02) |
473 * BulkOUT(0x83) |
474 */
475
478
480 if (iface) {
482 if (id == NULL) {
483 device_printf(dev, "no interface descriptor (2)\n");
484 goto detach;
485 }
486 sc->sc_data_iface_no = id->bInterfaceNumber;
490 } else {
493 }
494
497 UPLCOM_N_TRANSFER, sc, &sc->sc_mtx);
498 if (error) {
499 DPRINTF("one or more missing USB endpoints, "
500 "error=%s\n", usbd_errstr(error));
501 goto detach;
502 }
503 error = uplcom_reset(sc, uaa->device);
504 if (error) {
505 device_printf(dev, "reset failed, error=%s\n",
507 goto detach;
508 }
509
510 if (sc->sc_chiptype == TYPE_PL2303) {
511 /* HX variants seem to lock up after a clear stall request. */
512 mtx_lock(&sc->sc_mtx);
515 mtx_unlock(&sc->sc_mtx);
516 } else if (sc->sc_chiptype == TYPE_PL2303HX ||
518 /* reset upstream data pipes */
520 UPLCOM_SET_REQUEST, 8, 0, 0) ||
522 UPLCOM_SET_REQUEST, 9, 0, 0)) {
523 goto detach;
524 }
525 } else if (sc->sc_chiptype == TYPE_PL2303HXN) {
526 /* reset upstream data pipes */
528 UPLCOM_SET_REQUEST_PL2303HXN, 0x07, 0x03, 0)) {
529 goto detach;
530 }
531 }
532
533 error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
534 &uplcom_callback, &sc->sc_mtx);
535 if (error) {
536 goto detach;
537 }
538 /*
539 * do the initialization during attach so that the system does not
540 * sleep during open:
541 */
542 if (uplcom_pl2303_init(uaa->device, sc->sc_chiptype)) {
543 device_printf(dev, "init failed\n");
544 goto detach;
545 }
547
548 return (0);
549
550detach:
552 return (ENXIO);
553}
554
555static int
556uplcom_detach(device_t dev)
557{
558 struct uplcom_softc *sc = device_get_softc(dev);
559
560 DPRINTF("sc=%p\n", sc);
561
564
565 device_claim_softc(dev);
566
568
569 return (0);
570}
571
573
574static void
576{
577 if (ucom_unref(&sc->sc_super_ucom)) {
578 mtx_destroy(&sc->sc_mtx);
579 device_free_softc(sc);
580 }
581}
582
583static void
585{
587}
588
589static usb_error_t
590uplcom_reset(struct uplcom_softc *sc, struct usb_device *udev)
591{
592 struct usb_device_request req;
593
594 if (sc->sc_chiptype == TYPE_PL2303HXN) {
595 /* PL2303HXN doesn't need this reset sequence */
596 return (0);
597 }
598
599 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
600 req.bRequest = UPLCOM_SET_REQUEST;
601 USETW(req.wValue, 0);
602 req.wIndex[0] = sc->sc_data_iface_no;
603 req.wIndex[1] = 0;
604 USETW(req.wLength, 0);
605
606 return (usbd_do_request(udev, NULL, &req, NULL));
607}
608
609static usb_error_t
610uplcom_pl2303_do(struct usb_device *udev, uint8_t req_type, uint8_t request,
611 uint16_t value, uint16_t index, uint16_t length)
612{
613 struct usb_device_request req;
614 usb_error_t err;
615 uint8_t buf[4];
616
617 req.bmRequestType = req_type;
618 req.bRequest = request;
619 USETW(req.wValue, value);
620 USETW(req.wIndex, index);
621 USETW(req.wLength, length);
622
623 err = usbd_do_request(udev, NULL, &req, buf);
624 if (err) {
625 DPRINTF("error=%s\n", usbd_errstr(err));
626 return (1);
627 }
628 return (0);
629}
630
631static int
632uplcom_pl2303_init(struct usb_device *udev, uint8_t chiptype)
633{
634 int err;
635
636 if (chiptype == TYPE_PL2303HXN) {
637 /* PL2303HXN doesn't need this initialization sequence */
638 return (0);
639 }
640
651 return (EIO);
652
653 if (chiptype != TYPE_PL2303)
655 else
657 if (err)
658 return (EIO);
659
660 return (0);
661}
662
663static void
664uplcom_cfg_set_dtr(struct ucom_softc *ucom, uint8_t onoff)
665{
666 struct uplcom_softc *sc = ucom->sc_parent;
667 struct usb_device_request req;
668
669 DPRINTF("onoff = %d\n", onoff);
670
671 if (onoff)
672 sc->sc_line |= UCDC_LINE_DTR;
673 else
674 sc->sc_line &= ~UCDC_LINE_DTR;
675
676 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
678 USETW(req.wValue, sc->sc_line);
679 req.wIndex[0] = sc->sc_data_iface_no;
680 req.wIndex[1] = 0;
681 USETW(req.wLength, 0);
682
684 &req, NULL, 0, 1000);
685}
686
687static void
688uplcom_cfg_set_rts(struct ucom_softc *ucom, uint8_t onoff)
689{
690 struct uplcom_softc *sc = ucom->sc_parent;
691 struct usb_device_request req;
692
693 DPRINTF("onoff = %d\n", onoff);
694
695 if (onoff)
696 sc->sc_line |= UCDC_LINE_RTS;
697 else
698 sc->sc_line &= ~UCDC_LINE_RTS;
699
700 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
702 USETW(req.wValue, sc->sc_line);
703 req.wIndex[0] = sc->sc_data_iface_no;
704 req.wIndex[1] = 0;
705 USETW(req.wLength, 0);
706
708 &req, NULL, 0, 1000);
709}
710
711static void
712uplcom_cfg_set_break(struct ucom_softc *ucom, uint8_t onoff)
713{
714 struct uplcom_softc *sc = ucom->sc_parent;
715 struct usb_device_request req;
716 uint16_t temp;
717
718 DPRINTF("onoff = %d\n", onoff);
719
720 temp = (onoff ? UCDC_BREAK_ON : UCDC_BREAK_OFF);
721
722 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
723 req.bRequest = UCDC_SEND_BREAK;
724 USETW(req.wValue, temp);
725 req.wIndex[0] = sc->sc_data_iface_no;
726 req.wIndex[1] = 0;
727 USETW(req.wLength, 0);
728
730 &req, NULL, 0, 1000);
731}
732
733/*
734 * NOTE: These baud rates are officially supported, they can be written
735 * directly into dwDTERate register.
736 *
737 * Free baudrate setting is not supported by the base PL2303, and on
738 * other models it requires writing a divisor value to dwDTERate instead
739 * of the raw baudrate. The formula for divisor calculation is not published
740 * by the vendor, so it is speculative, though the official product homepage
741 * refers to the Linux module source as a reference implementation.
742 */
743static const uint32_t uplcom_rates[] = {
744 /*
745 * Basic 'standard' speed rates, supported by all models
746 * NOTE: 900 and 56000 actually works as well
747 */
748 75, 150, 300, 600, 900, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 14400,
749 19200, 28800, 38400, 56000, 57600, 115200,
750 /*
751 * Advanced speed rates up to 6Mbs, supported by HX/TA and HXD/TB/EA/RA
752 * NOTE: regardless of the spec, 256000 does not work
753 */
754 128000, 134400, 161280, 201600, 230400, 268800, 403200, 460800, 614400,
755 806400, 921600, 1228800, 2457600, 3000000, 6000000,
756 /*
757 * Advanced speed rates up to 12, supported by HXD/TB/EA/RA
758 */
759 12000000
760};
761
762#define N_UPLCOM_RATES nitems(uplcom_rates)
763
764static int
765uplcom_baud_supported(unsigned int speed)
766{
767 int i;
768 for (i = 0; i < N_UPLCOM_RATES; i++) {
769 if (uplcom_rates[i] == speed)
770 return 1;
771 }
772 return 0;
773}
774
775static int
776uplcom_pre_param(struct ucom_softc *ucom, struct termios *t)
777{
778 struct uplcom_softc *sc = ucom->sc_parent;
779
780 DPRINTF("\n");
781
791 /* accept raw divisor data, if someone wants to do the math in user domain */
792 if (t->c_ospeed & 0x80000000)
793 return 0;
794 switch (sc->sc_chiptype) {
795 case TYPE_PL2303HXN:
796 if (t->c_ospeed <= 12000000)
797 return (0);
798 break;
799 case TYPE_PL2303HXD:
800 if (t->c_ospeed <= 12000000)
801 return (0);
802 break;
803 case TYPE_PL2303HX:
804 if (t->c_ospeed <= 6000000)
805 return (0);
806 break;
807 default:
808 if (uplcom_baud_supported(t->c_ospeed))
809 return (0);
810 break;
811 }
812
813 DPRINTF("uplcom_param: bad baud rate (%d)\n", t->c_ospeed);
814 return (EIO);
815}
816
817static unsigned int
818uplcom_encode_baud_rate_divisor(uint8_t *buf, unsigned int baud)
819{
820 unsigned int baseline, mantissa, exponent;
821
822 /* Determine the baud rate divisor. This algorithm is taken from Linux. */
823 /*
824 * Apparently the formula is:
825 * baudrate = baseline / (mantissa * 4^exponent)
826 * where
827 * mantissa = buf[8:0]
828 * exponent = buf[11:9]
829 */
830 if (baud == 0)
831 baud = 1;
832 baseline = 383385600;
833 mantissa = baseline / baud;
834 if (mantissa == 0)
835 mantissa = 1;
836 exponent = 0;
837 while (mantissa >= 512) {
838 if (exponent < 7) {
839 mantissa >>= 2; /* divide by 4 */
840 exponent++;
841 } else {
842 /* Exponent is maxed. Trim mantissa and leave. This gives approx. 45.8 baud */
843 mantissa = 511;
844 break;
845 }
846 }
847
848 buf[3] = 0x80;
849 buf[2] = 0;
850 buf[1] = exponent << 1 | mantissa >> 8;
851 buf[0] = mantissa & 0xff;
852
853 /* Calculate and return the exact baud rate. */
854 baud = (baseline / mantissa) >> (exponent << 1);
855 DPRINTF("real baud rate will be %u\n", baud);
856
857 return baud;
858}
859static void
860uplcom_cfg_param(struct ucom_softc *ucom, struct termios *t)
861{
862 struct uplcom_softc *sc = ucom->sc_parent;
863 struct usb_cdc_line_state ls;
864 struct usb_device_request req;
865
866 DPRINTF("sc = %p\n", sc);
867
868 memset(&ls, 0, sizeof(ls));
869
870 /*
871 * NOTE: If unsupported baud rates are set directly, the PL2303* uses 9600 baud.
872 */
873 if ((t->c_ospeed & 0x80000000) || uplcom_baud_supported(t->c_ospeed))
874 USETDW(ls.dwDTERate, t->c_ospeed);
875 else
876 t->c_ospeed = uplcom_encode_baud_rate_divisor((uint8_t*)&ls.dwDTERate, t->c_ospeed);
877
878 if (t->c_cflag & CSTOPB) {
879 if ((t->c_cflag & CSIZE) == CS5) {
880 /*
881 * NOTE: Comply with "real" UARTs / RS232:
882 * use 1.5 instead of 2 stop bits with 5 data bits
883 */
885 } else {
887 }
888 } else {
890 }
891
892 if (t->c_cflag & PARENB) {
893 if (t->c_cflag & PARODD) {
895 } else {
897 }
898 } else {
900 }
901
902 switch (t->c_cflag & CSIZE) {
903 case CS5:
904 ls.bDataBits = 5;
905 break;
906 case CS6:
907 ls.bDataBits = 6;
908 break;
909 case CS7:
910 ls.bDataBits = 7;
911 break;
912 case CS8:
913 ls.bDataBits = 8;
914 break;
915 }
916
917 DPRINTF("rate=0x%08x fmt=%d parity=%d bits=%d\n",
919 ls.bParityType, ls.bDataBits);
920
921 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
922 req.bRequest = UCDC_SET_LINE_CODING;
923 USETW(req.wValue, 0);
924 req.wIndex[0] = sc->sc_data_iface_no;
925 req.wIndex[1] = 0;
927
929 &req, &ls, 0, 1000);
930
931 if (t->c_cflag & CRTSCTS) {
932 DPRINTF("crtscts = on\n");
933
934 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
935 if (sc->sc_chiptype == TYPE_PL2303HXN) {
939 } else {
940 req.bRequest = UPLCOM_SET_REQUEST;
941 USETW(req.wValue, 0);
942 if (sc->sc_chiptype != TYPE_PL2303)
944 else
946 }
947 USETW(req.wLength, 0);
948
950 &req, NULL, 0, 1000);
951 } else {
952 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
953 if (sc->sc_chiptype == TYPE_PL2303HXN) {
957 }
958 else {
959 req.bRequest = UPLCOM_SET_REQUEST;
960 USETW(req.wValue, 0);
961 USETW(req.wIndex, 0);
962 }
963 USETW(req.wLength, 0);
965 &req, NULL, 0, 1000);
966 }
967}
968
969static void
971{
972 struct uplcom_softc *sc = ucom->sc_parent;
973
974 /* start interrupt endpoint */
976
977 /* start read endpoint */
979}
980
981static void
983{
984 struct uplcom_softc *sc = ucom->sc_parent;
985
986 /* stop interrupt endpoint */
988
989 /* stop read endpoint */
991}
992
993static void
995{
996 struct uplcom_softc *sc = ucom->sc_parent;
997
999}
1000
1001static void
1003{
1004 struct uplcom_softc *sc = ucom->sc_parent;
1005
1007}
1008
1009static void
1010uplcom_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr)
1011{
1012 struct uplcom_softc *sc = ucom->sc_parent;
1013
1014 DPRINTF("\n");
1015
1016 *lsr = sc->sc_lsr;
1017 *msr = sc->sc_msr;
1018}
1019
1020static void
1022{
1023 struct uplcom_softc *sc = usbd_xfer_softc(xfer);
1024 struct usb_page_cache *pc;
1025 uint8_t buf[9];
1026 int actlen;
1027
1028 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
1029
1030 switch (USB_GET_STATE(xfer)) {
1031 case USB_ST_TRANSFERRED:
1032
1033 DPRINTF("actlen = %u\n", actlen);
1034
1035 if (actlen >= 9) {
1036 pc = usbd_xfer_get_frame(xfer, 0);
1037 usbd_copy_out(pc, 0, buf, sizeof(buf));
1038
1039 DPRINTF("status = 0x%02x\n", buf[UPLCOM_STATE_INDEX]);
1040
1041 sc->sc_lsr = 0;
1042 sc->sc_msr = 0;
1043
1045 sc->sc_msr |= SER_CTS;
1046 }
1048 sc->sc_lsr |= ULSR_OE;
1049 }
1051 sc->sc_lsr |= ULSR_PE;
1052 }
1054 sc->sc_lsr |= ULSR_FE;
1055 }
1057 sc->sc_msr |= SER_RI;
1058 }
1060 sc->sc_lsr |= ULSR_BI;
1061 }
1063 sc->sc_msr |= SER_DSR;
1064 }
1066 sc->sc_msr |= SER_DCD;
1067 }
1069 }
1070 case USB_ST_SETUP:
1071tr_setup:
1074 return;
1075
1076 default: /* Error */
1077 if (error != USB_ERR_CANCELLED) {
1078 /* try to clear stall first */
1079 usbd_xfer_set_stall(xfer);
1080 goto tr_setup;
1081 }
1082 return;
1083 }
1084}
1085
1086static void
1088{
1089 struct uplcom_softc *sc = usbd_xfer_softc(xfer);
1090 struct usb_page_cache *pc;
1091 uint32_t actlen;
1092
1093 switch (USB_GET_STATE(xfer)) {
1094 case USB_ST_SETUP:
1095 case USB_ST_TRANSFERRED:
1096tr_setup:
1097 pc = usbd_xfer_get_frame(xfer, 0);
1098 if (ucom_get_data(&sc->sc_ucom, pc, 0,
1099 UPLCOM_BULK_BUF_SIZE, &actlen)) {
1100 DPRINTF("actlen = %d\n", actlen);
1101
1102 usbd_xfer_set_frame_len(xfer, 0, actlen);
1104 }
1105 return;
1106
1107 default: /* Error */
1108 if (error != USB_ERR_CANCELLED) {
1109 /* try to clear stall first */
1110 usbd_xfer_set_stall(xfer);
1111 goto tr_setup;
1112 }
1113 return;
1114 }
1115}
1116
1117static void
1119{
1120 struct uplcom_softc *sc = usbd_xfer_softc(xfer);
1121 struct usb_page_cache *pc;
1122 int actlen;
1123
1124 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
1125
1126 switch (USB_GET_STATE(xfer)) {
1127 case USB_ST_TRANSFERRED:
1128 pc = usbd_xfer_get_frame(xfer, 0);
1129 ucom_put_data(&sc->sc_ucom, pc, 0, actlen);
1130
1131 case USB_ST_SETUP:
1132tr_setup:
1135 return;
1136
1137 default: /* Error */
1138 if (error != USB_ERR_CANCELLED) {
1139 /* try to clear stall first */
1140 usbd_xfer_set_stall(xfer);
1141 goto tr_setup;
1142 }
1143 return;
1144 }
1145}
1146
1147static void
1149{
1150 struct uplcom_softc *sc = ucom->sc_parent;
1152}
static int debug
Definition: cfumass.c:73
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
struct @109 error
uint8_t id
Definition: if_usievar.h:4
uint32_t value
u_int index
device_t dev
void(* ucom_cfg_get_status)(struct ucom_softc *, uint8_t *plsr, uint8_t *pmsr)
Definition: usb_serial.h:90
void * sc_parent
Definition: usb_serial.h:170
struct ucom_super_softc sc_super_ucom
Definition: uplcom.c:166
uint16_t sc_line
Definition: uplcom.c:173
struct usb_device * sc_udev
Definition: uplcom.c:170
uint8_t sc_iface_index[2]
Definition: uplcom.c:180
uint8_t sc_chiptype
Definition: uplcom.c:177
uint8_t sc_msr
Definition: uplcom.c:176
uint8_t sc_ctrl_iface_no
Definition: uplcom.c:178
struct usb_xfer * sc_xfer[UPLCOM_N_TRANSFER]
Definition: uplcom.c:169
struct mtx sc_mtx
Definition: uplcom.c:171
struct ucom_softc sc_ucom
Definition: uplcom.c:167
uint8_t sc_data_iface_no
Definition: uplcom.c:179
uint8_t sc_lsr
Definition: uplcom.c:175
enum usb_hc_mode usb_mode
Definition: usbdi.h:432
struct usbd_lookup_info info
Definition: usbdi.h:426
struct usb_device * device
Definition: usbdi.h:430
uDWord dwDTERate
Definition: usb_cdc.h:129
uint8_t type
Definition: usbdi.h:238
uByte bMaxPacketSize
Definition: usb.h:299
uByte bDeviceClass
Definition: usb.h:296
uint8_t bIfaceNum
Definition: usbdi.h:418
uint8_t bIfaceIndex
Definition: usbdi.h:417
uint8_t bConfigIndex
Definition: usbdi.h:419
#define DPRINTF(...)
Definition: umass.c:179
#define RSAQ_STATUS_BREAK_ERROR
Definition: uplcom.c:147
static usb_callback_t uplcom_intr_callback
Definition: uplcom.c:208
static driver_t uplcom_driver
Definition: uplcom.c:342
#define TYPE_PL2303HX
Definition: uplcom.c:152
static unsigned int uplcom_encode_baud_rate_divisor(uint8_t *buf, unsigned int baud)
Definition: uplcom.c:818
static void uplcom_poll(struct ucom_softc *ucom)
Definition: uplcom.c:1148
static const struct usb_config uplcom_config_data[UPLCOM_N_TRANSFER]
Definition: uplcom.c:212
static int uplcom_pre_param(struct ucom_softc *, struct termios *)
Definition: uplcom.c:776
#define UPLCOM_STATE_INDEX
Definition: uplcom.c:156
static int uplcom_pl2303_init(struct usb_device *, uint8_t)
Definition: uplcom.c:632
static void uplcom_start_write(struct ucom_softc *)
Definition: uplcom.c:994
#define UPLCOM_CONFIG_INDEX
Definition: uplcom.c:124
#define RSAQ_STATUS_OVERRUN_ERROR
Definition: uplcom.c:143
static void uplcom_stop_read(struct ucom_softc *)
Definition: uplcom.c:982
#define UPLCOM_DEV(v, p)
Definition: uplcom.c:259
static void uplcom_cfg_set_rts(struct ucom_softc *, uint8_t)
Definition: uplcom.c:688
#define UPLCOM_SET_CRTSCTS_PL2303X
Definition: uplcom.c:137
static device_method_t uplcom_methods[]
Definition: uplcom.c:333
#define UPLCOM_BULK_BUF_SIZE
Definition: uplcom.c:132
static struct ucom_callback uplcom_callback
Definition: uplcom.c:244
@ UPLCOM_INTR_DT_RD
Definition: uplcom.c:161
@ UPLCOM_N_TRANSFER
Definition: uplcom.c:162
@ UPLCOM_BULK_DT_RD
Definition: uplcom.c:160
@ UPLCOM_BULK_DT_WR
Definition: uplcom.c:159
#define TYPE_PL2303HXD
Definition: uplcom.c:153
#define UPLCOM_CRTSCTS_REG_PL2303HXN
Definition: uplcom.c:140
#define UPLCOM_SET_CRTSCTS_PL2303HXN
Definition: uplcom.c:138
DRIVER_MODULE(uplcom, uhub, uplcom_driver, uplcom_devclass, NULL, 0)
static usb_callback_t uplcom_read_callback
Definition: uplcom.c:210
static const STRUCT_USB_HOST_ID uplcom_devs[]
Definition: uplcom.c:262
#define UPLCOM_IFACE_INDEX
Definition: uplcom.c:125
static devclass_t uplcom_devclass
Definition: uplcom.c:340
static void uplcom_free_softc(struct uplcom_softc *)
Definition: uplcom.c:575
static void uplcom_stop_write(struct ucom_softc *)
Definition: uplcom.c:1002
static usb_error_t uplcom_reset(struct uplcom_softc *, struct usb_device *)
Definition: uplcom.c:590
#define UPLCOM_STATUS_REG_PL2303HX
Definition: uplcom.c:141
__FBSDID("$FreeBSD$")
MODULE_VERSION(uplcom, UPLCOM_MODVER)
static device_probe_t uplcom_probe
Definition: uplcom.c:203
static void uplcom_cfg_set_break(struct ucom_softc *, uint8_t)
Definition: uplcom.c:712
MODULE_DEPEND(uplcom, ucom, 1, 1, 1)
#define RSAQ_STATUS_DSR
Definition: uplcom.c:148
#define N_UPLCOM_RATES
Definition: uplcom.c:762
USB_PNP_HOST_INFO(uplcom_devs)
static void uplcom_free(struct ucom_softc *)
Definition: uplcom.c:584
#define UPLCOM_SET_CRTSCTS
Definition: uplcom.c:136
static usb_error_t uplcom_pl2303_do(struct usb_device *, uint8_t, uint8_t, uint16_t, uint16_t, uint16_t)
Definition: uplcom.c:610
static usb_callback_t uplcom_write_callback
Definition: uplcom.c:209
static device_detach_t uplcom_detach
Definition: uplcom.c:205
static int uplcom_baud_supported(unsigned int speed)
Definition: uplcom.c:765
#define RSAQ_STATUS_FRAME_ERROR
Definition: uplcom.c:145
#define TYPE_PL2303HXN
Definition: uplcom.c:154
#define RSAQ_STATUS_DCD
Definition: uplcom.c:149
#define RSAQ_STATUS_CTS
Definition: uplcom.c:142
#define RSAQ_STATUS_RING
Definition: uplcom.c:146
static void uplcom_start_read(struct ucom_softc *)
Definition: uplcom.c:970
#define UPLCOM_CLEAR_CRTSCTS_PL2303HXN
Definition: uplcom.c:139
static void uplcom_cfg_set_dtr(struct ucom_softc *, uint8_t)
Definition: uplcom.c:664
#define UPLCOM_SET_REQUEST
Definition: uplcom.c:134
static void uplcom_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *)
Definition: uplcom.c:1010
#define UPLCOM_SECOND_IFACE_INDEX
Definition: uplcom.c:126
static const uint32_t uplcom_rates[]
Definition: uplcom.c:743
static device_attach_t uplcom_attach
Definition: uplcom.c:204
#define RSAQ_STATUS_PARITY_ERROR
Definition: uplcom.c:144
#define UPLCOM_SET_REQUEST_PL2303HXN
Definition: uplcom.c:135
#define UPLCOM_MODVER
Definition: uplcom.c:122
static void uplcom_cfg_param(struct ucom_softc *, struct termios *)
Definition: uplcom.c:860
#define TYPE_PL2303
Definition: uplcom.c:151
UCOM_UNLOAD_DRAIN(uplcom)
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UT_WRITE_VENDOR_DEVICE
Definition: usb.h:184
#define UT_READ_VENDOR_DEVICE
Definition: usb.h:180
#define UE_DIR_IN
Definition: usb.h:531
#define UE_DIR_OUT
Definition: usb.h:532
@ USB_MODE_HOST
Definition: usb.h:778
#define UT_WRITE_CLASS_INTERFACE
Definition: usb.h:177
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
Definition: usb_busdma.c:283
#define UCDC_LINE_RTS
Definition: usb_cdc.h:115
#define UCDC_BREAK_ON
Definition: usb_cdc.h:117
#define UCDC_PARITY_ODD
Definition: usb_cdc.h:136
#define UCDC_PARITY_EVEN
Definition: usb_cdc.h:137
#define UCDC_LINE_DTR
Definition: usb_cdc.h:114
#define UCDC_STOP_BIT_2
Definition: usb_cdc.h:133
#define UCDC_PARITY_NONE
Definition: usb_cdc.h:135
#define UCDC_LINE_STATE_LENGTH
Definition: usb_cdc.h:143
#define UCDC_SET_LINE_CODING
Definition: usb_cdc.h:111
#define UCDC_SET_CONTROL_LINE_STATE
Definition: usb_cdc.h:113
#define UCDC_BREAK_OFF
Definition: usb_cdc.h:118
#define UCDC_STOP_BIT_1
Definition: usb_cdc.h:131
#define UCDC_STOP_BIT_1_5
Definition: usb_cdc.h:132
#define UCDC_SEND_BREAK
Definition: usb_cdc.h:116
struct usb_interface_descriptor * usbd_get_interface_descriptor(struct usb_interface *iface)
Definition: usb_device.c:2654
void usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index, uint8_t parent_index)
Definition: usb_device.c:1395
struct usb_device_descriptor * usbd_get_device_descriptor(struct usb_device *udev)
Definition: usb_device.c:2608
struct usb_interface * usbd_get_iface(struct usb_device *udev, uint8_t iface_index)
Definition: usb_device.c:2370
#define USETW(w, v)
Definition: usb_endian.h:77
#define USETDW(w, v)
Definition: usb_endian.h:82
#define UGETW(w)
Definition: usb_endian.h:53
#define UGETDW(w)
Definition: usb_endian.h:57
const char * usbd_errstr(usb_error_t err)
Definition: usb_error.c:93
const void * req
Definition: usb_if.m:51
INTERFACE usb
Definition: usb_if.m:35
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
Definition: usb_lookup.c:143
uint8_t ucom_get_data(struct ucom_softc *sc, struct usb_page_cache *pc, uint32_t offset, uint32_t len, uint32_t *actlen)
Definition: usb_serial.c:1384
void ucom_status_change(struct ucom_softc *sc)
Definition: usb_serial.c:1229
int ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, int subunits, void *parent, const struct ucom_callback *callback, struct mtx *mtx)
Definition: usb_serial.c:267
int ucom_unref(struct ucom_super_softc *ssc)
Definition: usb_serial.c:1730
void ucom_ref(struct ucom_super_softc *ssc)
Definition: usb_serial.c:1695
void ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
Definition: usb_serial.c:549
void ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc)
Definition: usb_serial.c:336
void ucom_put_data(struct ucom_softc *sc, struct usb_page_cache *pc, uint32_t offset, uint32_t len)
Definition: usb_serial.c:1462
#define ULSR_OE
Definition: usb_serial.h:117
#define ULSR_BI
Definition: usb_serial.h:114
#define ULSR_FE
Definition: usb_serial.h:115
#define ULSR_PE
Definition: usb_serial.h:116
#define ucom_cfg_do_request(udev, com, req, ptr, flags, timo)
Definition: usb_serial.h:208
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
Definition: usb_transfer.c:987
void usbd_transfer_start(struct usb_xfer *xfer)
void usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
#define USB_ST_SETUP
Definition: usbdi.h:502
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_CANCELLED
Definition: usbdi.h:51
#define USB_ST_TRANSFERRED
Definition: usbdi.h:503
void() usb_callback_t(struct usb_xfer *, usb_error_t)
Definition: usbdi.h:94
#define STRUCT_USB_HOST_ID
Definition: usbdi.h:258
#define USB_GET_STATE(xfer)
Definition: usbdi.h:515
#define usbd_do_request(u, m, r, d)
Definition: usbdi.h:596