summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2013-09-24 20:03:54 -0700
committerIsaac Christensen <isaac.christensen@se-eng.com>2014-09-04 01:28:42 +0200
commite00ba2168bf9e61535b83ab4320364fa8e26910c (patch)
tree98d9fdb28b0214fa7823b580b693635f4af62fe1 /payloads/libpayload/include
parentf9d7252a8d869cfda08c872b49d3ce5d7c27b083 (diff)
downloadcoreboot-e00ba2168bf9e61535b83ab4320364fa8e26910c.tar.xz
libpayload: usb: Unify USB speed between XHCI stack and USB core
This patch removes the confusing concept of a special "xhci_speed" with a different numeric value from the usual speed used throughout the USB core (except for the places directly interacting with the xHC, which are explicitly marked). It also moves the MPS0 decoding function into the core and moves some definitions around in preparation of later changes that will make the stack SuperSpeed-ready. It makes both set_address implementations share a constant for the specification-defined SetAddress() recovery delay and removes pointless additional delays from the non-XHCI version. Change-Id: I422379d05d4a502b12dae183504e5231add5466a Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170664 Reviewed-by: Stefan Reinauer <reinauer@google.com> Commit-Queue: Ronald Minnich <rminnich@chromium.org> (cherry picked from commit f160d4439c0d7cea1d2e6b97207935d61dcbb2f2) Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com> Reviewed-on: http://review.coreboot.org/6776 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/usb/usb.h177
1 files changed, 93 insertions, 84 deletions
diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h
index 2bf1993b82..83d4a85759 100644
--- a/payloads/libpayload/include/usb/usb.h
+++ b/payloads/libpayload/include/usb/usb.h
@@ -59,6 +59,88 @@ typedef enum {
TEST_MODE = 2
} feature_selectors;
+/* SetAddress() recovery interval (USB 2.0 specification 9.2.6.3 */
+#define SET_ADDRESS_MDELAY 2
+
+typedef struct {
+ unsigned char bDescLength;
+ unsigned char bDescriptorType;
+ unsigned char bNbrPorts;
+ union {
+ struct {
+ unsigned long logicalPowerSwitchingMode:2;
+ unsigned long isCompoundDevice:1;
+ unsigned long overcurrentProtectionMode:2;
+ unsigned long ttThinkTime:2;
+ unsigned long arePortIndicatorsSupported:1;
+ unsigned long:8;
+ } __attribute__ ((packed));
+ unsigned short wHubCharacteristics;
+ } __attribute__ ((packed));
+ unsigned char bPowerOn2PwrGood;
+ unsigned char bHubContrCurrent;
+ char DeviceRemovable[];
+} __attribute__ ((packed)) hub_descriptor_t;
+
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned short bcdUSB;
+ unsigned char bDeviceClass;
+ unsigned char bDeviceSubClass;
+ unsigned char bDeviceProtocol;
+ unsigned char bMaxPacketSize0;
+ unsigned short idVendor;
+ unsigned short idProduct;
+ unsigned short bcdDevice;
+ unsigned char iManufacturer;
+ unsigned char iProduct;
+ unsigned char iSerialNumber;
+ unsigned char bNumConfigurations;
+} __attribute__ ((packed)) device_descriptor_t;
+
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned short wTotalLength;
+ unsigned char bNumInterfaces;
+ unsigned char bConfigurationValue;
+ unsigned char iConfiguration;
+ unsigned char bmAttributes;
+ unsigned char bMaxPower;
+} __attribute__ ((packed)) configuration_descriptor_t;
+
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned char bInterfaceNumber;
+ unsigned char bAlternateSetting;
+ unsigned char bNumEndpoints;
+ unsigned char bInterfaceClass;
+ unsigned char bInterfaceSubClass;
+ unsigned char bInterfaceProtocol;
+ unsigned char iInterface;
+} __attribute__ ((packed)) interface_descriptor_t;
+
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned char bEndpointAddress;
+ unsigned char bmAttributes;
+ unsigned short wMaxPacketSize;
+ unsigned char bInterval;
+} __attribute__ ((packed)) endpoint_descriptor_t;
+
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned short bcdHID;
+ unsigned char bCountryCode;
+ unsigned char bNumDescriptors;
+ unsigned char bReportDescriptorType;
+ unsigned short wReportDescriptorLength;
+} __attribute__ ((packed)) hid_descriptor_t;
+
typedef struct {
union {
struct {
@@ -95,7 +177,9 @@ typedef struct {
of microframes (i.e. t = 125us * 2^interval) */
} endpoint_t;
-enum { FULL_SPEED = 0, LOW_SPEED = 1, HIGH_SPEED = 2, SUPER_SPEED = 3 };
+typedef enum {
+ FULL_SPEED = 0, LOW_SPEED = 1, HIGH_SPEED = 2, SUPER_SPEED = 3,
+} usb_speed;
struct usbdev {
hci_t *controller;
@@ -104,7 +188,7 @@ struct usbdev {
int address; // usb address
int hub; // hub, device is attached to
int port; // port where device is attached
- int speed; // 1: lowspeed, 0: fullspeed, 2: highspeed
+ usb_speed speed;
u32 quirks; // quirks field. got to love usb
void *data;
u8 *descriptor;
@@ -151,7 +235,8 @@ struct usbdev_hc {
do this by themself. Also, the usbdev
structure has to be allocated and
initialized. */
- int (*set_address) (hci_t *controller, int speed, int hubport, int hubaddr);
+ int (*set_address) (hci_t *controller, usb_speed speed,
+ int hubport, int hubaddr);
/* finish_device_config(): Another hook for xHCI,
returns 0 on success. */
int (*finish_device_config) (usbdev_t *dev);
@@ -161,91 +246,13 @@ struct usbdev_hc {
void (*destroy_device) (hci_t *controller, int devaddr);
};
-typedef struct {
- unsigned char bDescLength;
- unsigned char bDescriptorType;
- unsigned char bNbrPorts;
- union {
- struct {
- unsigned long logicalPowerSwitchingMode:2;
- unsigned long isCompoundDevice:1;
- unsigned long overcurrentProtectionMode:2;
- unsigned long ttThinkTime:2;
- unsigned long arePortIndicatorsSupported:1;
- unsigned long:8;
- } __attribute__ ((packed));
- unsigned short wHubCharacteristics;
- } __attribute__ ((packed));
- unsigned char bPowerOn2PwrGood;
- unsigned char bHubContrCurrent;
- char DeviceRemovable[];
-} __attribute__ ((packed)) hub_descriptor_t;
-
-typedef struct {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short bcdUSB;
- unsigned char bDeviceClass;
- unsigned char bDeviceSubClass;
- unsigned char bDeviceProtocol;
- unsigned char bMaxPacketSize0;
- unsigned short idVendor;
- unsigned short idProduct;
- unsigned short bcdDevice;
- unsigned char iManufacturer;
- unsigned char iProduct;
- unsigned char iSerialNumber;
- unsigned char bNumConfigurations;
-} __attribute__ ((packed)) device_descriptor_t;
-
-typedef struct {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short wTotalLength;
- unsigned char bNumInterfaces;
- unsigned char bConfigurationValue;
- unsigned char iConfiguration;
- unsigned char bmAttributes;
- unsigned char bMaxPower;
-} __attribute__ ((packed)) configuration_descriptor_t;
-
-typedef struct {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned char bInterfaceNumber;
- unsigned char bAlternateSetting;
- unsigned char bNumEndpoints;
- unsigned char bInterfaceClass;
- unsigned char bInterfaceSubClass;
- unsigned char bInterfaceProtocol;
- unsigned char iInterface;
-} __attribute__ ((packed)) interface_descriptor_t;
-
-typedef struct {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned char bEndpointAddress;
- unsigned char bmAttributes;
- unsigned short wMaxPacketSize;
- unsigned char bInterval;
-} __attribute__ ((packed)) endpoint_descriptor_t;
-
-typedef struct {
- unsigned char bLength;
- unsigned char bDescriptorType;
- unsigned short bcdHID;
- unsigned char bCountryCode;
- unsigned char bNumDescriptors;
- unsigned char bReportDescriptorType;
- unsigned short wReportDescriptorLength;
-} __attribute__ ((packed)) hid_descriptor_t;
-
hci_t *usb_add_mmio_hc(hc_type type, void *bar);
hci_t *new_controller (void);
void detach_controller (hci_t *controller);
void usb_poll (void);
void init_device_entry (hci_t *controller, int num);
+int usb_decode_mps0 (usb_speed speed, u8 bMaxPacketSize0);
void set_feature (usbdev_t *dev, int endp, int feature, int rtype);
void get_status (usbdev_t *dev, int endp, int rtype, int len, void *data);
void set_configuration (usbdev_t *dev);
@@ -268,10 +275,12 @@ gen_bmRequestType (dev_req_dir dir, dev_req_type type, dev_req_recp recp)
}
/* default "set address" handler */
-int generic_set_address (hci_t *controller, int speed, int hubport, int hubaddr);
+int generic_set_address (hci_t *controller, usb_speed speed,
+ int hubport, int hubaddr);
void usb_detach_device(hci_t *controller, int devno);
-int usb_attach_device(hci_t *controller, int hubaddress, int port, int speed);
+int usb_attach_device(hci_t *controller, int hubaddress, int port,
+ usb_speed speed);
u32 usb_quirk_check(u16 vendor, u16 device);
int usb_interface_check(u16 vendor, u16 device);