FreeBSD kernel usb device Code
ucycom.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/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.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 ucycom.c:

Go to the source code of this file.

Data Structures

struct  ucycom_softc
 

Macros

#define USB_DEBUG_VAR   usb_debug
 
#define UCYCOM_MAX_IOLEN   (1024 + 2) /* bytes */
 
#define UCYCOM_IFACE_INDEX   0
 
#define MODEL_CY7C63743   0x63743
 
#define MODEL_CY7C64013   0x64013
 
#define UCYCOM_CFG_RESET   0x80
 
#define UCYCOM_CFG_PARODD   0x20
 
#define UCYCOM_CFG_PAREN   0x10
 
#define UCYCOM_CFG_STOPB   0x08
 
#define UCYCOM_CFG_DATAB   0x03
 
#define UCYCOM_DEFAULT_RATE   4800
 
#define UCYCOM_DEFAULT_CFG   0x03 /* N-8-1 */
 

Enumerations

enum  { UCYCOM_CTRL_RD , UCYCOM_INTR_RD , UCYCOM_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ucycom_free_softc (struct ucycom_softc *)
 
static void ucycom_free (struct ucom_softc *)
 
static void ucycom_cfg_open (struct ucom_softc *)
 
static void ucycom_start_read (struct ucom_softc *)
 
static void ucycom_stop_read (struct ucom_softc *)
 
static void ucycom_start_write (struct ucom_softc *)
 
static void ucycom_stop_write (struct ucom_softc *)
 
static void ucycom_cfg_write (struct ucycom_softc *, uint32_t, uint8_t)
 
static int ucycom_pre_param (struct ucom_softc *, struct termios *)
 
static void ucycom_cfg_param (struct ucom_softc *, struct termios *)
 
static void ucycom_poll (struct ucom_softc *ucom)
 
 DRIVER_MODULE (ucycom, uhub, ucycom_driver, ucycom_devclass, NULL, 0)
 
 MODULE_DEPEND (ucycom, ucom, 1, 1, 1)
 
 MODULE_DEPEND (ucycom, usb, 1, 1, 1)
 
 MODULE_DEPEND (ucycom, hid, 1, 1, 1)
 
 MODULE_VERSION (ucycom, 1)
 
 USB_PNP_HOST_INFO (ucycom_devs)
 
static int ucycom_probe (device_t dev)
 
static int ucycom_attach (device_t dev)
 
static int ucycom_detach (device_t dev)
 
 UCOM_UNLOAD_DRAIN (ucycom)
 
static void ucycom_ctrl_write_callback (struct usb_xfer *xfer, usb_error_t error)
 
static void ucycom_intr_read_callback (struct usb_xfer *xfer, usb_error_t error)
 

Variables

static device_probe_t ucycom_probe
 
static device_attach_t ucycom_attach
 
static device_detach_t ucycom_detach
 
static usb_callback_t ucycom_ctrl_write_callback
 
static usb_callback_t ucycom_intr_read_callback
 
static const struct usb_config ucycom_config [UCYCOM_N_TRANSFER]
 
static const struct ucom_callback ucycom_callback
 
static device_method_t ucycom_methods []
 
static devclass_t ucycom_devclass
 
static driver_t ucycom_driver
 
static const STRUCT_USB_HOST_ID ucycom_devs []
 

Macro Definition Documentation

◆ MODEL_CY7C63743

#define MODEL_CY7C63743   0x63743

Definition at line 91 of file ucycom.c.

◆ MODEL_CY7C64013

#define MODEL_CY7C64013   0x64013

Definition at line 92 of file ucycom.c.

◆ UCYCOM_CFG_DATAB

#define UCYCOM_CFG_DATAB   0x03

Definition at line 106 of file ucycom.c.

◆ UCYCOM_CFG_PAREN

#define UCYCOM_CFG_PAREN   0x10

Definition at line 104 of file ucycom.c.

◆ UCYCOM_CFG_PARODD

#define UCYCOM_CFG_PARODD   0x20

Definition at line 103 of file ucycom.c.

◆ UCYCOM_CFG_RESET

#define UCYCOM_CFG_RESET   0x80

Definition at line 102 of file ucycom.c.

◆ UCYCOM_CFG_STOPB

#define UCYCOM_CFG_STOPB   0x08

Definition at line 105 of file ucycom.c.

◆ UCYCOM_DEFAULT_CFG

#define UCYCOM_DEFAULT_CFG   0x03 /* N-8-1 */

Definition at line 195 of file ucycom.c.

◆ UCYCOM_DEFAULT_RATE

#define UCYCOM_DEFAULT_RATE   4800

Definition at line 194 of file ucycom.c.

◆ UCYCOM_IFACE_INDEX

#define UCYCOM_IFACE_INDEX   0

Definition at line 74 of file ucycom.c.

◆ UCYCOM_MAX_IOLEN

#define UCYCOM_MAX_IOLEN   (1024 + 2) /* bytes */

Definition at line 72 of file ucycom.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   usb_debug

Definition at line 66 of file ucycom.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UCYCOM_CTRL_RD 
UCYCOM_INTR_RD 
UCYCOM_N_TRANSFER 

Definition at line 76 of file ucycom.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ucycom  ,
uhub  ,
ucycom_driver  ,
ucycom_devclass  ,
NULL  ,
 
)

