66 static const char *exponents[4] = {
"",
"k",
"M",
"G" };
67 static char buf[ 10 ];
68 unsigned int mantissa;
69 unsigned int exponent;
83 snprintf ( buf,
sizeof ( buf ),
"%d%sbps",
84 mantissa, exponents[exponent] );
121 unsigned int first ) {
126 if ( (
desc->header.type ==
169 unsigned int type,
unsigned int index ) {
177 ( (
desc->attributes &
221 static char buf[ 9 ];
224 snprintf ( buf,
sizeof ( buf ),
"EP%d%s",
244 unsigned int type,
unsigned int index ) {
250 unsigned int interval;
271 interval = ( 1 << (
desc->interval - 1 ) );
274 interval = (
desc->interval << 3 );
278 interval =
desc->interval;
302 if ( usb->
ep[idx] !=
NULL ) {
303 DBGC ( usb,
"USB %s %s is already open\n",
313 DBGC ( usb,
"USB %s %s could not open: %s\n", usb->
name,
319 DBGC2 ( usb,
"USB %s %s opened with MTU %zd, burst %d, interval %d\n",
356 DBGC (
usb,
"USB %s %s could not clear transaction translator: " 386 DBGC ( usb,
"USB %s %s could not clear endpoint halt: %s\n",
442 DBGC ( usb,
"USB %s %s could not reset: %s\n",
451 DBGC ( usb,
"USB %s %s reset\n",
470 DBGC ( usb,
"USB %s %s could not update MTU: %s\n",
504 if (
port->disconnected )
517 packet =
iob_push ( iobuf,
sizeof ( *packet ) );
525 DBGC ( usb,
"USB %s %s could not enqueue message transfer: " 553 if (
port->disconnected )
567 if ( (
rc = ep->
host->
stream ( ep, iobuf, zlp ) ) != 0 ) {
568 DBGC (
usb,
"USB %s %s could not enqueue stream transfer: %s\n",
596 DBGC ( usb,
"USB %s %s completion failed: %s\n",
760 pshdr =
iob_push ( iobuf,
sizeof ( *pshdr ) );
832 iob_pull ( cmplt,
sizeof ( *pshdr ) );
836 if ( cmplt != iobuf ) {
837 DBGC ( usb,
"USB %s stale control completion: " 847 DBGC ( usb,
"USB %s control %04x:%04x:%04x " 867 DBGC ( usb,
"USB %s timed out waiting for control %04x:%04x:%04x\n",
888 unsigned int language;
893 &
desc.header, sizeof (
desc ) ) ) !=0){
894 DBGC ( usb,
"USB %s has no default language: %s\n",
901 DBGC2 ( usb,
"USB %s default language %#04x\n", usb->
name, language );
916 unsigned int language,
char *buf,
size_t len ) {
926 if ( ( language == 0 ) && (
index != 0 ) ) {
941 language, &
desc->header,
942 sizeof ( *
desc ) ) ) != 0 )
943 goto err_get_descriptor;
946 if (
desc->header.len < sizeof (
desc->header ) ) {
950 actual = ( (
desc->header.len -
sizeof (
desc->header ) ) /
951 sizeof (
desc->character[0] ) );
955 for ( i = 0 ; ( ( i < actual ) && ( i <
len ) ) ; i++ )
997 sizeof ( partial ) ) ) != 0 ) {
998 DBGC ( usb,
"USB %s could not get configuration descriptor %d: " 1000 goto err_get_partial;
1003 if (
len <
sizeof ( partial ) ) {
1004 DBGC ( usb,
"USB %s underlength configuraton descriptor %d\n",
1007 goto err_partial_len;
1014 goto err_alloc_config;
1020 DBGC ( usb,
"USB %s could not get configuration descriptor %d: " 1022 goto err_get_config_descriptor;
1024 if ( (*config)->len != partial.
len ) {
1025 DBGC ( usb,
"USB %s bad configuration descriptor %d length\n",
1028 goto err_config_len;
1034 err_get_config_descriptor:
1068 if ( association ) {
1073 DBGC ( usb,
"USB %s has invalid association [%d-%d)\n",
1080 sizeof (
desc->class.class ) );
1082 for ( i = 0 ; i < association->
count ; i++ )
1090 DBGC ( usb,
"USB %s has no descriptor for interface %d\n",
1097 sizeof (
desc->class.class ) );
1110 if (
desc->count > config->interfaces ) {
1111 DBGC ( usb,
"USB %s has invalid union functional " 1112 "descriptor with %d interfaces\n",
1118 for ( i = 0 ; i <
desc->count ; i++ ) {
1119 if ( cdc_union->
interface[i] >= config->interfaces ) {
1120 DBGC ( usb,
"USB %s has invalid union " 1121 "functional descriptor covering " 1122 "interface %d\n", usb->
name,
1148 for ( i = 0 ; i <
count ; i++ ) {
1150 DBGC ( usb,
"USB %s interface %d already in use\n",
1173 for ( i = 0 ; i < driver->
id_count ; i++ ) {
1181 *
id = &driver->
ids[i];
1182 if ( ( ( (*id)->vendor ==
desc->vendor ) ||
1184 ( ( (*id)->product ==
desc->product ) ||
1210 unsigned int score = 0;
1214 memset ( used, 0,
sizeof ( used ) );
1234 score += driver->
score;
1257 DBGC ( usb,
"USB %s %04x:%04x class %d:%d:%d has no driver\n",
1271 if ( (
rc = driver->
probe ( func, config ) ) != 0 ) {
1272 DBGC ( usb,
"USB %s failed to probe driver %s: %s\n",
1308 memset ( used, 0,
sizeof ( used ) );
1316 func =
zalloc (
sizeof ( *func ) +
1336 &func->
desc ) ) != 0 )
1348 DBGC (
usb,
"USB %s %04x:%04x class %d:%d:%d interfaces ",
1353 for ( i = 0 ; i < func->
desc.
count ; i++ )
1354 DBGC (
usb,
"%s%d", ( i ?
"," :
"" ),
1415 for ( i = 0 ; i < (
sizeof (
usb->
ep ) /
sizeof (
usb->
ep[0] ) ) ; i++){
1432 unsigned int preferred = 0;
1452 DBGC2 ( usb,
"USB %s configuration %d score %d\n",
1456 if ( score > best ) {
1472 DBGC ( usb,
"USB %s could not set configuration %d: %s\n",
1474 goto err_set_configuration;
1487 err_set_configuration:
1517 usb =
zalloc (
sizeof ( *usb ) );
1521 ( hub->
usb ?
'.' :
'-' ),
port->address );
1547 DBGC (
hub,
"USB hub %s port %d is already registered to %s\n",
1559 DBGC (
hub,
"USB hub %s port %d could not enable: %s\n",
1569 DBGC (
hub,
"USB hub %s port %d could not get speed: %s\n",
1574 DBGC2 ( usb,
"USB %s attached as %s-speed device\n",
1578 if ( (
rc = usb->
host->
open ( usb ) ) != 0 ) {
1579 DBGC ( usb,
"USB %s could not open: %s\n",
1592 goto err_open_control;
1597 DBGC ( usb,
"USB %s could not set address: %s\n",
1608 DBGC ( usb,
"USB %s could not get MTU: %s\n",
1617 DBGC2 ( usb,
"USB %s has control MTU %zd (guessed %zd)\n",
1626 DBGC ( usb,
"USB %s could not get device descriptor: %s\n",
1628 goto err_get_device_descriptor;
1630 DBGC ( usb,
"USB %s addr %d %04x:%04x class %d:%d:%d (v%s, %s-speed, " 1640 goto err_autoconfigure;
1646 err_get_device_descriptor:
1676 DBGC ( usb,
"USB %s addr %d %04x:%04x class %d:%d:%d removed\n",
1718 for ( i = 0 ; i < (
sizeof ( usb->
ep ) /
sizeof ( usb->
ep[0] ) ) ; i++ )
1823 DBGC ( hub,
"USB hub %s port %d could not get speed: %s\n",
1826 port->disconnected = 1;
1831 if (
port->attached && (
port->disconnected || !
port->speed ) )
1835 port->disconnected = 0;
1838 if (
port->speed && ( !
port->attached ) &&
1957 for ( i = 1 ; i <=
hub->
ports ; i++ ) {
1986 DBGC (
hub,
"USB hub %s could not open: %s\n",
1993 DBGC (
hub,
"USB hub %s could not open: %s\n",
1995 goto err_driver_open;
2002 for ( i = 1 ; i <=
hub->
ports ; i++ ) {
2034 for ( i = 1 ; i <=
hub->
ports ; i++ ) {
2036 if (
port->attached )
2047 for ( i = 1 ; i <=
hub->
ports ; i++ ) {
2067 for ( i = 1 ; i <=
hub->
ports ; i++ ) {
2108 bus->host = &
bus->op->bus;
2142 if ( (
rc =
bus->host->open (
bus ) ) != 0 )
2150 goto err_register_hub;
2160 bus->host->close (
bus );
2182 bus->host->close (
bus );
2238 unsigned int location ) {
2242 if ( (
bus->dev->desc.bus_type == bus_type ) &&
2243 (
bus->dev->desc.location == location ) )
2272 bus->addresses |= ( 1ULL << (
address - 1 ) );
2290 bus->addresses &= ~( 1ULL << (
address - 1 ) );
2308 *busdev |= (
USB_BUS ( 1 ) - 1 );
2317 }
while ( ++(*busdev) );
2378 for ( ; ( parent = usb->
port->
hub->
usb ) ; usb = parent ) {
#define iob_pull(iobuf, len)
#define USB_BUS(busdev)
Extract USB bus address.
#define EINVAL
Invalid argument.
#define USB_SPEED_EXPONENT(speed)
Extract USB speed exponent.
struct arbelprm_rc_send_wqe rc
void(* close)(struct usb_endpoint *ep)
Close endpoint.
uint32_t low
Low 16 bits of address.
static void usb_hotplug(void)
Handle newly attached or detached USB device.
#define iob_put(iobuf, len)
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
static void usb_detached(struct usb_port *port)
Handle newly detached USB device.
static unsigned int usb_get_default_language(struct usb_device *usb)
Get default language ID.
static int usb_set_configuration(struct usb_device *usb, unsigned int index)
Set USB configuration.
static void usb_endpoint_describe(struct usb_endpoint *ep, unsigned int address, unsigned int attributes, size_t mtu, unsigned int burst, unsigned int interval)
Describe USB endpoint.
uint8_t interface[0]
List of interface numbers.
struct usb_bus * find_usb_bus(unsigned int address)
Find USB bus by address.
int(* mtu)(struct usb_endpoint *ep)
Update MTU.
unsigned int count
Number of interfaces.
#define USB_STRING_DESCRIPTOR
A USB string descriptor.
uint16_t vendor
Vendor ID.
#define list_add(new, head)
Add a new entry to the head of a list.
A USB interface association descriptor.
struct usb_bus * find_usb_bus_by_location(unsigned int bus_type, unsigned int location)
Find USB bus by device location.
struct usb_hub_host_operations * host
Host controller operations.
int usb_refill_limit(struct usb_endpoint *ep, unsigned int max)
Refill endpoint up to specified limit.
#define USB_EP0_DEFAULT_MTU(speed)
Calculate default MTU based on device speed.
void unregister_usb_hub(struct usb_hub *hub)
Unregister USB hub.
uint32_t first
First block in range.
struct usb_bus * alloc_usb_bus(struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op)
Allocate USB bus.
struct list_head recycled
Recycled I/O buffer list.
#define USB_RESET_RECOVER_DELAY_MS
Reset recovery time.
#define USB_ENDPOINT_ATTR_TYPE_MASK
Endpoint attribute transfer type mask.
static int usb_attached(struct usb_port *port)
Handle newly attached USB device.
#define iob_push(iobuf, len)
struct usb_descriptor_header header
Descriptor header.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
uint64_t address
Base address.
uint32_t type
Operating system type.
union usb_class_descriptor mask
Class mask.
static struct usb_descriptor_header * usb_next_descriptor(struct usb_descriptor_header *desc)
Get next USB descriptor.
size_t len
Refill buffer payload length.
uint64_t desc
Microcode descriptor list physical address.
static const char * usb_bcd(uint16_t bcd)
Transcribe USB BCD-coded value (for debugging)
static int usb_get_config_descriptor(struct usb_device *usb, unsigned int index, struct usb_configuration_descriptor *data, size_t len)
Get USB configuration descriptor.
struct usb_device * find_usb(struct usb_bus *bus, unsigned int address)
Find USB device by address.
uint16_t vendor
Vendor ID.
#define USB_ENDPOINT_MAX
Maximum endpoint number.
struct usb_driver * driver
Driver.
#define ENOENT
No such file or directory.
Standard Interface Descriptor USB 2.0 spec, Section 9.6.5.
int usb_endpoint_clear_halt(struct usb_endpoint *ep)
Clear endpoint halt (if applicable)
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
struct usb_device * usb
Currently attached device (if in use)
#define USB_SPEED_MANTISSA(speed)
Extract USB speed mantissa.
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
int usb_endpoint_open(struct usb_endpoint *ep)
Open USB endpoint.
#define for_each_interface_descriptor(desc, config, interface)
Iterate over all configuration descriptors within an interface descriptor.
uint8_t interfaces
Number of interfaces.
#define for_each_config_descriptor(desc, config)
Iterate over all configuration descriptors.
unsigned int protocol
Port protocol.
int(* reset)(struct usb_endpoint *ep)
Reset endpoint.
uint8_t direction
Direction.
#define USB_ENDPOINT_ATTR_PERIODIC
Endpoint periodic type.
static int usb_used(struct usb_device *usb, unsigned int count, uint8_t *interface, uint8_t *used)
Update list of used interface.
static void usb_control_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete USB control transfer.
#define USB_ENDPOINT_COMPANION_DESCRIPTOR
A USB endpoint companion descriptor.
static int usb_endpoint_mtu(struct usb_endpoint *ep, size_t mtu)
Update endpoint MTU.
#define offsetof(type, field)
Get offset of a field within a structure.
struct list_head changed
List of changed ports.
int(* clear_tt)(struct usb_hub *hub, struct usb_port *port, struct usb_endpoint *ep)
Clear transaction translator buffer.
void usb_endpoint_close(struct usb_endpoint *ep)
Close USB endpoint.
int open
Endpoint is open.
int usb_endpoint_described(struct usb_endpoint *ep, struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface, unsigned int type, unsigned int index)
Describe USB endpoint from device configuration.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
union usb_class_descriptor class
Class.
unsigned int vendor
Vendor ID.
struct device * parent
Bus device.
USB hub driver operations.
int usb_refill(struct usb_endpoint *ep)
Refill endpoint.
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
static void unregister_usb(struct usb_device *usb)
Unregister USB device.
unsigned int address
Device address, if assigned.
static int usb_autoconfigure(struct usb_device *usb)
Choose our preferred USB device configuration.
unsigned int speed
Device speed.
int(* probe)(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
void usb_port_changed(struct usb_port *port)
Report port status change.
A doubly-linked list entry (or list head)
int(* open)(struct usb_hub *hub)
Open hub.
#define list_empty(list)
Test whether a list is empty.
#define USB_BUSDEV(bus, dev)
Define a USB bus:device address.
union usb_class_descriptor class
Class.
struct usb_device_id * id
Driver device ID.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define for_each_usb_bus(bus)
Iterate over all USB buses.
#define USB_EP0_ATTRIBUTES
Control endpoint attributes.
#define list_del(list)
Delete an entry from a list.
uint16_t product
Product ID.
uint16_t product
Product ID.
#define ENOMEM
Not enough space.
struct usb_device * usb
Underlying USB device, if any.
int usb_find_next(struct usb_device **usb, uint16_t *busdev)
Find next USB device.
#define USB_EP0_BURST
Control endpoint maximum burst size.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define USB_RECIP_ENDPOINT
Request recipient is an endpoint.
int usb_message(struct usb_endpoint *ep, unsigned int request, unsigned int value, unsigned int index, struct io_buffer *iobuf)
Enqueue USB message transfer.
A USB interface descriptor.
A USB function descriptor.
PERMANENT_PROCESS(usb_process, usb_step)
USB process.
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
struct usb_port * port
USB port.
static void usb_probe_all(struct usb_device *usb, struct usb_configuration_descriptor *config)
Probe all USB device drivers.
struct usb_driver * usb_find_driver(struct usb_function_descriptor *desc, struct usb_device_id **id)
Find USB device driver.
#define ffsll(x)
Find first (i.e.
static struct usb_endpoint_driver_operations usb_control_operations
USB control endpoint driver operations.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct usb_hub_driver_operations * driver
Driver operations.
void(* close)(struct usb_hub *hub)
Close hub.
#define container_of(ptr, type, field)
Get containing structure.
struct device * dev
Underlying hardware device.
static int usb_clear_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Clear feature.
struct usb_class_id class
Class ID.
#define USB_ENDPOINT_BURST(sizes)
USB endpoint maximum burst size.
uint16_t index
Index parameter.
struct ib_cm_path alternate
Alternate path.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
static const char * usb_speed_name(unsigned int speed)
Get USB speed name (for debugging)
pseudo_bit_t value[0x00020]
struct usb_descriptor_header header
Descriptor header.
#define __unused
Declare a variable or data structure as unused.
Union functional descriptor.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
uint8_t configurations
Number of possible configurations.
struct list_head halted
List of halted endpoints.
struct usb_class class
Device class.
unsigned int burst
Maximum burst size.
void route(void)
Print routing table.
int(* enable)(struct usb_hub *hub, struct usb_port *port)
Enable port.
uint16_t count
Number of entries.
#define USB_CONTROL_MAX_WAIT_MS
Maximum time to wait for a control transaction to complete.
#define USB_DIR_IN
Data transfer is from device to host.
REQUIRING_SYMBOL(register_usb_bus)
unsigned int ports
Number of ports.
static void usb_step(struct process *process __unused)
USB process.
const char * driver_name
Driver name.
unsigned int location
Location.
size_t reserve
Refill buffer reserved header length.
void(* close)(struct usb_device *usb)
Close device.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
uint8_t id
Request identifier.
struct usb_interface_descriptor * usb_interface_descriptor(struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate)
Locate USB interface descriptor.
struct usb_endpoint control
Control endpoint.
uint32_t high
High 32 bits of address.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
#define USB_ENDPOINT_IN
Endpoint direction is in.
#define USB_ENDPOINT_ATTR_INTERRUPT
Interrupt endpoint transfer type.
Standard Interface Association Descriptor USB 3.0 spec, Section 9.6.4.
#define ERANGE
Result too large.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
struct list_head list
List of devices on this bus.
unsigned int score
Driver score.
unsigned int usb_route_string(struct usb_device *usb)
Get USB route string.
static const char * interfaces[2]
struct list_head siblings
Devices on the same bus.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define USB_LANG_ENGLISH
Language ID for English.
void usb_free_address(struct usb_bus *bus, unsigned int address)
Free device address.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
#define ENODEV
No such device.
static int usb_endpoint_reset(struct usb_endpoint *ep)
Reset USB endpoint.
static int usb_get_mtu(struct usb_device *usb, struct usb_device_descriptor *data)
Get first part of USB device descriptor (up to and including MTU)
uint8_t attributes
Attributes.
void(* close)(struct usb_hub *hub)
Close hub.
struct list_head usb_buses
List of USB buses.
unsigned int fill
Buffer fill level.
static int usb_score(struct usb_device *usb, struct usb_configuration_descriptor *config)
Get USB device configuration score.
static void usb_remove(struct usb_function *func)
Remove USB device driver.
struct usb_device_descriptor device
Device descriptor.
Standard Endpoint Descriptor USB 2.0 spec, Section 9.6.6.
struct usb_device * usb
USB device.
static void usb_endpoint_init(struct usb_endpoint *ep, struct usb_device *usb, struct usb_endpoint_driver_operations *driver)
Initialise USB endpoint.
#define le16_to_cpu(value)
uint32_t scalar
Scalar value.
struct usb_endpoint_companion_descriptor * usb_endpoint_companion_descriptor(struct usb_configuration_descriptor *config, struct usb_endpoint_descriptor *desc)
Locate USB endpoint companion descriptor.
void * malloc(size_t size)
Allocate memory.
#define USB_ENDPOINT_IDX(address)
Construct endpoint index from endpoint address.
#define EALREADY
Connection already in progress.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
struct usb_port * usb_root_hub_port(struct usb_device *usb)
Get USB root hub port.
uint8_t protocol
Protocol code.
#define USB_EP0_INTERVAL
Control endpoint interval.
static int usb_endpoint_clear_tt(struct usb_endpoint *ep)
Clear transaction translator (if applicable)
size_t mtu
Maximum transfer size.
uint8_t count
Interface count.
#define USB_CLASS_CDC
Class code for communications devices.
static void free_usb(struct usb_device *usb)
Free USB device.
void free_usb_hub(struct usb_hub *hub)
Free USB hub.
static void usb_remove_all(struct usb_device *usb)
Remove all device drivers.
struct usb_port * usb_transaction_translator(struct usb_device *usb)
Get USB transaction translator.
int(* disable)(struct usb_hub *hub, struct usb_port *port)
Disable port.
static int usb_hotplugged(struct usb_port *port)
Handle newly attached or detached USB device.
struct usb_host_operations * op
Host controller operations set.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
static int usb_get_device_descriptor(struct usb_device *usb, struct usb_device_descriptor *data)
Get USB device descriptor.
static void usb_deconfigure(struct usb_device *usb)
Clear USB device configuration.
#define iob_reserve(iobuf, len)
static uint16_t struct vmbus_xfer_pages_operations * op
unsigned int max
Maximum fill level.
#define INIT_LIST_HEAD(list)
Initialise a list head.
A USB configuration descriptor.
static int register_usb(struct usb_device *usb)
Register USB device.
static int usb_config_descriptor(struct usb_device *usb, unsigned int index, struct usb_configuration_descriptor **config)
Get USB configuration descriptor.
unsigned int language
Default language ID (if known)
static size_t iob_headroom(struct io_buffer *iobuf)
Calculate available space at start of an I/O buffer.
static struct list_head usb_halted
List of halted endpoints.
uint8_t subclass
Subclass code.
struct usb_endpoint_descriptor * usb_endpoint_descriptor(struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface, unsigned int type, unsigned int index)
Locate USB endpoint descriptor.
unsigned int bus_type
Bus type.
A USB endpoint descriptor.
uint8_t first
First interface number.
struct list_head list
List of which this buffer is a member.
uint8_t config
Configuration value.
struct list_head complete
Completed control transfers.
#define USB_ANY_ID
Match-anything ID.
uint16_t protocol
USB specification release number in BCD.
Universal Serial Bus (USB)
int register_usb_bus(struct usb_bus *bus)
Register USB bus.
struct list_head list
List of hubs.
unsigned int device
Device ID.
uint8_t mtu
Maximum packet size for endpoint zero.
A USB endpoint companion descriptor.
unsigned int address
Port address.
void * data
Start of data.
struct list_head children
Devices attached to this device.
struct usb_hub * hub
USB hub.
unsigned int id_count
Number of entries in ID table.
#define USB_SET_ADDRESS_RECOVER_DELAY_MS
Set address recovery time.
void(* remove)(struct usb_function *func)
Remove device.
struct usb_endpoint * ep[32]
Endpoint list.
unsigned int interval
Interval (in microframes)
struct ena_aq_header header
Header.
u8 request[0]
List of IEs requested.
struct usb_endpoint_host_operations endpoint
Endpoint operations.
#define cpu_to_le16(value)
int(* address)(struct usb_device *usb)
Assign device address.
uint8_t data[48]
Additional event data.
struct device_description desc
Device description.
USB host controller operations.
#define USB_ENDPOINT_ATTR_CONTROL
Control endpoint transfer type.
int register_usb_hub(struct usb_hub *hub)
Register USB hub.
#define USB_PORT_DELAY_MS
Time to wait for ports to stabilise.
struct usb_class class
Association class.
USB Communications Device Class (CDC)
struct usb_hub * hub
Root hub.
static struct usb_interface_association_descriptor * usb_interface_association_descriptor(struct usb_configuration_descriptor *config, unsigned int first)
Locate USB interface association descriptor.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
REQUIRE_OBJECT(config_usb)
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
uint16_t len
Total length.
uint16_t len
Length of data stage.
#define USB_DRIVERS
USB driver table.
struct usb_function_descriptor desc
Function descriptor.
struct usb_device * usb
USB device.
static struct usb_port * usb_port(struct usb_hub *hub, unsigned int address)
Get USB port.
uint16_t protocol
Protocol ID.
static int usb_is_within_config(struct usb_configuration_descriptor *config, struct usb_descriptor_header *desc)
Check that descriptor lies within a configuration descriptor.
typeof(acpi_finder=acpi_find)
ACPI table finder.
#define USB_ENDPOINT_MTU(sizes)
USB endpoint MTU.
struct usb_endpoint_driver_operations * driver
Driver operations.
int(* message)(struct usb_endpoint *ep, struct io_buffer *iobuf)
Enqueue message transfer.
int(* open)(struct usb_endpoint *ep)
Open endpoint.
void usb_flush(struct usb_endpoint *ep)
Discard endpoint recycled buffer list.
unsigned int protocol
Hub protocol.
struct usb_endpoint_host_operations * host
Host controller operations.
static int usb_get_descriptor(struct usb_device *usb, unsigned int type, unsigned int desc, unsigned int index, unsigned int language, struct usb_descriptor_header *data, size_t len)
Get USB descriptor.
struct usb_device_host_operations * host
Host controller operations.
static struct list_head usb_changed
List of changed ports.
USB endpoint driver operations.
#define LIST_HEAD_INIT(list)
Initialise a static list head.
struct device dev
Generic device.
uint16_t value
Value parameter.
#define BUS_TYPE_USB
USB bus type.
struct usb_bus * bus
USB bus.
struct list_head functions
List of functions.
static struct usb_device * alloc_usb(struct usb_port *port)
Allocate USB device.
#define USB_ENDPOINT_HALT
Endpoint halt feature.
#define USB_EP0_ADDRESS
Control endpoint address.
int(* speed)(struct usb_hub *hub, struct usb_port *port)
Update port speed.
#define NULL
NULL pointer (VOID *)
#define ETIMEDOUT
Connection timed out.
struct list_head list
List of functions within this USB device.
int usb_alloc_address(struct usb_bus *bus)
Allocate device address.
unsigned int attributes
Attributes.
uint8_t interface
Interface number.
static int usb_describe(struct usb_device *usb, struct usb_configuration_descriptor *config, unsigned int first, uint8_t *interfaces, struct usb_function_descriptor *desc)
Describe USB function.
uint8_t interface[1]
Interfaces (variable-length)
unsigned int address
Endpoint address.
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
uint8_t burst
Maximum burst size.
struct usb_class class
Class.
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
static int usb_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe USB device driver.
int(* open)(struct usb_hub *hub)
Open hub.
struct usb_device_id * ids
USB ID table.
int(* open)(struct usb_device *usb)
Open device.
int usb_get_string_descriptor(struct usb_device *usb, unsigned int index, unsigned int language, char *buf, size_t len)
Get USB string descriptor.
void * memset(void *dest, int character, size_t len) __nonnull
int(* stream)(struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp)
Enqueue stream transfer.
#define USB_DEV(busdev)
Extract USB device address.
struct usb_hub * alloc_usb_hub(struct usb_bus *bus, struct usb_device *usb, unsigned int ports, struct usb_hub_driver_operations *driver)
Allocate USB hub.
struct usb_port port[0]
Port list.