Lines Matching +full:ls +full:- +full:bits
3 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
31 /*-
61 * This driver supports several USB-to-RS232 serial adapters driven by
62 * Prolific PL-2303, PL-2303X and probably PL-2303HX USB-to-RS232
70 * PL-2303HX is probably programmed the same as PL-2303X.
72 * There are several differences between PL-2303 and PL-2303(H)X.
73 * PL-2303(H)X can do higher bitrate in bulk mode, has _probably_
261 UPLCOM_DEV(ADLINK, ND6530), /* ADLINK ND-6530 USB-Serial */
263 UPLCOM_DEV(ALCOR, AU9720), /* Alcor AU9720 USB 2.0-RS232 */
265 UPLCOM_DEV(ATEN, UC232A), /* PLANEX USB-RS232 URS-03 */
266 UPLCOM_DEV(ATEN, UC232B), /* Prolific USB-RS232 Controller D */
268 UPLCOM_DEV(COREGA, CGUSBRS232R), /* Corega CG-USBRS232R */
271 UPLCOM_DEV(ELECOM, UCSGT), /* ELECOM UC-SGT Serial Adapter */
272 UPLCOM_DEV(ELECOM, UCSGT0), /* ELECOM UC-SGT Serial Adapter */
275 UPLCOM_DEV(IODATA, USBRSAQ), /* I/O DATA USB-RSAQ */
276 UPLCOM_DEV(IODATA, USBRSAQ5), /* I/O DATA USB-RSAQ5 */
281 UPLCOM_DEV(MOBILEACTION, MA620), /* Mobile Action MA-620 Infrared Adapter */
282 UPLCOM_DEV(NETINDEX, WS002IN), /* Willcom W-S002IN */
283 UPLCOM_DEV(NOKIA2, CA42), /* Nokia CA-42 cable */
284 UPLCOM_DEV(OTI, DKU5), /* OTI DKU-5 cable */
285 UPLCOM_DEV(PANASONIC, TYTP50P6S), /* Panasonic TY-TP50P6-S flat screen */
286 UPLCOM_DEV(PLX, CA42), /* PLX CA-42 clone cable */
288 UPLCOM_DEV(PROLIFIC, ALDIGA_AL11U), /* AlDiga AL-11U modem */
289 UPLCOM_DEV(PROLIFIC, DCU11), /* DCU-11 Phone Cable */
301 UPLCOM_DEV(PROLIFIC, RSAQ2), /* I/O DATA USB-RSAQ2 */
302 UPLCOM_DEV(PROLIFIC, RSAQ3), /* I/O DATA USB-RSAQ3 */
306 UPLCOM_DEV(RATOC, REXUSB60), /* RATOC REX-USB60 */
307 UPLCOM_DEV(SAGEM, USBSERIAL), /* Sagem USB-Serial Controller */
309 UPLCOM_DEV(SANWA, KB_USB2), /* Sanwa KB-USB2 Multimeter cable */
318 UPLCOM_DEV(SONYERICSSON, DCU10), /* Sony Ericsson DCU-10 Cable */
321 UPLCOM_DEV(SPEEDDRAGON, MS3303H), /* Speed Dragon USB-Serial */
322 UPLCOM_DEV(SYNTECH, CPT8001C), /* Syntech CPT-8001C Barcode scanner */
323 UPLCOM_DEV(TDK, UHA6400), /* TDK USB-PHS Adapter UHA6400 */
324 UPLCOM_DEV(TDK, UPA9664), /* TDK USB-PHS Adapter UPA9664 */
325 UPLCOM_DEV(TRIPPLITE, U209), /* Tripp-Lite U209-000-R USB to Serial */
326 UPLCOM_DEV(YCCABLE, PL2303), /* YC Cable USB-Serial */
356 if (uaa->usb_mode != USB_MODE_HOST) { in uplcom_probe()
359 if (uaa->info.bConfigIndex != UPLCOM_CONFIG_INDEX) { in uplcom_probe()
362 if (uaa->info.bIfaceIndex != UPLCOM_IFACE_INDEX) { in uplcom_probe()
385 mtx_init(&sc->sc_mtx, "uplcom", NULL, MTX_DEF); in uplcom_attach()
386 ucom_ref(&sc->sc_super_ucom); in uplcom_attach()
390 sc->sc_udev = uaa->device; in uplcom_attach()
392 dd = usbd_get_device_descriptor(sc->sc_udev); in uplcom_attach()
394 switch (UGETW(dd->bcdDevice)) { in uplcom_attach()
396 sc->sc_chiptype = TYPE_PL2303HX; in uplcom_attach()
400 sc->sc_chiptype = TYPE_PL2303HXD; in uplcom_attach()
405 sc->sc_chiptype = TYPE_PL2303HXD; in uplcom_attach()
410 only fixed rates) and for PL2303SA (8-pin chip, up to 115200 baud */ in uplcom_attach()
412 if (dd->bDeviceClass == 0x02) in uplcom_attach()
413 sc->sc_chiptype = TYPE_PL2303; in uplcom_attach()
414 else if (dd->bMaxPacketSize == 0x40) in uplcom_attach()
415 sc->sc_chiptype = TYPE_PL2303HX; in uplcom_attach()
417 sc->sc_chiptype = TYPE_PL2303; in uplcom_attach()
425 * and PL2303HXN can be distinguished by issuing an old-style request in uplcom_attach()
428 if (sc->sc_chiptype == TYPE_PL2303HX) { in uplcom_attach()
432 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_attach()
435 err = usbd_do_request(sc->sc_udev, NULL, &req, buf); in uplcom_attach()
437 sc->sc_chiptype = TYPE_PL2303HXN; in uplcom_attach()
440 switch (sc->sc_chiptype) { in uplcom_attach()
454 DPRINTF("chiptype: unknown %d\n", sc->sc_chiptype); in uplcom_attach()
459 * USB-RSAQ1 has two interface in uplcom_attach()
461 * USB-RSAQ1 | USB-RSAQ2 in uplcom_attach()
462 * -----------------+----------------- in uplcom_attach()
465 * -----------------+ BulkIN(0x02) in uplcom_attach()
471 sc->sc_ctrl_iface_no = uaa->info.bIfaceNum; in uplcom_attach()
472 sc->sc_iface_index[1] = UPLCOM_IFACE_INDEX; in uplcom_attach()
474 iface = usbd_get_iface(uaa->device, UPLCOM_SECOND_IFACE_INDEX); in uplcom_attach()
481 sc->sc_data_iface_no = id->bInterfaceNumber; in uplcom_attach()
482 sc->sc_iface_index[0] = UPLCOM_SECOND_IFACE_INDEX; in uplcom_attach()
483 usbd_set_parent_iface(uaa->device, in uplcom_attach()
484 UPLCOM_SECOND_IFACE_INDEX, uaa->info.bIfaceIndex); in uplcom_attach()
486 sc->sc_data_iface_no = sc->sc_ctrl_iface_no; in uplcom_attach()
487 sc->sc_iface_index[0] = UPLCOM_IFACE_INDEX; in uplcom_attach()
490 error = usbd_transfer_setup(uaa->device, in uplcom_attach()
491 sc->sc_iface_index, sc->sc_xfer, uplcom_config_data, in uplcom_attach()
492 UPLCOM_N_TRANSFER, sc, &sc->sc_mtx); in uplcom_attach()
498 error = uplcom_reset(sc, uaa->device); in uplcom_attach()
505 if (sc->sc_chiptype == TYPE_PL2303) { in uplcom_attach()
507 mtx_lock(&sc->sc_mtx); in uplcom_attach()
508 usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]); in uplcom_attach()
509 usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]); in uplcom_attach()
510 mtx_unlock(&sc->sc_mtx); in uplcom_attach()
511 } else if (sc->sc_chiptype == TYPE_PL2303HX || in uplcom_attach()
512 sc->sc_chiptype == TYPE_PL2303HXD) { in uplcom_attach()
514 if (uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE, in uplcom_attach()
516 uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE, in uplcom_attach()
520 } else if (sc->sc_chiptype == TYPE_PL2303HXN) { in uplcom_attach()
522 if (uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE, in uplcom_attach()
528 error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc, in uplcom_attach()
529 &uplcom_callback, &sc->sc_mtx); in uplcom_attach()
537 if (uplcom_pl2303_init(uaa->device, sc->sc_chiptype)) { in uplcom_attach()
541 ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev); in uplcom_attach()
557 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom); in uplcom_detach()
558 usbd_transfer_unsetup(sc->sc_xfer, UPLCOM_N_TRANSFER); in uplcom_detach()
572 if (ucom_unref(&sc->sc_super_ucom)) { in uplcom_free_softc()
573 mtx_destroy(&sc->sc_mtx); in uplcom_free_softc()
581 uplcom_free_softc(ucom->sc_parent); in uplcom_free()
589 if (sc->sc_chiptype == TYPE_PL2303HXN) { in uplcom_reset()
597 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_reset()
661 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_cfg_set_dtr()
667 sc->sc_line |= UCDC_LINE_DTR; in uplcom_cfg_set_dtr()
669 sc->sc_line &= ~UCDC_LINE_DTR; in uplcom_cfg_set_dtr()
673 USETW(req.wValue, sc->sc_line); in uplcom_cfg_set_dtr()
674 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_cfg_set_dtr()
678 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_set_dtr()
685 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_cfg_set_rts()
691 sc->sc_line |= UCDC_LINE_RTS; in uplcom_cfg_set_rts()
693 sc->sc_line &= ~UCDC_LINE_RTS; in uplcom_cfg_set_rts()
697 USETW(req.wValue, sc->sc_line); in uplcom_cfg_set_rts()
698 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_cfg_set_rts()
702 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_set_rts()
709 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_cfg_set_break()
720 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_cfg_set_break()
724 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_set_break()
773 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_pre_param()
787 if (t->c_ospeed & 0x80000000) in uplcom_pre_param()
789 switch (sc->sc_chiptype) { in uplcom_pre_param()
791 if (t->c_ospeed <= 12000000) in uplcom_pre_param()
795 if (t->c_ospeed <= 12000000) in uplcom_pre_param()
799 if (t->c_ospeed <= 6000000) in uplcom_pre_param()
803 if (uplcom_baud_supported(t->c_ospeed)) in uplcom_pre_param()
808 DPRINTF("uplcom_param: bad baud rate (%d)\n", t->c_ospeed); in uplcom_pre_param()
857 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_cfg_param()
858 struct usb_cdc_line_state ls; in uplcom_cfg_param() local
863 memset(&ls, 0, sizeof(ls)); in uplcom_cfg_param()
868 if ((t->c_ospeed & 0x80000000) || uplcom_baud_supported(t->c_ospeed)) in uplcom_cfg_param()
869 USETDW(ls.dwDTERate, t->c_ospeed); in uplcom_cfg_param()
871 t->c_ospeed = uplcom_encode_baud_rate_divisor((uint8_t*)&ls.dwDTERate, t->c_ospeed); in uplcom_cfg_param()
873 if (t->c_cflag & CSTOPB) { in uplcom_cfg_param()
874 if ((t->c_cflag & CSIZE) == CS5) { in uplcom_cfg_param()
877 * use 1.5 instead of 2 stop bits with 5 data bits in uplcom_cfg_param()
879 ls.bCharFormat = UCDC_STOP_BIT_1_5; in uplcom_cfg_param()
881 ls.bCharFormat = UCDC_STOP_BIT_2; in uplcom_cfg_param()
884 ls.bCharFormat = UCDC_STOP_BIT_1; in uplcom_cfg_param()
887 if (t->c_cflag & PARENB) { in uplcom_cfg_param()
888 if (t->c_cflag & PARODD) { in uplcom_cfg_param()
889 ls.bParityType = UCDC_PARITY_ODD; in uplcom_cfg_param()
891 ls.bParityType = UCDC_PARITY_EVEN; in uplcom_cfg_param()
894 ls.bParityType = UCDC_PARITY_NONE; in uplcom_cfg_param()
897 switch (t->c_cflag & CSIZE) { in uplcom_cfg_param()
899 ls.bDataBits = 5; in uplcom_cfg_param()
902 ls.bDataBits = 6; in uplcom_cfg_param()
905 ls.bDataBits = 7; in uplcom_cfg_param()
908 ls.bDataBits = 8; in uplcom_cfg_param()
912 DPRINTF("rate=0x%08x fmt=%d parity=%d bits=%d\n", in uplcom_cfg_param()
913 UGETDW(ls.dwDTERate), ls.bCharFormat, in uplcom_cfg_param()
914 ls.bParityType, ls.bDataBits); in uplcom_cfg_param()
919 req.wIndex[0] = sc->sc_data_iface_no; in uplcom_cfg_param()
923 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_param()
924 &req, &ls, 0, 1000); in uplcom_cfg_param()
926 if (t->c_cflag & CRTSCTS) { in uplcom_cfg_param()
930 if (sc->sc_chiptype == TYPE_PL2303HXN) { in uplcom_cfg_param()
937 if (sc->sc_chiptype != TYPE_PL2303) in uplcom_cfg_param()
944 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_param()
948 if (sc->sc_chiptype == TYPE_PL2303HXN) { in uplcom_cfg_param()
959 ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, in uplcom_cfg_param()
967 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_start_read()
970 usbd_transfer_start(sc->sc_xfer[UPLCOM_INTR_DT_RD]); in uplcom_start_read()
973 usbd_transfer_start(sc->sc_xfer[UPLCOM_BULK_DT_RD]); in uplcom_start_read()
979 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_stop_read()
982 usbd_transfer_stop(sc->sc_xfer[UPLCOM_INTR_DT_RD]); in uplcom_stop_read()
985 usbd_transfer_stop(sc->sc_xfer[UPLCOM_BULK_DT_RD]); in uplcom_stop_read()
991 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_start_write()
993 usbd_transfer_start(sc->sc_xfer[UPLCOM_BULK_DT_WR]); in uplcom_start_write()
999 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_stop_write()
1001 usbd_transfer_stop(sc->sc_xfer[UPLCOM_BULK_DT_WR]); in uplcom_stop_write()
1007 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_cfg_get_status()
1011 *lsr = sc->sc_lsr; in uplcom_cfg_get_status()
1012 *msr = sc->sc_msr; in uplcom_cfg_get_status()
1036 sc->sc_lsr = 0; in uplcom_intr_callback()
1037 sc->sc_msr = 0; in uplcom_intr_callback()
1040 sc->sc_msr |= SER_CTS; in uplcom_intr_callback()
1043 sc->sc_lsr |= ULSR_OE; in uplcom_intr_callback()
1046 sc->sc_lsr |= ULSR_PE; in uplcom_intr_callback()
1049 sc->sc_lsr |= ULSR_FE; in uplcom_intr_callback()
1052 sc->sc_msr |= SER_RI; in uplcom_intr_callback()
1055 sc->sc_lsr |= ULSR_BI; in uplcom_intr_callback()
1058 sc->sc_msr |= SER_DSR; in uplcom_intr_callback()
1061 sc->sc_msr |= SER_DCD; in uplcom_intr_callback()
1063 ucom_status_change(&sc->sc_ucom); in uplcom_intr_callback()
1093 if (ucom_get_data(&sc->sc_ucom, pc, 0, in uplcom_write_callback()
1124 ucom_put_data(&sc->sc_ucom, pc, 0, actlen); in uplcom_read_callback()
1145 struct uplcom_softc *sc = ucom->sc_parent; in uplcom_poll()
1146 usbd_transfer_poll(sc->sc_xfer, UPLCOM_N_TRANSFER); in uplcom_poll()