| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi_device.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <amdblocks/acp.h> |
| 6 |
#include <amdblocks/acpimmio.h> |
| 7 |
#include <amdblocks/chip.h> |
| 8 |
#include <device/device.h> |
| 9 |
#include <device/pci.h> |
| 10 |
#include <device/pci_ops.h> |
| 11 |
#include <commonlib/helpers.h> |
| 12 |
#include "acp_def.h" |
| 13 |
|
| 14 |
_Static_assert(!(CONFIG(SOC_AMD_COMMON_BLOCK_ACP_GEN1) && CONFIG(SOC_AMD_COMMON_BLOCK_ACP_GEN2)), |
| 15 |
"Cannot select both ACP_GEN1 and ACP_GEN2 - check your config"); |
| 16 |
|
| 17 |
static const char *acp_acpi_name(const struct device *dev) |
| 18 |
{ |
| 19 |
return "ACPD"; |
| 20 |
} |
| 21 |
|
| 22 |
static void acp_fill_wov_method(const struct device *dev) |
| 23 |
{ |
| 24 |
const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 25 |
const char *scope = acpi_device_path(dev); |
| 26 |
|
| 27 |
if (!cfg->acp_config.dmic_present || !scope) |
| 28 |
return; |
| 29 |
|
| 30 |
|
| 31 |
acpigen_write_scope(scope); |
| 32 |
acpigen_write_method("_WOV", 0); |
| 33 |
acpigen_write_return_integer(1); |
| 34 |
acpigen_write_method_end(); |
| 35 |
acpigen_write_scope_end(); |
| 36 |
} |
| 37 |
|
| 38 |
static void acp_fill_ssdt(const struct device *dev) |
| 39 |
{ |
| 40 |
acpi_device_write_pci_dev(dev); |
| 41 |
acp_fill_wov_method(dev); |
| 42 |
if (CONFIG(SOC_AMD_COMMON_BLOCK_ACP_SOC_SPECIFIC_SSDT_ENTRY)) |
| 43 |
acp_soc_write_ssdt_entry(dev); |
| 44 |
} |
| 45 |
|
| 46 |
struct device_operations amd_acp_ops = { |
| 47 |
.read_resources = pci_dev_read_resources, |
| 48 |
.set_resources = pci_dev_set_resources, |
| 49 |
.enable_resources = pci_dev_enable_resources, |
| 50 |
.init = acp_init, |
| 51 |
.ops_pci = &pci_dev_ops_pci, |
| 52 |
.scan_bus = scan_static_bus, |
| 53 |
.acpi_name = acp_acpi_name, |
| 54 |
.acpi_fill_ssdt = acp_fill_ssdt, |
| 55 |
}; |