diff options
author | Duncan Laurie <dlaurie@chromium.org> | 2016-05-08 18:15:25 -0700 |
---|---|---|
committer | Duncan Laurie <dlaurie@google.com> | 2016-05-21 05:59:52 +0200 |
commit | d9af3cecaedeb3579bc7afcde586477827095f73 (patch) | |
tree | 4a0b0700e618e40ce08aa6b90a61c74bc959a2ce /src/include | |
parent | 3829f238fa6eca7676ea3122da94a1ba239c5153 (diff) | |
download | coreboot-d9af3cecaedeb3579bc7afcde586477827095f73.tar.xz |
device: Add an ACPI device name and path concept to devices
Add a function to "struct device_operations" to return the ACPI name
for the device, and helper functions to find this name (either from
the device or its parent) and to build a fully qualified ACPI path
from the root device.
This addition will allow device drivers to generate their ACPI AML in
the SSDT at boot, with customization supplied by devicetree.cb,
instead of needing custom DSDT ASL for every mainboard.
The root device acpi_name is defined as "\\_SB" and is used to start
the path when building a fully qualified name.
This requires SOC support to provide handlers for returning the ACPI
name for devices that it owns, and those names must match the objects
declared in the DSDT. The handler can be done either in each device
driver or with a global handler for the entire SOC.
Simplified example of how this can be used for an i2c device declared
in devicetree.cb with:
chip soc/intel/skylake # "\_SB" (from root device)
device domain 0 on # "PCI0"
device pci 19.2 on # "I2C4"
chip drivers/i2c/test0
device i2c 1a.0 on end # "TST0"
end
end
end
end
And basic SSDT generating code in the device driver:
acpigen_write_scope(acpi_device_scope(dev));
acpigen_write_device(acpi_device_name(dev));
acpigen_write_string("_HID", "TEST0000");
acpigen_write_byte("_UID", 0);
acpigen_pop_len(); /* device */
acpigen_pop_len(); /* scope */
Will produce this ACPI code:
Scope (\_SB.PCI0.I2C4) {
Device (TST0) {
Name (_HID, "TEST0000")
Name (_UID, 0)
}
}
Change-Id: Ie149595aeab96266fa5f006e7934339f0119ac54
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://review.coreboot.org/14840
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/device/device.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h index d9af64adf5..00ff3d9a07 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -59,6 +59,7 @@ struct device_operations { unsigned long (*write_acpi_tables)(device_t dev, unsigned long start, struct acpi_rsdp *rsdp); void (*acpi_fill_ssdt_generator)(device_t dev); void (*acpi_inject_dsdt_generator)(device_t dev); + const char *(*acpi_name)(device_t dev); #endif const struct pci_operations *ops_pci; const struct smbus_bus_operations *ops_smbus_bus; |