FreeBSD kernel usb device Code
musb_otg.c File Reference
#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/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_transfer.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_util.h>
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/controller/musb_otg.h>
Include dependency graph for musb_otg.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   musbotgdebug
 
#define MUSBOTG_INTR_ENDPT   1
 
#define MUSBOTG_BUS2SC(bus)    __containerof(bus, struct musbotg_softc, sc_bus)
 
#define MUSBOTG_PC2SC(pc)    MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
#define MAX_NAK_TO   16
 
#define HSETW(ptr, val)   ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) }
 
#define STRING_VENDOR    "M\0e\0n\0t\0o\0r\0 \0G\0r\0a\0p\0h\0i\0c\0s"
 
#define STRING_PRODUCT    "O\0T\0G\0 \0R\0o\0o\0t\0 \0H\0U\0B"
 

Functions

static void musbotg_device_done (struct usb_xfer *, usb_error_t)
 
static void musbotg_do_poll (struct usb_bus *)
 
static void musbotg_standard_done (struct usb_xfer *)
 
static void musbotg_interrupt_poll (struct musbotg_softc *)
 
static void musbotg_root_intr (struct musbotg_softc *)
 
static int musbotg_channel_alloc (struct musbotg_softc *, struct musbotg_td *td, uint8_t)
 
static void musbotg_channel_free (struct musbotg_softc *, struct musbotg_td *td)
 
static void musbotg_ep_int_set (struct musbotg_softc *sc, int channel, int on)
 
static void musbotg_get_hw_ep_profile (struct usb_device *udev, const struct usb_hw_ep_profile **ppf, uint8_t ep_addr)
 
static void musbotg_clocks_on (struct musbotg_softc *sc)
 
static void musbotg_clocks_off (struct musbotg_softc *sc)
 
static void musbotg_pull_common (struct musbotg_softc *sc, uint8_t on)
 
static void musbotg_pull_up (struct musbotg_softc *sc)
 
static void musbotg_pull_down (struct musbotg_softc *sc)
 
static void musbotg_suspend_host (struct musbotg_softc *sc)
 
static void musbotg_wakeup_host (struct musbotg_softc *sc)
 
static void musbotg_wakeup_peer (struct musbotg_softc *sc)
 
static void musbotg_set_address (struct musbotg_softc *sc, uint8_t addr)
 
static uint8_t musbotg_dev_ctrl_setup_rx (struct musbotg_td *td)
 
static uint8_t musbotg_host_ctrl_setup_tx (struct musbotg_td *td)
 
static uint8_t musbotg_dev_ctrl_data_rx (struct musbotg_td *td)
 
static uint8_t musbotg_dev_ctrl_data_tx (struct musbotg_td *td)
 
static uint8_t musbotg_host_ctrl_data_rx (struct musbotg_td *td)
 
static uint8_t musbotg_host_ctrl_data_tx (struct musbotg_td *td)
 
static uint8_t musbotg_dev_ctrl_status (struct musbotg_td *td)
 
static uint8_t musbotg_host_ctrl_status_rx (struct musbotg_td *td)
 
static uint8_t musbotg_host_ctrl_status_tx (struct musbotg_td *td)
 
static uint8_t musbotg_dev_data_rx (struct musbotg_td *td)
 
static uint8_t musbotg_dev_data_tx (struct musbotg_td *td)
 
static uint8_t musbotg_host_data_rx (struct musbotg_td *td)
 
static uint8_t musbotg_host_data_tx (struct musbotg_td *td)
 
static uint8_t musbotg_xfer_do_fifo (struct usb_xfer *xfer)
 
void musbotg_vbus_interrupt (struct musbotg_softc *sc, uint8_t is_on)
 
void musbotg_connect_interrupt (struct musbotg_softc *sc)
 
void musbotg_interrupt (struct musbotg_softc *sc, uint16_t rxstat, uint16_t txstat, uint8_t stat)
 
static void musbotg_setup_standard_chain_sub (struct musbotg_std_temp *temp)
 
static void musbotg_setup_standard_chain (struct usb_xfer *xfer)
 
static void musbotg_timeout (void *arg)
 
static void musbotg_start_standard_chain (struct usb_xfer *xfer)
 
static usb_error_t musbotg_standard_done_sub (struct usb_xfer *xfer)
 
static void musbotg_xfer_stall (struct usb_xfer *xfer)
 
static void musbotg_set_stall (struct usb_device *udev, struct usb_endpoint *ep, uint8_t *did_stall)
 
static void musbotg_clear_stall_sub (struct musbotg_softc *sc, uint16_t wMaxPacket, uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir)
 
static void musbotg_clear_stall (struct usb_device *udev, struct usb_endpoint *ep)
 
usb_error_t musbotg_init (struct musbotg_softc *sc)
 
void musbotg_uninit (struct musbotg_softc *sc)
 
static void musbotg_device_bulk_open (struct usb_xfer *xfer)
 
static void musbotg_device_bulk_close (struct usb_xfer *xfer)
 
static void musbotg_device_bulk_enter (struct usb_xfer *xfer)
 
static void musbotg_device_bulk_start (struct usb_xfer *xfer)
 
static void musbotg_device_ctrl_open (struct usb_xfer *xfer)
 
static void musbotg_device_ctrl_close (struct usb_xfer *xfer)
 
static void musbotg_device_ctrl_enter (struct usb_xfer *xfer)
 
static void musbotg_device_ctrl_start (struct usb_xfer *xfer)
 
static void musbotg_device_intr_open (struct usb_xfer *xfer)
 
