[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250528235026.4171109-4-anjelique.melendez@oss.qualcomm.com>
Date: Wed, 28 May 2025 16:50:24 -0700
From: Anjelique Melendez <anjelique.melendez@....qualcomm.com>
To: amitk@...nel.org, thara.gopinath@...il.com, rafael@...nel.org,
daniel.lezcano@...aro.org
Cc: rui.zhang@...el.com, lukasz.luba@....com, david.collins@....qualcomm.com,
srinivas.kandagatla@...aro.org, stefan.schmidt@...aro.org,
quic_tsoni@...cinc.com, linux-arm-msm@...r.kernel.org,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
dmitry.baryshkov@...aro.org, dmitry.baryshkov@....qualcomm.com
Subject: [PATCH v4 3/5] thermal: qcom-spmi-temp-alarm: Prepare to support additional Temp Alarm subtypes
In preparation to support newer temp alarm subtypes, add the "ops" and
"configure_trip_temps" references to spmi_temp_alarm_data. This will
allow for each Temp Alarm subtype to define its own
thermal_zone_device_ops and properly configure thermal trip temperature.
Signed-off-by: Anjelique Melendez <anjelique.melendez@....qualcomm.com>
---
drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 36 +++++++++++++++------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
index 0d8bbc5b7af6..59a25f02a278 100644
--- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
+++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
@@ -71,8 +71,10 @@ static const long temp_map_gen2_v1[THRESH_COUNT][STAGE_COUNT] = {
struct qpnp_tm_chip;
struct spmi_temp_alarm_data {
+ const struct thermal_zone_device_ops *ops;
const long (*temp_map)[THRESH_COUNT][STAGE_COUNT];
int (*get_temp_stage)(struct qpnp_tm_chip *chip);
+ int (*configure_trip_temps)(struct qpnp_tm_chip *chip);
};
struct qpnp_tm_chip {
@@ -311,18 +313,39 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data)
return IRQ_HANDLED;
}
+static int qpnp_tm_configure_trip_temp(struct qpnp_tm_chip *chip)
+{
+ int crit_temp, ret;
+
+ ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp);
+ if (ret)
+ crit_temp = THERMAL_TEMP_INVALID;
+
+ mutex_lock(&chip->lock);
+ ret = qpnp_tm_update_critical_trip_temp(chip, crit_temp);
+ mutex_unlock(&chip->lock);
+
+ return ret;
+}
+
static const struct spmi_temp_alarm_data spmi_temp_alarm_data = {
+ .ops = &qpnp_tm_sensor_ops,
.temp_map = &temp_map_gen1,
+ .configure_trip_temps = qpnp_tm_configure_trip_temp,
.get_temp_stage = qpnp_tm_gen1_get_temp_stage,
};
static const struct spmi_temp_alarm_data spmi_temp_alarm_gen2_data = {
+ .ops = &qpnp_tm_sensor_ops,
.temp_map = &temp_map_gen1,
+ .configure_trip_temps = qpnp_tm_configure_trip_temp,
.get_temp_stage = qpnp_tm_gen2_get_temp_stage,
};
static const struct spmi_temp_alarm_data spmi_temp_alarm_gen2_rev1_data = {
+ .ops = &qpnp_tm_sensor_ops,
.temp_map = &temp_map_gen2_v1,
+ .configure_trip_temps = qpnp_tm_configure_trip_temp,
.get_temp_stage = qpnp_tm_gen2_get_temp_stage,
};
@@ -335,7 +358,6 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip)
{
int ret;
u8 reg = 0;
- int crit_temp;
mutex_lock(&chip->lock);
@@ -356,16 +378,12 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip)
mutex_unlock(&chip->lock);
- ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp);
- if (ret)
- crit_temp = THERMAL_TEMP_INVALID;
+ ret = chip->data->configure_trip_temps(chip);
+ if (ret < 0)
+ return ret;
mutex_lock(&chip->lock);
- ret = qpnp_tm_update_critical_trip_temp(chip, crit_temp);
- if (ret < 0)
- goto out;
-
/* Enable the thermal alarm PMIC module in always-on mode. */
reg = ALARM_CTRL_FORCE_ENABLE;
ret = qpnp_tm_write(chip, QPNP_TM_REG_ALARM_CTRL, reg);
@@ -479,7 +497,7 @@ static int qpnp_tm_probe(struct platform_device *pdev)
* before the hardware initialization is completed.
*/
chip->tz_dev = devm_thermal_of_zone_register(
- &pdev->dev, 0, chip, &qpnp_tm_sensor_ops);
+ &pdev->dev, 0, chip, chip->data->ops);
if (IS_ERR(chip->tz_dev))
return dev_err_probe(&pdev->dev, PTR_ERR(chip->tz_dev),
"failed to register sensor\n");
--
2.34.1
Powered by blists - more mailing lists