coreboot-kgpe-d16/src/device/xhci.c
Robert Zieba 219cb952f8 device/xhci: Add functions to work with resource pointers
The XHCI device functions currently use functions that require a
access to the device tree. Create variant of these functions that can
operate with a resource* as an argument and refactor the existing
device*-based functions to operate by calling the resource*-based
variants. This is useful for stages like SMM that may not have access to
the device tree.

BRANCH=guybrush
BUG=b:186792595
TEST=Ran on skyrim device, verified that XHCI ACPI tables are still
generated correctly.

Change-Id: If5a74f9529d5dc6031ec968ef5f40a9cad5ffbc4
Signed-off-by: Robert Zieba <robertzieba@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69914
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
2023-03-05 15:32:34 +00:00

45 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <console/console.h>
#include <device/mmio.h>
#include <device/device.h>
#include <device/pci_def.h>
#include <device/xhci.h>
enum cb_err xhci_for_each_ext_cap(const struct device *device, void *context,
void (*callback)(void *context,
const struct xhci_ext_cap *cap))
{
const struct resource *res;
if (!device)
return CB_ERR;
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_ext_cap(res, context, callback);
}
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))
{
const struct resource *res;
if (!device)
return CB_ERR;
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);
}