static void musbotg_device_intr_close (struct usb_xfer *xfer)
 
static void musbotg_device_intr_enter (struct usb_xfer *xfer)
 
static void musbotg_device_intr_start (struct usb_xfer *xfer)
 
static void musbotg_device_isoc_open (struct usb_xfer *xfer)
 
static void musbotg_device_isoc_close (struct usb_xfer *xfer)
 
static void musbotg_device_isoc_enter (struct usb_xfer *xfer)
 
static void musbotg_device_isoc_start (struct usb_xfer *xfer)
 
 USB_MAKE_STRING_DESC (STRING_VENDOR, musbotg_vendor)
 
 USB_MAKE_STRING_DESC (STRING_PRODUCT, musbotg_product)
 
static usb_error_t musbotg_roothub_exec (struct usb_device *udev, struct usb_device_request *req, const void **pptr, uint16_t *plength)
 
static void musbotg_xfer_setup (struct usb_setup_params *parm)
 
static void musbotg_xfer_unsetup (struct usb_xfer *xfer)
 
static void musbotg_get_dma_delay (struct usb_device *udev, uint32_t *pus)
 
static void musbotg_ep_init (struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep)
 
static void musbotg_set_hw_power_sleep (struct usb_bus *bus, uint32_t state)
 

Variables

static const struct usb_bus_methods musbotg_bus_methods
 
static const struct usb_pipe_methods musbotg_device_bulk_methods
 
static const struct usb_pipe_methods musbotg_device_ctrl_methods
 
static const struct usb_pipe_methods musbotg_device_intr_methods
 
static const struct usb_pipe_methods musbotg_device_isoc_methods
 
static musbotg_cmd_t musbotg_dev_ctrl_setup_rx
 
static musbotg_cmd_t musbotg_dev_ctrl_data_rx
 
static musbotg_cmd_t musbotg_dev_ctrl_data_tx
 
static musbotg_cmd_t musbotg_dev_ctrl_status
 
static musbotg_cmd_t musbotg_host_ctrl_setup_tx
 
static musbotg_cmd_t musbotg_host_ctrl_data_rx
 
static musbotg_cmd_t musbotg_host_ctrl_data_tx
 
static musbotg_cmd_t musbotg_host_ctrl_status_rx
 
static musbotg_cmd_t musbotg_host_ctrl_status_tx
 
static musbotg_cmd_t musbotg_dev_data_rx
 
static musbotg_cmd_t musbotg_dev_data_tx
 
static musbotg_cmd_t musbotg_host_data_rx
 
static musbotg_cmd_t musbotg_host_data_tx
 
static const struct usb_hw_ep_profile musbotg_ep_profile [1]
 
static const struct musb_otg_ep_cfg musbotg_ep_default []
 
static const struct usb_device_descriptor musbotg_devd
 
static const struct usb_device_qualifier musbotg_odevd
 
static const struct musbotg_config_desc musbotg_confd
 
static const struct usb_hub_descriptor_min musbotg_hubd
 

Macro Definition Documentation

◆ HSETW

#define HSETW (   ptr,
  val 
)    ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) }

Definition at line 3529 of file musb_otg.c.

◆ MAX_NAK_TO

#define MAX_NAK_TO   16

Definition at line 99 of file musb_otg.c.

◆ MUSBOTG_BUS2SC

#define MUSBOTG_BUS2SC (   bus)     __containerof(bus, struct musbotg_softc, sc_bus)

Definition at line 84 of file musb_otg.c.

◆ MUSBOTG_INTR_ENDPT

#define MUSBOTG_INTR_ENDPT   1

Definition at line 82 of file musb_otg.c.

◆ MUSBOTG_PC2SC

#define MUSBOTG_PC2SC (   pc)     MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)

Definition at line 87 of file musb_otg.c.

◆ STRING_PRODUCT

#define STRING_PRODUCT    "O\0T\0G\0 \0R\0o\0o\0t\0 \0H\0U\0B"

Definition at line 3544 of file musb_otg.c.

◆ STRING_VENDOR

#define STRING_VENDOR    "M\0e\0n\0t\0o\0r\0 \0G\0r\0a\0p\0h\0i\0c\0s"

Definition at line 3541 of file musb_otg.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   musbotgdebug

Definition at line 65 of file musb_otg.c.

Function Documentation

◆ musbotg_channel_alloc()

◆ musbotg_channel_free()

◆ musbotg_clear_stall()

◆ musbotg_clear_stall_sub()

◆ musbotg_clocks_off()

static void musbotg_clocks_off ( struct musbotg_softc sc)
static

Definition at line 277 of file musb_otg.c.

References musbotg_flags::clocks_off, musbotg_softc::sc_clocks_arg, musbotg_softc::sc_clocks_off, and musbotg_softc::sc_flags.

Referenced by musbotg_init(), musbotg_roothub_exec(), and musbotg_uninit().

Here is the caller graph for this function:

◆ musbotg_clocks_on()

static void musbotg_clocks_on ( struct musbotg_softc sc)
static

Definition at line 261 of file musb_otg.c.

References musbotg_flags::clocks_off, musbotg_flags::port_powered, musbotg_softc::sc_clocks_arg, musbotg_softc::sc_clocks_on, and musbotg_softc::sc_flags.

Referenced by musbotg_roothub_exec().

Here is the caller graph for this function:

◆ musbotg_connect_interrupt()

void musbotg_connect_interrupt ( struct musbotg_softc sc)

Definition at line 2216 of file musb_otg.c.

