xref: /aosp_15_r20/external/coreboot/src/soc/intel/common/block/tracehub/tracehub.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
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 
tracehub_read_resources(struct device * dev)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_range(dev, 0, tracehub_info_hob->addr,
34 			   tracehub_info_hob->length);
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 	PCI_DID_INTEL_RPL_TRACEHUB,
47 	0
48 };
49 
50 static const struct pci_driver tracehub_driver __pci_driver = {
51 	.ops		= &dev_ops,
52 	.vendor		= PCI_VID_INTEL,
53 	.devices	= pci_device_ids,
54 };
55