blob: 0961d0c988d4ca561e79c66a979d106e78f3fd8c [file] [log] [blame]
Raul E Rangela5b7ddf2020-05-29 17:16:20 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
Raul E Rangela5b7ddf2020-05-29 17:16:20 -06003#include <console/console.h>
Elyes Haouas8823ba12022-12-05 08:48:50 +01004#include <device/mmio.h>
Robert Zieba219cb952022-11-18 18:06:28 +00005#include <device/device.h>
Raul E Rangela5b7ddf2020-05-29 17:16:20 -06006#include <device/pci_def.h>
Raul E Rangel2c952d62020-07-10 13:58:48 -06007#include <device/xhci.h>
Raul E Rangela5b7ddf2020-05-29 17:16:20 -06008
9enum cb_err xhci_for_each_ext_cap(const struct device *device, void *context,
10 void (*callback)(void *context,
11 const struct xhci_ext_cap *cap))
12{
Robert Zieba219cb952022-11-18 18:06:28 +000013 const struct resource *res;
Raul E Rangela5b7ddf2020-05-29 17:16:20 -060014
Robert Zieba219cb952022-11-18 18:06:28 +000015 if (!device)
16 return CB_ERR;
Raul E Rangela5b7ddf2020-05-29 17:16:20 -060017
18 res = probe_resource(device, PCI_BASE_ADDRESS_0);
19 if (!res) {
20 printk(BIOS_ERR, "%s: Unable to find BAR resource for %s\n", __func__,
21 dev_path(device));
22 return CB_ERR;
23 }
24
Robert Zieba219cb952022-11-18 18:06:28 +000025 return xhci_resource_for_each_ext_cap(res, context, callback);
Raul E Rangel2c952d62020-07-10 13:58:48 -060026}
27
28enum cb_err xhci_for_each_supported_usb_cap(
29 const struct device *device, void *context,
30 void (*callback)(void *context, const struct xhci_supported_protocol *data))
31{
Robert Zieba219cb952022-11-18 18:06:28 +000032 const struct resource *res;
Raul E Rangel2c952d62020-07-10 13:58:48 -060033
Robert Zieba219cb952022-11-18 18:06:28 +000034 if (!device)
35 return CB_ERR;
Raul E Rangel2c952d62020-07-10 13:58:48 -060036
Robert Zieba219cb952022-11-18 18:06:28 +000037 res = probe_resource(device, PCI_BASE_ADDRESS_0);
38 if (!res) {
39 printk(BIOS_ERR, "%s: Unable to find BAR resource for %s\n", __func__,
40 dev_path(device));
41 return CB_ERR;
42 }
43
44 return xhci_resource_for_each_supported_usb_cap(res, context, callback);
Raul E Rangela5b7ddf2020-05-29 17:16:20 -060045}