References musbotg_flags::change_connect, musbotg_root_intr(), musbotg_softc::sc_bus, musbotg_softc::sc_flags, USB_BUS_LOCK, and USB_BUS_UNLOCK.

Here is the call graph for this function:

◆ musbotg_dev_ctrl_data_rx()

◆ musbotg_dev_ctrl_data_tx()

◆ musbotg_dev_ctrl_setup_rx()

◆ musbotg_dev_ctrl_status()

static uint8_t musbotg_dev_ctrl_status ( struct musbotg_td td)
static

◆ musbotg_dev_data_rx()

◆ musbotg_dev_data_tx()

◆ musbotg_device_bulk_close()

static void musbotg_device_bulk_close ( struct usb_xfer xfer)
static

Definition at line 3318 of file musb_otg.c.

References musbotg_device_done(), and USB_ERR_CANCELLED.

Here is the call graph for this function:

◆ musbotg_device_bulk_enter()

static void musbotg_device_bulk_enter ( struct usb_xfer xfer)
static

Definition at line 3324 of file musb_otg.c.

◆ musbotg_device_bulk_open()

static void musbotg_device_bulk_open ( struct usb_xfer xfer)
static

Definition at line 3312 of file musb_otg.c.

◆ musbotg_device_bulk_start()

static void musbotg_device_bulk_start ( struct usb_xfer xfer)
static

Definition at line 3330 of file musb_otg.c.

References musbotg_setup_standard_chain(), and musbotg_start_standard_chain().

Here is the call graph for this function:

◆ musbotg_device_ctrl_close()

static void musbotg_device_ctrl_close ( struct usb_xfer xfer)
static

Definition at line 3355 of file musb_otg.c.

References musbotg_device_done(), and USB_ERR_CANCELLED.

Here is the call graph for this function:

◆ musbotg_device_ctrl_enter()

static void musbotg_device_ctrl_enter ( struct usb_xfer xfer)
static

Definition at line 3361 of file musb_otg.c.

◆ musbotg_device_ctrl_open()

static void musbotg_device_ctrl_open ( struct usb_xfer xfer)
static

Definition at line 3349 of file musb_otg.c.

◆ musbotg_device_ctrl_start()

static void musbotg_device_ctrl_start ( struct usb_xfer xfer)
static

Definition at line 3367 of file musb_otg.c.

References musbotg_setup_standard_chain(), and musbotg_start_standard_chain().

Here is the call graph for this function:

◆ musbotg_device_done()

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

◆ musbotg_device_intr_close()

static void musbotg_device_intr_close ( struct usb_xfer xfer)
static

Definition at line 3392 of file musb_otg.c.

References musbotg_device_done(), and USB_ERR_CANCELLED.

Here is the call graph for this function:

◆ musbotg_device_intr_enter()

static void musbotg_device_intr_enter ( struct usb_xfer xfer)
static

Definition at line 3398 of file musb_otg.c.

◆ musbotg_device_intr_open()

static void musbotg_device_intr_open ( struct usb_xfer xfer)
static

Definition at line 3386 of file musb_otg.c.

◆ musbotg_device_intr_start()

static void musbotg_device_intr_start ( struct usb_xfer xfer)
static

Definition at line 3404 of file musb_otg.c.

References musbotg_setup_standard_chain(), and musbotg_start_standard_chain().

Here is the call graph for this function:

◆ musbotg_device_isoc_close()

static void musbotg_device_isoc_close ( struct usb_xfer xfer)
static

Definition at line 3429 of file musb_otg.c.

References musbotg_device_done(), and USB_ERR_CANCELLED.

Here is the call graph for this function:

◆ musbotg_device_isoc_enter()

static void musbotg_device_isoc_enter ( struct usb_xfer xfer)
static

◆ musbotg_device_isoc_open()

static void musbotg_device_isoc_open ( struct usb_xfer xfer)
static

Definition at line 3423 of file musb_otg.c.

◆ musbotg_device_isoc_start()

static void musbotg_device_isoc_start ( struct usb_xfer xfer)
static

Definition at line 3456 of file musb_otg.c.

References musbotg_start_standard_chain().

Here is the call graph for this function:

◆ musbotg_do_poll()

static void musbotg_do_poll ( struct usb_bus bus)
static

Definition at line 3299 of file musb_otg.c.

References bus, MUSBOTG_BUS2SC, musbotg_interrupt_poll(), musbotg_softc::sc_bus, USB_BUS_LOCK, and USB_BUS_UNLOCK.

Referenced by musbotg_init().

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

◆ musbotg_ep_init()

◆ musbotg_ep_int_set()

static void musbotg_ep_int_set ( struct musbotg_softc sc,
int  channel,
int  on 
)
static

Definition at line 2619 of file musb_otg.c.

References MUSB2_MASK_EPINT, MUSB2_READ_2, MUSB2_REG_INTRXE, MUSB2_REG_INTTXE, MUSB2_WRITE_2, and musbotg_softc::sc_ep_int_set.

Referenced by musbotg_channel_alloc(), and musbotg_channel_free().

Here is the caller graph for this function:

◆ musbotg_get_dma_delay()

static void musbotg_get_dma_delay ( struct usb_device udev,
uint32_t *  pus 
)
static

Definition at line 4119 of file musb_otg.c.

References usb_device::bus, MUSB2_HOST_MODE, MUSBOTG_BUS2SC, and musbotg_softc::sc_mode.

◆ musbotg_get_hw_ep_profile()

