Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/data_fabric.h> |
Felix Held | 9cbdc8f | 2023-08-11 22:30:06 +0200 | [diff] [blame] | 4 | #include <amdblocks/root_complex.h> |
Felix Held | 55822d9 | 2023-08-08 21:38:07 +0200 | [diff] [blame] | 5 | #include <console/console.h> |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 6 | #include <device/device.h> |
| 7 | #include <types.h> |
| 8 | |
Felix Held | 6c00a6a | 2023-12-06 23:40:42 +0100 | [diff] [blame] | 9 | enum cb_err data_fabric_get_pci_bus_numbers(struct device *domain, uint8_t *segment_group, |
| 10 | uint8_t *first_bus, uint8_t *last_bus) |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 11 | { |
Felix Held | 9cbdc8f | 2023-08-11 22:30:06 +0200 | [diff] [blame] | 12 | const signed int iohc_dest_fabric_id = get_iohc_fabric_id(domain); |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 13 | union df_pci_cfg_map pci_bus_map; |
| 14 | |
| 15 | for (unsigned int i = 0; i < DF_PCI_CFG_MAP_COUNT; i++) { |
| 16 | pci_bus_map.raw = data_fabric_broadcast_read32(DF_PCI_CFG_MAP(i)); |
| 17 | |
Felix Held | 9cbdc8f | 2023-08-11 22:30:06 +0200 | [diff] [blame] | 18 | if (pci_bus_map.dst_fabric_id != iohc_dest_fabric_id) |
Felix Held | 55822d9 | 2023-08-08 21:38:07 +0200 | [diff] [blame] | 19 | continue; |
| 20 | |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 21 | if (pci_bus_map.we && pci_bus_map.re) { |
Felix Held | 6c00a6a | 2023-12-06 23:40:42 +0100 | [diff] [blame] | 22 | *segment_group = 0; |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 23 | *first_bus = pci_bus_map.bus_num_base; |
| 24 | *last_bus = pci_bus_map.bus_num_limit; |
| 25 | return CB_SUCCESS; |
| 26 | } |
| 27 | } |
| 28 | |
Felix Held | 55822d9 | 2023-08-08 21:38:07 +0200 | [diff] [blame] | 29 | printk(BIOS_ERR, "No valid DF PCI CFG register found for domain %x.\n", |
| 30 | domain->path.domain.domain); |
Felix Held | ea83139 | 2023-08-08 02:55:09 +0200 | [diff] [blame] | 31 | return CB_ERR; |
| 32 | } |