FreeBSD kernel usb device Code
usb_controller.c File Reference
#include "opt_ddb.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/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_dynamic.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_dev.h>
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/usb_pf.h>
#include "usb_if.h"
Include dependency graph for usb_controller.c:

Go to the source code of this file.

Macros

#define USB_DEBUG_VAR   usb_ctrl_debug
 

Functions

static void usb_attach_sub (device_t, struct usb_bus *)
 
 SYSCTL_INT (_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RWTUN, &usb_no_suspend_wait, 0, "No USB device waiting at system suspend.")
 
 SYSCTL_INT (_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown.")
 
 DRIVER_MODULE (usbus, ohci, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, uhci, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, ehci, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, xhci, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, musbotg, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, uss820dci, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, octusb, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, dwcotg, usb_driver, usb_devclass, 0, 0)
 
 DRIVER_MODULE (usbus, saf1761otg, usb_driver, usb_devclass, 0, 0)
 
static int usb_probe (device_t dev)
 
static int usb_attach (device_t dev)
 
static int usb_detach (device_t dev)
 
static int usb_suspend (device_t dev)
 
static int usb_resume (device_t dev)
 
void usb_bus_reset_async_locked (struct usb_bus *bus)
 
static int usb_shutdown (device_t dev)
 
static void usb_bus_explore (struct usb_proc_msg *pm)
 
static void usb_bus_detach (struct usb_proc_msg *pm)
 
static void usb_bus_suspend (struct usb_proc_msg *pm)
 
static void usb_bus_resume (struct usb_proc_msg *pm)
 
static void usb_bus_reset (struct usb_proc_msg *pm)
 
static void usb_bus_shutdown (struct usb_proc_msg *pm)
 
static void usb_power_wdog (void *arg)
 
static void usb_bus_attach (struct usb_proc_msg *pm)
 
 SYSUNINIT (usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL)
 
uint8_t usb_bus_mem_alloc_all (struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb)
 
void usb_bus_mem_free_all (struct usb_bus *bus, usb_bus_mem_cb_t *cb)
 
void usb_proc_explore_mwait (struct usb_device *udev, void *pm1, void *pm2)
 
void * usb_proc_explore_msignal (struct usb_device *udev, void *pm1, void *pm2)
 
void usb_proc_explore_lock (struct usb_device *udev)
 
void usb_proc_explore_unlock (struct usb_device *udev)
 

Variables

static device_probe_t usb_probe
 
static device_attach_t usb_attach
 
static device_detach_t usb_detach
 
static device_suspend_t usb_suspend
 
static device_resume_t usb_resume
 
static device_shutdown_t usb_shutdown
 
static int usb_no_suspend_wait = 0
 
static int usb_no_shutdown_wait = 0
 
static devclass_t usb_devclass
 
static device_method_t usb_methods []
 
static driver_t usb_driver
 

Macro Definition Documentation

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   usb_ctrl_debug

Definition at line 56 of file usb_controller.c.

Function Documentation

◆ DRIVER_MODULE() [1/9]

DRIVER_MODULE ( usbus  ,
dwcotg  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [2/9]

DRIVER_MODULE ( usbus  ,
ehci  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [3/9]

DRIVER_MODULE ( usbus  ,
musbotg  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [4/9]

DRIVER_MODULE ( usbus  ,
octusb  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [5/9]

DRIVER_MODULE ( usbus  ,
ohci  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [6/9]

DRIVER_MODULE ( usbus  ,
saf1761otg  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [7/9]

DRIVER_MODULE ( usbus  ,
uhci  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [8/9]

DRIVER_MODULE ( usbus  ,
uss820dci  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ DRIVER_MODULE() [9/9]

DRIVER_MODULE ( usbus  ,
xhci  ,
usb_driver  ,
usb_devclass  ,
,
 
)

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _hw_usb  ,
OID_AUTO  ,
no_shutdown_wait  ,
CTLFLAG_RWTUN  ,
usb_no_shutdown_wait,
,
"No USB device waiting at system shutdown."   
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _hw_usb  ,
OID_AUTO  ,
no_suspend_wait  ,
CTLFLAG_RWTUN  ,
usb_no_suspend_wait,
,
"No USB device waiting at system suspend."   
)

◆ SYSUNINIT()

SYSUNINIT ( usb_bus_unload  ,
SI_SUB_KLD  ,
SI_ORDER_ANY  ,
usb_bus_unload  ,
NULL   
)

◆ usb_attach()

static int usb_attach ( device_t  dev)
static

Definition at line 171 of file usb_controller.c.

References bus, dev, DPRINTF, and usb_attach_sub().

Here is the call graph for this function:

◆ usb_attach_sub()

◆ usb_bus_attach()

◆ usb_bus_detach()

static void usb_bus_detach ( struct usb_proc_msg pm)
static

Definition at line 427 of file usb_controller.c.

References usb_bus::bdev, usb_bus_msg::bus, usb_device::bus, bus, dev, usb_bus::devices, USB_BUS_LOCK, USB_BUS_UNLOCK, usb_free_device(), and USB_ROOT_HUB_ADDR.

Referenced by usb_attach_sub().

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

◆ usb_bus_explore()

static void usb_bus_explore ( struct usb_proc_msg pm)
static

◆ usb_bus_mem_alloc_all()

◆ usb_bus_mem_free_all()

void usb_bus_mem_free_all ( struct usb_bus bus,
usb_bus_mem_cb_t cb 
)

◆ usb_bus_reset()

static void usb_bus_reset ( struct usb_proc_msg pm)
static

Definition at line 581 of file usb_controller.c.

References usb_bus::bdev, usb_bus_msg::bus, bus, DPRINTF, usb_bus::no_explore, usb_bus_resume(), and usb_bus_suspend().

Referenced by usb_attach_sub().

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

◆ usb_bus_reset_async_locked()

void usb_bus_reset_async_locked ( struct usb_bus bus)

Definition at line 309 of file usb_controller.c.

References bus, DPRINTF, USB_BUS_LOCK_ASSERT, and usb_proc_msignal().

Referenced by xhci_do_command().

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

◆ usb_bus_resume()

◆ usb_bus_shutdown()

◆ usb_bus_suspend()

◆ usb_detach()

static int usb_detach ( device_t  dev)
static

Definition at line 197 of file usb_controller.c.

References bus, dev, DPRINTF, USB_BUS_LOCK, USB_BUS_UNLOCK, usb_callout_drain, usb_proc_free(), usb_proc_msignal(), usb_proc_mwait(), and usbpf_detach().

Here is the call graph for this function:

◆ usb_power_wdog()

static void usb_power_wdog ( void *  arg)
static

Definition at line 669 of file usb_controller.c.

References bus, USB_BUS_LOCK, USB_BUS_LOCK_ASSERT, usb_bus_power_update(), USB_BUS_UNLOCK, usb_callout_reset, usb_power_wdog(), and usb_proc_rewakeup().

Referenced by usb_bus_attach(), and usb_power_wdog().

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

◆ usb_probe()

static int usb_probe ( device_t  dev)
static

Definition at line 149 of file usb_controller.c.

References DPRINTF.

◆ usb_proc_explore_lock()

void usb_proc_explore_lock ( struct usb_device udev)

Definition at line 1027 of file usb_controller.c.

References usb_device::bus, and USB_BUS_LOCK.

Referenced by ugold_detach(), ugold_readout_msg(), and ugold_timeout().

Here is the caller graph for this function:

◆ usb_proc_explore_msignal()

void * usb_proc_explore_msignal ( struct usb_device udev,
void *  pm1,
void *  pm2 
)

Definition at line 1021 of file usb_controller.c.

References usb_device::bus, and usb_proc_msignal().

Referenced by ugold_timeout().

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

◆ usb_proc_explore_mwait()

void usb_proc_explore_mwait ( struct usb_device udev,
void *  pm1,
void *  pm2 
)

Definition at line 1015 of file usb_controller.c.

References usb_device::bus, and usb_proc_mwait().

Referenced by ugold_detach().

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

◆ usb_proc_explore_unlock()

void usb_proc_explore_unlock ( struct usb_device udev)

Definition at line 1033 of file usb_controller.c.

References usb_device::bus, and USB_BUS_UNLOCK.

Referenced by ugold_detach(), ugold_readout_msg(), and ugold_timeout().

Here is the caller graph for this function:

◆ usb_resume()

static int usb_resume ( device_t  dev)
static

Definition at line 286 of file usb_controller.c.

References bus, dev, DPRINTF, USB_BUS_LOCK, USB_BUS_UNLOCK, and usb_proc_msignal().

Here is the call graph for this function:

◆ usb_shutdown()

static int usb_shutdown ( device_t  dev)
static

Definition at line 331 of file usb_controller.c.

References bus, dev, DPRINTF, USB_BUS_LOCK, USB_BUS_UNLOCK, usb_no_shutdown_wait, usb_proc_msignal(), and usb_proc_mwait().

Here is the call graph for this function:

◆ usb_suspend()

static int usb_suspend ( device_t  dev)
static

Definition at line 258 of file usb_controller.c.

References bus, dev, DPRINTF, USB_BUS_LOCK, USB_BUS_UNLOCK, usb_no_suspend_wait, usb_proc_msignal(), and usb_proc_mwait().

Here is the call graph for this function:

Variable Documentation

◆ usb_attach

device_attach_t usb_attach
static

Definition at line 76 of file usb_controller.c.

◆ usb_detach

device_detach_t usb_detach
static

Definition at line 77 of file usb_controller.c.

◆ usb_devclass

devclass_t usb_devclass
static

Definition at line 109 of file usb_controller.c.

◆ usb_driver

driver_t usb_driver
static
Initial value:
= {
.name = "usbus",
.methods = usb_methods,
.size = 0,
}
static device_method_t usb_methods[]

Definition at line 122 of file usb_controller.c.

◆ usb_methods

device_method_t usb_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, usb_probe),
DEVMETHOD(device_attach, usb_attach),
DEVMETHOD(device_detach, usb_detach),
DEVMETHOD(device_suspend, usb_suspend),
DEVMETHOD(device_resume, usb_resume),
DEVMETHOD(device_shutdown, usb_shutdown),
DEVMETHOD_END
}
static device_shutdown_t usb_shutdown
static device_probe_t usb_probe
static device_suspend_t usb_suspend
static device_resume_t usb_resume
static device_attach_t usb_attach
static device_detach_t usb_detach

Definition at line 111 of file usb_controller.c.

◆ usb_no_shutdown_wait

int usb_no_shutdown_wait = 0
static

Definition at line 105 of file usb_controller.c.

Referenced by usb_shutdown().

◆ usb_no_suspend_wait

int usb_no_suspend_wait = 0
static

Definition at line 101 of file usb_controller.c.

Referenced by usb_suspend().

◆ usb_probe

device_probe_t usb_probe
static

Definition at line 75 of file usb_controller.c.

◆ usb_resume

device_resume_t usb_resume
static

Definition at line 79 of file usb_controller.c.

◆ usb_shutdown

device_shutdown_t usb_shutdown
static

Definition at line 80 of file usb_controller.c.

◆ usb_suspend

device_suspend_t usb_suspend
static

Definition at line 78 of file usb_controller.c.