static void musbotg_get_hw_ep_profile ( struct usb_device udev,
const struct usb_hw_ep_profile **  ppf,
uint8_t  ep_addr 
)
static

Definition at line 242 of file musb_otg.c.

References usb_device::bus, MUSBOTG_BUS2SC, musbotg_ep_profile, musbotg_softc::sc_ep_max, and musbotg_softc::sc_hw_ep_profile.

Referenced by musbotg_xfer_setup().

Here is the caller graph for this function:

◆ musbotg_host_ctrl_data_rx()

◆ musbotg_host_ctrl_data_tx()

◆ musbotg_host_ctrl_setup_tx()

◆ musbotg_host_ctrl_status_rx()

◆ musbotg_host_ctrl_status_tx()

◆ musbotg_host_data_rx()

◆ musbotg_host_data_tx()

◆ musbotg_init()

◆ musbotg_interrupt()

◆ musbotg_interrupt_poll()

static void musbotg_interrupt_poll ( struct musbotg_softc sc)
static

Definition at line 2173 of file musb_otg.c.

References usb_bus::intr_q, musbotg_xfer_do_fifo(), and musbotg_softc::sc_bus.

Referenced by musbotg_do_poll(), and musbotg_interrupt().

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

◆ musbotg_pull_common()

static void musbotg_pull_common ( struct musbotg_softc sc,
uint8_t  on 
)
static

Definition at line 292 of file musb_otg.c.

References MUSB2_MASK_SOFTC, MUSB2_READ_1, MUSB2_REG_POWER, and MUSB2_WRITE_1.

Referenced by musbotg_init(), musbotg_pull_down(), and musbotg_pull_up().

Here is the caller graph for this function:

◆ musbotg_pull_down()

static void musbotg_pull_down ( struct musbotg_softc sc)
static

Definition at line 318 of file musb_otg.c.

References musbotg_flags::d_pulled_up, musbotg_pull_common(), and musbotg_softc::sc_flags.

Referenced by musbotg_roothub_exec(), and musbotg_uninit().

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

◆ musbotg_pull_up()

static void musbotg_pull_up ( struct musbotg_softc sc)
static

Definition at line 306 of file musb_otg.c.

References musbotg_flags::d_pulled_up, musbotg_pull_common(), musbotg_flags::port_powered, and musbotg_softc::sc_flags.

Referenced by musbotg_roothub_exec().

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

◆ musbotg_root_intr()

static void musbotg_root_intr ( struct musbotg_softc sc)
static

Definition at line 2682 of file musb_otg.c.

References musbotg_softc::sc_bus, musbotg_softc::sc_hub_idata, uhub_root_intr(), and USB_BUS_LOCK_ASSERT.

Referenced by musbotg_connect_interrupt(), musbotg_interrupt(), and musbotg_vbus_interrupt().

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

◆ musbotg_roothub_exec()

static usb_error_t musbotg_roothub_exec ( struct usb_device udev,
struct usb_device_request req,
const void **  pptr,
uint16_t *  plength 
)
static

Definition at line 3551 of file musb_otg.c.

References usb_device::bus, usb_bus::bus_mtx, musbotg_flags::change_connect, musbotg_flags::change_enabled, musbotg_flags::change_over_current, musbotg_flags::change_reset, musbotg_flags::change_suspend, index, len, MUSB2_DEVICE_MODE, MUSB2_HOST_MODE, MUSB2_MASK_HSMODE, MUSB2_MASK_RESET, MUSB2_READ_1, MUSB2_REG_POWER, MUSB2_WRITE_1, MUSBOTG_BUS2SC, musbotg_clocks_off(), musbotg_clocks_on(), musbotg_confd, musbotg_devd, musbotg_hubd, musbotg_odevd, musbotg_pull_down(), musbotg_pull_up(), musbotg_suspend_host(), musbotg_wakeup_host(), musbotg_wakeup_peer(), musbotg_flags::port_enabled, musbotg_flags::port_over_current, musbotg_flags::port_powered, pptr, musbotg_hub_temp::ps, reg, req, musbotg_softc::sc_bus, musbotg_softc::sc_conf, musbotg_softc::sc_ep0_busy, musbotg_softc::sc_ep0_cmd, musbotg_softc::sc_flags, musbotg_softc::sc_hub_temp, musbotg_softc::sc_mode, musbotg_softc::sc_rt_addr, musbotg_flags::status_bus_reset, musbotg_flags::status_high_speed, musbotg_flags::status_suspend, musbotg_flags::status_vbus, UDESC_CONFIG, UDESC_DEVICE, UDESC_DEVICE_QUALIFIER, UDESC_STRING, UDS_SELF_POWERED, UF_DEVICE_REMOTE_WAKEUP, UF_ENDPOINT_HALT, UGETW, UHF_C_PORT_CONNECTION, UHF_C_PORT_ENABLE, UHF_C_PORT_OVER_CURRENT, UHF_C_PORT_RESET, UHF_C_PORT_SUSPEND, UHF_PORT_ENABLE, UHF_PORT_INDICATOR, UHF_PORT_POWER, UHF_PORT_RESET, UHF_PORT_SUSPEND, UHF_PORT_TEST, UPS_C_CONNECT_STATUS, UPS_C_OVERCURRENT_INDICATOR, UPS_C_PORT_RESET, UPS_C_SUSPEND, UPS_CURRENT_CONNECT_STATUS, UPS_HIGH_SPEED, UPS_OVERCURRENT_INDICATOR, UPS_PORT_ENABLED, UPS_PORT_MODE_DEVICE, UPS_PORT_POWER, UPS_SUSPEND, UR_CLEAR_FEATURE, UR_CLEAR_TT_BUFFER, UR_GET_CONFIG, UR_GET_DESCRIPTOR, UR_GET_INTERFACE, UR_GET_STATUS, UR_GET_TT_STATE, UR_RESET_TT, UR_SET_ADDRESS, UR_SET_CONFIG, UR_SET_DESCRIPTOR, UR_SET_FEATURE, UR_SET_INTERFACE, UR_STOP_TT, UR_SYNCH_FRAME, USB_BUS_LOCK_ASSERT, USB_ERR_IOERROR, USB_ERR_STALLED, usb_pause_mtx(), usb_string_lang_en, USETW, UT_READ_CLASS_DEVICE, UT_READ_CLASS_INTERFACE, UT_READ_CLASS_OTHER, UT_READ_DEVICE, UT_READ_ENDPOINT, UT_READ_INTERFACE, UT_READ_VENDOR_INTERFACE, UT_WRITE_CLASS_DEVICE, UT_WRITE_CLASS_INTERFACE, UT_WRITE_CLASS_OTHER, UT_WRITE_DEVICE, UT_WRITE_ENDPOINT, UT_WRITE_INTERFACE, UT_WRITE_VENDOR_INTERFACE, value, usb_port_status::wPortChange, usb_port_status::wPortStatus, and musbotg_hub_temp::wValue.

