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 | |
Fred Reitberger | 0fcf835 | 2022-02-10 11:00:46 -0500 | [diff] [blame^] | 15 | _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 Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 17 | |
Furquan Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame] | 18 | static const char *acp_acpi_name(const struct device *dev) |
| 19 | { |
| 20 | return "ACPD"; |
| 21 | } |
| 22 | |
Karthikeyan Ramasubramanian | 4ce48b3 | 2021-05-27 16:25:28 -0600 | [diff] [blame] | 23 | static 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 | |
| 39 | static 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 Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 45 | static struct device_operations acp_ops = { |
| 46 | .read_resources = pci_dev_read_resources, |
| 47 | .set_resources = pci_dev_set_resources, |
Aaron Durbin | a6e3b5a | 2020-06-09 07:56:43 -0600 | [diff] [blame] | 48 | .enable_resources = pci_dev_enable_resources, |
Fred Reitberger | 6f0b5b3 | 2022-02-08 11:55:48 -0500 | [diff] [blame] | 49 | .init = acp_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 50 | .ops_pci = &pci_dev_ops_pci, |
Furquan Shaikh | de4baff | 2020-07-16 13:26:44 -0700 | [diff] [blame] | 51 | .scan_bus = scan_static_bus, |
Furquan Shaikh | 0d787a1 | 2020-06-18 22:20:52 -0700 | [diff] [blame] | 52 | .acpi_name = acp_acpi_name, |
Karthikeyan Ramasubramanian | 4ce48b3 | 2021-05-27 16:25:28 -0600 | [diff] [blame] | 53 | .acpi_fill_ssdt = acp_fill_ssdt, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static const struct pci_driver acp_driver __pci_driver = { |
| 57 | .ops = &acp_ops, |
| 58 | .vendor = PCI_VENDOR_ID_AMD, |
Furquan Shaikh | a1cd7eb | 2020-04-15 23:58:22 -0700 | [diff] [blame] | 59 | .device = PCI_DEVICE_ID_AMD_FAM17H_ACP, |
Marshall Dawson | 3edc9e2 | 2019-08-16 08:45:20 -0600 | [diff] [blame] | 60 | }; |