| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <acpi/acpigen_pci.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <device/pci.h> |
| 8 |
#include "chip.h" |
| 9 |
|
| 10 |
static const char *pcie_generic_acpi_name(const struct device *dev) |
| 11 |
{ |
| 12 |
struct drivers_pcie_generic_config *config = dev->chip_info; |
| 13 |
|
| 14 |
if (!config || !config->name) |
| 15 |
return "DEV0"; |
| 16 |
|
| 17 |
return config->name; |
| 18 |
} |
| 19 |
|
| 20 |
static void pcie_generic_fill_ssdt(const struct device *dev) |
| 21 |
{ |
| 22 |
struct drivers_pcie_generic_config *config; |
| 23 |
|
| 24 |
if (!is_dev_enabled(dev)) |
| 25 |
return; |
| 26 |
|
| 27 |
pci_rom_ssdt(dev); |
| 28 |
|
| 29 |
config = dev->chip_info; |
| 30 |
if (!config || !dev->upstream || !dev->upstream->dev) |
| 31 |
return; |
| 32 |
|
| 33 |
const char *scope; |
| 34 |
const char *name; |
| 35 |
|
| 36 |
scope = acpi_device_path(dev->upstream->dev); |
| 37 |
name = acpi_device_name(dev); |
| 38 |
|
| 39 |
acpigen_write_scope(scope); |
| 40 |
acpigen_write_device(name); |
| 41 |
acpigen_write_ADR_pci_device(dev); |
| 42 |
|
| 43 |
if (config->wake_gpe) |
| 44 |
acpigen_write_PRW(config->wake_gpe, config->wake_deepest); |
| 45 |
if (config->add_acpi_dma_property) |
| 46 |
acpi_device_add_dma_property(NULL); |
| 47 |
|
| 48 |
acpigen_write_device_end(); |
| 49 |
acpigen_write_scope_end(); |
| 50 |
|
| 51 |
printk(BIOS_INFO, "%s.%s: Enable ACPI properties for %s (%s)\n", scope, name, |
| 52 |
dev_path(dev), dev->chip_ops->name); |
| 53 |
} |
| 54 |
|
| 55 |
struct device_operations pcie_generic_ops = { |
| 56 |
.read_resources = pci_dev_read_resources, |
| 57 |
.set_resources = pci_dev_set_resources, |
| 58 |
.enable_resources = pci_dev_enable_resources, |
| 59 |
.init = pci_dev_init, |
| 60 |
.ops_pci = &pci_dev_ops_pci, |
| 61 |
.acpi_name = pcie_generic_acpi_name, |
| 62 |
.acpi_fill_ssdt = pcie_generic_fill_ssdt, |
| 63 |
}; |
| 64 |
|
| 65 |
static void pcie_generic_enable(struct device *dev) |
| 66 |
{ |
| 67 |
dev->ops = &pcie_generic_ops; |
| 68 |
} |
| 69 |
|
| 70 |
struct chip_operations drivers_pcie_generic_ops = { |
| 71 |
.name = "PCIe Device", |
| 72 |
.enable_dev = pcie_generic_enable |
| 73 |
}; |