Here is the call graph for this function:

◆ musbotg_set_address()

static void musbotg_set_address ( struct musbotg_softc sc,
uint8_t  addr 
)
static

Definition at line 391 of file musb_otg.c.

References addr, MUSB2_REG_FADDR, and MUSB2_WRITE_1.

Referenced by musbotg_dev_ctrl_status().

Here is the caller graph for this function:

◆ musbotg_set_hw_power_sleep()

static void musbotg_set_hw_power_sleep ( struct usb_bus bus,
uint32_t  state 
)
static

Definition at line 4162 of file musb_otg.c.

References bus, MUSBOTG_BUS2SC, musbotg_init(), musbotg_uninit(), state, USB_HW_POWER_RESUME, USB_HW_POWER_SHUTDOWN, and USB_HW_POWER_SUSPEND.

Here is the call graph for this function:

◆ musbotg_set_stall()

◆ musbotg_setup_standard_chain()

static void musbotg_setup_standard_chain ( struct usb_xfer xfer)
static

Definition at line 2391 of file musb_otg.c.

References usb_xfer::address, usb_endpoint_descriptor::bmAttributes, usb_xfer_root::bus, musbotg_std_temp::channel, usb_xfer_flags_int::control_act, usb_xfer_flags_int::control_hdr, usb_xfer_flags_int::control_stall, usb_xfer_flags_int::control_xfr, musbotg_td::dev_addr, musbotg_std_temp::dev_addr, musbotg_std_temp::did_stall, usb_endpoint::edesc, usb_xfer::endpoint, usb_xfer::endpointno, musbotg_td::ep_no, usb_xfer::flags, usb_xfer::flags_int, usb_xfer_flags::force_short_xfer, usb_xfer::frbuffers, usb_xfer::frlengths, musbotg_std_temp::func, musbotg_std_temp::haddr, musbotg_std_temp::hport, usb_device::hs_hub_addr, usb_device::hs_port_no, usb_xfer_flags_int::isochronous_xfr, musbotg_std_temp::len, musbotg_std_temp::max_frame_size, usb_xfer::max_frame_size, MUSB2_DEVICE_MODE, MUSB2_MASK_TI_PROTO_BULK, MUSB2_MASK_TI_PROTO_CTRL, MUSB2_MASK_TI_PROTO_INTR, MUSB2_MASK_TI_PROTO_ISOC, MUSB2_MASK_TI_SPEED_FS, MUSB2_MASK_TI_SPEED_HS, MUSB2_MASK_TI_SPEED_LO, MUSBOTG_BUS2SC, musbotg_dev_ctrl_data_rx, musbotg_dev_ctrl_data_tx, musbotg_dev_ctrl_setup_rx, musbotg_dev_ctrl_status, musbotg_dev_data_rx, musbotg_dev_data_tx, musbotg_host_ctrl_data_rx, musbotg_host_ctrl_data_tx, musbotg_host_ctrl_setup_tx, musbotg_host_ctrl_status_rx, musbotg_host_ctrl_status_tx, musbotg_host_data_rx, musbotg_host_data_tx, musbotg_setup_standard_chain_sub(), usb_xfer::nframes, musbotg_std_temp::offset, musbotg_std_temp::pc, musbotg_softc::sc_mode, musbotg_std_temp::setup_alt_next, usb_xfer_flags_int::short_frames_ok, musbotg_std_temp::short_pkt, usb_xfer::sumlen, musbotg_std_temp::td, musbotg_std_temp::td_next, usb_xfer::td_start, usb_xfer::td_transfer_cache, usb_xfer::td_transfer_first, usb_xfer::td_transfer_last, musbotg_td::toggle, usb_endpoint::toggle_next, musbotg_std_temp::transfer_type, tx, usb_xfer_root::udev, UE_ADDR, UE_BULK, UE_CONTROL, UE_DIR_IN, UE_GET_ADDR, UE_INTERRUPT, UE_ISOCHRONOUS, UE_XFERTYPE, usb_xfer_flags_int::usb_mode, USB_MODE_DEVICE, USB_MODE_HOST, USB_SPEED_FULL, USB_SPEED_HIGH, USB_SPEED_LOW, usbd_get_speed(), and usb_xfer::xroot.

