From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 27 Sep 2022 12:57:38 +0000 (+0200)
Subject: Merge branch 'platform-drivers-x86-amd-pmf' into review-hans
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a283781baa0c38a8e9c7b26780e3ee7a91a4f186;p=linux.git

Merge branch 'platform-drivers-x86-amd-pmf' into review-hans
---

a283781baa0c38a8e9c7b26780e3ee7a91a4f186
diff --cc drivers/platform/x86/amd/pmf/acpi.c
index 05a2b8a056fcc,b445c91aa52e5..081e84e116e79
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@@ -233,16 -233,28 +233,38 @@@ static int apmf_get_system_params(struc
  	return 0;
  }
  
 +int apmf_get_dyn_slider_def_ac(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
 +{
 +	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_AC, data, sizeof(*data));
 +}
 +
 +int apmf_get_dyn_slider_def_dc(struct amd_pmf_dev *pdev, struct apmf_dyn_slider_output *data)
 +{
 +	return apmf_if_call_store_buffer(pdev, APMF_FUNC_DYN_SLIDER_DC, data, sizeof(*data));
 +}
 +
+ int apmf_install_handler(struct amd_pmf_dev *pmf_dev)
+ {
+ 	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
+ 	acpi_status status;
+ 
+ 	/* Install the APMF Notify handler */
+ 	if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) &&
+ 	    is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) {
+ 		status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
+ 						     apmf_event_handler, pmf_dev);
+ 		if (ACPI_FAILURE(status)) {
+ 			dev_err(pmf_dev->dev, "failed to install notify handler\n");
+ 			return -ENODEV;
+ 		}
+ 
+ 		/* Call the handler once manually to catch up with possibly missed notifies. */
+ 		apmf_event_handler(ahandle, 0, pmf_dev);
+ 	}
+ 
+ 	return 0;
+ }
+ 
  void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
  {
  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);