linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1
@ 2015-12-07  7:42 Kuninori Morimoto
  2015-12-07  7:42 ` [PATCH 1/8 v3] thermal: rcar: move rcar_thermal_dt_ids to upside Kuninori Morimoto
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:42 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree


Hi

These are v3 of thermal-zone support for r8a7790/r8a7791.
Mainly, it cares return value of get_temp()

I think 8) is needed on of-thermal (?)

Kuninori Morimoto (8):
      1) thermal: rcar: move rcar_thermal_dt_ids to upside
      2) thermal: rcar: check every rcar_thermal_update_temp() return value
      3) thermal: rcar: check irq possibility in rcar_thermal_irq_xxx()
      4) thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update
      5) thermal: rcar: enable to use thermal-zone on DT
      6) ARM: shmobile: r8a7790: enable to use thermal-zone
      7) ARM: shmobile: r8a7791: enable to use thermal-zone
      8) thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update()

 Documentation/devicetree/bindings/thermal/rcar-thermal.txt | 37 +++++++++++++++++++++++++++++++++++--
 arch/arm/boot/dts/r8a7790.dtsi                             | 26 ++++++++++++++++++++++++--
 arch/arm/boot/dts/r8a7791.dtsi                             | 26 ++++++++++++++++++++++++--
 drivers/thermal/of-thermal.c                               |  2 ++
 drivers/thermal/rcar_thermal.c                             | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
 5 files changed, 160 insertions(+), 27 deletions(-)

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/8 v3] thermal: rcar: move rcar_thermal_dt_ids to upside
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
@ 2015-12-07  7:42 ` Kuninori Morimoto
  2015-12-07  7:43 ` [PATCH 2/8 v3] thermal: rcar: check every rcar_thermal_update_temp() return value Kuninori Morimoto
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:42 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch is prepare for of-thermal support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - no change

 drivers/thermal/rcar_thermal.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 13d01ed..96707a6 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -81,6 +81,12 @@ struct rcar_thermal_priv {
 # define rcar_force_update_temp(priv)	0
 #endif
 
+static const struct of_device_id rcar_thermal_dt_ids[] = {
+	{ .compatible = "renesas,rcar-thermal", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
+
 /*
  *		basic functions
  */
@@ -484,12 +490,6 @@ error_unregister:
 	return ret;
 }
 
-static const struct of_device_id rcar_thermal_dt_ids[] = {
-	{ .compatible = "renesas,rcar-thermal", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
-
 static struct platform_driver rcar_thermal_driver = {
 	.driver	= {
 		.name	= "rcar_thermal",
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/8 v3] thermal: rcar: check every rcar_thermal_update_temp() return value
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
  2015-12-07  7:42 ` [PATCH 1/8 v3] thermal: rcar: move rcar_thermal_dt_ids to upside Kuninori Morimoto
@ 2015-12-07  7:43 ` Kuninori Morimoto
  2015-12-07  7:43 ` [PATCH 3/8 v3] thermal: rcar: check irq possibility in rcar_thermal_irq_xxx() Kuninori Morimoto
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:43 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - no change

 drivers/thermal/rcar_thermal.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 96707a6..4d1bc2b 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -210,8 +210,11 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 {
 	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 
-	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv))
-		rcar_thermal_update_temp(priv);
+	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
+		int ret = rcar_thermal_update_temp(priv);
+		if (ret < 0)
+			return ret;
+	}
 
 	mutex_lock(&priv->lock);
 	*temp =  MCELSIUS((priv->ctemp * 5) - 65);