Referenced by musbotg_device_bulk_start(), musbotg_device_ctrl_start(), musbotg_device_intr_start(), and musbotg_device_isoc_enter().

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

◆ musbotg_setup_standard_chain_sub()

◆ musbotg_standard_done()

static void musbotg_standard_done ( struct usb_xfer xfer)
static

◆ musbotg_standard_done_sub()

◆ musbotg_start_standard_chain()

static void musbotg_start_standard_chain ( struct usb_xfer xfer)
static

◆ musbotg_suspend_host()

static void musbotg_suspend_host ( struct musbotg_softc sc)
static

Definition at line 329 of file musb_otg.c.

References MUSB2_MASK_SUSPMODE, MUSB2_READ_1, MUSB2_REG_POWER, MUSB2_WRITE_1, musbotg_softc::sc_flags, and musbotg_flags::status_suspend.

Referenced by musbotg_roothub_exec().

Here is the caller graph for this function:

◆ musbotg_timeout()

static void musbotg_timeout ( void *  arg)
static

Definition at line 2606 of file musb_otg.c.

References usb_xfer_root::bus, musbotg_device_done(), USB_BUS_LOCK_ASSERT, USB_ERR_TIMEOUT, and usb_xfer::xroot.

Referenced by musbotg_start_standard_chain().

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

◆ musbotg_uninit()

◆ musbotg_vbus_interrupt()

void musbotg_vbus_interrupt ( struct musbotg_softc sc,
uint8_t  is_on 
)

◆ musbotg_wakeup_host()

static void musbotg_wakeup_host ( struct musbotg_softc sc)
static

Definition at line 344 of file musb_otg.c.

References usb_bus::bus_mtx, MUSB2_MASK_RESUME, MUSB2_READ_1, MUSB2_REG_POWER, MUSB2_WRITE_1, musbotg_softc::sc_bus, musbotg_softc::sc_flags, musbotg_flags::status_suspend, and usb_pause_mtx().

Referenced by musbotg_roothub_exec().

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

◆ musbotg_wakeup_peer()

static void musbotg_wakeup_peer ( struct musbotg_softc sc)
static

Definition at line 369 of file musb_otg.c.

References usb_bus::bus_mtx, MUSB2_MASK_RESUME, MUSB2_READ_1, MUSB2_REG_POWER, MUSB2_WRITE_1, musbotg_softc::sc_bus, musbotg_softc::sc_flags, musbotg_flags::status_suspend, and usb_pause_mtx().

Referenced by musbotg_roothub_exec().

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

◆ musbotg_xfer_do_fifo()

static uint8_t musbotg_xfer_do_fifo ( struct usb_xfer xfer)
static

Definition at line 2127 of file musb_otg.c.

References usb_xfer_root::bus, musbotg_td::func, MUSBOTG_BUS2SC, musbotg_standard_done(), usb_xfer::td_transfer_cache, usb_xfer::td_transfer_last, and usb_xfer::xroot.

Referenced by musbotg_interrupt_poll(), and musbotg_start_standard_chain().

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

◆ musbotg_xfer_setup()

◆ musbotg_xfer_stall()

static void musbotg_xfer_stall ( struct usb_xfer xfer)
static

Definition at line 2831 of file musb_otg.c.

References musbotg_device_done(), and USB_ERR_STALLED.

Here is the call graph for this function:

◆ musbotg_xfer_unsetup()

static void musbotg_xfer_unsetup ( struct usb_xfer xfer)
static

Definition at line 4113 of file musb_otg.c.

◆ USB_MAKE_STRING_DESC() [1/2]

USB_MAKE_STRING_DESC ( STRING_PRODUCT  ,
musbotg_product   
)

◆ USB_MAKE_STRING_DESC() [2/2]

USB_MAKE_STRING_DESC ( STRING_VENDOR  ,
musbotg_vendor   
)

Variable Documentation

◆ musbotg_bus_methods

static const struct usb_bus_methods musbotg_bus_methods
static
Initial value:
=
{
.endpoint_init = &musbotg_ep_init,
.get_dma_delay = &musbotg_get_dma_delay,
.xfer_setup = &musbotg_xfer_setup,
.xfer_unsetup = &musbotg_xfer_unsetup,
.get_hw_ep_profile = &musbotg_get_hw_ep_profile,
.xfer_stall = &musbotg_xfer_stall,
.set_stall = &musbotg_set_stall,
.clear_stall = &musbotg_clear_stall,
.roothub_exec = &musbotg_roothub_exec,
.xfer_poll = &musbotg_do_poll,
.set_hw_power_sleep = &musbotg_set_hw_power_sleep,
}
static usb_error_t musbotg_roothub_exec(struct usb_device *udev, struct usb_device_request *req, const void **pptr, uint16_t *plength)
Definition: musb_otg.c:3551
static void musbotg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep)
Definition: musb_otg.c:4130
static void musbotg_get_dma_delay(struct usb_device *udev, uint32_t *pus)
Definition: musb_otg.c:4119
static void musbotg_clear_stall(struct usb_device *udev, struct usb_endpoint *ep)
Definition: musb_otg.c:3014
static void musbotg_set_hw_power_sleep(struct usb_bus *bus, uint32_t state)
Definition: musb_otg.c:4162
static void musbotg_xfer_unsetup(struct usb_xfer *xfer)
Definition: musb_otg.c:4113
static void musbotg_do_poll(struct usb_bus *)
Definition: musb_otg.c:3299
static void musbotg_get_hw_ep_profile(struct usb_device *udev, const struct usb_hw_ep_profile **ppf, uint8_t ep_addr)
Definition: musb_otg.c:242
static void musbotg_set_stall(struct usb_device *udev, struct usb_endpoint *ep, uint8_t *did_stall)
Definition: musb_otg.c:2837
static void musbotg_xfer_setup(struct usb_setup_params *parm)
Definition: musb_otg.c:4013
static void musbotg_xfer_stall(struct usb_xfer *xfer)
Definition: musb_otg.c:2831

