FreeBSD kernel usb device Code
|
#include <sys/cdefs.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usb_cdc.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/serial/usb_serial.h>
Go to the source code of this file.
Data Structures | |
struct | uplcom_softc |
Enumerations | |
enum | { UPLCOM_BULK_DT_WR , UPLCOM_BULK_DT_RD , UPLCOM_INTR_DT_RD , UPLCOM_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static usb_error_t | uplcom_reset (struct uplcom_softc *, struct usb_device *) |
static usb_error_t | uplcom_pl2303_do (struct usb_device *, uint8_t, uint8_t, uint16_t, uint16_t, uint16_t) |
static int | uplcom_pl2303_init (struct usb_device *, uint8_t) |
static void | uplcom_free (struct ucom_softc *) |
static void | uplcom_cfg_set_dtr (struct ucom_softc *, uint8_t) |
static void | uplcom_cfg_set_rts (struct ucom_softc *, uint8_t) |
static void | uplcom_cfg_set_break (struct ucom_softc *, uint8_t) |
static int | uplcom_pre_param (struct ucom_softc *, struct termios *) |
static void | uplcom_cfg_param (struct ucom_softc *, struct termios *) |
static void | uplcom_start_read (struct ucom_softc *) |
static void | uplcom_stop_read (struct ucom_softc *) |
static void | uplcom_start_write (struct ucom_softc *) |
static void | uplcom_stop_write (struct ucom_softc *) |
static void | uplcom_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *) |
static void | uplcom_poll (struct ucom_softc *ucom) |
static void | uplcom_free_softc (struct uplcom_softc *) |
DRIVER_MODULE (uplcom, uhub, uplcom_driver, uplcom_devclass, NULL, 0) | |
MODULE_DEPEND (uplcom, ucom, 1, 1, 1) | |
MODULE_DEPEND (uplcom, usb, 1, 1, 1) | |
MODULE_VERSION (uplcom, UPLCOM_MODVER) | |
USB_PNP_HOST_INFO (uplcom_devs) | |
static int | uplcom_probe (device_t dev) |
static int | uplcom_attach (device_t dev) |
static int | uplcom_detach (device_t dev) |
UCOM_UNLOAD_DRAIN (uplcom) | |
static int | uplcom_baud_supported (unsigned int speed) |
static unsigned int | uplcom_encode_baud_rate_divisor (uint8_t *buf, unsigned int baud) |
static void | uplcom_intr_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | uplcom_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | uplcom_read_callback (struct usb_xfer *xfer, usb_error_t error) |
Variables | |
static device_probe_t | uplcom_probe |
static device_attach_t | uplcom_attach |
static device_detach_t | uplcom_detach |
static usb_callback_t | uplcom_intr_callback |
static usb_callback_t | uplcom_write_callback |
static usb_callback_t | uplcom_read_callback |
static const struct usb_config | uplcom_config_data [UPLCOM_N_TRANSFER] |
static struct ucom_callback | uplcom_callback |
static const STRUCT_USB_HOST_ID | uplcom_devs [] |
static device_method_t | uplcom_methods [] |
static devclass_t | uplcom_devclass |
static driver_t | uplcom_driver |
static const uint32_t | uplcom_rates [] |
#define N_UPLCOM_RATES nitems(uplcom_rates) |
#define UPLCOM_DEV | ( | v, | |
p | |||
) | { USB_VENDOR(USB_VENDOR_##v), USB_PRODUCT(USB_PRODUCT_##v##_##p) } |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | uplcom | , |
uhub | , | ||
uplcom_driver | , | ||
uplcom_devclass | , | ||
NULL | , | ||
0 | |||
) |
MODULE_DEPEND | ( | uplcom | , |
ucom | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | uplcom | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | uplcom | , |
UPLCOM_MODVER | |||
) |
UCOM_UNLOAD_DRAIN | ( | uplcom | ) |
|
static |
Definition at line 374 of file uplcom.c.
References usb_device_descriptor::bcdDevice, usb_device_descriptor::bDeviceClass, usbd_lookup_info::bIfaceIndex, usbd_lookup_info::bIfaceNum, usb_device_descriptor::bMaxPacketSize, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, error, id, usb_attach_arg::info, req, uplcom_softc::sc_chiptype, uplcom_softc::sc_ctrl_iface_no, uplcom_softc::sc_data_iface_no, uplcom_softc::sc_iface_index, uplcom_softc::sc_mtx, uplcom_softc::sc_super_ucom, uplcom_softc::sc_ucom, uplcom_softc::sc_udev, uplcom_softc::sc_xfer, TYPE_PL2303, TYPE_PL2303HX, TYPE_PL2303HXD, TYPE_PL2303HXN, ucom_attach(), ucom_ref(), ucom_set_pnpinfo_usb(), UGETW, UPLCOM_BULK_DT_RD, UPLCOM_BULK_DT_WR, uplcom_callback, uplcom_config_data, uplcom_detach, UPLCOM_IFACE_INDEX, UPLCOM_N_TRANSFER, uplcom_pl2303_do(), uplcom_pl2303_init(), uplcom_reset(), UPLCOM_SECOND_IFACE_INDEX, UPLCOM_SET_REQUEST, UPLCOM_SET_REQUEST_PL2303HXN, UPLCOM_STATUS_REG_PL2303HX, usbd_do_request, usbd_errstr(), usbd_get_device_descriptor(), usbd_get_iface(), usbd_get_interface_descriptor(), usbd_set_parent_iface(), usbd_transfer_setup(), usbd_xfer_set_stall(), USETW, UT_READ_VENDOR_DEVICE, and UT_WRITE_VENDOR_DEVICE.
|
static |
Definition at line 765 of file uplcom.c.
References N_UPLCOM_RATES, and uplcom_rates.
Referenced by uplcom_cfg_param(), and uplcom_pre_param().
|
static |
Definition at line 1010 of file uplcom.c.
References DPRINTF, uplcom_softc::sc_lsr, uplcom_softc::sc_msr, and ucom_softc::sc_parent.
|
static |
Definition at line 860 of file uplcom.c.
References usb_cdc_line_state::bCharFormat, usb_cdc_line_state::bDataBits, usb_cdc_line_state::bParityType, DPRINTF, usb_cdc_line_state::dwDTERate, req, uplcom_softc::sc_chiptype, uplcom_softc::sc_data_iface_no, ucom_softc::sc_parent, uplcom_softc::sc_ucom, uplcom_softc::sc_udev, TYPE_PL2303, TYPE_PL2303HXN, UCDC_LINE_STATE_LENGTH, UCDC_PARITY_EVEN, UCDC_PARITY_NONE, UCDC_PARITY_ODD, UCDC_SET_LINE_CODING, UCDC_STOP_BIT_1, UCDC_STOP_BIT_1_5, UCDC_STOP_BIT_2, ucom_cfg_do_request, UGETDW, uplcom_baud_supported(), UPLCOM_CLEAR_CRTSCTS_PL2303HXN, UPLCOM_CRTSCTS_REG_PL2303HXN, uplcom_encode_baud_rate_divisor(), UPLCOM_SET_CRTSCTS, UPLCOM_SET_CRTSCTS_PL2303HXN, UPLCOM_SET_CRTSCTS_PL2303X, UPLCOM_SET_REQUEST, UPLCOM_SET_REQUEST_PL2303HXN, USETDW, USETW, UT_WRITE_CLASS_INTERFACE, and UT_WRITE_VENDOR_DEVICE.
|
static |
Definition at line 712 of file uplcom.c.
References DPRINTF, req, uplcom_softc::sc_data_iface_no, ucom_softc::sc_parent, uplcom_softc::sc_ucom, uplcom_softc::sc_udev, UCDC_BREAK_OFF, UCDC_BREAK_ON, UCDC_SEND_BREAK, ucom_cfg_do_request, USETW, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 664 of file uplcom.c.
References DPRINTF, req, uplcom_softc::sc_data_iface_no, uplcom_softc::sc_line, ucom_softc::sc_parent, uplcom_softc::sc_ucom, uplcom_softc::sc_udev, UCDC_LINE_DTR, UCDC_SET_CONTROL_LINE_STATE, ucom_cfg_do_request, USETW, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 688 of file uplcom.c.
References DPRINTF, req, uplcom_softc::sc_data_iface_no, uplcom_softc::sc_line, ucom_softc::sc_parent, uplcom_softc::sc_ucom, uplcom_softc::sc_udev, UCDC_LINE_RTS, UCDC_SET_CONTROL_LINE_STATE, ucom_cfg_do_request, USETW, and UT_WRITE_CLASS_INTERFACE.
|
static |
Definition at line 556 of file uplcom.c.
References dev, DPRINTF, uplcom_softc::sc_super_ucom, uplcom_softc::sc_ucom, uplcom_softc::sc_xfer, ucom_detach(), uplcom_free_softc(), UPLCOM_N_TRANSFER, and usbd_transfer_unsetup().
|
static |
Definition at line 818 of file uplcom.c.
References DPRINTF.
Referenced by uplcom_cfg_param().
|
static |
Definition at line 584 of file uplcom.c.
References ucom_softc::sc_parent, and uplcom_free_softc().
|
static |
Definition at line 575 of file uplcom.c.
References uplcom_softc::sc_mtx, uplcom_softc::sc_super_ucom, and ucom_unref().
Referenced by uplcom_detach(), and uplcom_free().
|
static |
Definition at line 1021 of file uplcom.c.
References DPRINTF, error, RSAQ_STATUS_BREAK_ERROR, RSAQ_STATUS_CTS, RSAQ_STATUS_DCD, RSAQ_STATUS_DSR, RSAQ_STATUS_FRAME_ERROR, RSAQ_STATUS_OVERRUN_ERROR, RSAQ_STATUS_PARITY_ERROR, RSAQ_STATUS_RING, uplcom_softc::sc_lsr, uplcom_softc::sc_msr, uplcom_softc::sc_ucom, ucom_status_change(), ULSR_BI, ULSR_FE, ULSR_OE, ULSR_PE, UPLCOM_STATE_INDEX, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_out(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 610 of file uplcom.c.
References DPRINTF, index, req, usbd_do_request, usbd_errstr(), USETW, and value.
Referenced by uplcom_attach(), and uplcom_pl2303_init().
|
static |
Definition at line 632 of file uplcom.c.
References TYPE_PL2303, TYPE_PL2303HXN, uplcom_pl2303_do(), UPLCOM_SET_REQUEST, UT_READ_VENDOR_DEVICE, and UT_WRITE_VENDOR_DEVICE.
Referenced by uplcom_attach().
|
static |
Definition at line 1148 of file uplcom.c.
References ucom_softc::sc_parent, uplcom_softc::sc_xfer, UPLCOM_N_TRANSFER, and usbd_transfer_poll().
|
static |
Check requested baud rate.
The PL2303 can only set specific baud rates, up to 1228800 baud. The PL2303HX can set any baud rate up to 6Mb. The PL2303HX rev. D and PL2303HXN can set any baud rate up to 12Mb.
Definition at line 776 of file uplcom.c.
References DPRINTF, uplcom_softc::sc_chiptype, ucom_softc::sc_parent, TYPE_PL2303HX, TYPE_PL2303HXD, TYPE_PL2303HXN, and uplcom_baud_supported().
|
static |
Definition at line 355 of file uplcom.c.
References usbd_lookup_info::bConfigIndex, usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::info, UPLCOM_CONFIG_INDEX, uplcom_devs, UPLCOM_IFACE_INDEX, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().
|
static |
Definition at line 1118 of file uplcom.c.
References error, uplcom_softc::sc_ucom, ucom_put_data(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_max_len(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), and usbd_xfer_status().
|
static |
Definition at line 590 of file uplcom.c.
References req, uplcom_softc::sc_chiptype, uplcom_softc::sc_data_iface_no, TYPE_PL2303HXN, UPLCOM_SET_REQUEST, usbd_do_request, USETW, and UT_WRITE_VENDOR_DEVICE.
Referenced by uplcom_attach().
|
static |
Definition at line 970 of file uplcom.c.
References ucom_softc::sc_parent, uplcom_softc::sc_xfer, UPLCOM_BULK_DT_RD, UPLCOM_INTR_DT_RD, and usbd_transfer_start().
|
static |
Definition at line 994 of file uplcom.c.
References ucom_softc::sc_parent, uplcom_softc::sc_xfer, UPLCOM_BULK_DT_WR, and usbd_transfer_start().
|
static |
Definition at line 982 of file uplcom.c.
References ucom_softc::sc_parent, uplcom_softc::sc_xfer, UPLCOM_BULK_DT_RD, UPLCOM_INTR_DT_RD, and usbd_transfer_stop().
|
static |
Definition at line 1002 of file uplcom.c.
References ucom_softc::sc_parent, uplcom_softc::sc_xfer, UPLCOM_BULK_DT_WR, and usbd_transfer_stop().
|
static |
Definition at line 1087 of file uplcom.c.
References DPRINTF, error, uplcom_softc::sc_ucom, ucom_get_data(), UPLCOM_BULK_BUF_SIZE, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), and usbd_xfer_softc().
USB_PNP_HOST_INFO | ( | uplcom_devs | ) |
|
static |
Definition at line 244 of file uplcom.c.
Referenced by uplcom_attach().
|
static |
Definition at line 212 of file uplcom.c.
Referenced by uplcom_attach().
|
static |
Definition at line 205 of file uplcom.c.
Referenced by uplcom_attach().
|
static |
Definition at line 262 of file uplcom.c.
Referenced by uplcom_probe().
|
static |
|
static |
|
static |
|
static |
Definition at line 743 of file uplcom.c.
Referenced by uplcom_baud_supported().
|
static |
|
static |