@@ -305,11 +308,15 @@ static void rcar_thermal_work(struct work_struct *work)
 {
 	struct rcar_thermal_priv *priv;
 	int cctemp, nctemp;
+	int ret;
 
 	priv = container_of(work, struct rcar_thermal_priv, work.work);
 
 	rcar_thermal_get_temp(priv->zone, &cctemp);
-	rcar_thermal_update_temp(priv);
+	ret = rcar_thermal_update_temp(priv);
+	if (ret < 0)
+		return;
+
 	rcar_thermal_irq_enable(priv);
 
 	rcar_thermal_get_temp(priv->zone, &nctemp);
@@ -447,7 +454,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		mutex_init(&priv->lock);
 		INIT_LIST_HEAD(&priv->list);
 		INIT_DELAYED_WORK(&priv->work, rcar_thermal_work);
-		rcar_thermal_update_temp(priv);
+		ret = rcar_thermal_update_temp(priv);
+		if (ret < 0)
+			goto error_unregister;
 
 		priv->zone = thermal_zone_device_register("rcar_thermal",
 						1, 0, priv,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/8 v3] thermal: rcar: check irq possibility in rcar_thermal_irq_xxx()
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
  2015-12-07  7:42 ` [PATCH 1/8 v3] thermal: rcar: move rcar_thermal_dt_ids to upside Kuninori Morimoto
  2015-12-07  7:43 ` [PATCH 2/8 v3] thermal: rcar: check every rcar_thermal_update_temp() return value Kuninori Morimoto
@ 2015-12-07  7:43 ` Kuninori Morimoto
  2015-12-07  7:43 ` [PATCH 4/8 v3] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update Kuninori Morimoto
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:43 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rcar thermal driver sometimes checks irq possibility when it
calls rcar_thermal_irq_enable/disable(), but sometimes not.
This patch checks it inside rcar_thermal_irq_enable/disable().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - no change

 drivers/thermal/rcar_thermal.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 4d1bc2b..aaedf37 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -297,6 +297,9 @@ static void _rcar_thermal_irq_ctrl(struct rcar_thermal_priv *priv, int enable)
 	unsigned long flags;
 	u32 mask = 0x3 << rcar_id_to_shift(priv); /* enable Rising/Falling */
 
+	if (!rcar_has_irq_support(priv))
+		return;
+
 	spin_lock_irqsave(&common->lock, flags);
 
 	rcar_thermal_common_bset(common, INTMSK, mask, enable ? 0 : mask);
@@ -381,8 +384,7 @@ static int rcar_thermal_remove(struct platform_device *pdev)
 	struct rcar_thermal_priv *priv;
 
 	rcar_thermal_for_each_priv(priv, common) {
-		if (rcar_has_irq_support(priv))
-			rcar_thermal_irq_disable(priv);
+		rcar_thermal_irq_disable(priv);
 		thermal_zone_device_unregister(priv->zone);
 	}
 
@@ -468,8 +470,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 			goto error_unregister;
 		}
 
