Skip to content

Commit 118063f

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Get Human presence information from AMD SFH driver
AMD SFH driver has APIs defined to export the human presence information; use this within the PMF driver to send inputs to the PMF TA, so that PMF driver can enact to the actions coming from the TA. Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20240123141458.3715211-1-Shyam-sundar.S-k@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 732c35c commit 118063f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

drivers/platform/x86/amd/pmf/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config AMD_PMF
1010
depends on AMD_NB
1111
select ACPI_PLATFORM_PROFILE
1212
depends on TEE && AMDTEE
13+
depends on AMD_SFH_HID
1314
help
1415
This driver provides support for the AMD Platform Management Framework.
1516
The goal is to enhance end user experience by making AMD PCs smarter,

drivers/platform/x86/amd/pmf/spc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <acpi/button.h>
13+
#include <linux/amd-pmf-io.h>
1314
#include <linux/power_supply.h>
1415
#include <linux/units.h>
1516
#include "pmf.h"
@@ -44,6 +45,7 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
4445
dev_dbg(dev->dev, "Max C0 Residency: %u\n", in->ev_info.max_c0residency);
4546
dev_dbg(dev->dev, "GFX Busy: %u\n", in->ev_info.gfx_busy);
4647
dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open");
48+
dev_dbg(dev->dev, "User Presence: %s\n", in->ev_info.user_present ? "Present" : "Away");
4749
dev_dbg(dev->dev, "==== TA inputs END ====\n");
4850
}
4951
#else
@@ -147,6 +149,31 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
147149
return 0;
148150
}
149151

152+
static int amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
153+
{
154+
struct amd_sfh_info sfh_info;
155+
int ret;
156+
157+
/* get HPD data */
158+
ret = amd_get_sfh_info(&sfh_info, MT_HPD);
159+
if (ret)
160+
return ret;
161+
162+
switch (sfh_info.user_present) {
163+
case SFH_NOT_DETECTED:
164+
in->ev_info.user_present = 0xff; /* assume no sensors connected */
165+
break;
166+
case SFH_USER_PRESENT:
167+
in->ev_info.user_present = 1;
168+
break;
169+
case SFH_USER_AWAY:
170+
in->ev_info.user_present = 0;
171+
break;
172+
}
173+
174+
return 0;
175+
}
176+
150177
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
151178
{
152179
/* TA side lid open is 1 and close is 0, hence the ! here */
@@ -155,4 +182,5 @@ void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_tab
155182
amd_pmf_get_smu_info(dev, in);
156183
amd_pmf_get_battery_info(dev, in);
157184
amd_pmf_get_slider_info(dev, in);
185+
amd_pmf_get_sensor_info(dev, in);
158186
}

0 commit comments

Comments
 (0)