From: Chad Monroe <chad@monroe.io>
Date: Mon, 01 Sep 2025 06:42:10 -0700
Subject: [PATCH] thermal/drivers/mediatek/lvts_thermal: Add irq_enable
 support.

Allow interrupt support to be disabled as some SoCs don't support it.

Signed-off-by: Chad Monroe <chad@monroe.io>
---
 drivers/thermal/mediatek/lvts_thermal.c |   33 ++++++++++++++++------
 1 file changed, 25 insertions(+), 8 deletions(-)

--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -127,6 +127,7 @@ struct lvts_data {
 	const struct lvts_ctrl_data *lvts_ctrl;
 	const u32 *conn_cmd;
 	const u32 *init_cmd;
+	bool irq_enable;
 	int num_lvts_ctrl;
 	int num_conn_cmd;
 	int num_init_cmd;
@@ -408,6 +409,10 @@ static int lvts_set_trips(struct thermal
 		lvts_ctrl->high_thresh = high;
 		lvts_ctrl->low_thresh = low;
 	}
+
+	if (!lvts_data->irq_enable)
+		return 0;
+
 	lvts_update_irq_mask(lvts_ctrl);
 
 	if (!should_update_thresh)
@@ -921,6 +926,8 @@ static void lvts_write_config(struct lvt
 
 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,7 +961,8 @@ static int lvts_irq_init(struct lvts_ctr
 	 * 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));
 
 	return 0;
 }
@@ -1338,9 +1346,11 @@ static int lvts_probe(struct platform_de
 	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 +1362,12 @@ static int lvts_probe(struct platform_de
 	 * 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);
 
@@ -1754,6 +1766,7 @@ static const struct lvts_ctrl_data mt819
 };
 
 static const struct lvts_data mt7988_lvts_ap_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt7988_lvts_ap_data_ctrl,
 	.conn_cmd	= mt7988_conn_cmds,
 	.init_cmd	= mt7988_init_cmds,
@@ -1766,6 +1779,7 @@ static const struct lvts_data mt7988_lvt
 };
 
 static const struct lvts_data mt8186_lvts_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8186_lvts_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1779,6 +1793,7 @@ static const struct lvts_data mt8186_lvt
 };
 
 static const struct lvts_data mt8188_lvts_mcu_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8188_lvts_mcu_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1792,6 +1807,7 @@ static const struct lvts_data mt8188_lvt
 };
 
 static const struct lvts_data mt8188_lvts_ap_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8188_lvts_ap_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1805,6 +1821,7 @@ static const struct lvts_data mt8188_lvt
 };
 
 static const struct lvts_data mt8192_lvts_mcu_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8192_lvts_mcu_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1818,6 +1835,7 @@ static const struct lvts_data mt8192_lvt
 };
 
 static const struct lvts_data mt8192_lvts_ap_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8192_lvts_ap_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1831,6 +1849,7 @@ static const struct lvts_data mt8192_lvt
 };
 
 static const struct lvts_data mt8195_lvts_mcu_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8195_lvts_mcu_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
@@ -1844,6 +1863,7 @@ static const struct lvts_data mt8195_lvt
 };
 
 static const struct lvts_data mt8195_lvts_ap_data = {
+	.irq_enable	= true,
 	.lvts_ctrl	= mt8195_lvts_ap_data_ctrl,
 	.conn_cmd	= default_conn_cmds,
 	.init_cmd	= default_init_cmds,