Definition at line 103 of file musb_otg.c.

Referenced by musbotg_init().

◆ musbotg_confd

const struct musbotg_config_desc musbotg_confd
static
Initial value:
= {
.confd = {
.bLength = sizeof(struct usb_config_descriptor),
.wTotalLength[0] = sizeof(musbotg_confd),
.bMaxPower = 0,
},
.ifcd = {
.bLength = sizeof(struct usb_interface_descriptor),
.bNumEndpoints = 1,
.bInterfaceClass = UICLASS_HUB,
.bInterfaceSubClass = UISUBCLASS_HUB,
.bInterfaceProtocol = 0,
},
.endpd = {
.bLength = sizeof(struct usb_endpoint_descriptor),
.bEndpointAddress = (UE_DIR_IN | MUSBOTG_INTR_ENDPT),
.wMaxPacketSize[0] = 8,
.bInterval = 255,
},
}
static const struct musbotg_config_desc musbotg_confd
Definition: musb_otg.c:3501
#define MUSBOTG_INTR_ENDPT
Definition: musb_otg.c:82
uByte bDescriptorType
Definition: usb.h:387
uByte bNumInterface
Definition: usb.h:389
uByte bmAttributes
Definition: usb.h:393
uByte iConfiguration
Definition: usb.h:392
uByte bConfigurationValue
Definition: usb.h:390
uByte bDescriptorType
Definition: usb.h:527
uWord wMaxPacketSize
Definition: usb.h:558
#define UE_INTERRUPT
Definition: usb.h:544
#define UC_SELF_POWERED
Definition: usb.h:395
#define UISUBCLASS_HUB
Definition: usb.h:480
#define UDESC_CONFIG
Definition: usb.h:196
#define UDESC_ENDPOINT
Definition: usb.h:200
#define UE_DIR_IN
Definition: usb.h:531
#define UICLASS_HUB
Definition: usb.h:479
#define UDESC_INTERFACE
Definition: usb.h:199

Definition at line 3501 of file musb_otg.c.

Referenced by musbotg_roothub_exec().

◆ musbotg_dev_ctrl_data_rx

musbotg_cmd_t musbotg_dev_ctrl_data_rx
static

Definition at line 111 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_dev_ctrl_data_tx

musbotg_cmd_t musbotg_dev_ctrl_data_tx
static

Definition at line 112 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_dev_ctrl_setup_rx

musbotg_cmd_t musbotg_dev_ctrl_setup_rx
static

Definition at line 110 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_dev_ctrl_status

musbotg_cmd_t musbotg_dev_ctrl_status
static

Definition at line 113 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_dev_data_rx

musbotg_cmd_t musbotg_dev_data_rx
static

Definition at line 123 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_dev_data_tx

musbotg_cmd_t musbotg_dev_data_tx
static

Definition at line 124 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_devd

const struct usb_device_descriptor musbotg_devd
static
Initial value:
= {
.bLength = sizeof(struct usb_device_descriptor),
.bcdUSB = {0x00, 0x02},
.bDeviceClass = UDCLASS_HUB,
.bDeviceSubClass = UDSUBCLASS_HUB,
.bDeviceProtocol = UDPROTO_HSHUBSTT,
.bMaxPacketSize = 64,
.bcdDevice = {0x00, 0x01},
.iManufacturer = 1,
.iProduct = 2,
.bNumConfigurations = 1,
}
uByte bDescriptorType
Definition: usb.h:290
#define UDSUBCLASS_HUB
Definition: usb.h:374
#define UDCLASS_HUB
Definition: usb.h:373
#define UDPROTO_HSHUBSTT
Definition: usb.h:376
#define UDESC_DEVICE
Definition: usb.h:195

Definition at line 3476 of file musb_otg.c.

Referenced by musbotg_roothub_exec().

◆ musbotg_device_bulk_methods

static const struct usb_pipe_methods musbotg_device_bulk_methods
static
Initial value:
=
{
}
static void musbotg_device_bulk_close(struct usb_xfer *xfer)
Definition: musb_otg.c:3318
static void musbotg_device_bulk_start(struct usb_xfer *xfer)
Definition: musb_otg.c:3330
static void musbotg_device_bulk_enter(struct usb_xfer *xfer)
Definition: musb_otg.c:3324
static void musbotg_device_bulk_open(struct usb_xfer *xfer)
Definition: musb_otg.c:3312

Definition at line 104 of file musb_otg.c.

Referenced by musbotg_ep_init(), and musbotg_xfer_setup().

◆ musbotg_device_ctrl_methods

static const struct usb_pipe_methods musbotg_device_ctrl_methods
static
Initial value:
=
{
}
static void musbotg_device_ctrl_start(struct usb_xfer *xfer)
Definition: musb_otg.c:3367
static void musbotg_device_ctrl_close(struct usb_xfer *xfer)
Definition: musb_otg.c:3355
static void musbotg_device_ctrl_enter(struct usb_xfer *xfer)
Definition: musb_otg.c:3361
static void musbotg_device_ctrl_open(struct usb_xfer *xfer)
Definition: musb_otg.c:3349

