blob: 17ce846459fb0efde47506efed26bd030ed45268 [file] [log] [blame]
Raul E Rangela5b7ddf2020-05-29 17:16:20 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#ifndef __DEVICE_XHCI_H__
4#define __DEVICE_XHCI_H__
5
6#include <stdint.h>
7#include <device/device.h>
8#include <commonlib/bsd/cb_err.h>
9
10#define XHCI_HCCPARAMS1_XECP 0x12
11
12#define XHCI_ECP_CAP_ID_LEGACY 1
13#define XHCI_ECP_CAP_ID_SUPP 2
14
15struct xhci_supported_protocol {
16 union {
17 uint32_t reg0;
18 struct {
19 uint32_t cap_id : 8;
20 uint32_t next_ptr : 8;
21 uint32_t minor_rev : 8;
22 uint32_t major_rev : 8;
23 };
24 };
25 union {
26 uint32_t reg1;
27 char name[4];
28 };
29 union {
30 uint32_t reg2;
31 struct {
32 uint32_t port_offset : 8;
33 uint32_t port_count : 8;
34 uint32_t reserved : 12;
35 uint32_t protocol_speed_id_count : 4;
36 };
37 };
38};
39
40struct xhci_ext_cap {
41 uint32_t cap_id;
42 /* cap_id is used to select the correct struct in the union. */
43 union {
44 struct xhci_supported_protocol supported_protocol;
45 };
46};
47
48/**
49 * Iterates over the xHCI Extended Capabilities List.
50 */
51enum cb_err xhci_for_each_ext_cap(const struct device *device, void *context,
52 void (*callback)(void *context,
53 const struct xhci_ext_cap *cap));
54
Raul E Rangel2c952d62020-07-10 13:58:48 -060055/**
56 * Helper method that iterates over only the USB supported capabilities structures in the
57 * xHCI Extended Capabilities List.
58 */
59enum cb_err xhci_for_each_supported_usb_cap(
60 const struct device *device, void *context,
61 void (*callback)(void *context, const struct xhci_supported_protocol *data));
62
Raul E Rangela5b7ddf2020-05-29 17:16:20 -060063void xhci_print_supported_protocol(const struct xhci_supported_protocol *supported_protocol);
64
65#endif /* __DEVICE_XHCI_H__ */