diff options
author | Duncan Laurie <dlaurie@google.com> | 2020-04-29 12:13:14 -0700 |
---|---|---|
committer | Duncan Laurie <dlaurie@chromium.org> | 2020-05-21 08:04:12 +0000 |
commit | 08a942fd32d23b940b8671e35e94f88062d7859f (patch) | |
tree | dc8266489bceee3f53d8f9dd890a571e0e9ec7dc /src | |
parent | e8189b74261f28293b650fd9a45e7b3a225990a9 (diff) |
acpi/device: Add a helper function to write SoundWire _ADR
This change adds a help function to write a SoundWire ACPI address
object that conforms to the SoundWire DisCo Specification Version 1.0
The SoundWire address structure is defined in include/device/soundwire.h
and provides the properties that are used to form the _ADR object.
BUG=b:146482091
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Change-Id: I6efbf52ce20b53f96d69efe2bf004b98dbe06552
Reviewed-on: https://review.coreboot.org/c/coreboot/+/40885
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/acpi/acpigen.c | 28 | ||||
-rw-r--r-- | src/include/acpi/acpigen.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 08f482d2a2..793841cc5b 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -18,6 +18,7 @@ #include <device/device.h> #include <device/pci_def.h> #include <device/pci_type.h> +#include <device/soundwire.h> static char *gencurrent; @@ -1885,3 +1886,30 @@ void acpigen_write_ADR_pci_device(const struct device *dev) assert(dev->path.type == DEVICE_PATH_PCI); acpigen_write_ADR_pci_devfn(dev->path.pci.devfn); } + +/** + * acpigen_write_ADR_soundwire_device() - SoundWire ACPI Device Address Encoding. + * @address: SoundWire device address properties. + * + * From SoundWire Discovery and Configuration Specification Version 1.0 Table 3. + * + * 63..52 - Reserved (0) + * 51..48 - Zero-based SoundWire Link ID, relative to the immediate parent. + * Used when a Controller has multiple master devices, each producing a + * separate SoundWire Link. Set to 0 for single-link controllers. + * 47..0 - SoundWire Device ID Encoding from specification version 1.2 table 88 + * 47..44 - SoundWire specification version that this device supports + * 43..40 - Unique ID for multiple devices + * 39..24 - MIPI standard manufacturer code + * 23..08 - Vendor defined part ID + * 07..00 - MIPI class encoding + */ +void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address) +{ + acpigen_write_ADR((((uint64_t)address->link_id & 0xf) << 48) | + (((uint64_t)address->version & 0xf) << 44) | + (((uint64_t)address->unique_id & 0xf) << 40) | + (((uint64_t)address->manufacturer_id & 0xffff) << 24) | + (((uint64_t)address->part_id & 0xffff) << 8) | + (((uint64_t)address->class & 0xff))); +} diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 895433546e..a99489de1f 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -374,6 +374,8 @@ void acpigen_write_pld(const struct acpi_pld *pld); void acpigen_write_ADR(uint64_t adr); void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn); void acpigen_write_ADR_pci_device(const struct device *dev); +struct soundwire_address; +void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address); /* * Generate ACPI AML code for _DSM method. * This function takes as input uuid for the device, set of callbacks and |