Definition at line 105 of file musb_otg.c.

Referenced by musbotg_ep_init(), and musbotg_xfer_setup().

◆ musbotg_device_intr_methods

static const struct usb_pipe_methods musbotg_device_intr_methods
static
Initial value:
=
{
}
static void musbotg_device_intr_enter(struct usb_xfer *xfer)
Definition: musb_otg.c:3398
static void musbotg_device_intr_close(struct usb_xfer *xfer)
Definition: musb_otg.c:3392
static void musbotg_device_intr_start(struct usb_xfer *xfer)
Definition: musb_otg.c:3404
static void musbotg_device_intr_open(struct usb_xfer *xfer)
Definition: musb_otg.c:3386

Definition at line 106 of file musb_otg.c.

Referenced by musbotg_ep_init(), and musbotg_xfer_setup().

◆ musbotg_device_isoc_methods

static const struct usb_pipe_methods musbotg_device_isoc_methods
static
Initial value:
=
{
}
static void musbotg_device_isoc_close(struct usb_xfer *xfer)
Definition: musb_otg.c:3429
static void musbotg_device_isoc_open(struct usb_xfer *xfer)
Definition: musb_otg.c:3423
static void musbotg_device_isoc_enter(struct usb_xfer *xfer)
Definition: musb_otg.c:3435
static void musbotg_device_isoc_start(struct usb_xfer *xfer)
Definition: musb_otg.c:3456

Definition at line 107 of file musb_otg.c.

Referenced by musbotg_ep_init(), and musbotg_xfer_setup().

◆ musbotg_ep_default

const struct musb_otg_ep_cfg musbotg_ep_default[]
static
Initial value:
= {
{
.ep_end = 1,
.ep_fifosz_shift = 12,
},
{
.ep_end = 7,
.ep_fifosz_shift = 10,
},
{
.ep_end = 15,
.ep_fifosz_shift = 7,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_128,
},
{
.ep_end = -1,
},
}
#define MUSB2_MASK_FIFODB
Definition: musb_otg.h:228
#define MUSB2_VAL_FIFOSZ_4096
Definition: musb_otg.h:239
#define MUSB2_VAL_FIFOSZ_512
Definition: musb_otg.h:236
#define MUSB2_VAL_FIFOSZ_128
Definition: musb_otg.h:234

Definition at line 151 of file musb_otg.c.

Referenced by musbotg_init().

◆ musbotg_ep_profile

const struct usb_hw_ep_profile musbotg_ep_profile[1]
static
Initial value:
= {
[0] = {
.max_in_frame_size = 64,
.max_out_frame_size = 64,
.is_simplex = 1,
.support_control = 1,
}
}

Definition at line 142 of file musb_otg.c.

Referenced by musbotg_get_hw_ep_profile().

◆ musbotg_host_ctrl_data_rx

musbotg_cmd_t musbotg_host_ctrl_data_rx
static

Definition at line 117 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_ctrl_data_tx

musbotg_cmd_t musbotg_host_ctrl_data_tx
static

Definition at line 118 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_ctrl_setup_tx

musbotg_cmd_t musbotg_host_ctrl_setup_tx
static

Definition at line 116 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_ctrl_status_rx

musbotg_cmd_t musbotg_host_ctrl_status_rx
static

Definition at line 119 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_ctrl_status_tx

musbotg_cmd_t musbotg_host_ctrl_status_tx
static

Definition at line 120 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_data_rx

musbotg_cmd_t musbotg_host_data_rx
static

Definition at line 127 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_host_data_tx

musbotg_cmd_t musbotg_host_data_tx
static

Definition at line 128 of file musb_otg.c.

Referenced by musbotg_setup_standard_chain().

◆ musbotg_hubd

const struct usb_hub_descriptor_min musbotg_hubd
static
Initial value:
= {
.bDescLength = sizeof(musbotg_hubd),
.bDescriptorType = UDESC_HUB,
.bNbrPorts = 1,
HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)),
.bPwrOn2PwrGood = 50,
.bHubContrCurrent = 0,
.DeviceRemovable = {0},
}
static const struct usb_hub_descriptor_min musbotg_hubd
Definition: musb_otg.c:3531
#define HSETW(ptr, val)
Definition: musb_otg.c:3529
#define UDESC_HUB
Definition: usb.h:214
#define UHD_OC_INDIVIDUAL
Definition: usb.h:614
#define UHD_PWR_NO_SWITCH
Definition: usb.h:610

Definition at line 3531 of file musb_otg.c.

Referenced by musbotg_roothub_exec().

◆ musbotg_odevd

const struct usb_device_qualifier musbotg_odevd
static
Initial value:
= {
.bLength = sizeof(struct usb_device_qualifier),
.bcdUSB = {0x00, 0x02},
.bDeviceClass = UDCLASS_HUB,
.bDeviceSubClass = UDSUBCLASS_HUB,
.bDeviceProtocol = UDPROTO_FSHUB,
.bMaxPacketSize0 = 0,
.bNumConfigurations = 0,
}
uByte bDescriptorType
Definition: usb.h:660
#define UDESC_DEVICE_QUALIFIER
Definition: usb.h:201
#define UDPROTO_FSHUB
Definition: usb.h:375

Definition at line 3490 of file musb_otg.c.

Referenced by musbotg_roothub_exec().