-		if (rcar_has_irq_support(priv))
-			rcar_thermal_irq_enable(priv);
+		rcar_thermal_irq_enable(priv);
 
 		list_move_tail(&priv->list, &common->head);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/8 v3] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2015-12-07  7:43 ` [PATCH 3/8 v3] thermal: rcar: check irq possibility in rcar_thermal_irq_xxx() Kuninori Morimoto
@ 2015-12-07  7:43 ` Kuninori Morimoto
  2015-12-07  7:44 ` [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT Kuninori Morimoto
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:43 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current rcar_thermal_get_temp() returns latest temperature, but it might
not be updated if some HW issue happend. This means user might get
wrong temperature. This patch solved this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - no change

 drivers/thermal/rcar_thermal.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index aaedf37..52493b4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -199,9 +199,9 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
 
 	dev_dbg(dev, "thermal%d  %d -> %d\n", priv->id, priv->ctemp, ctemp);
 
-	priv->ctemp = ctemp;
 	ret = 0;
 err_out_unlock:
+	priv->ctemp = ctemp;
 	mutex_unlock(&priv->lock);
 	return ret;
 }
@@ -209,6 +209,7 @@ err_out_unlock:
 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 {
 	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+	int tmp;
 
 	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
 		int ret = rcar_thermal_update_temp(priv);
@@ -217,9 +218,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	}
 
 	mutex_lock(&priv->lock);
-	*temp =  MCELSIUS((priv->ctemp * 5) - 65);
+	tmp =  MCELSIUS((priv->ctemp * 5) - 65);
 	mutex_unlock(&priv->lock);
 
+	if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) {
+		struct device *dev = rcar_priv_to_dev(priv);
+
+		dev_err(dev, "it couldn't measure temperature correctly\n");
+		return -EIO;
+	}
+
+	*temp = tmp;
+
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2015-12-07  7:43 ` [PATCH 4/8 v3] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update Kuninori Morimoto
@ 2015-12-07  7:44 ` Kuninori Morimoto
  2015-12-08 15:20   ` Rob Herring
  2015-12-07  7:44 ` [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone Kuninori Morimoto
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:44 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch enables to use thermal-zone on DT if it was call as
"renesas,rcar-thermal-gen2".
Previous style is still supported by "renesas,rcar-thermal".

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"

 .../devicetree/bindings/thermal/rcar-thermal.txt   | 37 +++++++++++++++++-
 drivers/thermal/rcar_thermal.c                     | 44 +++++++++++++++++++---
 2 files changed, 74 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
index 332e625..601a54d 100644
--- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
@@ -1,8 +1,9 @@
 * Renesas R-Car Thermal
 
 Required properties:
-- compatible		: "renesas,thermal-<soctype>", "renesas,rcar-thermal"
-			  as fallback.
+- compatible		: "renesas,thermal-<soctype>",
+			   "renesas,rcar-gen2-thermal" (with thermal-zone) or
+			   "renesas,rcar-thermal" (without thermal-zone) as fallback.
 			  Examples with soctypes are:
 			    - "renesas,thermal-r8a73a4" (R-Mobile APE6)
 			    - "renesas,thermal-r8a7779" (R-Car H1)
@@ -36,3 +37,35 @@ thermal@e61f0000 {
 		0xe61f0300 0x38>;
 	interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
 };
+
+Example (with thermal-zone):
+
+thermal-zones {
+	cpu_thermal: cpu-thermal {
+		polling-delay-passive	= <1000>;
+		polling-delay		= <5000>;
+
+		thermal-sensors = <&thermal>;
+
+		trips {
+			cpu-crit {
+				temperature	= <1150000>;
+				hysteresis	= <0>;
+				type		= "critical";
+			};
+		};
+		cooling-maps {
+		};
+	};
+};
+
+thermal: thermal@e61f0000 {
+	compatible =	"renesas,thermal-r8a7790",
+			"renesas,rcar-gen2-thermal",
+			"renesas,rcar-thermal";
+	reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
+	interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+	clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
+	power-domains = <&cpg_clocks>;
+	#thermal-sensor-cells = <0>;
+};
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 52493b4..a8c88f4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/reboot.h>
@@ -81,8 +82,10 @@ struct rcar_thermal_priv {
 # define rcar_force_update_temp(priv)	0
 #endif
 
+#define USE_OF_THERMAL	1
 static const struct of_device_id rcar_thermal_dt_ids[] = {
 	{ .compatible = "renesas,rcar-thermal", },
+	{ .compatible = "renesas,rcar-gen2-thermal", .data = (void *)USE_OF_THERMAL },
 	{},
 };
 MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
@@ -206,9 +209,8 @@ err_out_unlock:
 	return ret;
 }
 
-static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
+static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv, int *temp)
 {
-	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
 	int tmp;
 
 	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
@@ -233,6 +235,20 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	return 0;
 }
 
+static int rcar_thermal_of_get_temp(void *data, int *temp)
+{
+	struct rcar_thermal_priv *priv = data;
+
+	return rcar_thermal_get_current_temp(priv, temp);
+}
+
+static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	return rcar_thermal_get_current_temp(priv, temp);
+}
+
 static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
 				      int trip, enum thermal_trip_type *type)
 {
@@ -289,6 +305,10 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone,
 	return 0;
 }
 
+static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = {
+	.get_temp	= rcar_thermal_of_get_temp,
+};
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
 	.get_temp	= rcar_thermal_get_temp,
 	.get_trip_type	= rcar_thermal_get_trip_type,
@@ -325,14 +345,20 @@ static void rcar_thermal_work(struct work_struct *work)
 
 	priv = container_of(work, struct rcar_thermal_priv, work.work);
 
-	rcar_thermal_get_temp(priv->zone, &cctemp);
+	ret = rcar_thermal_get_current_temp(priv, &cctemp);
+	if (ret < 0)
+		return;
+
 	ret = rcar_thermal_update_temp(priv);
 	if (ret < 0)
 		return;
 
 	rcar_thermal_irq_enable(priv);
 
-	rcar_thermal_get_temp(priv->zone, &nctemp);
+	ret = rcar_thermal_get_current_temp(priv, &nctemp);
+	if (ret < 0)
+		return;
+
 	if (nctemp != cctemp)
 		thermal_zone_device_update(priv->zone);
 }
@@ -410,6 +436,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 	struct rcar_thermal_priv *priv;
 	struct device *dev = &pdev->dev;
 	struct resource *res, *irq;
+	const struct of_device_id *of_id = of_match_device(rcar_thermal_dt_ids, dev);
+	unsigned long of_data = (unsigned long)of_id->data;
 	int mres = 0;
 	int i;
 	int ret = -ENODEV;
@@ -470,7 +498,13 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto error_unregister;
 
-		priv->zone = thermal_zone_device_register("rcar_thermal",
+		if (of_data == USE_OF_THERMAL)
+			priv->zone = thermal_zone_of_sensor_register(
+						dev, i, priv,
+						&rcar_thermal_zone_of_ops);
+		else
+			priv->zone = thermal_zone_device_register(
+						"rcar_thermal",
 						1, 0, priv,
 						&rcar_thermal_zone_ops, NULL, 0,
 						idle);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2015-12-07  7:44 ` [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT Kuninori Morimoto
@ 2015-12-07  7:44 ` Kuninori Morimoto
  2015-12-08  3:06   ` Khiem Nguyen
  2015-12-07  7:44 ` [PATCH 7/8 v3] ARM: shmobile: r8a7791: " Kuninori Morimoto
  2015-12-07  7:45 ` [PATCH 8/8 v3] thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update() Kuninori Morimoto
  7 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:44 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch enables to use thermal-zone on r8a7790.
This thermal sensor can measure temperature from -40000 to 125000,
but over 117000 can be critical on this chip.
Thus, default critical temperature is now set as 115000 (this driver
is using 5000 steps) (Current critical temperature is using it as
90000, but there is no big reason about it)

And it doesn't check thermal zone periodically (same as current
behavior). You can exchange it by modifing polling-delay[-passive]
property.

