Pratikkumar Prajapati | 0a71e09 | 2023-02-01 17:26:20 -0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <device/pci_ids.h> |
| 6 | #include <fsp/util.h> |
| 7 | |
| 8 | static const uint8_t fsp_tracehub_guid[16] = { |
| 9 | 0x09, 0x59, 0xb3, 0x5f, 0x1c, 0x5a, 0x31, 0x4a, |
| 10 | 0xad, 0xaf, 0x57, 0x7b, 0x54, 0x68, 0x26, 0x3f, |
| 11 | }; |
| 12 | |
| 13 | static void tracehub_read_resources(struct device *dev) |
| 14 | { |
| 15 | const struct hob_resource *tracehub_info_hob; |
| 16 | |
| 17 | /* Read standard PCI resources. */ |
| 18 | pci_dev_read_resources(dev); |
| 19 | |
| 20 | /* |
| 21 | * Find the Trace Hub HOB generated by Intel FSP. If the Trace Hub |
| 22 | * is configured to save data in DRAM, FSP will generate this HOB. |
| 23 | * This HOB contains address and length of the memory region used |
| 24 | * by Trace Hub to save traces. Mark this memory region as reserved. |
| 25 | */ |
| 26 | tracehub_info_hob = fsp_find_resource_hob_by_guid(fsp_tracehub_guid); |
| 27 | if (!tracehub_info_hob) { |
| 28 | printk(BIOS_INFO, "Trace Hub HOB not found\n"); |
| 29 | return; |
| 30 | } |
| 31 | printk(BIOS_DEBUG, "Trace Hub HOB found: addr=0x%08llx length=0x%08llx\n", |
| 32 | tracehub_info_hob->addr, tracehub_info_hob->length); |
| 33 | reserved_ram_resource_kb(dev, 0, tracehub_info_hob->addr / KiB, |
| 34 | tracehub_info_hob->length / KiB); |
| 35 | } |
| 36 | |
| 37 | static struct device_operations dev_ops = { |
| 38 | .read_resources = tracehub_read_resources, |
| 39 | .set_resources = pci_dev_set_resources, |
| 40 | .enable_resources = pci_dev_enable_resources, |
| 41 | .ops_pci = &pci_dev_ops_pci, |
| 42 | }; |
| 43 | |
| 44 | static const unsigned short pci_device_ids[] = { |
| 45 | PCI_DID_INTEL_MTL_TRACEHUB, |
| 46 | 0 |
| 47 | }; |
| 48 | |
| 49 | static const struct pci_driver tracehub_driver __pci_driver = { |
| 50 | .ops = &dev_ops, |
| 51 | .vendor = PCI_VID_INTEL, |
| 52 | .devices = pci_device_ids, |
| 53 | }; |