From: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
To: <jikos@kernel.org>, <bentiss@kernel.org>
Cc: <linux-input@vger.kernel.org>,
Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Subject: [PATCH 4/4] HID: amd_sfh: Add device mode support for latest AMD SOC.
Date: Wed, 2 Sep 2026 19:14:31 +0530 [thread overview]
Message-ID: <20260902134431.3146117-5-Basavaraj.Natikar@amd.com> (raw)
In-Reply-To: <20260902134431.3146117-1-Basavaraj.Natikar@amd.com>
Use device mode data from DRAM instead of reading from the C2P
register in latest AMD SOC.
Co-developed-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Guruvendra Punugupati <Guruvendra.Punugupati@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
.../amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 23 +++++++++++++++++--
.../amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
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 034ec237659a..bc0adb789896 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
@@ -98,6 +98,25 @@ void sfh_interface_init(struct amd_mp2_dev *mp2)
emp2 = mp2;
}
+static unsigned int amd_sfh_read_c2p3(struct amd_mp2_dev *mp2)
+{
+ struct sfh_accel_data accel_data;
+ void __iomem *sensoraddr;
+ u32 val;
+
+ if (mp2->mp2_ver >= MP2_VER_1_2) {
+ sensoraddr = mp2->vsbase +
+ (SRA_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) +
+ OFFSET_SENSOR_DATA_DEFAULT;
+ memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data));
+ val = accel_data.c2p3_data;
+ } else {
+ val = readl(mp2->mmio + amd_get_c2p_val(mp2, 3));
+ }
+
+ return val;
+}
+
static int amd_sfh_op_mode_info(u32 *op_mode)
{
struct sfh_op_mode mode;
@@ -114,7 +133,7 @@ static int amd_sfh_op_mode_info(u32 *op_mode)
if (!present)
return -ENODEV;
- mode.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 3));
+ mode.val = amd_sfh_read_c2p3(emp2);
dev_dbg(&emp2->pdev->dev, "op-mode: %s (mode=%u)\n",
mode.op_mode.mode == SFH_MODE_TABLET ? "tablet" : "laptop",
mode.op_mode.mode);
@@ -133,7 +152,7 @@ static int amd_sfh_mode_info(u32 *platform_type, u32 *laptop_placement)
if (!emp2 || !emp2->dev_en.is_sra_present)
return -ENODEV;
- mode.val = readl(emp2->mmio + amd_get_c2p_val(emp2, 3));
+ mode.val = amd_sfh_read_c2p3(emp2);
*platform_type = mode.op_mode.devicemode;
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 11c7a86ac52e..eaa90c689049 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
@@ -130,6 +130,7 @@ struct sfh_accel_data {
struct sfh_common_data commondata;
struct sfh_float32 acceldata;
u32 accelstatus;
+ u32 c2p3_data;
};
struct sfh_gyro_data {
--
2.34.1
next prev parent reply other threads:[~2026-09-02 13:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 13:44 [PATCH 0/4] HID: amd_sfh: Add DMI quirk and support for new AMD SoCs Basavaraj Natikar
2026-09-02 13:44 ` [PATCH 1/4] HID: amd_sfh: Add DMI quirk and module param to disable interrupts Basavaraj Natikar
2026-09-02 13:54 ` sashiko-bot
2026-09-02 13:44 ` [PATCH 2/4] HID: amd_sfh: Add support for newer AMD SoCs Basavaraj Natikar
2026-09-02 13:44 ` [PATCH 3/4] HID: amd_sfh: Add HPD support for new AMD SOC Basavaraj Natikar
2026-09-02 14:02 ` sashiko-bot
2026-09-02 13:44 ` Basavaraj Natikar [this message]
2026-09-02 13:59 ` [PATCH 4/4] HID: amd_sfh: Add device mode support for latest " sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902134431.3146117-5-Basavaraj.Natikar@amd.com \
--to=basavaraj.natikar@amd.com \
--cc=Guruvendra.Punugupati@amd.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox