blob: 0510ef2bb465a6cbf28ad49bed2be1f0c6f04f0b [file] [log] [blame]
Angel Pons80d92382020-04-05 15:47:00 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02002
Mariusz Szafranskia4041332017-08-02 17:28:17 +02003#include <device/pci.h>
4#include <device/pci_ids.h>
5#include <console/console.h>
6#include <soc/pci_devs.h>
7#include <soc/ramstage.h>
8
9/**
10* Read the base address registers for a given device.
11*
12* @param dev Pointer to the dev structure.
13* @param howmany How many registers to read.
14*/
15static void pci_read_bases(struct device *dev, unsigned int howmany)
16{
17 unsigned long index;
18
19 for (index = PCI_BASE_ADDRESS_0;
20 (index < PCI_BASE_ADDRESS_0 + (howmany << 2));) {
21 struct resource *resource;
22 resource = pci_get_resource(dev, index);
23 /**
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010024 * Workaround for Denverton-NS silicon (Rev A0/A1 for CSME/IE,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020025 * Rev B0 for CSME only)
26 * CSME&IEs KT IO bar must be 16-byte aligned
27 */
28 if ((resource->flags & IORESOURCE_IO) &&
29 (resource->align != 4)) {
30 printk(BIOS_DEBUG,
31 "CSME&IEs KT IO bar must be 16-byte aligned!\n");
32 resource->align = 4;
33 resource->gran = 4;
34 resource->size = 16;
35 }
36 index += (resource->flags & IORESOURCE_PCI64) ? 8 : 4;
37 }
38
39 compact_resources(dev);
40}
41
Elyes HAOUAS951d9f62018-09-19 14:57:42 +020042static void pci_csme_ie_kt_read_resources(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020043{
44 /**
Jonathan Neuschäfer5268b762018-02-12 12:24:25 +010045 * CSME/IE KT has 2 BARs to check:
Mariusz Szafranskia4041332017-08-02 17:28:17 +020046 * 0x10 - KT IO BAR
47 * 0x14 - KT Memory BAR
48 * CSME/IE KT has no Expansion ROM BAR to check:
49 * 0x30 - KT Host XRBAR, READ ONLY
50 */
51 pci_read_bases(dev, 2);
52}
53
54static struct device_operations csme_ie_kt_ops = {
55 .read_resources = pci_csme_ie_kt_read_resources,
56 .set_resources = pci_dev_set_resources,
57 .enable_resources = pci_dev_enable_resources,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020058 .ops_pci = &soc_pci_ops,
59};
60
61static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010062 PCI_DID_INTEL_DNV_ME_KT,
63 PCI_DID_INTEL_DNV_IE_KT,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020064 0
65};
66
67static const struct pci_driver csme_ie_kt __pci_driver = {
68 .ops = &csme_ie_kt_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010069 .vendor = PCI_VID_INTEL,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020070 .devices = pci_device_ids,
71};