blob: 84ee919bfe2dc4d356e187ed2ced47742f8f806e [file] [log] [blame]
Angel Pons80d92382020-04-05 15:47:00 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02003
4#include <stdint.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02005#include <device/pci.h>
6#include <device/pci_ids.h>
7#include <console/console.h>
8#include <soc/pci_devs.h>
9#include <soc/ramstage.h>
10
11/**
12* Read the base address registers for a given device.
13*
14* @param dev Pointer to the dev structure.
15* @param howmany How many registers to read.
16*/
17static void pci_read_bases(struct device *dev, unsigned int howmany)
18{
19 unsigned long index;
20
21 for (index = PCI_BASE_ADDRESS_0;
22 (index < PCI_BASE_ADDRESS_0 + (howmany << 2));) {
23 struct resource *resource;
24 resource = pci_get_resource(dev, index);
25 /**
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010026 * Workaround for Denverton-NS silicon (Rev A0/A1 for CSME/IE,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020027 * Rev B0 for CSME only)
28 * CSME&IEs KT IO bar must be 16-byte aligned
29 */
30 if ((resource->flags & IORESOURCE_IO) &&
31 (resource->align != 4)) {
32 printk(BIOS_DEBUG,
33 "CSME&IEs KT IO bar must be 16-byte aligned!\n");
34 resource->align = 4;
35 resource->gran = 4;
36 resource->size = 16;
37 }
38 index += (resource->flags & IORESOURCE_PCI64) ? 8 : 4;
39 }
40
41 compact_resources(dev);
42}
43
Elyes HAOUAS951d9f62018-09-19 14:57:42 +020044static void pci_csme_ie_kt_read_resources(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020045{
46 /**
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010047 * CSME/IE KT has 2 BARs to check:
Mariusz Szafranskia4041332017-08-02 17:28:17 +020048 * 0x10 - KT IO BAR
49 * 0x14 - KT Memory BAR
50 * CSME/IE KT has no Expansion ROM BAR to check:
51 * 0x30 - KT Host XRBAR, READ ONLY
52 */
53 pci_read_bases(dev, 2);
54}
55
56static struct device_operations csme_ie_kt_ops = {
57 .read_resources = pci_csme_ie_kt_read_resources,
58 .set_resources = pci_dev_set_resources,
59 .enable_resources = pci_dev_enable_resources,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020060 .ops_pci = &soc_pci_ops,
61};
62
63static const unsigned short pci_device_ids[] = {
Felix Singerdbc90df2019-11-22 00:10:20 +010064 PCI_DEVICE_ID_INTEL_DENVERTON_ME_KT,
65 PCI_DEVICE_ID_INTEL_DENVERTON_IE_KT,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020066 0
67};
68
69static const struct pci_driver csme_ie_kt __pci_driver = {
70 .ops = &csme_ie_kt_ops,
71 .vendor = PCI_VENDOR_ID_INTEL,
72 .devices = pci_device_ids,
73};