blob: cf0e9f8fe29d29157b42673bfce59b7c65bf35bb [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marshall Dawson3edc9e22019-08-16 08:45:20 -06002
Furquan Shaikh583ba8b2020-06-30 23:51:24 -07003#include <acpi/acpi_device.h>
4#include <acpi/acpigen.h>
Karthikeyan Ramasubramanian4520aa22021-04-23 11:42:19 -06005#include <amdblocks/acp.h>
6#include <amdblocks/acpimmio.h>
7#include <amdblocks/chip.h>
Marshall Dawson3edc9e22019-08-16 08:45:20 -06008#include <device/device.h>
9#include <device/pci.h>
10#include <device/pci_ids.h>
11#include <device/pci_ops.h>
Marshall Dawson3edc9e22019-08-16 08:45:20 -060012#include <commonlib/helpers.h>
Fred Reitberger6f0b5b32022-02-08 11:55:48 -050013#include "acp_def.h"
Marshall Dawson3edc9e22019-08-16 08:45:20 -060014
Fred Reitberger0fcf8352022-02-10 11:00:46 -050015_Static_assert(!(CONFIG(SOC_AMD_COMMON_BLOCK_ACP_GEN1) && CONFIG(SOC_AMD_COMMON_BLOCK_ACP_GEN2)),
16 "Cannot select both ACP_GEN1 and ACP_GEN2 - check your config");
Marshall Dawson3edc9e22019-08-16 08:45:20 -060017
Furquan Shaikh0d787a12020-06-18 22:20:52 -070018static const char *acp_acpi_name(const struct device *dev)
19{
20 return "ACPD";
21}
22
Karthikeyan Ramasubramanian4ce48b32021-05-27 16:25:28 -060023static void acp_fill_wov_method(const struct device *dev)
24{
25 const struct soc_amd_common_config *cfg = soc_get_common_config();
26 const char *scope = acpi_device_path(dev);
27
28 if (!cfg->acp_config.dmic_present || !scope)
29 return;
30
31 /* For ACP DMIC hardware runtime detection on the platform, _WOV method is populated. */
32 acpigen_write_scope(scope); /* Scope */
33 acpigen_write_method("_WOV", 0);
34 acpigen_write_return_integer(1);
35 acpigen_write_method_end();
36 acpigen_write_scope_end();
37}
38
39static void acp_fill_ssdt(const struct device *dev)
40{
41 acpi_device_write_pci_dev(dev);
42 acp_fill_wov_method(dev);
43}
44
Marshall Dawson3edc9e22019-08-16 08:45:20 -060045static struct device_operations acp_ops = {
46 .read_resources = pci_dev_read_resources,
47 .set_resources = pci_dev_set_resources,
Aaron Durbina6e3b5a2020-06-09 07:56:43 -060048 .enable_resources = pci_dev_enable_resources,
Fred Reitberger6f0b5b32022-02-08 11:55:48 -050049 .init = acp_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020050 .ops_pci = &pci_dev_ops_pci,
Furquan Shaikhde4baff2020-07-16 13:26:44 -070051 .scan_bus = scan_static_bus,
Furquan Shaikh0d787a12020-06-18 22:20:52 -070052 .acpi_name = acp_acpi_name,
Karthikeyan Ramasubramanian4ce48b32021-05-27 16:25:28 -060053 .acpi_fill_ssdt = acp_fill_ssdt,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060054};
55
56static const struct pci_driver acp_driver __pci_driver = {
57 .ops = &acp_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010058 .vendor = PCI_VID_AMD,
59 .device = PCI_DID_AMD_FAM17H_ACP,
Marshall Dawson3edc9e22019-08-16 08:45:20 -060060};