Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 3 | #include <console/console.h> |
Elyes Haouas | 8823ba1 | 2022-12-05 08:48:50 +0100 | [diff] [blame] | 4 | #include <device/mmio.h> |
Robert Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 5 | #include <device/device.h> |
Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 6 | #include <device/pci_def.h> |
Raul E Rangel | 2c952d6 | 2020-07-10 13:58:48 -0600 | [diff] [blame] | 7 | #include <device/xhci.h> |
Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 8 | |
| 9 | enum 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 Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 13 | const struct resource *res; |
Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 14 | |
Robert Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 15 | if (!device) |
| 16 | return CB_ERR; |
Raul E Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 17 | |
| 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 Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 25 | return xhci_resource_for_each_ext_cap(res, context, callback); |
Raul E Rangel | 2c952d6 | 2020-07-10 13:58:48 -0600 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | enum 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 Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 32 | const struct resource *res; |
Raul E Rangel | 2c952d6 | 2020-07-10 13:58:48 -0600 | [diff] [blame] | 33 | |
Robert Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 34 | if (!device) |
| 35 | return CB_ERR; |
Raul E Rangel | 2c952d6 | 2020-07-10 13:58:48 -0600 | [diff] [blame] | 36 | |
Robert Zieba | 219cb95 | 2022-11-18 18:06:28 +0000 | [diff] [blame] | 37 | 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 Rangel | a5b7ddf | 2020-05-29 17:16:20 -0600 | [diff] [blame] | 45 | } |