Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 2 | |
Furquan Shaikh | 583ba8b | 2020-06-30 23:51:24 -0700 | [diff] [blame] | 3 | #include <acpi/acpi_device.h> |
| 4 | #include <acpi/acpigen.h> |
Karthikeyan Ramasubramanian | 4520aa2 | 2021-04-23 11:42:19 -0600 | [diff] [blame] | 5 | #include <amdblocks/acp.h> |
| 6 | #include <amdblocks/acpimmio.h> |
| 7 | #include <amdblocks/chip.h> |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
| 10 | #include <device/pci_ids.h> |
| 11 | #include <device/pci_ops.h> |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 12 | #include <commonlib/helpers.h> |
Fred Reitberger | 6f0b5b3 | 2022-02-08 11:55:48 -0500 | [diff] [blame] | 13 | #include "acp_def.h" |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 14 | |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 15 | |
Furquan Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame] | 16 | static const char *acp_acpi_name(const struct device *dev) |
| 17 | { |
| 18 | return "ACPD"; |
| 19 | } |
| 20 | |
Karthikeyan Ramasubramanian | 4ce48b3 | 2021-05-27 16:25:28 -0600 | [diff] [blame] | 21 | static void acp_fill_wov_method(const struct device *dev) |
| 22 | { |
| 23 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 24 | const char *scope = acpi_device_path(dev); |
| 25 | |
| 26 | if (!cfg->acp_config.dmic_present || !scope) |
| 27 | return; |
| 28 | |
| 29 | /* For ACP DMIC hardware runtime detection on the platform, _WOV method is populated. */ |
| 30 | acpigen_write_scope(scope); /* Scope */ |
| 31 | acpigen_write_method("_WOV", 0); |
| 32 | acpigen_write_return_integer(1); |
| 33 | acpigen_write_method_end(); |
| 34 | acpigen_write_scope_end(); |
| 35 | } |
| 36 | |
| 37 | static void acp_fill_ssdt(const struct device *dev) |
| 38 | { |
| 39 | acpi_device_write_pci_dev(dev); |
| 40 | acp_fill_wov_method(dev); |
| 41 | } |
| 42 | |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 43 | static struct device_operations acp_ops = { |
| 44 | .read_resources = pci_dev_read_resources, |
| 45 | .set_resources = pci_dev_set_resources, |
Aaron Durbin | a6e3b5a | 2020-06-09 07:56:43 -0600 | [diff] [blame] | 46 | .enable_resources = pci_dev_enable_resources, |
Fred Reitberger | 6f0b5b3 | 2022-02-08 11:55:48 -0500 | [diff] [blame] | 47 | .init = acp_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 48 | .ops_pci = &pci_dev_ops_pci, |
Furquan Shaikh | de4baff | 2020-07-16 13:26:44 -0700 | [diff] [blame] | 49 | .scan_bus = scan_static_bus, |
Furquan Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame] | 50 | .acpi_name = acp_acpi_name, |
Karthikeyan Ramasubramanian | 4ce48b3 | 2021-05-27 16:25:28 -0600 | [diff] [blame] | 51 | .acpi_fill_ssdt = acp_fill_ssdt, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | static const struct pci_driver acp_driver __pci_driver = { |
| 55 | .ops = &acp_ops, |
| 56 | .vendor = PCI_VENDOR_ID_AMD, |
Furquan Shaikh | a1cd7eb | 2020-04-15 23:58:22 -0700 | [diff] [blame] | 57 | .device = PCI_DEVICE_ID_AMD_FAM17H_ACP, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 58 | }; |