[PATCH 3/4] firmware: samsung: acpm: add TMU set_hysteresis op

From: André Draszik

Date: Tue Dec 01 2026 - 08:20:12 EST


The ACPM TMU protocol has no helper for the ACPM_TMU_HYSTERESIS (0x16)
command, so all eight threshold slots of a zone keep the firmware's
default hysteresis of 5 K.

When a zone is enabled, the firmware programs the falling comparator of
each slot to threshold - hysteresis. A client enabling a slot's
interrupt therefore always gets a falling interrupt 5 K below its
threshold and cannot adjust it.

Add acpm_tmu_set_hysteresis() and expose it through struct acpm_tmu_ops.

Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>
---
drivers/firmware/samsung/exynos-acpm-tmu.c | 29 +++++++++++++++++-----
drivers/firmware/samsung/exynos-acpm-tmu.h | 3 +++
drivers/firmware/samsung/exynos-acpm.c | 1 +
.../linux/firmware/samsung/exynos-acpm-protocol.h | 3 +++
4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/samsung/exynos-acpm-tmu.c b/drivers/firmware/samsung/exynos-acpm-tmu.c
index c68d60b4c0b3..c92ab9a00e2a 100644
--- a/drivers/firmware/samsung/exynos-acpm-tmu.c
+++ b/drivers/firmware/samsung/exynos-acpm-tmu.c
@@ -26,6 +26,7 @@
#define ACPM_TMU_INTEN 0x12
#define ACPM_TMU_CONTROL 0x13
#define ACPM_TMU_IRQ_CLEAR 0x14
+#define ACPM_TMU_HYSTERESIS 0x16

#define ACPM_TMU_TX_DATA_LEN 8
#define ACPM_TMU_RX_DATA_LEN 7
@@ -115,20 +116,20 @@ int acpm_tmu_read_temp(struct acpm_handle *handle, unsigned int acpm_chan_id,
return 0;
}

-int acpm_tmu_set_threshold(struct acpm_handle *handle,
- unsigned int acpm_chan_id, u8 tz,
- const u8 temperature[8], size_t tlen)
+static int acpm_tmu_set_data(struct acpm_handle *handle,
+ unsigned int acpm_chan_id, u8 type, u8 tz,
+ const u8 *data, size_t len)
{
union acpm_tmu_msg msg = {0};
struct acpm_xfer xfer;
int ret;

- if (tlen > ACPM_TMU_TX_DATA_LEN)
+ if (len > ACPM_TMU_TX_DATA_LEN)
return -EINVAL;

- msg.tx.type = ACPM_TMU_THRESHOLD;
+ msg.tx.type = type;
msg.tx.tzid = tz;
- memcpy(msg.tx.data, temperature, tlen);
+ memcpy(msg.tx.data, data, len);

acpm_set_xfer(&xfer, msg.data, ARRAY_SIZE(msg.data), acpm_chan_id,
true);
@@ -140,6 +141,22 @@ int acpm_tmu_set_threshold(struct acpm_handle *handle,
return acpm_tmu_to_linux_err(msg.rx.ret);
}

+int acpm_tmu_set_threshold(struct acpm_handle *handle,
+ unsigned int acpm_chan_id, u8 tz,
+ const u8 temperature[8], size_t tlen)
+{
+ return acpm_tmu_set_data(handle, acpm_chan_id, ACPM_TMU_THRESHOLD,
+ tz, temperature, tlen);
+}
+
+int acpm_tmu_set_hysteresis(struct acpm_handle *handle,
+ unsigned int acpm_chan_id, u8 tz,
+ const u8 hysteresis[8], size_t hlen)
+{
+ return acpm_tmu_set_data(handle, acpm_chan_id, ACPM_TMU_HYSTERESIS,
+ tz, hysteresis, hlen);
+}
+
int acpm_tmu_set_interrupt_enable(struct acpm_handle *handle,
unsigned int acpm_chan_id, u8 tz, u8 inten)
{
diff --git a/drivers/firmware/samsung/exynos-acpm-tmu.h b/drivers/firmware/samsung/exynos-acpm-tmu.h
index 8b89f29fda67..960bbc86afc8 100644
--- a/drivers/firmware/samsung/exynos-acpm-tmu.h
+++ b/drivers/firmware/samsung/exynos-acpm-tmu.h
@@ -17,6 +17,9 @@ int acpm_tmu_read_temp(struct acpm_handle *handle, unsigned int acpm_chan_id,
int acpm_tmu_set_threshold(struct acpm_handle *handle,
unsigned int acpm_chan_id, u8 tz,
const u8 temperature[8], size_t tlen);
+int acpm_tmu_set_hysteresis(struct acpm_handle *handle,
+ unsigned int acpm_chan_id, u8 tz,
+ const u8 hysteresis[8], size_t hlen);
int acpm_tmu_set_interrupt_enable(struct acpm_handle *handle,
unsigned int acpm_chan_id, u8 tz, u8 inten);
int acpm_tmu_tz_control(struct acpm_handle *handle, unsigned int acpm_chan_id,
diff --git a/drivers/firmware/samsung/exynos-acpm.c b/drivers/firmware/samsung/exynos-acpm.c
index a575caf871b9..2080f0267061 100644
--- a/drivers/firmware/samsung/exynos-acpm.c
+++ b/drivers/firmware/samsung/exynos-acpm.c
@@ -689,6 +689,7 @@ static const struct acpm_ops exynos_acpm_driver_ops = {
.init = acpm_tmu_init,
.read_temp = acpm_tmu_read_temp,
.set_threshold = acpm_tmu_set_threshold,
+ .set_hysteresis = acpm_tmu_set_hysteresis,
.set_interrupt_enable = acpm_tmu_set_interrupt_enable,
.tz_control = acpm_tmu_tz_control,
.clear_tz_irq = acpm_tmu_clear_tz_irq,
diff --git a/include/linux/firmware/samsung/exynos-acpm-protocol.h b/include/linux/firmware/samsung/exynos-acpm-protocol.h
index c6b35c0ff300..8d4d3f5a33a8 100644
--- a/include/linux/firmware/samsung/exynos-acpm-protocol.h
+++ b/include/linux/firmware/samsung/exynos-acpm-protocol.h
@@ -41,6 +41,9 @@ struct acpm_tmu_ops {
int (*set_threshold)(struct acpm_handle *handle,
unsigned int acpm_chan_id, u8 tz,
const u8 temperature[8], size_t tlen);
+ int (*set_hysteresis)(struct acpm_handle *handle,
+ unsigned int acpm_chan_id, u8 tz,
+ const u8 hysteresis[8], size_t hlen);
int (*set_interrupt_enable)(struct acpm_handle *handle,
unsigned int acpm_chan_id, u8 tz, u8 inten);
int (*tz_control)(struct acpm_handle *handle, unsigned int acpm_chan_id,

--
2.56.1.839.g22a8290db9-goog