You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS,
but you need to take care to use it, since it will call
orderly_poweroff() it it reached to the value.
echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"

 arch/arm/boot/dts/r8a7790.dtsi | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 6cfd0dc..49aaa67 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -112,6 +112,25 @@
 		};
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive	= <0>;
+			polling-delay		= <0>;
+
+			thermal-sensors = <&thermal>;
+
+			trips {
+				cpu-crit {
+					temperature	= <1150000>;
+					hysteresis	= <0>;
+					type		= "critical";
+				};
+			};
+			cooling-maps {
+			};
+		};
+	};
+
 	gic: interrupt-controller@f1001000 {
 		compatible = "arm,gic-400";
 		#interrupt-cells = <3>;
@@ -202,12 +221,15 @@
 		power-domains = <&cpg_clocks>;
 	};
 
-	thermal@e61f0000 {
-		compatible = "renesas,thermal-r8a7790", "renesas,rcar-thermal";
+	thermal: thermal@e61f0000 {
+		compatible =	"renesas,thermal-r8a7790",
+				"renesas,rcar-gen2-thermal",
+				"renesas,rcar-thermal";
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
 		power-domains = <&cpg_clocks>;
+		#thermal-sensor-cells = <0>;
 	};
 
 	timer {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 7/8 v3] ARM: shmobile: r8a7791: enable to use thermal-zone
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2015-12-07  7:44 ` [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone Kuninori Morimoto
@ 2015-12-07  7:44 ` Kuninori Morimoto
  2015-12-08  3:10   ` Khiem Nguyen
  2015-12-07  7:45 ` [PATCH 8/8 v3] thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update() Kuninori Morimoto
  7 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:44 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch enables to use thermal-zone on r8a7791.
This thermal sensor can measure temperature from -40000 to 125000,
but over 117000 can be critical on this chip.
Thus, default critical temperature is now set as 115000 (this driver
is using 5000 steps) (Current critical temperature is using it as
90000, but there is no big reason about it)

And it doesn't check thermal zone periodically (same as current
behavior). You can exchange it by modifing polling-delay[-passive]
property.