◆ MODULE_DEPEND() [1/3]

MODULE_DEPEND ( ucycom  ,
hid  ,
,
,
 
)

◆ MODULE_DEPEND() [2/3]

MODULE_DEPEND ( ucycom  ,
ucom  ,
,
,
 
)

◆ MODULE_DEPEND() [3/3]

MODULE_DEPEND ( ucycom  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ucycom  ,
 
)

◆ UCOM_UNLOAD_DRAIN()

UCOM_UNLOAD_DRAIN ( ucycom  )

◆ ucycom_attach()

◆ ucycom_cfg_open()

static void ucycom_cfg_open ( struct ucom_softc ucom)
static

Definition at line 331 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_cfg_write(), UCYCOM_DEFAULT_CFG, and UCYCOM_DEFAULT_RATE.

Here is the call graph for this function:

◆ ucycom_cfg_param()

static void ucycom_cfg_param ( struct ucom_softc ucom,
struct termios *  t 
)
static

Definition at line 505 of file ucycom.c.

References DPRINTF, ucycom_softc::sc_cfg, ucom_softc::sc_parent, UCYCOM_CFG_PAREN, UCYCOM_CFG_PARODD, UCYCOM_CFG_STOPB, and ucycom_cfg_write().

Here is the call graph for this function:

◆ ucycom_cfg_write()

static void ucycom_cfg_write ( struct ucycom_softc sc,
uint32_t  baud,
uint8_t  cfg 
)
static

◆ ucycom_ctrl_write_callback()

◆ ucycom_detach()

static int ucycom_detach ( device_t  dev)
static

Definition at line 299 of file ucycom.c.

References dev, ucycom_softc::sc_super_ucom, ucycom_softc::sc_ucom, ucycom_softc::sc_xfer, ucom_detach(), ucycom_free_softc(), UCYCOM_N_TRANSFER, and usbd_transfer_unsetup().

Here is the call graph for this function:

◆ ucycom_free()

static void ucycom_free ( struct ucom_softc ucom)
static

Definition at line 325 of file ucycom.c.

References ucom_softc::sc_parent, and ucycom_free_softc().

Here is the call graph for this function:

◆ ucycom_free_softc()

static void ucycom_free_softc ( struct ucycom_softc sc)
static

Definition at line 316 of file ucycom.c.

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

Referenced by ucycom_detach(), and ucycom_free().

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

◆ ucycom_intr_read_callback()

◆ ucycom_poll()

static void ucycom_poll ( struct ucom_softc ucom)
static

Definition at line 610 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_softc::sc_xfer, UCYCOM_N_TRANSFER, and usbd_transfer_poll().

Here is the call graph for this function:

◆ ucycom_pre_param()

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

Definition at line 477 of file ucycom.c.

◆ ucycom_probe()

static int ucycom_probe ( device_t  dev)
static

◆ ucycom_start_read()

static void ucycom_start_read ( struct ucom_softc ucom)
static

Definition at line 340 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_softc::sc_xfer, UCYCOM_INTR_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ ucycom_start_write()

static void ucycom_start_write ( struct ucom_softc ucom)
static

Definition at line 356 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_softc::sc_xfer, UCYCOM_CTRL_RD, and usbd_transfer_start().

Here is the call graph for this function:

◆ ucycom_stop_read()

static void ucycom_stop_read ( struct ucom_softc ucom)
static

Definition at line 348 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_softc::sc_xfer, UCYCOM_INTR_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ ucycom_stop_write()

static void ucycom_stop_write ( struct ucom_softc ucom)
static

Definition at line 364 of file ucycom.c.

References ucom_softc::sc_parent, ucycom_softc::sc_xfer, UCYCOM_CTRL_RD, and usbd_transfer_stop().

