FreeBSD kernel usb device Code
uchcom.c File Reference
#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 "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/serial/usb_serial.h>
Include dependency graph for uchcom.c:

Go to the source code of this file.

Data Structures

struct  uchcom_softc
 
struct  uchcom_divider
 
struct  uchcom_divider_record
 

Macros

#define USB_DEBUG_VAR   uchcom_debug
 
#define UCHCOM_IFACE_INDEX   0
 
#define UCHCOM_CONFIG_INDEX   0
 
#define UCHCOM_REV_CH340   0x0250
 
#define UCHCOM_INPUT_BUF_SIZE   8
 
#define UCHCOM_REQ_GET_VERSION   0x5F
 
#define UCHCOM_REQ_READ_REG   0x95
 
#define UCHCOM_REQ_WRITE_REG   0x9A
 
#define UCHCOM_REQ_RESET   0xA1
 
#define UCHCOM_REQ_SET_DTRRTS   0xA4
 
#define UCHCOM_REG_STAT1   0x06
 
#define UCHCOM_REG_STAT2   0x07
 
#define UCHCOM_REG_BPS_PRE   0x12
 
#define UCHCOM_REG_BPS_DIV   0x13
 
#define UCHCOM_REG_BPS_MOD   0x14
 
#define UCHCOM_REG_BPS_PAD   0x0F
 
#define UCHCOM_REG_BREAK1   0x05
 
#define UCHCOM_REG_LCR1   0x18
 
#define UCHCOM_REG_LCR2   0x25
 
#define UCHCOM_VER_20   0x20
 
#define UCHCOM_VER_30   0x30
 
#define UCHCOM_BASE_UNKNOWN   0
 
#define UCHCOM_BPS_MOD_BASE   20000000
 
#define UCHCOM_BPS_MOD_BASE_OFS   1100
 
#define UCHCOM_DTR_MASK   0x20
 
#define UCHCOM_RTS_MASK   0x40
 
#define UCHCOM_BRK_MASK   0x01
 
#define UCHCOM_LCR1_MASK   0xAF
 
#define UCHCOM_LCR2_MASK   0x07
 
#define UCHCOM_LCR1_RX   0x80
 
#define UCHCOM_LCR1_TX   0x40
 
#define UCHCOM_LCR1_PARENB   0x08
 
#define UCHCOM_LCR1_CS8   0x03
 
#define UCHCOM_LCR2_PAREVEN   0x07
 
#define UCHCOM_LCR2_PARODD   0x06
 
#define UCHCOM_LCR2_PARMARK   0x05
 
#define UCHCOM_LCR2_PARSPACE   0x04
 
#define UCHCOM_INTR_STAT1   0x02
 
#define UCHCOM_INTR_STAT2   0x03
 
#define UCHCOM_INTR_LEAST   4
 
#define UCHCOM_BULK_BUF_SIZE   1024 /* bytes */
 
#define NUM_DIVIDERS   nitems(dividers)
 

Enumerations