You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS,
but you need to take care to use it, since it will call
orderly_poweroff() it it reached to the value.
echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"

 arch/arm/boot/dts/r8a7791.dtsi | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 1487d92..d885e5f 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -69,6 +69,25 @@
 		};
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive	= <0>;
+			polling-delay		= <0>;
+
+			thermal-sensors = <&thermal>;
+
+			trips {
+				cpu-crit {
+					temperature	= <1150000>;
+					hysteresis	= <0>;
+					type		= "critical";
+				};
+			};
+			cooling-maps {
+			};
+		};
+	};
+
 	gic: interrupt-controller@f1001000 {
 		compatible = "arm,gic-400";
 		#interrupt-cells = <3>;
@@ -185,12 +204,15 @@
 		power-domains = <&cpg_clocks>;
 	};
 
-	thermal@e61f0000 {
-		compatible = "renesas,thermal-r8a7791", "renesas,rcar-thermal";
+	thermal: thermal@e61f0000 {
+		compatible =	"renesas,thermal-r8a7791",
+				"renesas,rcar-gen2-thermal",
+				"renesas,rcar-thermal";
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp5_clks R8A7791_CLK_THERMAL>;
 		power-domains = <&cpg_clocks>;
+		#thermal-sensor-cells = <0>;
 	};
 
 	timer {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 8/8 v3] thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update()
  2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2015-12-07  7:44 ` [PATCH 7/8 v3] ARM: shmobile: r8a7791: " Kuninori Morimoto
@ 2015-12-07  7:45 ` Kuninori Morimoto
  7 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-07  7:45 UTC (permalink / raw)
  To: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven
  Cc: Magnus, linux-sh, linux-pm, linux-kernel, devicetree

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

of_thermal_set_trip_temp() updates trip temperature. It should call
thermal_zone_device_update() immediately.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v2 -> v3

 - no change

 drivers/thermal/of-thermal.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index be4eedc..d59595b 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -334,6 +334,8 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
 	/* thermal framework should take care of data->mask & (1 << trip) */
 	data->trips[trip].temperature = temp;
 
+	thermal_zone_device_update(tz);
+
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone
  2015-12-07  7:44 ` [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone Kuninori Morimoto
@ 2015-12-08  3:06   ` Khiem Nguyen
  0 siblings, 0 replies; 13+ messages in thread
From: Khiem Nguyen @ 2015-12-08  3:06 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven, Magnus,
	linux-sh, linux-pm, linux-kernel, devicetree, Khiem Nguyen,
	Hien Duy. Dang, Toru Oishi

Hi Morimoto-san,

Thanks for your patch.

On 12/7/2015 2:44 PM, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> This patch enables to use thermal-zone on r8a7790.
> This thermal sensor can measure temperature from -40000 to 125000,
> but over 117000 can be critical on this chip.
> Thus, default critical temperature is now set as 115000 (this driver
> is using 5000 steps) (Current critical temperature is using it as
> 90000, but there is no big reason about it)
>
> And it doesn't check thermal zone periodically (same as current
> behavior). You can exchange it by modifing polling-delay[-passive]

modifing -> modifying

> property.
>
> You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS,
> but you need to take care to use it, since it will call
> orderly_poweroff() it it reached to the value.

if it reaches

> echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> v2 -> v3
>
>   - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"
>
>   arch/arm/boot/dts/r8a7790.dtsi | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> index 6cfd0dc..49aaa67 100644
> --- a/arch/arm/boot/dts/r8a7790.dtsi
> +++ b/arch/arm/boot/dts/r8a7790.dtsi
> @@ -112,6 +112,25 @@
>   		};
>   	};
>
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			polling-delay-passive	= <0>;
> +			polling-delay		= <0>;
> +
> +			thermal-sensors = <&thermal>;
> +
> +			trips {
> +				cpu-crit {
> +					temperature	= <1150000>;

One zero is redundant here. It should be 115000.

> +					hysteresis	= <0>;
> +					type		= "critical";
> +				};
> +			};
> +			cooling-maps {
> +			};
> +		};
> +	};
> +
>   	gic: interrupt-controller@f1001000 {
>   		compatible = "arm,gic-400";
>   		#interrupt-cells = <3>;
> @@ -202,12 +221,15 @@
>   		power-domains = <&cpg_clocks>;
>   	};
>
> -	thermal@e61f0000 {
> -		compatible = "renesas,thermal-r8a7790", "renesas,rcar-thermal";
> +	thermal: thermal@e61f0000 {
> +		compatible =	"renesas,thermal-r8a7790",
> +				"renesas,rcar-gen2-thermal",
> +				"renesas,rcar-thermal";
>   		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
>   		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
>   		clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
>   		power-domains = <&cpg_clocks>;
> +		#thermal-sensor-cells = <0>;
>   	};
>
>   	timer {
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 7/8 v3] ARM: shmobile: r8a7791: enable to use thermal-zone
  2015-12-07  7:44 ` [PATCH 7/8 v3] ARM: shmobile: r8a7791: " Kuninori Morimoto
@ 2015-12-08  3:10   ` Khiem Nguyen
  2015-12-08  5:03     ` Kuninori Morimoto
  0 siblings, 1 reply; 13+ messages in thread
From: Khiem Nguyen @ 2015-12-08  3:10 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven, Magnus,
	linux-sh, linux-pm, linux-kernel, devicetree, Hien Duy. Dang,
	Toru Oishi, Khiem Nguyen

Hi Morimoto-san,

Thanks for your patch.
I have same comments as patch 0006.

On 12/7/2015 2:44 PM, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> This patch enables to use thermal-zone on r8a7791.
> This thermal sensor can measure temperature from -40000 to 125000,
> but over 117000 can be critical on this chip.
> Thus, default critical temperature is now set as 115000 (this driver
> is using 5000 steps) (Current critical temperature is using it as
> 90000, but there is no big reason about it)
>
> And it doesn't check thermal zone periodically (same as current
> behavior). You can exchange it by modifing polling-delay[-passive]

modifing -> modifying

> property.
>
> You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS,
> but you need to take care to use it, since it will call
> orderly_poweroff() it it reached to the value.

if it reaches

> echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> v2 -> v3
>
>   - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"
>
>   arch/arm/boot/dts/r8a7791.dtsi | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index 1487d92..d885e5f 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -69,6 +69,25 @@
>   		};
>   	};
>
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			polling-delay-passive	= <0>;
> +			polling-delay		= <0>;
> +
> +			thermal-sensors = <&thermal>;
> +
> +			trips {
> +				cpu-crit {
> +					temperature	= <1150000>;

One zero is redundant here. It should be 115000.

> +					hysteresis	= <0>;
> +					type		= "critical";
> +				};
> +			};
> +			cooling-maps {
> +			};
> +		};
> +	};
> +
>   	gic: interrupt-controller@f1001000 {
>   		compatible = "arm,gic-400";
>   		#interrupt-cells = <3>;
> @@ -185,12 +204,15 @@
>   		power-domains = <&cpg_clocks>;
>   	};
>
> -	thermal@e61f0000 {
> -		compatible = "renesas,thermal-r8a7791", "renesas,rcar-thermal";
> +	thermal: thermal@e61f0000 {
> +		compatible =	"renesas,thermal-r8a7791",
> +				"renesas,rcar-gen2-thermal",
> +				"renesas,rcar-thermal";
>   		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
>   		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
>   		clocks = <&mstp5_clks R8A7791_CLK_THERMAL>;
>   		power-domains = <&cpg_clocks>;
> +		#thermal-sensor-cells = <0>;
>   	};
>
>   	timer {
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 7/8 v3] ARM: shmobile: r8a7791: enable to use thermal-zone
  2015-12-08  3:10   ` Khiem Nguyen
@ 2015-12-08  5:03     ` Kuninori Morimoto
  0 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-12-08  5:03 UTC (permalink / raw)
  To: Khiem Nguyen
  Cc: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven, Magnus,
	linux-sh, linux-pm, linux-kernel, devicetree, Hien Duy. Dang,
	Toru Oishi


Hi Khiem

> Hi Morimoto-san,
> 
> Thanks for your patch.
> I have same comments as patch 0006.

Thanks, will fix in v4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT
  2015-12-07  7:44 ` [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT Kuninori Morimoto
@ 2015-12-08 15:20   ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2015-12-08 15:20 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Simon, Zhang Rui, Eduardo Valentin, Geert Uytterhoeven, Magnus,
	linux-sh, linux-pm, linux-kernel, devicetree

On Mon, Dec 07, 2015 at 07:44:09AM +0000, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> This patch enables to use thermal-zone on DT if it was call as
> "renesas,rcar-thermal-gen2".
> Previous style is still supported by "renesas,rcar-thermal".
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> v2 -> v3
> 
>  - compatible "renesas,rcar-thermal-gen2" -> "renesas,rcar-gen2-thermal"
> 
>  .../devicetree/bindings/thermal/rcar-thermal.txt   | 37 +++++++++++++++++-

For the binding:

Acked-by: Rob Herring <robh@kernel.org>

>  drivers/thermal/rcar_thermal.c                     | 44 +++++++++++++++++++---
>  2 files changed, 74 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> index 332e625..601a54d 100644
> --- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
> @@ -1,8 +1,9 @@
>  * Renesas R-Car Thermal
>  
>  Required properties:
> -- compatible		: "renesas,thermal-<soctype>", "renesas,rcar-thermal"
> -			  as fallback.
> +- compatible		: "renesas,thermal-<soctype>",
> +			   "renesas,rcar-gen2-thermal" (with thermal-zone) or
> +			   "renesas,rcar-thermal" (without thermal-zone) as fallback.
>  			  Examples with soctypes are:
>  			    - "renesas,thermal-r8a73a4" (R-Mobile APE6)
>  			    - "renesas,thermal-r8a7779" (R-Car H1)
> @@ -36,3 +37,35 @@ thermal@e61f0000 {
>  		0xe61f0300 0x38>;
>  	interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
>  };
> +
> +Example (with thermal-zone):
> +
> +thermal-zones {
> +	cpu_thermal: cpu-thermal {
> +		polling-delay-passive	= <1000>;
> +		polling-delay		= <5000>;
> +
> +		thermal-sensors = <&thermal>;
> +
> +		trips {
> +			cpu-crit {
> +				temperature	= <1150000>;
> +				hysteresis	= <0>;
> +				type		= "critical";
> +			};
> +		};
> +		cooling-maps {
> +		};
> +	};
> +};
> +
> +thermal: thermal@e61f0000 {
> +	compatible =	"renesas,thermal-r8a7790",
> +			"renesas,rcar-gen2-thermal",
> +			"renesas,rcar-thermal";
> +	reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
> +	interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
> +	clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
> +	power-domains = <&cpg_clocks>;
> +	#thermal-sensor-cells = <0>;
> +};
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 52493b4..a8c88f4 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -23,6 +23,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/reboot.h>
> @@ -81,8 +82,10 @@ struct rcar_thermal_priv {
>  # define rcar_force_update_temp(priv)	0
>  #endif
>  
> +#define USE_OF_THERMAL	1
>  static const struct of_device_id rcar_thermal_dt_ids[] = {
>  	{ .compatible = "renesas,rcar-thermal", },
> +	{ .compatible = "renesas,rcar-gen2-thermal", .data = (void *)USE_OF_THERMAL },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
> @@ -206,9 +209,8 @@ err_out_unlock:
>  	return ret;
>  }
>  
> -static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
> +static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv, int *temp)
>  {
> -	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
>  	int tmp;
>  
>  	if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) {
> @@ -233,6 +235,20 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
>  	return 0;
>  }
>  
> +static int rcar_thermal_of_get_temp(void *data, int *temp)
> +{
> +	struct rcar_thermal_priv *priv = data;
> +
> +	return rcar_thermal_get_current_temp(priv, temp);
> +}
> +
> +static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
> +{
> +	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
> +
> +	return rcar_thermal_get_current_temp(priv, temp);
> +}
> +
>  static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
>  				      int trip, enum thermal_trip_type *type)
>  {
> @@ -289,6 +305,10 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone,
>  	return 0;
>  }
>  
> +static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = {
> +	.get_temp	= rcar_thermal_of_get_temp,
> +};
> +
>  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
>  	.get_temp	= rcar_thermal_get_temp,
>  	.get_trip_type	= rcar_thermal_get_trip_type,
> @@ -325,14 +345,20 @@ static void rcar_thermal_work(struct work_struct *work)
>  
>  	priv = container_of(work, struct rcar_thermal_priv, work.work);
>  
> -	rcar_thermal_get_temp(priv->zone, &cctemp);
> +	ret = rcar_thermal_get_current_temp(priv, &cctemp);
> +	if (ret < 0)
> +		return;
> +
>  	ret = rcar_thermal_update_temp(priv);
>  	if (ret < 0)
>  		return;
>  
>  	rcar_thermal_irq_enable(priv);
>  
> -	rcar_thermal_get_temp(priv->zone, &nctemp);
> +	ret = rcar_thermal_get_current_temp(priv, &nctemp);
> +	if (ret < 0)
> +		return;
> +
>  	if (nctemp != cctemp)
>  		thermal_zone_device_update(priv->zone);
>  }
> @@ -410,6 +436,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  	struct rcar_thermal_priv *priv;
>  	struct device *dev = &pdev->dev;
>  	struct resource *res, *irq;
> +	const struct of_device_id *of_id = of_match_device(rcar_thermal_dt_ids, dev);
> +	unsigned long of_data = (unsigned long)of_id->data;
>  	int mres = 0;
>  	int i;
>  	int ret = -ENODEV;
> @@ -470,7 +498,13 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  		if (ret < 0)
>  			goto error_unregister;
>  
> -		priv->zone = thermal_zone_device_register("rcar_thermal",
> +		if (of_data == USE_OF_THERMAL)
> +			priv->zone = thermal_zone_of_sensor_register(
> +						dev, i, priv,
> +						&rcar_thermal_zone_of_ops);
> +		else
> +			priv->zone = thermal_zone_device_register(
> +						"rcar_thermal",
>  						1, 0, priv,
>  						&rcar_thermal_zone_ops, NULL, 0,
>  						idle);
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-12-08 15:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-07  7:42 [PATCH 0/8 v3] enable to use thermal-zone on r8a7790/1 Kuninori Morimoto
2015-12-07  7:42 ` [PATCH 1/8 v3] thermal: rcar: move rcar_thermal_dt_ids to upside Kuninori Morimoto
2015-12-07  7:43 ` [PATCH 2/8 v3] thermal: rcar: check every rcar_thermal_update_temp() return value Kuninori Morimoto
2015-12-07  7:43 ` [PATCH 3/8 v3] thermal: rcar: check irq possibility in rcar_thermal_irq_xxx() Kuninori Morimoto
2015-12-07  7:43 ` [PATCH 4/8 v3] thermal: rcar: retern error rcar_thermal_get_temp() if no ctemp update Kuninori Morimoto
2015-12-07  7:44 ` [PATCH 5/8 v3] thermal: rcar: enable to use thermal-zone on DT Kuninori Morimoto
2015-12-08 15:20   ` Rob Herring
2015-12-07  7:44 ` [PATCH 6/8 v3] ARM: shmobile: r8a7790: enable to use thermal-zone Kuninori Morimoto
2015-12-08  3:06   ` Khiem Nguyen
2015-12-07  7:44 ` [PATCH 7/8 v3] ARM: shmobile: r8a7791: " Kuninori Morimoto
2015-12-08  3:10   ` Khiem Nguyen
2015-12-08  5:03     ` Kuninori Morimoto
2015-12-07  7:45 ` [PATCH 8/8 v3] thermal: of-thermal: of_thermal_set_trip_temp() call thermal_zone_device_update() Kuninori Morimoto

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).