summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/amd
diff options
context:
space:
mode:
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>2022-08-02 20:41:44 +0530
committerHans de Goede <hdegoede@redhat.com>2022-08-15 13:23:38 +0200
commita3281ec556071bda86964b6cf3ed42ec9f924cd8 (patch)
tree8e616fcd3e42052c1331183b715cadfdea2ba6d6 /drivers/platform/x86/amd
parentb9ab888b4eccfd9b90835d6d95459aec7382564d (diff)
platform/x86/amd/pmf: Add fan control support
PMF has a generic interface defined via PMF ACPI fn9 for influencing fan policy during mode switch. PMF ACPI fn9 will normally be invoked when AMDPMF needs to change the fan table index for the EC. When AMDPMF is loaded this function will be invoked to change fan speed. OEM can also choose to report the actual fan table index and fan RPM to PMF through OEM structure. This information will be communicated by PMF driver to customer BIOS. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Link: https://lore.kernel.org/r/20220802151149.2123699-7-Shyam-sundar.S-k@amd.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/amd')
-rw-r--r--drivers/platform/x86/amd/pmf/acpi.c25
-rw-r--r--drivers/platform/x86/amd/pmf/pmf.h16
2 files changed, 41 insertions, 0 deletions
diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
index 6af0e23257ea..1fc4d1400364 100644
--- a/drivers/platform/x86/amd/pmf/acpi.c
+++ b/drivers/platform/x86/amd/pmf/acpi.c
@@ -119,6 +119,31 @@ out:
kfree(info);
}
+int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx)
+{
+ union acpi_object *info;
+ struct apmf_fan_idx args;
+ struct acpi_buffer params;
+ int err = 0;
+
+ args.size = sizeof(args);
+ args.fan_ctl_mode = manual;
+ args.fan_ctl_idx = idx;
+
+ params.length = sizeof(args);
+ params.pointer = (void *)&args;
+
+ info = apmf_if_call(pdev, APMF_FUNC_SET_FAN_IDX, &params);
+ if (!info) {
+ err = -EIO;
+ goto out;
+ }
+
+out:
+ kfree(info);
+ return err;
+}
+
static int apmf_if_verify_interface(struct amd_pmf_dev *pdev)
{
struct apmf_verify_interface output;
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index e3a21e4e1c9b..3c64903d67d3 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -18,6 +18,7 @@
#define APMF_FUNC_VERIFY_INTERFACE 0
#define APMF_FUNC_GET_SYS_PARAMS 1
#define APMF_FUNC_SBIOS_HEARTBEAT 4
+#define APMF_FUNC_SET_FAN_IDX 7
#define APMF_FUNC_STATIC_SLIDER_GRANULAR 9
/* Message Definitions */
@@ -39,6 +40,9 @@
#define GET_STT_LIMIT_APU 0x20
#define GET_STT_LIMIT_HS2 0x21
+/* Fan Index for Auto Mode */
+#define FAN_INDEX_AUTO 0xFFFFFFFF
+
#define ARG_NONE 0
/* AMD PMF BIOS interfaces */
@@ -57,6 +61,12 @@ struct apmf_system_params {
u32 heartbeat_int;
} __packed;
+struct apmf_fan_idx {
+ u16 size;
+ u8 fan_ctl_mode;
+ u32 fan_ctl_idx;
+} __packed;
+
enum amd_stt_skin_temp {
STT_TEMP_APU,
STT_TEMP_HS2,
@@ -118,6 +128,11 @@ struct amd_pmf_static_slider_granular {
struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX][POWER_MODE_MAX];
};
+struct fan_table_control {
+ bool manual;
+ unsigned long fan_id;
+};
+
/* Core Layer */
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
@@ -135,4 +150,5 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
struct apmf_static_slider_granular_output *output);
+int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
#endif /* PMF_H */