summaryrefslogtreecommitdiff
path: root/src/device/xhci.c
blob: 0961d0c988d4ca561e79c66a979d106e78f3fd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* 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);
}