[Unstable][PATCH 3/4] UBUNTU: SAUCE: HID: amd_sfh: Add HPD support for new AMD SOC
You-Sheng Yang
vicamo.yang at canonical.com
Mon Sep 14 09:20:53 UTC 2026
From: Basavaraj Natikar <Basavaraj.Natikar at amd.com>
BugLink: https://bugs.launchpad.net/bugs/2167219
Use HPD data from DRAM instead of reading from the C2P4 register
path in latest AMD SOC.
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati at amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati at amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar at amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1 at kernel.org>
Signed-off-by: Jiri Kosina <jkosina at suse.com>
(cherry picked from commit https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/commit/?id=6d7898e93937d2cb54fd0564a10f8da1cdcf6e5e)
Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>
---
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 13 +++++++++++--
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 14 ++++++++++++--
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 6 ++++++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
index c8916afefa626..b81a97dbb1b01 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
@@ -187,6 +187,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
struct sfh_gyro_data gyro_data;
struct sfh_mag_data mag_data;
struct sfh_als_data als_data;
+ struct sfh_hpd_data hpd_data;
struct hpd_status hpdstatus;
struct sfh_base_info binfo;
void __iomem *sensoraddr;
@@ -251,8 +252,16 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
break;
case HPD_IDX:
get_common_inputs(&hpd_input.common_property, report_id);
- hpdstatus.val = readl(mp2->mmio + amd_get_c2p_val(mp2, 4));
- hpd_input.human_presence = hpdstatus.shpd.presence;
+ if (mp2->mp2_ver >= MP2_VER_1_2) {
+ sensoraddr = mp2->vsbase +
+ (HPD_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) +
+ OFFSET_SENSOR_DATA_DEFAULT;
+ memcpy_fromio(&hpd_data, sensoraddr, sizeof(struct sfh_hpd_data));
+ hpd_input.human_presence = hpd_data.status.shpd.presence;
+ } else {
+ hpdstatus.val = readl(mp2->mmio + amd_get_c2p_val(mp2, 4));
+ hpd_input.human_presence = hpdstatus.shpd.presence;
+ }
report_size = sizeof(hpd_input);
memcpy(input_report, &hpd_input, sizeof(hpd_input));
break;
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
index 60c185a9cd501..034ec237659a8 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
@@ -160,7 +160,9 @@ static int amd_sfh_mode_info(u32 *platform_type, u32 *laptop_placement)
static int amd_sfh_hpd_info(u8 *user_present)
{
+ struct sfh_hpd_data hpd_data;
struct hpd_status hpdstatus;
+ void __iomem *sensoraddr;
if (!user_present)
return -EINVAL;
@@ -168,8 +170,16 @@ static int amd_sfh_hpd_info(u8 *user_present)
if (!emp2 || !emp2->dev_en.is_hpd_present || !emp2->dev_en.is_hpd_enabled)
return -ENODEV;
- hpdstatus.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 4));
- *user_present = hpdstatus.shpd.presence;
+ if (emp2->mp2_ver >= MP2_VER_1_2) {
+ sensoraddr = emp2->vsbase +
+ (HPD_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) +
+ OFFSET_SENSOR_DATA_DEFAULT;
+ memcpy_fromio(&hpd_data, sensoraddr, sizeof(struct sfh_hpd_data));
+ *user_present = hpd_data.status.shpd.presence;
+ } else {
+ hpdstatus.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 4));
+ *user_present = hpdstatus.shpd.presence;
+ }
return 0;
}
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
index 56258c4d1b3ad..11c7a86ac52ed 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
@@ -165,6 +165,12 @@ struct hpd_status {
};
};
+struct sfh_hpd_data {
+ struct sfh_common_data commondata;
+ u32 reserved;
+ struct hpd_status status;
+};
+
struct sfh_op_mode {
union {
u32 val;
--
2.55.0
More information about the kernel-team
mailing list