diff mbox series

[v2,6/6] thermal: tegra: Avoid setting edp_irq when not relevant

Message ID 20200927150956.34609-7-kwizart@gmail.com
State New
Delegated to: Daniel Lezcano
Headers show
Series thermal: tegra: soctherm bugfixes | expand

Commit Message

Nicolas Chauvet Sept. 27, 2020, 3:09 p.m. UTC
According to the binding, the edp_irq is not available on tegra124/132

This commit moves the initialization of tegra->edp_irq after the
introduced has_edp_irq condition. This will have the following effects:
 - soctherm_interrupts_init will not return prematurely with unfinished
thermal_irq initialization on tegra124 and tegra132
 - edp_irq initialization will be done only when relevant

As a result, this will clear the following error on jetson-tk1 :
  kernel: tegra_soctherm 700e2000.thermal-sensor: IRQ index 1 not found

v2:
    * Use .has_edp_irq boolean instead of of_compatible
    * Switch subject prefix to use thermal instead of ARM

Fixes: 4a04beb1bf2e (thermal: tegra: add support for EDP IRQ)
Cc: stable@vger.kernel.org
Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
---
 drivers/thermal/tegra/soctherm.c          | 38 +++++++++++++----------
 drivers/thermal/tegra/soctherm.h          |  1 +
 drivers/thermal/tegra/tegra124-soctherm.c |  1 +
 drivers/thermal/tegra/tegra132-soctherm.c |  1 +
 drivers/thermal/tegra/tegra210-soctherm.c |  1 +
 5 files changed, 26 insertions(+), 16 deletions(-)

Comments

Jon Hunter Nov. 19, 2020, 7:15 p.m. UTC | #1
On 27/09/2020 16:09, Nicolas Chauvet wrote:
> According to the binding, the edp_irq is not available on tegra124/132

It appears that the binding doc is not update to date or missing the
relevant information. Looking at the Tegra124 TRM I see that there is a
SOCTHERM EDP IRQ (51) and so maybe the correct fix is to add this.

Cheers
Jon
diff mbox series

Patch

diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 66e0639da4bf..0c79e033e7ea 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -2025,12 +2025,6 @@  static int soctherm_interrupts_init(struct platform_device *pdev,
 		return 0;
 	}
 
-	tegra->edp_irq = platform_get_irq(pdev, 1);
-	if (tegra->edp_irq < 0) {
-		dev_dbg(&pdev->dev, "get 'edp_irq' failed.\n");
-		return 0;
-	}
-
 	ret = devm_request_threaded_irq(&pdev->dev,
 					tegra->thermal_irq,
 					soctherm_thermal_isr,
@@ -2043,16 +2037,28 @@  static int soctherm_interrupts_init(struct platform_device *pdev,
 		return ret;
 	}
 
-	ret = devm_request_threaded_irq(&pdev->dev,
-					tegra->edp_irq,
-					soctherm_edp_isr,
-					soctherm_edp_isr_thread,
-					IRQF_ONESHOT,
-					"soctherm_edp",
-					tegra);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "request_irq 'edp_irq' failed.\n");
-		return ret;
+	/* Initialize edp_irq when available */
+	if (tegra->soc->has_edp_irq) {
+		/* get IRQ */
+
+		tegra->edp_irq = platform_get_irq(pdev, 1);
+		if (tegra->edp_irq < 0) {
+			dev_dbg(&pdev->dev, "get 'edp_irq' failed.\n");
+			return 0;
+		}
+
+		/* request IRQ */
+		ret = devm_request_threaded_irq(&pdev->dev,
+						tegra->edp_irq,
+						soctherm_edp_isr,
+						soctherm_edp_isr_thread,
+						IRQF_ONESHOT,
+						"soctherm_edp",
+						tegra);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "request_irq 'edp_irq' failed.\n");
+			return ret;
+		}
 	}
 
 	return 0;
diff --git a/drivers/thermal/tegra/soctherm.h b/drivers/thermal/tegra/soctherm.h
index 70501e73d586..b93cfdd06e5d 100644
--- a/drivers/thermal/tegra/soctherm.h
+++ b/drivers/thermal/tegra/soctherm.h
@@ -128,6 +128,7 @@  struct tegra_soctherm_soc {
 	const int thresh_grain;
 	const unsigned int bptt;
 	const bool use_ccroc;
+	const bool has_edp_irq;
 	struct tsensor_group_thermtrips *thermtrips;
 };
 
diff --git a/drivers/thermal/tegra/tegra124-soctherm.c b/drivers/thermal/tegra/tegra124-soctherm.c
index 20ad27f4d1a1..c8c8231f6cdd 100644
--- a/drivers/thermal/tegra/tegra124-soctherm.c
+++ b/drivers/thermal/tegra/tegra124-soctherm.c
@@ -216,4 +216,5 @@  const struct tegra_soctherm_soc tegra124_soctherm = {
 	.thresh_grain = TEGRA124_THRESH_GRAIN,
 	.bptt = TEGRA124_BPTT,
 	.use_ccroc = false,
+	.has_edp_irq = false,
 };
diff --git a/drivers/thermal/tegra/tegra132-soctherm.c b/drivers/thermal/tegra/tegra132-soctherm.c
index b76308fdad9e..1bc9481de5fc 100644
--- a/drivers/thermal/tegra/tegra132-soctherm.c
+++ b/drivers/thermal/tegra/tegra132-soctherm.c
@@ -216,4 +216,5 @@  const struct tegra_soctherm_soc tegra132_soctherm = {
 	.thresh_grain = TEGRA132_THRESH_GRAIN,
 	.bptt = TEGRA132_BPTT,
 	.use_ccroc = true,
+	.has_edp_irq = false,
 };
diff --git a/drivers/thermal/tegra/tegra210-soctherm.c b/drivers/thermal/tegra/tegra210-soctherm.c
index d0ff793f18c5..2b09c8a811d0 100644
--- a/drivers/thermal/tegra/tegra210-soctherm.c
+++ b/drivers/thermal/tegra/tegra210-soctherm.c
@@ -224,5 +224,6 @@  const struct tegra_soctherm_soc tegra210_soctherm = {
 	.thresh_grain = TEGRA210_THRESH_GRAIN,
 	.bptt = TEGRA210_BPTT,
 	.use_ccroc = false,
+	.has_edp_irq = true,
 	.thermtrips = tegra210_tsensor_thermtrips,
 };