enum  { UCHCOM_BULK_DT_WR , UCHCOM_BULK_DT_RD , UCHCOM_INTR_DT_RD , UCHCOM_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void uchcom_free (struct ucom_softc *)
 
static int uchcom_pre_param (struct ucom_softc *, struct termios *)
 
static void uchcom_cfg_get_status (struct ucom_softc *, uint8_t *, uint8_t *)
 
static void uchcom_cfg_open (struct ucom_softc *ucom)
 
static void uchcom_cfg_param (struct ucom_softc *, struct termios *)
 
static void uchcom_cfg_set_break (struct ucom_softc *, uint8_t)
 
static void uchcom_cfg_set_dtr (struct ucom_softc *, uint8_t)
 
static void uchcom_cfg_set_rts (struct ucom_softc *, uint8_t)
 
static void uchcom_start_read (struct ucom_softc *)
 
static void uchcom_start_write (struct ucom_softc *)
 
static void uchcom_stop_read (struct ucom_softc *)
 
static void uchcom_stop_write (struct ucom_softc *)
 
static void uchcom_update_version (struct uchcom_softc *)
 
static void uchcom_convert_status (struct uchcom_softc *, uint8_t)
 
static void uchcom_update_status (struct uchcom_softc *)
 
static void uchcom_set_dtr_rts (struct uchcom_softc *)
 
static int uchcom_calc_divider_settings (struct uchcom_divider *, uint32_t)
 
static void uchcom_set_baudrate (struct uchcom_softc *, uint32_t)
 
static void uchcom_poll (struct ucom_softc *ucom)
 
static void uchcom_free_softc (struct uchcom_softc *)
 
static int uchcom_probe (device_t dev)
 
static int uchcom_attach (device_t dev)
 
static int uchcom_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (uchcom)
 
static void uchcom_ctrl_write (struct uchcom_softc *sc, uint8_t reqno, uint16_t value, uint16_t index)
 
static void uchcom_ctrl_read (struct uchcom_softc *sc, uint8_t reqno, uint16_t value, uint16_t index, void *buf, uint16_t buflen)
 
static void uchcom_write_reg (struct uchcom_softc *sc, uint8_t reg1, uint8_t val1, uint8_t reg2, uint8_t val2)
 
static void uchcom_read_reg (struct uchcom_softc *sc, uint8_t reg1, uint8_t *rval1, uint8_t reg2, uint8_t *rval2)
 
static void uchcom_get_version (struct uchcom_softc *sc, uint8_t *rver)
 
static void uchcom_get_status (struct uchcom_softc *sc, uint8_t *rval)
 
static void uchcom_set_dtr_rts_10 (struct uchcom_softc *sc, uint8_t val)
 
static void uchcom_set_dtr_rts_20 (struct uchcom_softc *sc, uint8_t val)
 
static void uchcom_intr_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void uchcom_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void uchcom_read_callback (struct usb_xfer *xfer, usb_error_t error)
 
 DRIVER_MODULE (uchcom, uhub, uchcom_driver, uchcom_devclass, NULL, 0)
 
 MODULE_DEPEND (uchcom, ucom, 1, 1, 1)
 
 MODULE_DEPEND (uchcom, usb, 1, 1, 1)
 
 MODULE_VERSION (uchcom, 1)
 
