From a5b7ddf94047aed0444b0fd44c3498a639577d58 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Fri, 29 May 2020 17:16:20 -0600 Subject: device/xhci: Add xHCI utility to enumerate capabilities This will allow enumerating an xHCI controller to allow dynamically generating the ACPI device nodes. BUG=b:154756391 TEST=Boot trembyle and see capabilities printed on console xHCI Supported Protocol: Major: 0x2, Minor: 0x0, Protocol: 'USB ' Port Offset: 1, Port Count: 2 xHCI Supported Protocol: Major: 0x3, Minor: 0x10, Protocol: 'USB ' Port Offset: 3, Port Count: 1 Signed-off-by: Raul E Rangel Change-Id: I3065c3fffad01b5378a55cfe904f971079b13d0f Reviewed-on: https://review.coreboot.org/c/coreboot/+/41899 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/include/device/xhci.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/include/device/xhci.h (limited to 'src/include/device') diff --git a/src/include/device/xhci.h b/src/include/device/xhci.h new file mode 100644 index 0000000000..25f950be2e --- /dev/null +++ b/src/include/device/xhci.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __DEVICE_XHCI_H__ +#define __DEVICE_XHCI_H__ + +#include +#include +#include + +#define XHCI_HCCPARAMS1_XECP 0x12 + +#define XHCI_ECP_CAP_ID_LEGACY 1 +#define XHCI_ECP_CAP_ID_SUPP 2 + +struct xhci_supported_protocol { + union { + uint32_t reg0; + struct { + uint32_t cap_id : 8; + uint32_t next_ptr : 8; + uint32_t minor_rev : 8; + uint32_t major_rev : 8; + }; + }; + union { + uint32_t reg1; + char name[4]; + }; + union { + uint32_t reg2; + struct { + uint32_t port_offset : 8; + uint32_t port_count : 8; + uint32_t reserved : 12; + uint32_t protocol_speed_id_count : 4; + }; + }; +}; + +struct xhci_ext_cap { + uint32_t cap_id; + /* cap_id is used to select the correct struct in the union. */ + union { + struct xhci_supported_protocol supported_protocol; + }; +}; + +/** + * Iterates over the xHCI Extended Capabilities List. + */ +enum cb_err xhci_for_each_ext_cap(const struct device *device, void *context, + void (*callback)(void *context, + const struct xhci_ext_cap *cap)); + +void xhci_print_supported_protocol(const struct xhci_supported_protocol *supported_protocol); + +#endif /* __DEVICE_XHCI_H__ */ -- cgit v1.2.3