summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/tracehub/tracehub.c
blob: 4faa9ebc91249dde2834b5a5347213601d23fc9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <fsp/util.h>

static const uint8_t fsp_tracehub_guid[16] = {
	0x09, 0x59, 0xb3, 0x5f, 0x1c, 0x5a, 0x31, 0x4a,
	0xad, 0xaf, 0x57, 0x7b, 0x54, 0x68, 0x26, 0x3f,
};

static void tracehub_read_resources(struct device *dev)
{
	const struct hob_resource *tracehub_info_hob;

	/* Read standard PCI resources. */
	pci_dev_read_resources(dev);

	/*
	 * Find the Trace Hub HOB generated by Intel FSP. If the Trace Hub
	 * is configured to save data in DRAM, FSP will generate this HOB.
	 * This HOB contains address and length of the memory region used
	 * by Trace Hub to save traces. Mark this memory region as reserved.
	 */
	tracehub_info_hob = fsp_find_resource_hob_by_guid(fsp_tracehub_guid);
	if (!tracehub_info_hob) {
		printk(BIOS_INFO, "Trace Hub HOB not found\n");
		return;
	}
	printk(BIOS_DEBUG, "Trace Hub HOB found: addr=0x%08llx length=0x%08llx\n",
			tracehub_info_hob->addr, tracehub_info_hob->length);
	reserved_ram_range(dev, 0, tracehub_info_hob->addr,
			   tracehub_info_hob->length);
}

static struct device_operations dev_ops = {
	.read_resources		= tracehub_read_resources,
	.set_resources		= pci_dev_set_resources,
	.enable_resources	= pci_dev_enable_resources,
	.ops_pci		= &pci_dev_ops_pci,
};

static const unsigned short pci_device_ids[] = {
	PCI_DID_INTEL_MTL_TRACEHUB,
	0
};

static const struct pci_driver tracehub_driver __pci_driver = {
	.ops		= &dev_ops,
	.vendor		= PCI_VID_INTEL,
	.devices	= pci_device_ids,
};