 USB_PNP_HOST_INFO (uchcom_devs)
 

Variables

static const struct uchcom_divider_record dividers []
 
static const STRUCT_USB_HOST_ID uchcom_devs []
 
static device_probe_t uchcom_probe
 
static device_attach_t uchcom_attach
 
static device_detach_t uchcom_detach
 
static usb_callback_t uchcom_intr_callback
 
static usb_callback_t uchcom_write_callback
 
static usb_callback_t uchcom_read_callback
 
static const struct usb_config uchcom_config_data [UCHCOM_N_TRANSFER]
 
static struct ucom_callback uchcom_callback
 
static device_method_t uchcom_methods []
 
static driver_t uchcom_driver
 
static devclass_t uchcom_devclass
 

Macro Definition Documentation

◆ NUM_DIVIDERS

#define NUM_DIVIDERS   nitems(dividers)

Definition at line 203 of file uchcom.c.

◆ UCHCOM_BASE_UNKNOWN

#define UCHCOM_BASE_UNKNOWN   0

Definition at line 132 of file uchcom.c.

◆ UCHCOM_BPS_MOD_BASE

#define UCHCOM_BPS_MOD_BASE   20000000

Definition at line 133 of file uchcom.c.

◆ UCHCOM_BPS_MOD_BASE_OFS

#define UCHCOM_BPS_MOD_BASE_OFS   1100

Definition at line 134 of file uchcom.c.

◆ UCHCOM_BRK_MASK

#define UCHCOM_BRK_MASK   0x01

Definition at line 139 of file uchcom.c.

◆ UCHCOM_BULK_BUF_SIZE

#define UCHCOM_BULK_BUF_SIZE   1024 /* bytes */

Definition at line 156 of file uchcom.c.

◆ UCHCOM_CONFIG_INDEX

#define UCHCOM_CONFIG_INDEX   0

Definition at line 108 of file uchcom.c.

◆ UCHCOM_DTR_MASK

#define UCHCOM_DTR_MASK   0x20

Definition at line 136 of file uchcom.c.

◆ UCHCOM_IFACE_INDEX

#define UCHCOM_IFACE_INDEX   0

Definition at line 107 of file uchcom.c.

◆ UCHCOM_INPUT_BUF_SIZE

#define UCHCOM_INPUT_BUF_SIZE   8

Definition at line 111 of file uchcom.c.

◆ UCHCOM_INTR_LEAST

#define UCHCOM_INTR_LEAST   4

Definition at line 154 of file uchcom.c.

◆ UCHCOM_INTR_STAT1

#define UCHCOM_INTR_STAT1   0x02

Definition at line 152 of file uchcom.c.

◆ UCHCOM_INTR_STAT2

#define UCHCOM_INTR_STAT2   0x03

Definition at line 153 of file uchcom.c.

◆ UCHCOM_LCR1_CS8

#define UCHCOM_LCR1_CS8   0x03

Definition at line 146 of file uchcom.c.

◆ UCHCOM_LCR1_MASK

#define UCHCOM_LCR1_MASK   0xAF

Definition at line 141 of file uchcom.c.

◆ UCHCOM_LCR1_PARENB

#define UCHCOM_LCR1_PARENB   0x08

Definition at line 145 of file uchcom.c.

◆ UCHCOM_LCR1_RX

#define UCHCOM_LCR1_RX   0x80

Definition at line 143 of file uchcom.c.

◆ UCHCOM_LCR1_TX

#define UCHCOM_LCR1_TX   0x40

Definition at line 144 of file uchcom.c.

◆ UCHCOM_LCR2_MASK

#define UCHCOM_LCR2_MASK   0x07

Definition at line 142 of file uchcom.c.

◆ UCHCOM_LCR2_PAREVEN

#define UCHCOM_LCR2_PAREVEN   0x07

Definition at line 147 of file uchcom.c.

◆ UCHCOM_LCR2_PARMARK

#define UCHCOM_LCR2_PARMARK   0x05

Definition at line 149 of file uchcom.c.

◆ UCHCOM_LCR2_PARODD

#define UCHCOM_LCR2_PARODD   0x06

Definition at line 148 of file uchcom.c.

◆ UCHCOM_LCR2_PARSPACE

#define UCHCOM_LCR2_PARSPACE   0x04

Definition at line 150 of file uchcom.c.

◆ UCHCOM_REG_BPS_DIV

#define UCHCOM_REG_BPS_DIV   0x13

Definition at line 122 of file uchcom.c.

◆ UCHCOM_REG_BPS_MOD

#define UCHCOM_REG_BPS_MOD   0x14

Definition at line 123 of file uchcom.c.

◆ UCHCOM_REG_BPS_PAD

#define UCHCOM_REG_BPS_PAD   0x0F

Definition at line 124 of file uchcom.c.

◆ UCHCOM_REG_BPS_PRE

#define UCHCOM_REG_BPS_PRE   0x12

Definition at line 121 of file uchcom.c.

◆ UCHCOM_REG_BREAK1

#define UCHCOM_REG_BREAK1   0x05

Definition at line 125 of file uchcom.c.

◆ UCHCOM_REG_LCR1

#define UCHCOM_REG_LCR1   0x18

Definition at line 126 of file uchcom.c.

◆ UCHCOM_REG_LCR2

#define UCHCOM_REG_LCR2   0x25

Definition at line 127 of file uchcom.c.

◆ UCHCOM_REG_STAT1

#define UCHCOM_REG_STAT1   0x06

Definition at line 119 of file uchcom.c.

◆ UCHCOM_REG_STAT2

#define UCHCOM_REG_STAT2   0x07

Definition at line 120 of file uchcom.c.

◆ UCHCOM_REQ_GET_VERSION

#define UCHCOM_REQ_GET_VERSION   0x5F

Definition at line 113 of file uchcom.c.

◆ UCHCOM_REQ_READ_REG

#define UCHCOM_REQ_READ_REG   0x95

Definition at line 114 of file uchcom.c.

◆ UCHCOM_REQ_RESET

#define UCHCOM_REQ_RESET   0xA1

Definition at line 116 of file uchcom.c.

◆ UCHCOM_REQ_SET_DTRRTS

#define UCHCOM_REQ_SET_DTRRTS   0xA4

Definition at line 117 of file uchcom.c.

◆ UCHCOM_REQ_WRITE_REG

#define UCHCOM_REQ_WRITE_REG   0x9A

Definition at line 115 of file uchcom.c.

◆ UCHCOM_REV_CH340

#define UCHCOM_REV_CH340   0x0250

Definition at line 110 of file uchcom.c.

◆ UCHCOM_RTS_MASK

#define UCHCOM_RTS_MASK   0x40

Definition at line 137 of file uchcom.c.

◆ UCHCOM_VER_20

#define UCHCOM_VER_20   0x20

Definition at line 129 of file uchcom.c.

◆ UCHCOM_VER_30

#define UCHCOM_VER_30   0x30

Definition at line 130 of file uchcom.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   uchcom_debug

Definition at line 92 of file uchcom.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UCHCOM_BULK_DT_WR 
UCHCOM_BULK_DT_RD 
UCHCOM_INTR_DT_RD 
UCHCOM_N_TRANSFER 

Definition at line 158 of file uchcom.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( uchcom  ,
uhub  ,
uchcom_driver  ,
uchcom_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( uchcom  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( uchcom  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( uchcom  ,
 
)

◆ uchcom_attach()

◆ uchcom_calc_divider_settings()

◆ uchcom_cfg_get_status()

static void uchcom_cfg_get_status ( struct ucom_softc ucom,
uint8_t *  lsr,
uint8_t *  msr 
)
static

Definition at line 638 of file uchcom.c.

References DPRINTF, uchcom_softc::sc_lsr, uchcom_softc::sc_msr, and ucom_softc::sc_parent.

◆ uchcom_cfg_open()

static void uchcom_cfg_open ( struct ucom_softc ucom)
static

Definition at line 672 of file uchcom.c.

References DPRINTF, ucom_softc::sc_parent, uchcom_update_status(), and uchcom_update_version().

Here is the call graph for this function:

◆ uchcom_cfg_param()

◆ uchcom_cfg_set_break()

static void uchcom_cfg_set_break ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 554 of file uchcom.c.

References ucom_softc::sc_parent, UCHCOM_BRK_MASK, UCHCOM_LCR1_TX, uchcom_read_reg(), UCHCOM_REG_BREAK1, UCHCOM_REG_LCR1, and uchcom_write_reg().

Here is the call graph for this function:

◆ uchcom_cfg_set_dtr()

static void uchcom_cfg_set_dtr ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 650 of file uchcom.c.

References DPRINTF, uchcom_softc::sc_dtr, ucom_softc::sc_parent, and uchcom_set_dtr_rts().

Here is the call graph for this function:

◆ uchcom_cfg_set_rts()

static void uchcom_cfg_set_rts ( struct ucom_softc ucom,
uint8_t  onoff 
)
static

Definition at line 661 of file uchcom.c.

References DPRINTF, ucom_softc::sc_parent, uchcom_softc::sc_rts, and uchcom_set_dtr_rts().

Here is the call graph for this function:

◆ uchcom_convert_status()

static void uchcom_convert_status ( struct uchcom_softc sc,
uint8_t  cur 
)
static

Definition at line 519 of file uchcom.c.

References uchcom_softc::sc_dtr, uchcom_softc::sc_msr, uchcom_softc::sc_rts, UCHCOM_DTR_MASK, and UCHCOM_RTS_MASK.

Referenced by uchcom_intr_callback(), and uchcom_update_status().

Here is the caller graph for this function:

◆ uchcom_ctrl_read()

static void uchcom_ctrl_read ( struct uchcom_softc sc,
uint8_t  reqno,
uint16_t  value,
uint16_t  index,
void *  buf,
uint16_t  buflen 
)
static

Definition at line 429 of file uchcom.c.

References DPRINTF, index, req, uchcom_softc::sc_ucom, uchcom_softc::sc_udev, ucom_cfg_do_request, USB_SHORT_XFER_OK, USETW, UT_READ_VENDOR_DEVICE, and value.

Referenced by uchcom_get_version(), and uchcom_read_reg().

Here is the caller graph for this function:

◆ uchcom_ctrl_write()

static void uchcom_ctrl_write ( struct uchcom_softc sc,
uint8_t  reqno,
uint16_t  value,
uint16_t  index 
)
static

Definition at line 411 of file uchcom.c.

References DPRINTF, index, req, uchcom_softc::sc_ucom, uchcom_softc::sc_udev, ucom_cfg_do_request, USETW, UT_WRITE_VENDOR_DEVICE, and value.

Referenced by uchcom_cfg_param(), uchcom_set_dtr_rts_20(), and uchcom_write_reg().

Here is the caller graph for this function:

◆ uchcom_detach()

static int uchcom_detach ( device_t  dev)
static

Definition at line 373 of file uchcom.c.

References dev, uchcom_softc::sc_super_ucom, uchcom_softc::sc_ucom, uchcom_softc::sc_xfer, uchcom_free_softc(), UCHCOM_N_TRANSFER, ucom_detach(), and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ uchcom_free()

static void uchcom_free ( struct ucom_softc ucom)
static

Definition at line 401 of file uchcom.c.

References ucom_softc::sc_parent, and uchcom_free_softc().

Here is the call graph for this function:

◆ uchcom_free_softc()

static void uchcom_free_softc ( struct uchcom_softc sc)
static

Definition at line 392 of file uchcom.c.

References uchcom_softc::sc_mtx, uchcom_softc::sc_super_ucom, and ucom_unref().

Referenced by uchcom_detach(), and uchcom_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_get_status()

static void uchcom_get_status ( struct uchcom_softc sc,
uint8_t *  rval 
)
static

Definition at line 490 of file uchcom.c.

References uchcom_read_reg(), UCHCOM_REG_STAT1, and UCHCOM_REG_STAT2.

Referenced by uchcom_update_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_get_version()

static void uchcom_get_version ( struct uchcom_softc sc,
uint8_t *  rver 
)
static

Definition at line 479 of file uchcom.c.

References uchcom_ctrl_read(), UCHCOM_INPUT_BUF_SIZE, and UCHCOM_REQ_GET_VERSION.

Referenced by uchcom_cfg_param(), and uchcom_update_version().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_intr_callback()

◆ uchcom_poll()

static void uchcom_poll ( struct ucom_softc ucom)
static

Definition at line 886 of file uchcom.c.

References ucom_softc::sc_parent, uchcom_softc::sc_xfer, UCHCOM_N_TRANSFER, and usbd_transfer_poll().

Here is the call graph for this function:

◆ uchcom_pre_param()

static int uchcom_pre_param ( struct ucom_softc ucom,
struct termios *  t 
)
static

Definition at line 683 of file uchcom.c.

References uchcom_calc_divider_settings().

Here is the call graph for this function:

◆ uchcom_probe()

static int uchcom_probe ( device_t  dev)
static

◆ uchcom_read_callback()

static void uchcom_read_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ uchcom_read_reg()

static void uchcom_read_reg ( struct uchcom_softc sc,
uint8_t  reg1,
uint8_t *  rval1,
uint8_t  reg2,
uint8_t *  rval2 
)
static

Definition at line 459 of file uchcom.c.

References DPRINTF, uchcom_ctrl_read(), UCHCOM_INPUT_BUF_SIZE, and UCHCOM_REQ_READ_REG.

Referenced by uchcom_cfg_param(), uchcom_cfg_set_break(), and uchcom_get_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_set_baudrate()

static void uchcom_set_baudrate ( struct uchcom_softc sc,
uint32_t  rate 
)
static

Definition at line 615 of file uchcom.c.

References uchcom_divider::dv_div, uchcom_divider::dv_mod, uchcom_divider::dv_prescaler, uchcom_calc_divider_settings(), UCHCOM_REG_BPS_DIV, UCHCOM_REG_BPS_MOD, UCHCOM_REG_BPS_PAD, UCHCOM_REG_BPS_PRE, and uchcom_write_reg().

Referenced by uchcom_cfg_param().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_set_dtr_rts()

static void uchcom_set_dtr_rts ( struct uchcom_softc sc)
static

Definition at line 538 of file uchcom.c.

References uchcom_softc::sc_dtr, uchcom_softc::sc_rts, uchcom_softc::sc_version, UCHCOM_DTR_MASK, UCHCOM_RTS_MASK, uchcom_set_dtr_rts_10(), uchcom_set_dtr_rts_20(), UCHCOM_VER_20, and val.

Referenced by uchcom_cfg_param(), uchcom_cfg_set_dtr(), and uchcom_cfg_set_rts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_set_dtr_rts_10()

static void uchcom_set_dtr_rts_10 ( struct uchcom_softc sc,
uint8_t  val 
)
static

Definition at line 496 of file uchcom.c.

References UCHCOM_REG_STAT1, uchcom_write_reg(), and val.

Referenced by uchcom_set_dtr_rts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_set_dtr_rts_20()

static void uchcom_set_dtr_rts_20 ( struct uchcom_softc sc,
uint8_t  val 
)
static

Definition at line 502 of file uchcom.c.

References uchcom_ctrl_write(), UCHCOM_REQ_SET_DTRRTS, and val.

Referenced by uchcom_set_dtr_rts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_start_read()

static void uchcom_start_read ( struct ucom_softc ucom)
static

Definition at line 737 of file uchcom.c.

References ucom_softc::sc_parent, uchcom_softc::sc_xfer, UCHCOM_BULK_DT_RD, UCHCOM_INTR_DT_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ uchcom_start_write()

static void uchcom_start_write ( struct ucom_softc ucom)
static

Definition at line 761 of file uchcom.c.

References ucom_softc::sc_parent, uchcom_softc::sc_xfer, UCHCOM_BULK_DT_WR, and usbd_transfer_start().

Here is the call graph for this function:

◆ uchcom_stop_read()

static void uchcom_stop_read ( struct ucom_softc ucom)
static

Definition at line 749 of file uchcom.c.

References ucom_softc::sc_parent, uchcom_softc::sc_xfer, UCHCOM_BULK_DT_RD, UCHCOM_INTR_DT_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ uchcom_stop_write()

static void uchcom_stop_write ( struct ucom_softc ucom)
static

Definition at line 769 of file uchcom.c.

References ucom_softc::sc_parent, uchcom_softc::sc_xfer, UCHCOM_BULK_DT_WR, and usbd_transfer_stop().

Here is the call graph for this function:

◆ uchcom_update_status()

static void uchcom_update_status ( struct uchcom_softc sc)
static

Definition at line 529 of file uchcom.c.

References uchcom_convert_status(), and uchcom_get_status().

Referenced by uchcom_cfg_open(), and uchcom_cfg_param().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_update_version()

static void uchcom_update_version ( struct uchcom_softc sc)
static

Definition at line 512 of file uchcom.c.

References DPRINTF, uchcom_softc::sc_version, and uchcom_get_version().

Referenced by uchcom_cfg_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uchcom_write_callback()

static void uchcom_write_callback ( struct usb_xfer xfer,
usb_error_t  error 
)
static

◆ uchcom_write_reg()

static void uchcom_write_reg ( struct uchcom_softc sc,
uint8_t  reg1,
uint8_t  val1,
uint8_t  reg2,
uint8_t  val2 
)
static

Definition at line 447 of file uchcom.c.

References DPRINTF, uchcom_ctrl_write(), and UCHCOM_REQ_WRITE_REG.

Referenced by uchcom_cfg_param(), uchcom_cfg_set_break(), uchcom_set_baudrate(), and uchcom_set_dtr_rts_10().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( uchcom  )

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( uchcom_devs  )

Variable Documentation

◆ dividers

const struct uchcom_divider_record dividers[]
static
Initial value:
=
{
{307200, 307200, UCHCOM_BASE_UNKNOWN, {7, 0xD9, 0}},
{921600, 921600, UCHCOM_BASE_UNKNOWN, {7, 0xF3, 0}},
{2999999, 23530, 6000000, {3, 0, 0}},
{23529, 2942, 750000, {2, 0, 0}},
{2941, 368, 93750, {1, 0, 0}},
{367, 1, 11719, {0, 0, 0}},
}
#define UCHCOM_BASE_UNKNOWN
Definition: uchcom.c:132

Definition at line 193 of file uchcom.c.

Referenced by uchcom_calc_divider_settings().

◆ uchcom_attach

device_attach_t uchcom_attach
static

Definition at line 235 of file uchcom.c.

◆ uchcom_callback

struct ucom_callback uchcom_callback
static
Initial value:
= {
.ucom_cfg_get_status = &uchcom_cfg_get_status,
.ucom_cfg_set_dtr = &uchcom_cfg_set_dtr,
.ucom_cfg_set_rts = &uchcom_cfg_set_rts,
.ucom_cfg_set_break = &uchcom_cfg_set_break,
.ucom_cfg_open = &uchcom_cfg_open,
.ucom_cfg_param = &uchcom_cfg_param,
.ucom_pre_param = &uchcom_pre_param,
.ucom_start_read = &uchcom_start_read,
.ucom_stop_read = &uchcom_stop_read,
.ucom_start_write = &uchcom_start_write,
.ucom_stop_write = &uchcom_stop_write,
.ucom_poll = &uchcom_poll,
.ucom_free = &uchcom_free,
}
static void uchcom_cfg_open(struct ucom_softc *ucom)
Definition: uchcom.c:672
static void uchcom_stop_read(struct ucom_softc *)
Definition: uchcom.c:749
static void uchcom_free(struct ucom_softc *)
Definition: uchcom.c:401
static int uchcom_pre_param(struct ucom_softc *, struct termios *)
Definition: uchcom.c:683
static void uchcom_cfg_param(struct ucom_softc *, struct termios *)
Definition: uchcom.c:705
static void uchcom_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *)
Definition: uchcom.c:638
static void uchcom_cfg_set_dtr(struct ucom_softc *, uint8_t)
Definition: uchcom.c:650
static void uchcom_cfg_set_rts(struct ucom_softc *, uint8_t)
Definition: uchcom.c:661
static void uchcom_start_write(struct ucom_softc *)
Definition: uchcom.c:761
static void uchcom_cfg_set_break(struct ucom_softc *, uint8_t)
Definition: uchcom.c:554
static void uchcom_start_read(struct ucom_softc *)
Definition: uchcom.c:737
static void uchcom_stop_write(struct ucom_softc *)
Definition: uchcom.c:769
static void uchcom_poll(struct ucom_softc *ucom)
Definition: uchcom.c:886

Definition at line 272 of file uchcom.c.

Referenced by uchcom_attach().

◆ uchcom_config_data

const struct usb_config uchcom_config_data[UCHCOM_N_TRANSFER]
static
Initial value:
= {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = &uchcom_write_callback,
},
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.callback = &uchcom_read_callback,
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &uchcom_intr_callback,
},
}
static usb_callback_t uchcom_intr_callback
Definition: uchcom.c:239
static usb_callback_t uchcom_read_callback
Definition: uchcom.c:241
static usb_callback_t uchcom_write_callback
Definition: uchcom.c:240
#define UCHCOM_BULK_BUF_SIZE
Definition: uchcom.c:156
@ UCHCOM_BULK_DT_RD
Definition: uchcom.c:160
@ UCHCOM_INTR_DT_RD
Definition: uchcom.c:161
@ UCHCOM_BULK_DT_WR
Definition: uchcom.c:159
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UE_DIR_IN
Definition: usb.h:531
#define UE_DIR_OUT
Definition: usb.h:532

Definition at line 243 of file uchcom.c.

Referenced by uchcom_attach().

◆ uchcom_detach

device_detach_t uchcom_detach
static

Definition at line 236 of file uchcom.c.

Referenced by uchcom_attach().

◆ uchcom_devclass

devclass_t uchcom_devclass
static

Definition at line 906 of file uchcom.c.

◆ uchcom_devs

const STRUCT_USB_HOST_ID uchcom_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)},
{USB_VPI(USB_VENDOR_WCH2, USB_PRODUCT_WCH2_CH341SER, 0)},
{USB_VPI(USB_VENDOR_WCH2, USB_PRODUCT_WCH2_CH341SER_2, 0)},
}
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367

