Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; version 2 of |
| 8 | * the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pciexp.h> |
| 20 | #include <device/pci_ids.h> |
| 21 | #include <assert.h> |
| 22 | |
| 23 | static void pcie_disable(struct device *dev) |
| 24 | { |
| 25 | printk(BIOS_INFO, "%s: Disabling device\n", dev_path(dev)); |
| 26 | dev->enabled = 0; |
| 27 | } |
| 28 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 29 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 30 | static const char *pcie_acpi_name(const struct device *dev) |
| 31 | { |
| 32 | assert(dev); |
| 33 | |
| 34 | if (dev->path.type != DEVICE_PATH_PCI) |
| 35 | return NULL; |
| 36 | |
| 37 | assert(dev->bus); |
| 38 | if (dev->bus->secondary == 0) |
| 39 | switch (dev->path.pci.devfn) { |
| 40 | case PCI_DEVFN(1, 0): |
| 41 | return "PEGP"; |
| 42 | case PCI_DEVFN(1, 1): |
| 43 | return "PEG1"; |
| 44 | case PCI_DEVFN(1, 2): |
| 45 | return "PEG2"; |
| 46 | case PCI_DEVFN(6, 0): |
| 47 | return "PEG6"; |
| 48 | }; |
| 49 | |
Elyes HAOUAS | ee8ce8d | 2018-05-22 10:22:30 +0200 | [diff] [blame] | 50 | struct device *const port = dev->bus->dev; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 51 | assert(port); |
| 52 | assert(port->bus); |
| 53 | |
| 54 | if (dev->path.pci.devfn == PCI_DEVFN(0, 0) && |
| 55 | port->bus->secondary == 0 && |
| 56 | (port->path.pci.devfn == PCI_DEVFN(1, 0) || |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 57 | port->path.pci.devfn == PCI_DEVFN(1, 1) || |
| 58 | port->path.pci.devfn == PCI_DEVFN(1, 2) || |
| 59 | port->path.pci.devfn == PCI_DEVFN(6, 0))) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 60 | return "DEV0"; |
| 61 | |
| 62 | return NULL; |
| 63 | } |
| 64 | #endif |
| 65 | |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 66 | static struct pci_operations pci_ops = { |
Subrata Banik | 15ccbf0 | 2019-03-20 15:09:44 +0530 | [diff] [blame] | 67 | .set_subsystem = pci_dev_set_subsystem, |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static struct device_operations device_ops = { |
| 71 | .read_resources = pci_bus_read_resources, |
| 72 | .set_resources = pci_dev_set_resources, |
| 73 | .enable_resources = pci_bus_enable_resources, |
| 74 | .scan_bus = pciexp_scan_bridge, |
| 75 | .reset_bus = pci_bus_reset, |
| 76 | .disable = pcie_disable, |
| 77 | .init = pci_dev_init, |
| 78 | .ops_pci = &pci_ops, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 79 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 80 | .acpi_name = pcie_acpi_name, |
| 81 | #endif |
| 82 | }; |
| 83 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 84 | static const unsigned short pci_device_ids[] = { |
| 85 | 0x0101, 0x0105, 0x0109, 0x010d, |
| 86 | 0x0151, 0x0155, 0x0159, 0x015d, |
| 87 | 0, |
| 88 | }; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 89 | |
| 90 | static const struct pci_driver pch_pcie __pci_driver = { |
| 91 | .ops = &device_ops, |
| 92 | .vendor = PCI_VENDOR_ID_INTEL, |
| 93 | .devices = pci_device_ids, |
| 94 | }; |