FreeBSD kernel usb device Code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/condvar.h>
#include <sys/bus.h>
#include <sys/gpio.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/sdt.h>
#include <sys/sx.h>
#include <dev/gpio/gpiobusvar.h>
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
#include "iicbus_if.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>
Go to the source code of this file.
Data Structures | |
struct | version_request |
struct | gpio_get_req |
struct | gpio_set_req |
struct | gpio_config_req |
struct | i2c_xfer_status_req |
struct | i2c_xfer_status_resp |
struct | i2c_data_read_force_send_req |
struct | i2c_data_read_resp |
struct | i2c_write_read_req |
struct | i2c_read_req |
struct | i2c_write_req |
struct | i2c_cfg_req |
struct | cp2112_softc |
struct | cp2112gpio_softc |
struct | cp2112iic_softc |
Enumerations | |
enum | cp2112_out_mode { OUT_OD , OUT_PP , OUT_KEEP } |
enum | { CP2112_INTR_OUT = 0 , CP2112_INTR_IN , CP2112_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static int | cp2112_detach (device_t dev) |
static int | cp2112gpio_detach (device_t dev) |
static int | cp2112iic_detach (device_t dev) |
static int | cp2112_get_report (device_t dev, uint8_t id, void *data, uint16_t len) |
static int | cp2112_set_report (device_t dev, uint8_t id, void *data, uint16_t len) |
static int | cp2112_probe (device_t dev) |
static int | cp2112_attach (device_t dev) |
static int | cp2112_gpio_read_pin (device_t dev, uint32_t pin_num, bool *on) |
static int | cp2112_gpio_write_pin (device_t dev, uint32_t pin_num, bool on) |
static int | cp2112_gpio_configure_write_pin (device_t dev, uint32_t pin_num, bool output, enum cp2112_out_mode *mode) |
static device_t | cp2112_gpio_get_bus (device_t dev) |
static int | cp2112_gpio_pin_max (device_t dev, int *maxpin) |
static int | cp2112_gpio_pin_set (device_t dev, uint32_t pin_num, uint32_t pin_value) |
static int | cp2112_gpio_pin_get (device_t dev, uint32_t pin_num, uint32_t *pin_value) |
static int | cp2112_gpio_pin_toggle (device_t dev, uint32_t pin_num) |
static int | cp2112_gpio_pin_getcaps (device_t dev, uint32_t pin_num, uint32_t *caps) |
static int | cp2112_gpio_pin_getflags (device_t dev, uint32_t pin_num, uint32_t *flags) |
static int | cp2112_gpio_pin_getname (device_t dev, uint32_t pin_num, char *name) |
static int | cp2112_gpio_pin_setflags (device_t dev, uint32_t pin_num, uint32_t flags) |
static int | cp2112gpio_probe (device_t dev) |
static int | cp2112gpio_attach (device_t dev) |
static void | cp2112iic_intr_write_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | cp2112iic_intr_read_callback (struct usb_xfer *xfer, usb_error_t error) |
static int | cp2112iic_send_req (struct cp2112iic_softc *sc, const void *data, uint16_t len) |
static int | cp2112iic_req_resp (struct cp2112iic_softc *sc, const void *req_data, uint16_t req_len, void *resp_data, uint16_t resp_len) |
static int | cp2112iic_check_req_status (struct cp2112iic_softc *sc) |
static int | cp2112iic_read_data (struct cp2112iic_softc *sc, void *data, uint16_t in_len, uint16_t *out_len) |
static int | cp2112iic_transfer (device_t dev, struct iic_msg *msgs, uint32_t nmsgs) |
static int | cp2112iic_reset (device_t dev, u_char speed, u_char addr, u_char *oldaddr) |
static int | cp2112iic_probe (device_t dev) |
static int | cp2112iic_attach (device_t dev) |
DRIVER_MODULE (cp2112hid, uhub, cp2112hid_driver, cp2112hid_devclass, NULL, NULL) | |
MODULE_DEPEND (cp2112hid, usb, 1, 1, 1) | |
MODULE_VERSION (cp2112hid, 1) | |
USB_PNP_HOST_INFO (cp2112_devs) | |
DRIVER_MODULE (cp2112gpio, cp2112hid, cp2112gpio_driver, cp2112gpio_devclass, NULL, NULL) | |
MODULE_DEPEND (cp2112gpio, cp2112hid, 1, 1, 1) | |
MODULE_DEPEND (cp2112gpio, gpiobus, 1, 1, 1) | |
MODULE_VERSION (cp2112gpio, 1) | |
DRIVER_MODULE (cp2112iic, cp2112hid, cp2112iic_driver, cp2112iic_devclass, NULL, NULL) | |
MODULE_DEPEND (cp2112iic, cp2112hid, 1, 1, 1) | |
MODULE_DEPEND (cp2112iic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER) | |
MODULE_VERSION (cp2112iic, 1) | |
Variables | |
struct version_request | __packed |
static const STRUCT_USB_HOST_ID | cp2112_devs [] |
static const struct usb_config | cp2112iic_config [CP2112_N_TRANSFER] |
static device_method_t | cp2112hid_methods [] |
static driver_t | cp2112hid_driver |
static devclass_t | cp2112hid_devclass |
static device_method_t | cp2112gpio_methods [] |
static driver_t | cp2112gpio_driver |
static devclass_t | cp2112gpio_devclass |
static device_method_t | cp2112iic_methods [] |
static driver_t | cp2112iic_driver |
static devclass_t | cp2112iic_devclass |
#define CP2112_GPIO_SPEC_CLK7 1 /* Pin 7 is clock output. */ |
#define CP2112_GPIO_SPEC_RX1 4 /* Pin 1 pulses on USB RX. */ |
#define CP2112_GPIO_SPEC_TX0 2 /* Pin 0 pulses on USB TX. */ |
#define CP2112GPIO_LOCKED | ( | sc | ) | sx_assert(&sc->gpio_lock, SX_XLOCKED) |
#define SIZEOF_FIELD | ( | _s, | |
_f | |||
) | sizeof(((struct _s *)NULL)->_f) |
anonymous enum |
enum cp2112_out_mode |
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 309 of file cp2112.c.
References usbd_lookup_info::bIfaceIndex, cp2112_detach(), cp2112_get_report(), CP2112_PART_NUM, CP2112_REQ_VERSION, dev, usb_attach_arg::device, device_set_usb_desc(), usb_attach_arg::info, version_request::part_num, cp2112_softc::sc_gpio_dev, cp2112_softc::sc_iface_index, cp2112_softc::sc_iic_dev, cp2112_softc::sc_udev, cp2112_softc::sc_version, and version_request::version.
|
static |
Definition at line 362 of file cp2112.c.
References dev.
Referenced by cp2112_attach().
|
static |
Definition at line 268 of file cp2112.c.
References data, dev, len, cp2112_softc::sc_iface_index, cp2112_softc::sc_udev, UHID_FEATURE_REPORT, and usbd_req_get_report().
Referenced by cp2112_attach(), cp2112_gpio_configure_write_pin(), cp2112_gpio_read_pin(), cp2112gpio_attach(), and cp2112iic_reset().
|
static |
Definition at line 418 of file cp2112.c.
References cp2112_get_report(), CP2112_REQ_GPIO_CFG, cp2112_set_report(), CP2112GPIO_LOCKED, data, dev, OUT_OD, and OUT_PP.
Referenced by cp2112_gpio_pin_setflags().
|
static |
Definition at line 484 of file cp2112.c.
References cp2112gpio_softc::busdev, and dev.
|
static |
Definition at line 518 of file cp2112.c.
References CP2112_GPIO_COUNT, cp2112_gpio_read_pin(), CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, and dev.
|
static |
Definition at line 558 of file cp2112.c.
References CP2112_GPIO_COUNT, CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, dev, and cp2112gpio_softc::gpio_caps.
|
static |
Definition at line 574 of file cp2112.c.
References CP2112_GPIO_COUNT, CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, dev, and cp2112gpio_softc::pins.
|
static |
Definition at line 590 of file cp2112.c.
References CP2112_GPIO_COUNT, CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, dev, name, and cp2112gpio_softc::pins.
|
static |
Definition at line 493 of file cp2112.c.
References CP2112_GPIO_COUNT.
|
static |
Definition at line 501 of file cp2112.c.
References CP2112_GPIO_COUNT, cp2112_gpio_write_pin(), CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, and dev.
|
static |
Definition at line 606 of file cp2112.c.
References cp2112_gpio_configure_write_pin(), CP2112_GPIO_COUNT, CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, dev, cp2112gpio_softc::gpio_caps, OUT_KEEP, OUT_OD, OUT_PP, pin, and cp2112gpio_softc::pins.
|
static |
Definition at line 538 of file cp2112.c.
References CP2112_GPIO_COUNT, cp2112_gpio_read_pin(), cp2112_gpio_write_pin(), CP2112GPIO_LOCK, CP2112GPIO_UNLOCK, and dev.
|
static |
Definition at line 374 of file cp2112.c.
References cp2112_get_report(), CP2112_REQ_GPIO_GET, CP2112GPIO_LOCKED, data, and dev.
Referenced by cp2112_gpio_pin_get(), cp2112_gpio_pin_toggle(), and cp2112_gpio_write_pin().
|
static |
Definition at line 393 of file cp2112.c.
References cp2112_gpio_read_pin(), CP2112_REQ_GPIO_SET, cp2112_set_report(), CP2112GPIO_LOCKED, data, and dev.
Referenced by cp2112_gpio_pin_set(), and cp2112_gpio_pin_toggle().
|
static |
Definition at line 293 of file cp2112.c.
References usbd_lookup_info::bInterfaceClass, cp2112_devs, dev, usb_attach_arg::info, UICLASS_HID, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().
|
static |
Definition at line 280 of file cp2112.c.
References data, dev, len, cp2112_softc::sc_iface_index, cp2112_softc::sc_udev, UHID_FEATURE_REPORT, and usbd_req_set_report().
Referenced by cp2112_gpio_configure_write_pin(), cp2112_gpio_write_pin(), and cp2112iic_reset().
|
static |
Definition at line 681 of file cp2112.c.
References cp2112gpio_softc::busdev, cp2112_get_report(), CP2112_GPIO_COUNT, CP2112_GPIO_SPEC_CLK7, CP2112_GPIO_SPEC_RX1, CP2112_GPIO_SPEC_TX0, CP2112_REQ_GPIO_CFG, cp2112gpio_detach(), data, dev, cp2112gpio_softc::gpio_caps, cp2112gpio_softc::gpio_lock, pin, and cp2112gpio_softc::pins.
|
static |
Definition at line 740 of file cp2112.c.
References cp2112gpio_softc::busdev, dev, and cp2112gpio_softc::gpio_lock.
Referenced by cp2112gpio_attach().
|
static |
|
static |
Definition at line 1314 of file cp2112.c.
References CP2112_INTR_IN, cp2112iic_config, cp2112iic_detach(), cp2112iic_softc::cv, cp2112iic_softc::dev, dev, cp2112iic_softc::iicbus_dev, cp2112iic_softc::io, cp2112iic_softc::lock, cp2112_softc::sc_iface_index, cp2112_softc::sc_udev, usbd_transfer_setup(), usbd_transfer_start(), and cp2112iic_softc::xfers.
|
static |
Definition at line 954 of file cp2112.c.
References CP2112_IIC_STATUS0_BUSY, CP2112_IIC_STATUS0_CMP, CP2112_IIC_STATUS0_ERROR, CP2112_IIC_STATUS0_IDLE, CP2112_IIC_STATUS1_ARB_LOST, CP2112_IIC_STATUS1_TIMEOUT_BUS, CP2112_IIC_STATUS1_TIMEOUT_NACK, CP2112_REQ_SMB_XFER_STATUS_REQ, CP2112_REQ_SMB_XFER_STATUS_RESP, cp2112iic_req_resp(), cp2112iic_softc::dev, i2c_xfer_status_req::id, i2c_xfer_status_resp::id, cp2112iic_softc::io, cp2112iic_softc::lock, i2c_xfer_status_req::request, i2c_xfer_status_resp::status0, i2c_xfer_status_resp::status1, i2c_xfer_status_resp::status2, and i2c_xfer_status_resp::status3.
Referenced by cp2112iic_transfer().
|
static |
Definition at line 1357 of file cp2112.c.
References CP2112_INTR_IN, cp2112iic_config, cp2112iic_softc::cv, cp2112iic_softc::dev, cp2112iic_softc::io, cp2112iic_softc::lock, usbd_transfer_stop(), usbd_transfer_unsetup(), and cp2112iic_softc::xfers.
Referenced by cp2112iic_attach().
|
static |
Definition at line 790 of file cp2112.c.
References CP2112_REPORT_SIZE, CP2112_REQ_SMB_XFER_STATUS_RESP, cp2112iic_softc::cv, cp2112iic_softc::data, cp2112iic_softc::dev, cp2112iic_softc::done, cp2112iic_softc::error, error, cp2112iic_softc::in, cp2112iic_softc::io, len, cp2112iic_softc::len, cp2112iic_softc::lock, 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 752 of file cp2112.c.
References cp2112iic_softc::cv, cp2112iic_softc::data, cp2112iic_softc::dev, cp2112iic_softc::done, cp2112iic_softc::error, error, cp2112iic_softc::io, cp2112iic_softc::len, cp2112iic_softc::lock, cp2112iic_softc::out, USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_in(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_frames(), usbd_xfer_set_stall(), and usbd_xfer_softc().
|
static |
Definition at line 1307 of file cp2112.c.
References cp2112iic_softc::dev.
|
static |
Definition at line 1025 of file cp2112.c.
References CP2112_IIC_STATUS0_CMP, CP2112_IIC_STATUS0_IDLE, CP2112_REQ_SMB_READ_FORCE_SEND, CP2112_REQ_SMB_READ_RESPONSE, cp2112iic_req_resp(), i2c_data_read_resp::data, cp2112iic_softc::dev, i2c_data_read_force_send_req::id, i2c_data_read_resp::id, cp2112iic_softc::io, i2c_data_read_force_send_req::len, i2c_data_read_resp::len, cp2112iic_softc::lock, and i2c_data_read_resp::status.
Referenced by cp2112iic_transfer().
|
static |
Definition at line 920 of file cp2112.c.
References cp2112iic_send_req(), cp2112iic_softc::cv, cp2112iic_softc::data, cp2112iic_softc::done, cp2112iic_softc::error, cp2112iic_softc::in, cp2112iic_softc::io, cp2112iic_softc::len, and cp2112iic_softc::lock.
Referenced by cp2112iic_check_req_status(), and cp2112iic_read_data().
|
static |
Definition at line 1241 of file cp2112.c.
References addr, i2c_cfg_req::auto_send_read, cp2112_get_report(), CP2112_REQ_SMB_CFG, cp2112_set_report(), cp2112iic_softc::dev, cp2112iic_softc::iicbus_dev, i2c_cfg_req::read_timeout, i2c_cfg_req::retry_count, i2c_cfg_req::scl_low_timeout, i2c_cfg_req::slave_addr, i2c_cfg_req::speed, and i2c_cfg_req::write_timeout.
|
static |
Definition at line 888 of file cp2112.c.
References CP2112_INTR_OUT, cp2112iic_softc::cv, cp2112iic_softc::data, data, cp2112iic_softc::dev, cp2112iic_softc::done, cp2112iic_softc::error, cp2112iic_softc::io, len, cp2112iic_softc::len, cp2112iic_softc::lock, cp2112iic_softc::out, usbd_transfer_start(), usbd_transfer_stop(), and cp2112iic_softc::xfers.
Referenced by cp2112iic_req_resp(), and cp2112iic_transfer().
|
static |
Definition at line 1084 of file cp2112.c.
References CP2112_IIC_MAX_READ_LEN, CP2112_IIC_REPSTART_VER, CP2112_REQ_SMB_READ, CP2112_REQ_SMB_WRITE, CP2112_REQ_SMB_WRITE_READ, cp2112iic_check_req_status(), cp2112iic_read_data(), cp2112iic_send_req(), data, cp2112iic_softc::dev, dev, cp2112iic_softc::io, len, cp2112iic_softc::lock, req, cp2112_softc::sc_version, and SIZEOF_FIELD.
DRIVER_MODULE | ( | cp2112gpio | , |
cp2112hid | , | ||
cp2112gpio_driver | , | ||
cp2112gpio_devclass | , | ||
NULL | , | ||
NULL | |||
) |
DRIVER_MODULE | ( | cp2112hid | , |
uhub | , | ||
cp2112hid_driver | , | ||
cp2112hid_devclass | , | ||
NULL | , | ||
NULL | |||
) |
DRIVER_MODULE | ( | cp2112iic | , |
cp2112hid | , | ||
cp2112iic_driver | , | ||
cp2112iic_devclass | , | ||
NULL | , | ||
NULL | |||
) |
MODULE_DEPEND | ( | cp2112gpio | , |
cp2112hid | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cp2112gpio | , |
gpiobus | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cp2112hid | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cp2112iic | , |
cp2112hid | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | cp2112iic | , |
iicbus | , | ||
IICBUS_MINVER | , | ||
IICBUS_PREFVER | , | ||
IICBUS_MAXVER | |||
) |
MODULE_VERSION | ( | cp2112gpio | , |
1 | |||
) |
MODULE_VERSION | ( | cp2112hid | , |
1 | |||
) |
MODULE_VERSION | ( | cp2112iic | , |
1 | |||
) |
USB_PNP_HOST_INFO | ( | cp2112_devs | ) |
struct i2c_cfg_req __packed |
|
static |
Definition at line 262 of file cp2112.c.
Referenced by cp2112_probe().
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 868 of file cp2112.c.
Referenced by cp2112iic_attach(), and cp2112iic_detach().
|
static |
|
static |