35 #define USB_SPEED( mantissa, exponent ) ( (exponent << 16) | (mantissa) ) 38 #define USB_SPEED_MANTISSA(speed) ( (speed) & 0xffff ) 41 #define USB_SPEED_EXPONENT(speed) ( ( (speed) >> 16 ) & 0x3 ) 63 #define USB_BUSDEV( bus, dev ) ( ( (bus) << 8 ) | (dev) ) 66 #define USB_BUS( busdev ) ( (busdev) >> 8 ) 69 #define USB_DEV( busdev ) ( (busdev) & 0xff ) 94 #define USB_DIR_OUT ( 0 << 7 ) 97 #define USB_DIR_IN ( 1 << 7 ) 100 #define USB_TYPE_STANDARD ( 0 << 5 ) 103 #define USB_TYPE_CLASS ( 1 << 5 ) 106 #define USB_TYPE_VENDOR ( 2 << 5 ) 109 #define USB_RECIP_MASK ( 0x1f << 0 ) 112 #define USB_RECIP_DEVICE ( 0 << 0 ) 115 #define USB_RECIP_INTERFACE ( 1 << 0 ) 118 #define USB_RECIP_ENDPOINT ( 2 << 0 ) 121 #define USB_REQUEST_TYPE(type) ( (type) << 8 ) 124 #define USB_GET_STATUS ( USB_DIR_IN | USB_REQUEST_TYPE ( 0 ) ) 127 #define USB_CLEAR_FEATURE ( USB_DIR_OUT | USB_REQUEST_TYPE ( 1 ) ) 130 #define USB_SET_FEATURE ( USB_DIR_OUT | USB_REQUEST_TYPE ( 3 ) ) 133 #define USB_SET_ADDRESS ( USB_DIR_OUT | USB_REQUEST_TYPE ( 5 ) ) 136 #define USB_GET_DESCRIPTOR ( USB_DIR_IN | USB_REQUEST_TYPE ( 6 ) ) 139 #define USB_SET_DESCRIPTOR ( USB_DIR_OUT | USB_REQUEST_TYPE ( 7 ) ) 142 #define USB_GET_CONFIGURATION ( USB_DIR_IN | USB_REQUEST_TYPE ( 8 ) ) 145 #define USB_SET_CONFIGURATION ( USB_DIR_OUT | USB_REQUEST_TYPE ( 9 ) ) 148 #define USB_GET_INTERFACE \ 149 ( USB_DIR_IN | USB_RECIP_INTERFACE | USB_REQUEST_TYPE ( 10 ) ) 152 #define USB_SET_INTERFACE \ 153 ( USB_DIR_OUT | USB_RECIP_INTERFACE | USB_REQUEST_TYPE ( 11 ) ) 156 #define USB_ENDPOINT_HALT 0 169 #define USB_CLASS_HUB 9 206 #define USB_DEVICE_DESCRIPTOR 1 227 #define USB_CONFIGURATION_DESCRIPTOR 2 238 #define USB_STRING_DESCRIPTOR 3 241 #define USB_LANG_ENGLISH 0x0409 260 #define USB_INTERFACE_DESCRIPTOR 4 277 #define USB_ENDPOINT_DESCRIPTOR 5 280 #define USB_ENDPOINT_ATTR_TYPE_MASK 0x03 283 #define USB_ENDPOINT_ATTR_PERIODIC 0x01 286 #define USB_ENDPOINT_ATTR_CONTROL 0x00 289 #define USB_ENDPOINT_ATTR_BULK 0x02 292 #define USB_ENDPOINT_ATTR_INTERRUPT 0x03 295 #define USB_BULK_OUT ( USB_ENDPOINT_ATTR_BULK | USB_DIR_OUT ) 298 #define USB_BULK_IN ( USB_ENDPOINT_ATTR_BULK | USB_DIR_IN ) 301 #define USB_INTERRUPT_IN ( USB_ENDPOINT_ATTR_INTERRUPT | USB_DIR_IN ) 304 #define USB_INTERRUPT_OUT ( USB_ENDPOINT_ATTR_INTERRUPT | USB_DIR_OUT ) 307 #define USB_ENDPOINT_MTU(sizes) ( ( (sizes) >> 0 ) & 0x07ff ) 310 #define USB_ENDPOINT_BURST(sizes) ( ( (sizes) >> 11 ) & 0x0003 ) 325 #define USB_ENDPOINT_COMPANION_DESCRIPTOR 48 342 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR 11 345 #define USB_CS_INTERFACE_DESCRIPTOR 36 348 #define USB_CS_ENDPOINT_DESCRIPTOR 37 359 return ( ( (
void * )
desc ) +
desc->len );
385 #define for_each_config_descriptor( desc, config ) \ 386 for ( desc = container_of ( &(config)->header, \ 387 typeof ( *desc ), header ) ; \ 388 usb_is_within_config ( (config), &desc->header ) ; \ 389 desc = container_of ( usb_next_descriptor ( &desc->header ), \ 390 typeof ( *desc ), header ) ) 393 #define for_each_interface_descriptor( desc, config, interface ) \ 394 for ( desc = container_of ( usb_next_descriptor ( &(interface)-> \ 396 typeof ( *desc ), header ) ; \ 397 ( usb_is_within_config ( (config), &desc->header ) && \ 398 ( desc->header.type != USB_INTERFACE_DESCRIPTOR ) ) ; \ 399 desc = container_of ( usb_next_descriptor ( &desc->header ), \ 400 typeof ( *desc ), header ) ) 500 #define USB_EP0_ADDRESS 0x00 503 #define USB_EP0_ATTRIBUTES 0x00 510 #define USB_EP0_DEFAULT_MTU(speed) \ 511 ( ( (speed) >= USB_SPEED_SUPER ) ? 512 : \ 512 ( ( (speed) >= USB_SPEED_FULL ) ? 64 : 8 ) ) 515 #define USB_EP0_BURST 0 518 #define USB_EP0_INTERVAL 0 521 #define USB_ENDPOINT_MAX 0x0f 524 #define USB_ENDPOINT_IN 0x80 527 #define USB_ENDPOINT_IDX(address) \ 528 ( ( (address) & USB_ENDPOINT_MAX ) | \ 529 ( ( (address) & USB_ENDPOINT_IN ) >> 3 ) ) 558 unsigned int attributes,
size_t mtu,
559 unsigned int burst,
unsigned int interval ) {
1076 #define for_each_usb_bus( bus ) \ 1077 list_for_each_entry ( (bus), &usb_buses, list ) 1095 unsigned int language,
1096 char *buf,
size_t len );
1198 sizeof (
data->mtu ) ) );
1273 for ( depth = 0 ; ( parent = usb->
port->
hub->
usb ) ; usb = parent )
1287 unsigned int type,
unsigned int index );
1306 unsigned int ports,
size_t mtu,
1313 unsigned int location );
1327 #define USB_RESET_DELAY_MS 50 1334 #define USB_RESET_RECOVER_DELAY_MS 10 1341 #define USB_CONTROL_MAX_WAIT_MS 5000 1348 #define USB_SET_ADDRESS_RECOVER_DELAY_MS 2 1357 #define USB_PORT_DELAY_MS 200 1372 #define USB_ANY_ID 0xffff 1388 #define USB_CLASS_ID( base, subclass, protocol ) { \ 1391 ( (base) & 0xff ), \ 1392 ( (subclass) & 0xff ), \ 1393 ( (protocol) & 0xff ), \ 1398 ( ( (base) == USB_ANY_ID ) ? 0x00 : 0xff ), \ 1399 ( ( (subclass) == USB_ANY_ID ) ? 0x00 : 0xff ), \ 1400 ( ( (protocol) == USB_ANY_ID ) ? 0x00 : 0xff ), \ 1437 #define USB_DRIVERS __table ( struct usb_driver, "usb_drivers" ) 1440 #define __usb_driver __table_entry ( USB_DRIVERS, 01 ) 1443 #define __usb_fallback_driver __table_entry ( USB_DRIVERS, 02 ) int(* open)(struct usb_bus *bus)
Open bus.
void unregister_usb_hub(struct usb_hub *hub)
Unregister USB hub.
void(* poll)(struct usb_bus *bus)
Poll bus.
size_t mtu
Largest transfer allowed on the bus.
static void usb_endpoint_set_hostdata(struct usb_endpoint *ep, void *priv)
Set USB endpoint host controller private data.
struct arbelprm_rc_send_wqe rc
void * priv
Host controller private data.
void(* close)(struct usb_endpoint *ep)
Close endpoint.
struct usb_bus * find_usb_bus(unsigned int address)
Find USB bus by address.
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
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 interval
Polling interval.
int disconnected
Port disconnection has been detected.
int usb_endpoint_open(struct usb_endpoint *ep)
Open USB endpoint.
int(* mtu)(struct usb_endpoint *ep)
Update MTU.
usb_protocol
USB protocols.
unsigned int count
Number of interfaces.
uint16_t vendor
Vendor ID.
A USB interface association descriptor.
struct usb_hub_host_operations * host
Host controller operations.
void unregister_usb_bus(struct usb_bus *bus)
Unregister USB bus.
struct list_head recycled
Recycled I/O buffer list.
#define USB_GET_DESCRIPTOR
Get descriptor.
struct usb_endpoint_companion_descriptor * usb_endpoint_companion_descriptor(struct usb_configuration_descriptor *config, struct usb_endpoint_descriptor *desc)
Locate USB endpoint companion descriptor.
uint8_t extended
Extended attributes.
void usb_flush(struct usb_endpoint *ep)
Discard endpoint recycled buffer list.
struct usb_descriptor_header header
Descriptor header.
uint64_t address
Base address.
static void usb_set_hostdata(struct usb_device *usb, void *priv)
Set USB device host controller private data.
uint32_t type
Operating system type.
struct usb_descriptor_header header
Descriptor header.
union usb_class_descriptor mask
Class mask.
static struct usb_descriptor_header * usb_next_descriptor(struct usb_descriptor_header *desc)
Get next USB descriptor.
struct usb_hub_host_operations hub
Hub operations.
size_t len
Refill buffer payload length.
struct usb_device * find_usb(struct usb_bus *bus, unsigned int address)
Find USB device by address.
uint16_t periodic
Number of bytes per service interval.
struct usb_bus_host_operations bus
Bus operations.
uint64_t desc
Microcode descriptor list physical address.
struct usb_class class
Interface class.
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.
void usb_free_address(struct usb_bus *bus, unsigned int address)
Free device address.
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.
uint16_t vendor
Vendor ID.
struct usb_driver * driver
Driver.
void free_usb_bus(struct usb_bus *bus)
Free USB bus.
int attached
Port has an attached device.
int usb_message(struct usb_endpoint *ep, unsigned int request, unsigned int value, unsigned int index, struct io_buffer *iobuf)
Enqueue USB message transfer.
struct usb_device * usb
Currently attached device (if in use)
uint8_t name
Association name.
uint8_t interfaces
Number of interfaces.
unsigned int protocol
Port protocol.
struct usb_bus * find_usb_bus_by_location(unsigned int bus_type, unsigned int location)
Find USB bus by device location.
int(* reset)(struct usb_endpoint *ep)
Reset endpoint.
uint8_t endpoint
Endpoint address.
struct usb_descriptor_header header
Descriptor header.
void usb_port_changed(struct usb_port *port)
Report port status change.
#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.
struct usb_driver * usb_find_driver(struct usb_function_descriptor *desc, struct usb_device_id **id)
Find USB device driver.
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.
unsigned long long addresses
Address in-use mask.
struct usb_interface_descriptor * usb_interface_descriptor(struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate)
Locate USB interface descriptor.
union usb_class_descriptor class
Class.
uint8_t attributes
Attributes.
USB hub driver operations.
struct list_head hubs
List of hubs.
unsigned int address
Device address, if assigned.
#define USB_GET_STATUS
Get status.
unsigned int speed
Device speed.
int(* probe)(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
A doubly-linked list entry (or list head)
int(* open)(struct usb_hub *hub)
Open hub.
static int usb_set_interface(struct usb_device *usb, unsigned int interface, unsigned int alternate)
Set USB interface alternate setting.
void * priv
Host controller private data.
static void usb_bus_set_hostdata(struct usb_bus *bus, void *priv)
Set USB bus host controller private data.
static int usb_set_address(struct usb_device *usb, unsigned int address)
Set address.
union usb_class_descriptor class
Class.
struct usb_device_id * id
Driver device ID.
uint16_t product
Product ID.
int register_usb_hub(struct usb_hub *hub)
Register USB hub.
uint16_t product
Product ID.
struct usb_device * usb
Underlying USB device, if any.
uint8_t manufacturer
Manufacturer string.
void * priv
Driver private data.
A USB interface descriptor.
struct list_head usb_buses
List of USB buses.
A USB function descriptor.
struct usb_descriptor_header header
Descriptor header.
struct usb_port * port
USB port.
struct usb_hub_driver_operations root
Root hub operations.
static void usb_recycle(struct usb_endpoint *ep, struct io_buffer *iobuf)
Recycle I/O buffer.
struct usb_hub_driver_operations * driver
Driver operations.
void(* close)(struct usb_hub *hub)
Close hub.
struct device * dev
Underlying hardware device.
struct usb_descriptor_header header
Descriptor header.
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.
uint16_t index
Index parameter.
struct ib_cm_path alternate
Alternate path.
pseudo_bit_t value[0x00020]
usb_driver_score
USB driver scores.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
uint8_t configurations
Number of possible configurations.
uint8_t serial
Serial number string.
struct list_head halted
List of halted endpoints.
struct usb_class class
Device class.
uint8_t power
Maximum power consumption.
unsigned int burst
Maximum burst size.
unsigned int usb_route_string(struct usb_device *usb)
Get USB route string.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
unsigned int address
Bus address.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
struct list_head list
List of USB buses.
int(* enable)(struct usb_hub *hub, struct usb_port *port)
Enable port.
int usb_alloc_address(struct usb_bus *bus)
Allocate device address.
USB bus host controller operations.
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
unsigned int ports
Number of ports.
#define USB_SPEED(mantissa, exponent)
Define a USB speed.
size_t reserve
Refill buffer reserved header length.
#define USB_CONFIGURATION_DESCRIPTOR
A USB configuration descriptor.
void(* close)(struct usb_device *usb)
Close device.
static unsigned int usb_depth(struct usb_device *usb)
Get USB depth.
int usb_refill(struct usb_endpoint *ep)
Refill endpoint.
struct usb_endpoint control
Control endpoint.
void(* close)(struct usb_bus *bus)
Close bus.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
static int usb_set_feature(struct usb_device *usb, unsigned int type, unsigned int feature, unsigned int index)
Set feature.
static struct usb_endpoint * usb_endpoint(struct usb_device *usb, unsigned int address)
Get USB endpoint.
#define USB_SET_INTERFACE
Set interface.
uint16_t product
Product ID.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct list_head list
List of devices on this bus.
void * priv
Driver private data.
unsigned int score
Driver score.
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 usb_endpoint_close(struct usb_endpoint *ep)
Close USB endpoint.
uint8_t name
Configuration string.
#define USB_CLEAR_FEATURE
Clear feature.
USB device host controller operations.
uint8_t endpoints
Number of endpoints.
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)
struct usb_hub * alloc_usb_hub(struct usb_bus *bus, struct usb_device *usb, unsigned int ports, struct usb_hub_driver_operations *op)
Allocate USB hub.
uint8_t attributes
Attributes.
void(* close)(struct usb_hub *hub)
Close hub.
void * priv
Host controller private data.
static void * usb_get_hostdata(struct usb_device *usb)
Get USB device host controller private data.
uint8_t name
Interface name.
unsigned int fill
Buffer fill level.
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.
void free_usb_hub(struct usb_hub *hub)
Free USB hub.
#define USB_ENDPOINT_IDX(address)
Construct endpoint index from endpoint address.
uint16_t release
Device release number in BCD.
uint8_t protocol
Protocol code.
int usb_refill_limit(struct usb_endpoint *ep, unsigned int max)
Refill endpoint up to specified limit.
unsigned long driver_data
Arbitrary driver data.
struct usb_descriptor_header header
Descriptor header.
USB endpoint host controller operations.
size_t mtu
Maximum transfer size.
uint8_t count
Interface count.
int(* disable)(struct usb_hub *hub, struct usb_port *port)
Disable port.
struct usb_port * usb_root_hub_port(struct usb_device *usb)
Get USB root hub port.
struct usb_host_operations * op
Host controller operations set.
static int usb_get_device_descriptor(struct usb_device *usb, struct usb_device_descriptor *data)
Get USB device descriptor.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
USB hub host controller operations.
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.
uint16_t vendor
Vendor ID.
unsigned int language
Default language ID (if known)
uint8_t subclass
Subclass code.
A USB endpoint descriptor.
static void * usb_bus_get_hostdata(struct usb_bus *bus)
Get USB bus host controller private data.
uint8_t first
First interface number.
uint8_t alternate
Alternate setting.
struct list_head list
List of which this buffer is a member.
uint8_t config
Configuration value.
struct list_head complete
Completed control transfers.
static struct tlan_private * priv
uint16_t protocol
USB specification release number in BCD.
struct list_head list
List of hubs.
static int usb_get_status(struct usb_device *usb, unsigned int type, unsigned int index, void *data, size_t len)
Get status.
uint8_t mtu
Maximum packet size for endpoint zero.
struct usb_bus * alloc_usb_bus(struct device *dev, unsigned int ports, size_t mtu, struct usb_host_operations *op)
Allocate USB bus.
uint8_t name
Product string.
static void usb_complete(struct usb_endpoint *ep, struct io_buffer *iobuf)
Complete transfer (without error)
A USB endpoint companion descriptor.
unsigned int address
Port address.
int register_usb_bus(struct usb_bus *bus)
Register USB bus.
struct usb_hub * hub
USB hub.
unsigned int id_count
Number of entries in ID table.
int usb_endpoint_clear_halt(struct usb_endpoint *ep)
Clear endpoint halt (if applicable)
#define USB_SET_ADDRESS
Set address.
void(* remove)(struct usb_function *func)
Remove device.
struct usb_endpoint * ep[32]
Endpoint list.
unsigned int interval
Interval (in microframes)
u8 request[0]
List of IEs requested.
struct usb_endpoint_host_operations endpoint
Endpoint operations.
uint32_t end
Ending offset.
int(* address)(struct usb_device *usb)
Assign device address.
uint8_t data[48]
Additional event data.
USB host controller operations.
void usb_complete_err(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer (possibly with error)
struct usb_class class
Association class.
struct usb_port * usb_transaction_translator(struct usb_device *usb)
Get USB transaction translator.
struct usb_descriptor_header header
Descriptor header.
struct usb_hub * hub
Root hub.
uint16_t len
Total length.
uint16_t len
Length of data stage.
struct usb_function_descriptor desc
Function descriptor.
static void usb_hub_set_drvdata(struct usb_hub *hub, void *priv)
Set USB hub driver private data.
struct usb_device * usb
USB device.
usb_speed
USB device speeds.
static struct usb_port * usb_port(struct usb_hub *hub, unsigned int address)
Get USB port.
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.
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.
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.
struct usb_bus_host_operations * host
Host controller operations.
#define USB_SET_FEATURE
Set feature.
USB endpoint driver operations.
struct device dev
Generic device.
uint16_t value
Value parameter.
uint16_t sizes
Maximum packet size and burst size.
struct usb_bus * bus
USB bus.
struct list_head functions
List of functions.
Fallback driver (has no effect on overall score)
unsigned int speed
Port speed.
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.
int(* speed)(struct usb_hub *hub, struct usb_port *port)
Update port speed.
#define USB_SET_CONFIGURATION
Set configuration.
#define NULL
NULL pointer (VOID *)
Standard Device Descriptor USB 2.0 spec, Section 9.6.1.
struct list_head list
List of functions within this USB device.
unsigned int attributes
Attributes.
struct list_head devices
List of devices.
uint8_t interface
Interface number.
unsigned int address
Endpoint address.
uint8_t burst
Maximum burst size.
struct usb_class class
Class.
static void * usb_hub_get_drvdata(struct usb_hub *hub)
Get USB hub driver private data.
int usb_find_next(struct usb_device **usb, uint16_t *busdev)
Find next USB device.
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
int(* open)(struct usb_hub *hub)
Open hub.
struct usb_device_id * ids
USB ID table.
int(* open)(struct usb_device *usb)
Open device.
static void * usb_endpoint_get_hostdata(struct usb_endpoint *ep)
Get USB endpoint host controller private data.
int(* stream)(struct usb_endpoint *ep, struct io_buffer *iobuf, int zlp)
Enqueue stream transfer.
struct usb_port port[0]
Port list.