2020-05-30 01:16:20 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
|
|
|
#include <console/console.h>
|
2022-12-05 08:48:50 +01:00
|
|
|
#include <device/mmio.h>
|
2022-11-18 19:06:28 +01:00
|
|
|
#include <device/device.h>
|
2020-05-30 01:16:20 +02:00
|
|
|
#include <device/pci_def.h>
|
2020-07-10 21:58:48 +02:00
|
|
|
#include <device/xhci.h>
|
2020-05-30 01:16:20 +02:00
|
|
|
|
|
|
|
enum cb_err xhci_for_each_ext_cap(const struct device *device, void *context,
|
|
|
|
void (*callback)(void *context,
|
|
|
|
const struct xhci_ext_cap *cap))
|
|
|
|
{
|
2022-11-18 19:06:28 +01:00
|
|
|
const struct resource *res;
|
2020-05-30 01:16:20 +02:00
|
|
|
|
2022-11-18 19:06:28 +01:00
|
|
|
if (!device)
|
|
|
|
return CB_ERR;
|
2020-05-30 01:16:20 +02:00
|
|
|
|
|
|
|
res = probe_resource(device, PCI_BASE_ADDRESS_0);
|
|
|
|
if (!res) {
|
|
|
|
printk(BIOS_ERR, "%s: Unable to find BAR resource for %s\n", __func__,
|
|
|
|
dev_path(device));
|
|
|
|
return CB_ERR;
|
|
|
|
}
|
|
|
|
|
2022-11-18 19:06:28 +01:00
|
|
|
return xhci_resource_for_each_ext_cap(res, context, callback);
|
2020-07-10 21:58:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum cb_err xhci_for_each_supported_usb_cap(
|
|
|
|
const struct device *device, void *context,
|
|
|
|
void (*callback)(void *context, const struct xhci_supported_protocol *data))
|
|
|
|
{
|
2022-11-18 19:06:28 +01:00
|
|
|
const struct resource *res;
|
2020-07-10 21:58:48 +02:00
|
|
|
|
2022-11-18 19:06:28 +01:00
|
|
|
if (!device)
|
|
|
|
return CB_ERR;
|
2020-07-10 21:58:48 +02:00
|
|
|
|
2022-11-18 19:06:28 +01:00
|
|
|
res = probe_resource(device, PCI_BASE_ADDRESS_0);
|
|
|
|
if (!res) {
|
|
|
|
printk(BIOS_ERR, "%s: Unable to find BAR resource for %s\n", __func__,
|
|
|
|
dev_path(device));
|
|
|
|
return CB_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xhci_resource_for_each_supported_usb_cap(res, context, callback);
|
2020-05-30 01:16:20 +02:00
|
|
|
}
|