Here is the call graph for this function:

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( ucycom_devs  )

Variable Documentation

◆ ucycom_attach

device_attach_t ucycom_attach
static

Definition at line 115 of file ucycom.c.

◆ ucycom_callback

const struct ucom_callback ucycom_callback
static
Initial value:
= {
.ucom_cfg_param = &ucycom_cfg_param,
.ucom_cfg_open = &ucycom_cfg_open,
.ucom_pre_param = &ucycom_pre_param,
.ucom_start_read = &ucycom_start_read,
.ucom_stop_read = &ucycom_stop_read,
.ucom_start_write = &ucycom_start_write,
.ucom_stop_write = &ucycom_stop_write,
.ucom_poll = &ucycom_poll,
.ucom_free = &ucycom_free,
}
static void ucycom_cfg_open(struct ucom_softc *)
Definition: ucycom.c:331
static void ucycom_start_write(struct ucom_softc *)
Definition: ucycom.c:356
static void ucycom_free(struct ucom_softc *)
Definition: ucycom.c:325
static void ucycom_stop_write(struct ucom_softc *)
Definition: ucycom.c:364
static void ucycom_cfg_param(struct ucom_softc *, struct termios *)
Definition: ucycom.c:505
static void ucycom_start_read(struct ucom_softc *)
Definition: ucycom.c:340
static int ucycom_pre_param(struct ucom_softc *, struct termios *)
Definition: ucycom.c:477
static void ucycom_poll(struct ucom_softc *ucom)
Definition: ucycom.c:610
static void ucycom_stop_read(struct ucom_softc *)
Definition: ucycom.c:348

Definition at line 153 of file ucycom.c.

Referenced by ucycom_attach().

◆ ucycom_config

const struct usb_config ucycom_config[UCYCOM_N_TRANSFER]
static
Initial value:
= {
.type = UE_CONTROL,
.endpoint = 0x00,
.direction = UE_DIR_ANY,
.bufsize = (sizeof(struct usb_device_request) + UCYCOM_MAX_IOLEN),
.timeout = 1000,
},
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = UCYCOM_MAX_IOLEN,
},
}
static usb_callback_t ucycom_intr_read_callback
Definition: ucycom.c:120
#define UCYCOM_MAX_IOLEN
Definition: ucycom.c:72
static usb_callback_t ucycom_ctrl_write_callback
Definition: ucycom.c:119
@ UCYCOM_CTRL_RD
Definition: ucycom.c:77
@ UCYCOM_INTR_RD
Definition: ucycom.c:78
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_DIR_ANY
Definition: usb.h:535
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_DIR_IN
Definition: usb.h:531
#define UE_CONTROL
Definition: usb.h:541

Definition at line 133 of file ucycom.c.

Referenced by ucycom_attach().

◆ ucycom_ctrl_write_callback

usb_callback_t ucycom_ctrl_write_callback
static

Definition at line 119 of file ucycom.c.

◆ ucycom_detach

device_detach_t ucycom_detach
static

Definition at line 116 of file ucycom.c.

Referenced by ucycom_attach().

◆ ucycom_devclass

devclass_t ucycom_devclass
static

Definition at line 172 of file ucycom.c.

◆ ucycom_devs

const STRUCT_USB_HOST_ID ucycom_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE, MODEL_CY7C64013)},
}
#define MODEL_CY7C64013
Definition: ucycom.c:92
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367

Definition at line 183 of file ucycom.c.

Referenced by ucycom_probe().

◆ ucycom_driver

driver_t ucycom_driver
static
Initial value:
= {
.name = "ucycom",
.methods = ucycom_methods,
.size = sizeof(struct ucycom_softc),
}
static device_method_t ucycom_methods[]
Definition: ucycom.c:165

Definition at line 174 of file ucycom.c.

◆ ucycom_intr_read_callback

usb_callback_t ucycom_intr_read_callback
static

Definition at line 120 of file ucycom.c.

◆ ucycom_methods

device_method_t ucycom_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ucycom_probe),
DEVMETHOD(device_attach, ucycom_attach),
DEVMETHOD(device_detach, ucycom_detach),
DEVMETHOD_END
}
static device_detach_t ucycom_detach
Definition: ucycom.c:116
static device_attach_t ucycom_attach
Definition: ucycom.c:115
static device_probe_t ucycom_probe
Definition: ucycom.c:114

Definition at line 165 of file ucycom.c.

◆ ucycom_probe

device_probe_t ucycom_probe
static

Definition at line 114 of file ucycom.c.