From: Frank Wunderlich <linux@fw-web.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: "Frank Wunderlich" <frank-w@public-files.de>,
"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
"Mason Chang" <mason-cw.chang@mediatek.com>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Balsam CHIHI" <bchihi@baylibre.com>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH v1 3/5] thermal/drivers/mediatek/lvts_thermal: Add no-irq-mode for mt7987
Date: Sun, 26 Oct 2025 13:21:32 +0100 [thread overview]
Message-ID: <20251026122143.71100-4-linux@fw-web.de> (raw)
In-Reply-To: <20251026122143.71100-1-linux@fw-web.de>
From: Frank Wunderlich <frank-w@public-files.de>
Upcoming MT7987 does not have IRQ for thermal. Add a field in lvts_data
to configure this based on SoC.
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
drivers/thermal/mediatek/lvts_thermal.c | 51 ++++++++++++++++++++-----
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index ab55b20cda47..9413b30f7b69 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -94,6 +94,8 @@
#define LVTS_MSR_READ_TIMEOUT_US 400
#define LVTS_MSR_READ_WAIT_US (LVTS_MSR_READ_TIMEOUT_US / 2)
+#define LVTS_HW_RESET_TEMP 125000
+
#define LVTS_MINIMUM_THRESHOLD 20000
static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
@@ -134,6 +136,7 @@ struct lvts_data {
int temp_offset;
int gt_calib_bit_offset;
unsigned int def_calibration;
+ bool irq_enable;
};
struct lvts_sensor {
@@ -151,6 +154,7 @@ struct lvts_ctrl {
const struct lvts_data *lvts_data;
u32 calibration[LVTS_SENSOR_MAX];
u8 valid_sensor_mask;
+ u32 hw_reset_raw_temp;
int mode;
void __iomem *base;
int low_thresh;
@@ -410,6 +414,9 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
}
lvts_update_irq_mask(lvts_ctrl);
+ if (!lvts_data->irq_enable)
+ return 0;
+
if (!should_update_thresh)
return 0;
@@ -859,6 +866,14 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
*/
lvts_ctrl[i].mode = lvts_data->lvts_ctrl[i].mode;
+ /*
+ * The temperature to raw temperature must be done
+ * after initializing the calibration.
+ */
+ lvts_ctrl[i].hw_reset_raw_temp =
+ lvts_temp_to_raw(LVTS_HW_RESET_TEMP,
+ lvts_data->temp_factor);
+
lvts_ctrl[i].low_thresh = INT_MIN;
lvts_ctrl[i].high_thresh = INT_MIN;
}
@@ -915,12 +930,13 @@ static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, const u32 *cmds, int
*/
for (i = 0; i < nr_cmds; i++) {
writel(cmds[i], LVTS_CONFIG(lvts_ctrl->base));
- usleep_range(2, 4);
+ usleep_range(5, 15);
}
}
static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)
{
+ const struct lvts_data *lvts_data = lvts_ctrl->lvts_data;
/*
* LVTS_PROTCTL : Thermal Protection Sensor Selection
*
@@ -954,8 +970,12 @@ static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)
* The LVTS_MONINT register layout is the same as the LVTS_MONINTSTS
* register, except we set the bits to enable the interrupt.
*/
- writel(0, LVTS_MONINT(lvts_ctrl->base));
-
+ if (lvts_data->irq_enable) {
+ writel(0, LVTS_MONINT(lvts_ctrl->base));
+ } else {
+ writel(BIT(16), LVTS_PROTCTL(lvts_ctrl->base));
+ writel(lvts_ctrl->hw_reset_raw_temp, LVTS_PROTTC(lvts_ctrl->base));
+ }
return 0;
}
@@ -1338,9 +1358,11 @@ static int lvts_probe(struct platform_device *pdev)
if (IS_ERR(lvts_td->reset))
return dev_err_probe(dev, PTR_ERR(lvts_td->reset), "Failed to get reset control\n");
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (lvts_data->irq_enable) {
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+ }
golden_temp_offset = lvts_data->temp_offset;
@@ -1352,10 +1374,12 @@ static int lvts_probe(struct platform_device *pdev)
* At this point the LVTS is initialized and enabled. We can
* safely enable the interrupt.
*/
- ret = devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler,
- IRQF_ONESHOT, dev_name(dev), lvts_td);
- if (ret)
- return dev_err_probe(dev, ret, "Failed to request interrupt\n");
+ if (lvts_data->irq_enable) {
+ ret = devm_request_threaded_irq(dev, irq, NULL, lvts_irq_handler,
+ IRQF_ONESHOT, dev_name(dev), lvts_td);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to request interrupt\n");
+ }
platform_set_drvdata(pdev, lvts_td);
@@ -1763,6 +1787,7 @@ static const struct lvts_data mt7988_lvts_ap_data = {
.temp_factor = LVTS_COEFF_A_MT7988,
.temp_offset = LVTS_COEFF_B_MT7988,
.gt_calib_bit_offset = 24,
+ .irq_enable = true, //SDK false
};
static const struct lvts_data mt8186_lvts_data = {
@@ -1776,6 +1801,7 @@ static const struct lvts_data mt8186_lvts_data = {
.temp_offset = LVTS_COEFF_B_MT7988,
.gt_calib_bit_offset = 24,
.def_calibration = 19000,
+ .irq_enable = true,
};
static const struct lvts_data mt8188_lvts_mcu_data = {
@@ -1789,6 +1815,7 @@ static const struct lvts_data mt8188_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
+ .irq_enable = true,
};
static const struct lvts_data mt8188_lvts_ap_data = {
@@ -1802,6 +1829,7 @@ static const struct lvts_data mt8188_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
+ .irq_enable = true,
};
static const struct lvts_data mt8192_lvts_mcu_data = {
@@ -1815,6 +1843,7 @@ static const struct lvts_data mt8192_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .irq_enable = true,
};
static const struct lvts_data mt8192_lvts_ap_data = {
@@ -1828,6 +1857,7 @@ static const struct lvts_data mt8192_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .irq_enable = true,
};
static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1841,6 +1871,7 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .irq_enable = true,
};
static const struct lvts_data mt8195_lvts_ap_data = {
--
2.43.0
next prev parent reply other threads:[~2025-10-26 12:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 12:21 [PATCH v1 0/5] Add MT7987 Thermal support Frank Wunderlich
2025-10-26 12:21 ` [PATCH v1 1/5] dt-bindings: thermal: mediatek: make interrupt only required for current SoCs Frank Wunderlich
2025-10-27 10:43 ` AngeloGioacchino Del Regno
2025-10-26 12:21 ` [PATCH v1 2/5] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT7987 Frank Wunderlich
2025-10-27 19:25 ` Rob Herring (Arm)
2025-10-26 12:21 ` Frank Wunderlich [this message]
2025-10-26 12:21 ` [PATCH v1 4/5] thermal/drivers/mediatek/lvts_thermal: Add SoC based golden Temp Frank Wunderlich
2025-10-27 10:45 ` AngeloGioacchino Del Regno
2025-10-27 11:56 ` Aw: " Frank Wunderlich
2025-10-26 12:21 ` [PATCH v1 5/5] thermal/drivers/mediatek/lvts_thermal: Add mt7987 support Frank Wunderlich
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=20251026122143.71100-4-linux@fw-web.de \
--to=linux@fw-web.de \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bchihi@baylibre.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=frank-w@public-files.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mason-cw.chang@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=nfraprado@collabora.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=u.kleine-koenig@baylibre.com \
/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;
as well as URLs for NNTP newsgroup(s).