blob: dd065d50425c65fe3905680b3bb9d7210089b535 [file] [log] [blame]
Pratikkumar Prajapati0a71e092023-02-01 17:26:20 -08001/* 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
8static 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
13static 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
37static 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
44static const unsigned short pci_device_ids[] = {
45 PCI_DID_INTEL_MTL_TRACEHUB,
46 0
47};
48
49static const struct pci_driver tracehub_driver __pci_driver = {
50 .ops = &dev_ops,
51 .vendor = PCI_VID_INTEL,
52 .devices = pci_device_ids,
53};