Definition at line 205 of file uchcom.c.

Referenced by uchcom_probe().

◆ uchcom_driver

driver_t uchcom_driver
static
Initial value:
= {
.name = "uchcom",
.methods = uchcom_methods,
.size = sizeof(struct uchcom_softc)
}
static device_method_t uchcom_methods[]
Definition: uchcom.c:892

Definition at line 900 of file uchcom.c.

◆ uchcom_intr_callback

usb_callback_t uchcom_intr_callback
static

Definition at line 239 of file uchcom.c.

◆ uchcom_methods

device_method_t uchcom_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, uchcom_probe),
DEVMETHOD(device_attach, uchcom_attach),
DEVMETHOD(device_detach, uchcom_detach),
DEVMETHOD_END
}
static device_detach_t uchcom_detach
Definition: uchcom.c:236
static device_probe_t uchcom_probe
Definition: uchcom.c:234
static device_attach_t uchcom_attach
Definition: uchcom.c:235

Definition at line 892 of file uchcom.c.

◆ uchcom_probe

device_probe_t uchcom_probe
static

Definition at line 234 of file uchcom.c.

◆ uchcom_read_callback

usb_callback_t uchcom_read_callback
static

Definition at line 241 of file uchcom.c.

◆ uchcom_write_callback

usb_callback_t uchcom_write_callback
static

Definition at line 240 of file uchcom.c.