Angel Pons | 80d9238 | 2020-04-05 15:47:00 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 5 | #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 | */ |
| 17 | static 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äfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 26 | * Workaround for Denverton-NS silicon (Rev A0/A1 for CSME/IE, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 27 | * 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 HAOUAS | 951d9f6 | 2018-09-19 14:57:42 +0200 | [diff] [blame] | 44 | static void pci_csme_ie_kt_read_resources(struct device *dev) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 45 | { |
| 46 | /** |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 47 | * CSME/IE KT has 2 BARs to check: |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 48 | * 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 | |
| 56 | static 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 Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 60 | .ops_pci = &soc_pci_ops, |
| 61 | }; |
| 62 | |
| 63 | static const unsigned short pci_device_ids[] = { |
Felix Singer | dbc90df | 2019-11-22 00:10:20 +0100 | [diff] [blame] | 64 | PCI_DEVICE_ID_INTEL_DENVERTON_ME_KT, |
| 65 | PCI_DEVICE_ID_INTEL_DENVERTON_IE_KT, |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 66 | 0 |
| 67 | }; |
| 68 | |
| 69 | static 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 | }; |