linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support
@ 2018-09-25  9:02 Daniel Lezcano
  2018-09-25  9:02 ` [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Daniel Lezcano
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:02 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan

This patch series provides the changes to support the dual clusters sensor on
the hikey960 board.

Most of the patches set the scene for the addition of other sensors which comes
at the end of the series.

Daniel Lezcano (14):
  thermal/drivers/hisi: Change the platform data pointer to sensor ops
  thermal/drivers/hisi: Change the driver to be sensor oriented
  thermal/drivers/hisi: Set the thermal zone private data to the sensor
    pointer
  thermal/drivers/hisi: Factor out the probe functions
  thermal/drivers/hisi: Prepare to support multiple sensors
  thermal/drivers/hisi: Add multiple sensors support
  thermal/drivers/hisi: Replace macro name with relevant sensor location
  ARM64: dts: hisilicon: Add tsensor interrupt name
  thermal/drivers/hisi: Use platform_get_irq_byname
  ARM64: dts: hisilicon: Add interrupt names for the tsensors
  thermal/drivers/hisi: Remove pointless irq field
  thermal/drivers/hisi: Add more sensors channel
  ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660
  thermal/drivers/hisi: Add the dual clusters sensors for hi3660

 .../bindings/thermal/hisilicon-thermal.txt         |   9 +-
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi          |  60 +++--
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |   1 +
 drivers/thermal/hisi_thermal.c                     | 249 ++++++++++++---------
 4 files changed, 204 insertions(+), 115 deletions(-)

-- 
2.7.4


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

* [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
@ 2018-09-25  9:02 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented Daniel Lezcano
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:02 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Group the temperature sensor specific ops into a single structure and
assign it to hisi thermal data structure.

Change the platform data pointer to reference the specific sensor ops
instead of the probe functions.

Moving out those allow to split the code to self-encapsulate the
sensor object.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 60 ++++++++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 26 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 761d055..9794cfe 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -64,11 +64,18 @@ struct hisi_thermal_sensor {
 	uint32_t thres_temp;
 };
 
-struct hisi_thermal_data {
+struct hisi_thermal_data;
+
+struct hisi_thermal_ops {
 	int (*get_temp)(struct hisi_thermal_data *data);
 	int (*enable_sensor)(struct hisi_thermal_data *data);
 	int (*disable_sensor)(struct hisi_thermal_data *data);
 	int (*irq_handler)(struct hisi_thermal_data *data);
+	int (*probe)(struct hisi_thermal_data *data);
+};
+
+struct hisi_thermal_data {
+	const struct hisi_thermal_ops *ops;
 	struct platform_device *pdev;
 	struct clk *clk;
 	struct hisi_thermal_sensor sensor;
@@ -374,11 +381,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 	struct resource *res;
 	int ret;
 
-	data->get_temp = hi6220_thermal_get_temp;
-	data->enable_sensor = hi6220_thermal_enable_sensor;
-	data->disable_sensor = hi6220_thermal_disable_sensor;
-	data->irq_handler = hi6220_thermal_irq_handler;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	data->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(data->regs)) {
@@ -409,11 +411,6 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 	struct device *dev = &pdev->dev;
 	struct resource *res;
 
-	data->get_temp = hi3660_thermal_get_temp;
-	data->enable_sensor = hi3660_thermal_enable_sensor;
-	data->disable_sensor = hi3660_thermal_disable_sensor;
-	data->irq_handler = hi3660_thermal_irq_handler;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	data->regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(data->regs)) {
@@ -435,7 +432,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp)
 	struct hisi_thermal_data *data = __data;
 	struct hisi_thermal_sensor *sensor = &data->sensor;
 
-	*temp = data->get_temp(data);
+	*temp = data->ops->get_temp(data);
 
 	dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n",
 		sensor->id, *temp, sensor->thres_temp);
@@ -453,7 +450,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 	struct hisi_thermal_sensor *sensor = &data->sensor;
 	int temp = 0;
 
-	data->irq_handler(data);
+	data->ops->irq_handler(data);
 
 	hisi_thermal_get_temp(data, &temp);
 
@@ -502,14 +499,30 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,
 	return 0;
 }
 
+static const struct hisi_thermal_ops hi6220_ops = {
+	.get_temp	= hi6220_thermal_get_temp,
+	.enable_sensor	= hi6220_thermal_enable_sensor,
+	.disable_sensor	= hi6220_thermal_disable_sensor,
+	.irq_handler	= hi6220_thermal_irq_handler,
+	.probe		= hi6220_thermal_probe,
+};
+
+static const struct hisi_thermal_ops hi3660_ops = {
+	.get_temp	= hi3660_thermal_get_temp,
+	.enable_sensor	= hi3660_thermal_enable_sensor,
+	.disable_sensor	= hi3660_thermal_disable_sensor,
+	.irq_handler	= hi3660_thermal_irq_handler,
+	.probe		= hi3660_thermal_probe,
+};
+
 static const struct of_device_id of_hisi_thermal_match[] = {
 	{
 		.compatible = "hisilicon,tsensor",
-		.data = hi6220_thermal_probe
+		.data = &hi6220_ops,
 	},
 	{
 		.compatible = "hisilicon,hi3660-tsensor",
-		.data = hi3660_thermal_probe
+		.data = &hi3660_ops,
 	},
 	{ /* end */ }
 };
@@ -527,7 +540,6 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor,
 static int hisi_thermal_probe(struct platform_device *pdev)
 {
 	struct hisi_thermal_data *data;
-	int (*platform_probe)(struct hisi_thermal_data *);
 	struct device *dev = &pdev->dev;
 	int ret;
 
@@ -538,13 +550,9 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 	data->pdev = pdev;
 	platform_set_drvdata(pdev, data);
 
-	platform_probe = of_device_get_match_data(dev);
-	if (!platform_probe) {
-		dev_err(dev, "failed to get probe func\n");
-		return -EINVAL;
-	}
+	data->ops = of_device_get_match_data(dev);
 
-	ret = platform_probe(data);
+	ret = data->ops->probe(data);
 	if (ret)
 		return ret;
 
@@ -555,7 +563,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = data->enable_sensor(data);
+	ret = data->ops->enable_sensor(data);
 	if (ret) {
 		dev_err(dev, "Failed to setup the sensor: %d\n", ret);
 		return ret;
@@ -583,7 +591,7 @@ static int hisi_thermal_remove(struct platform_device *pdev)
 
 	hisi_thermal_toggle_sensor(sensor, false);
 
-	data->disable_sensor(data);
+	data->ops->disable_sensor(data);
 
 	return 0;
 }
@@ -593,7 +601,7 @@ static int hisi_thermal_suspend(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	data->disable_sensor(data);
+	data->ops->disable_sensor(data);
 
 	return 0;
 }
@@ -602,7 +610,7 @@ static int hisi_thermal_resume(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	return data->enable_sensor(data);
+	return data->ops->enable_sensor(data);
 }
 #endif
 
-- 
2.7.4


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

* [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
  2018-09-25  9:02 ` [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer Daniel Lezcano
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

In order to support multiple sensors, we have to change the code to
deal with sensors and not the hisi thermal structure.

Add a back pointer to the hisi thermal structure (containerof is not a
good option because later we convert the sensor field to a pointer).

Change the functions parameters to take a sensor instead of this hisi
thermal 'data' structure.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 72 ++++++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 30 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 9794cfe..1fdda55 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -58,27 +58,28 @@
 #define HI6220_DEFAULT_SENSOR		2
 #define HI3660_DEFAULT_SENSOR		1
 
+struct hisi_thermal_data;
+
 struct hisi_thermal_sensor {
+	struct hisi_thermal_data *data;
 	struct thermal_zone_device *tzd;
 	uint32_t id;
 	uint32_t thres_temp;
 };
 
-struct hisi_thermal_data;
-
 struct hisi_thermal_ops {
-	int (*get_temp)(struct hisi_thermal_data *data);
-	int (*enable_sensor)(struct hisi_thermal_data *data);
-	int (*disable_sensor)(struct hisi_thermal_data *data);
-	int (*irq_handler)(struct hisi_thermal_data *data);
+	int (*get_temp)(struct hisi_thermal_sensor *sensor);
+	int (*enable_sensor)(struct hisi_thermal_sensor *sensor);
+	int (*disable_sensor)(struct hisi_thermal_sensor *sensor);
+	int (*irq_handler)(struct hisi_thermal_sensor *sensor);
 	int (*probe)(struct hisi_thermal_data *data);
 };
 
 struct hisi_thermal_data {
 	const struct hisi_thermal_ops *ops;
+	struct hisi_thermal_sensor sensor;
 	struct platform_device *pdev;
 	struct clk *clk;
-	struct hisi_thermal_sensor sensor;
 	void __iomem *regs;
 	int irq;
 };
@@ -273,30 +274,40 @@ static inline void hi6220_thermal_hdak_set(void __iomem *addr, int value)
 	       (value << 4), addr + HI6220_TEMP0_CFG);
 }
 
-static int hi6220_thermal_irq_handler(struct hisi_thermal_data *data)
+static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
 {
+	struct hisi_thermal_data *data = sensor->data;
+
 	hi6220_thermal_alarm_clear(data->regs, 1);
 	return 0;
 }
 
-static int hi3660_thermal_irq_handler(struct hisi_thermal_data *data)
+static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
 {
-	hi3660_thermal_alarm_clear(data->regs, data->sensor.id, 1);
+	struct hisi_thermal_data *data = sensor->data;
+
+	hi3660_thermal_alarm_clear(data->regs, sensor->id, 1);
 	return 0;
 }
 
-static int hi6220_thermal_get_temp(struct hisi_thermal_data *data)
+static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor)
 {
+	struct hisi_thermal_data *data = sensor->data;
+
 	return hi6220_thermal_get_temperature(data->regs);
 }
 
-static int hi3660_thermal_get_temp(struct hisi_thermal_data *data)
+static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor)
 {
-	return hi3660_thermal_get_temperature(data->regs, data->sensor.id);
+	struct hisi_thermal_data *data = sensor->data;
+
+	return hi3660_thermal_get_temperature(data->regs, sensor->id);
 }
 
-static int hi6220_thermal_disable_sensor(struct hisi_thermal_data *data)
+static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
 {
+	struct hisi_thermal_data *data = sensor->data;
+
 	/* disable sensor module */
 	hi6220_thermal_enable(data->regs, 0);
 	hi6220_thermal_alarm_enable(data->regs, 0);
@@ -307,16 +318,18 @@ static int hi6220_thermal_disable_sensor(struct hisi_thermal_data *data)
 	return 0;
 }
 
-static int hi3660_thermal_disable_sensor(struct hisi_thermal_data *data)
+static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
 {
+	struct hisi_thermal_data *data = sensor->data;
+
 	/* disable sensor module */
-	hi3660_thermal_alarm_enable(data->regs, data->sensor.id, 0);
+	hi3660_thermal_alarm_enable(data->regs, sensor->id, 0);
 	return 0;
 }
 
-static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data)
+static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
 {
-	struct hisi_thermal_sensor *sensor = &data->sensor;
+	struct hisi_thermal_data *data = sensor->data;
 	int ret;
 
 	/* enable clock for tsensor */
@@ -352,10 +365,10 @@ static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data)
 	return 0;
 }
 
-static int hi3660_thermal_enable_sensor(struct hisi_thermal_data *data)
+static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
 {
 	unsigned int value;
-	struct hisi_thermal_sensor *sensor = &data->sensor;
+	struct hisi_thermal_data *data = sensor->data;
 
 	/* disable interrupt */
 	hi3660_thermal_alarm_enable(data->regs, sensor->id, 0);
@@ -432,7 +445,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp)
 	struct hisi_thermal_data *data = __data;
 	struct hisi_thermal_sensor *sensor = &data->sensor;
 
-	*temp = data->ops->get_temp(data);
+	*temp = data->ops->get_temp(sensor);
 
 	dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n",
 		sensor->id, *temp, sensor->thres_temp);
@@ -450,7 +463,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 	struct hisi_thermal_sensor *sensor = &data->sensor;
 	int temp = 0;
 
-	data->ops->irq_handler(data);
+	data->ops->irq_handler(sensor);
 
 	hisi_thermal_get_temp(data, &temp);
 
@@ -470,10 +483,10 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 }
 
 static int hisi_thermal_register_sensor(struct platform_device *pdev,
-					struct hisi_thermal_data *data,
 					struct hisi_thermal_sensor *sensor)
 {
 	int ret, i;
+	struct hisi_thermal_data *data = sensor->data;
 	const struct thermal_trip *trip;
 
 	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
@@ -549,21 +562,20 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 
 	data->pdev = pdev;
 	platform_set_drvdata(pdev, data);
-
+	data->sensor.data = data;
 	data->ops = of_device_get_match_data(dev);
 
 	ret = data->ops->probe(data);
 	if (ret)
 		return ret;
 
-	ret = hisi_thermal_register_sensor(pdev, data,
-					   &data->sensor);
+	ret = hisi_thermal_register_sensor(pdev, &data->sensor);
 	if (ret) {
 		dev_err(dev, "failed to register thermal sensor: %d\n", ret);
 		return ret;
 	}
 
-	ret = data->ops->enable_sensor(data);
+	ret = data->ops->enable_sensor(&data->sensor);
 	if (ret) {
 		dev_err(dev, "Failed to setup the sensor: %d\n", ret);
 		return ret;
@@ -591,7 +603,7 @@ static int hisi_thermal_remove(struct platform_device *pdev)
 
 	hisi_thermal_toggle_sensor(sensor, false);
 
-	data->ops->disable_sensor(data);
+	data->ops->disable_sensor(&data->sensor);
 
 	return 0;
 }
@@ -601,7 +613,7 @@ static int hisi_thermal_suspend(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	data->ops->disable_sensor(data);
+	data->ops->disable_sensor(&data->sensor);
 
 	return 0;
 }
@@ -610,7 +622,7 @@ static int hisi_thermal_resume(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	return data->ops->enable_sensor(data);
+	return data->ops->enable_sensor(&data->sensor);
 }
 #endif
 
-- 
2.7.4


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

* [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
  2018-09-25  9:02 ` [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions Daniel Lezcano
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Store the sensor pointer in the thermal zone private data and use it
in the callback functions. That allows to continue the conversion to
sensor oriented code where the pointers are the sensors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 1fdda55..567fde6 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -442,8 +442,8 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 
 static int hisi_thermal_get_temp(void *__data, int *temp)
 {
-	struct hisi_thermal_data *data = __data;
-	struct hisi_thermal_sensor *sensor = &data->sensor;
+	struct hisi_thermal_sensor *sensor = __data;
+	struct hisi_thermal_data *data = sensor->data;
 
 	*temp = data->ops->get_temp(sensor);
 
@@ -465,7 +465,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 
 	data->ops->irq_handler(sensor);
 
-	hisi_thermal_get_temp(data, &temp);
+	hisi_thermal_get_temp(sensor, &temp);
 
 	if (temp >= sensor->thres_temp) {
 		dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n",
@@ -486,11 +486,10 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,
 					struct hisi_thermal_sensor *sensor)
 {
 	int ret, i;
-	struct hisi_thermal_data *data = sensor->data;
 	const struct thermal_trip *trip;
 
 	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
-							   sensor->id, data,
+							   sensor->id, sensor,
 							   &hisi_of_thermal_ops);
 	if (IS_ERR(sensor->tzd)) {
 		ret = PTR_ERR(sensor->tzd);
-- 
2.7.4


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

* [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (2 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Daniel Lezcano
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

The hi6220 and the hi3660 probe functions are doing almost the same
operations, they can share 90% of their code.

Factor out the probe functions by moving the common code in the common
probe function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 567fde6..7287818 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -391,16 +391,8 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 {
 	struct platform_device *pdev = data->pdev;
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	data->regs = devm_ioremap_resource(dev, res);
-	if (IS_ERR(data->regs)) {
-		dev_err(dev, "failed to get io address\n");
-		return PTR_ERR(data->regs);
-	}
-
 	data->clk = devm_clk_get(dev, "thermal_clk");
 	if (IS_ERR(data->clk)) {
 		ret = PTR_ERR(data->clk);
@@ -409,10 +401,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 		return ret;
 	}
 
-	data->irq = platform_get_irq(pdev, 0);
-	if (data->irq < 0)
-		return data->irq;
-
 	data->sensor.id = HI6220_DEFAULT_SENSOR;
 
 	return 0;
@@ -420,21 +408,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 
 static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 {
-	struct platform_device *pdev = data->pdev;
-	struct device *dev = &pdev->dev;
-	struct resource *res;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	data->regs = devm_ioremap_resource(dev, res);
-	if (IS_ERR(data->regs)) {
-		dev_err(dev, "failed to get io address\n");
-		return PTR_ERR(data->regs);
-	}
-
-	data->irq = platform_get_irq(pdev, 0);
-	if (data->irq < 0)
-		return data->irq;
-
 	data->sensor.id = HI3660_DEFAULT_SENSOR;
 
 	return 0;
@@ -553,6 +526,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 {
 	struct hisi_thermal_data *data;
 	struct device *dev = &pdev->dev;
+	struct resource *res;
 	int ret;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -564,6 +538,17 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 	data->sensor.data = data;
 	data->ops = of_device_get_match_data(dev);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	data->regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(data->regs)) {
+		dev_err(dev, "failed to get io address\n");
+		return PTR_ERR(data->regs);
+	}
+
+	data->irq = platform_get_irq(pdev, 0);
+	if (data->irq < 0)
+		return data->irq;
+
 	ret = data->ops->probe(data);
 	if (ret)
 		return ret;
-- 
2.7.4


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

* [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (3 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Daniel Lezcano
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Convert the 'sensor' field to a pointer and propagate the change in
the file. Havintg a pointer, gives us the opportunity to define
multiple sensors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 7287818..87b82fb 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -77,10 +77,11 @@ struct hisi_thermal_ops {
 
 struct hisi_thermal_data {
 	const struct hisi_thermal_ops *ops;
-	struct hisi_thermal_sensor sensor;
+	struct hisi_thermal_sensor *sensor;
 	struct platform_device *pdev;
 	struct clk *clk;
 	void __iomem *regs;
+	int nr_sensors;
 	int irq;
 };
 
@@ -401,14 +402,29 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 		return ret;
 	}
 
-	data->sensor.id = HI6220_DEFAULT_SENSOR;
+	data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL);
+	if (!data->sensor)
+		return -ENOMEM;
+
+	data->sensor[0].id = HI6220_DEFAULT_SENSOR;
+	data->sensor[0].data = data;
+	data->nr_sensors = 1;
 
 	return 0;
 }
 
 static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 {
-	data->sensor.id = HI3660_DEFAULT_SENSOR;
+	struct platform_device *pdev = data->pdev;
+	struct device *dev = &pdev->dev;
+
+	data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL);
+	if (!data->sensor)
+		return -ENOMEM;
+
+	data->sensor[0].id = HI3660_DEFAULT_SENSOR;
+	data->sensor[0].data = data;
+	data->nr_sensors = 1;
 
 	return 0;
 }
@@ -433,7 +449,7 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = {
 static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 {
 	struct hisi_thermal_data *data = dev;
-	struct hisi_thermal_sensor *sensor = &data->sensor;
+	struct hisi_thermal_sensor *sensor = &data->sensor[0];
 	int temp = 0;
 
 	data->ops->irq_handler(sensor);
@@ -444,7 +460,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 		dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n",
 			 temp, sensor->thres_temp);
 
-		thermal_zone_device_update(data->sensor.tzd,
+		thermal_zone_device_update(data->sensor[0].tzd,
 					   THERMAL_EVENT_UNSPECIFIED);
 
 	} else {
@@ -535,7 +551,6 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 
 	data->pdev = pdev;
 	platform_set_drvdata(pdev, data);
-	data->sensor.data = data;
 	data->ops = of_device_get_match_data(dev);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -553,13 +568,13 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = hisi_thermal_register_sensor(pdev, &data->sensor);
+	ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]);
 	if (ret) {
 		dev_err(dev, "failed to register thermal sensor: %d\n", ret);
 		return ret;
 	}
 
-	ret = data->ops->enable_sensor(&data->sensor);
+	ret = data->ops->enable_sensor(&data->sensor[0]);
 	if (ret) {
 		dev_err(dev, "Failed to setup the sensor: %d\n", ret);
 		return ret;
@@ -575,7 +590,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 		}
 	}
 
-	hisi_thermal_toggle_sensor(&data->sensor, true);
+	hisi_thermal_toggle_sensor(&data->sensor[0], true);
 
 	return 0;
 }
@@ -583,11 +598,11 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 static int hisi_thermal_remove(struct platform_device *pdev)
 {
 	struct hisi_thermal_data *data = platform_get_drvdata(pdev);
-	struct hisi_thermal_sensor *sensor = &data->sensor;
+	struct hisi_thermal_sensor *sensor = &data->sensor[0];
 
 	hisi_thermal_toggle_sensor(sensor, false);
 
-	data->ops->disable_sensor(&data->sensor);
+	data->ops->disable_sensor(sensor);
 
 	return 0;
 }
@@ -597,7 +612,7 @@ static int hisi_thermal_suspend(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	data->ops->disable_sensor(&data->sensor);
+	data->ops->disable_sensor(&data->sensor[0]);
 
 	return 0;
 }
@@ -606,7 +621,7 @@ static int hisi_thermal_resume(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
 
-	return data->ops->enable_sensor(&data->sensor);
+	return data->ops->enable_sensor(&data->sensor[0]);
 }
 #endif
 
-- 
2.7.4


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

* [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (4 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Daniel Lezcano
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Change the code as it is dealing with several sensors.

For git-bisect compatibility (compilation and booting), assume the DT
is not yet changed and we have a single interrupt.

Next changes will support multiple interrupt sorted by their name.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 79 +++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 87b82fb..a5756f6 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -448,8 +448,8 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = {
 
 static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 {
-	struct hisi_thermal_data *data = dev;
-	struct hisi_thermal_sensor *sensor = &data->sensor[0];
+	struct hisi_thermal_sensor *sensor = dev;
+	struct hisi_thermal_data *data = sensor->data;
 	int temp = 0;
 
 	data->ops->irq_handler(sensor);
@@ -457,15 +457,17 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
 	hisi_thermal_get_temp(sensor, &temp);
 
 	if (temp >= sensor->thres_temp) {
-		dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n",
-			 temp, sensor->thres_temp);
+		dev_crit(&data->pdev->dev,
+			 "sensor <%d> THERMAL ALARM: %d > %d\n",
+			 sensor->id, temp, sensor->thres_temp);
 
-		thermal_zone_device_update(data->sensor[0].tzd,
+		thermal_zone_device_update(sensor->tzd,
 					   THERMAL_EVENT_UNSPECIFIED);
 
 	} else {
-		dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n",
-			 temp, sensor->thres_temp);
+		dev_crit(&data->pdev->dev,
+			 "sensor <%d> THERMAL ALARM stopped: %d < %d\n",
+			 sensor->id, temp, sensor->thres_temp);
 	}
 
 	return IRQ_HANDLED;
@@ -543,7 +545,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 	struct hisi_thermal_data *data;
 	struct device *dev = &pdev->dev;
 	struct resource *res;
-	int ret;
+	int i, ret;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -560,37 +562,41 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 		return PTR_ERR(data->regs);
 	}
 
-	data->irq = platform_get_irq(pdev, 0);
-	if (data->irq < 0)
-		return data->irq;
-
 	ret = data->ops->probe(data);
 	if (ret)
 		return ret;
 
-	ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]);
-	if (ret) {
-		dev_err(dev, "failed to register thermal sensor: %d\n", ret);
-		return ret;
-	}
+	for (i = 0; i < data->nr_sensors; i++) {
+		struct hisi_thermal_sensor *sensor = &data->sensor[i];
 
-	ret = data->ops->enable_sensor(&data->sensor[0]);
-	if (ret) {
-		dev_err(dev, "Failed to setup the sensor: %d\n", ret);
-		return ret;
-	}
+		ret = hisi_thermal_register_sensor(pdev, sensor);
+		if (ret) {
+			dev_err(dev, "failed to register thermal sensor: %d\n",
+				ret);
+			return ret;
+		}
+
+		data->irq = platform_get_irq(pdev, 0);
+		if (data->irq < 0)
+			return data->irq;
 
-	if (data->irq) {
 		ret = devm_request_threaded_irq(dev, data->irq, NULL,
-				hisi_thermal_alarm_irq_thread,
-				IRQF_ONESHOT, "hisi_thermal", data);
+						hisi_thermal_alarm_irq_thread,
+						IRQF_ONESHOT, "hisi_thermal",
+						sensor);
 		if (ret < 0) {
 			dev_err(dev, "failed to request alarm irq: %d\n", ret);
 			return ret;
 		}
-	}
 
-	hisi_thermal_toggle_sensor(&data->sensor[0], true);
+		ret = data->ops->enable_sensor(sensor);
+		if (ret) {
+			dev_err(dev, "Failed to setup the sensor: %d\n", ret);
+			return ret;
+		}
+
+		hisi_thermal_toggle_sensor(sensor, true);
+	}
 
 	return 0;
 }
@@ -598,11 +604,14 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 static int hisi_thermal_remove(struct platform_device *pdev)
 {
 	struct hisi_thermal_data *data = platform_get_drvdata(pdev);
-	struct hisi_thermal_sensor *sensor = &data->sensor[0];
+	int i;
 
-	hisi_thermal_toggle_sensor(sensor, false);
+	for (i = 0; i < data->nr_sensors; i++) {
+		struct hisi_thermal_sensor *sensor = &data->sensor[i];
 
-	data->ops->disable_sensor(sensor);
+		hisi_thermal_toggle_sensor(sensor, false);
+		data->ops->disable_sensor(sensor);
+	}
 
 	return 0;
 }
@@ -611,8 +620,10 @@ static int hisi_thermal_remove(struct platform_device *pdev)
 static int hisi_thermal_suspend(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
+	int i;
 
-	data->ops->disable_sensor(&data->sensor[0]);
+	for (i = 0; i < data->nr_sensors; i++)
+		data->ops->disable_sensor(&data->sensor[i]);
 
 	return 0;
 }
@@ -620,8 +631,12 @@ static int hisi_thermal_suspend(struct device *dev)
 static int hisi_thermal_resume(struct device *dev)
 {
 	struct hisi_thermal_data *data = dev_get_drvdata(dev);
+	int i, ret = 0;
+
+	for (i = 0; i < data->nr_sensors; i++)
+		ret |= data->ops->enable_sensor(&data->sensor[i]);
 
-	return data->ops->enable_sensor(&data->sensor[0]);
+	return ret;
 }
 #endif
 
-- 
2.7.4


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

* [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (5 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Daniel Lezcano
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Change the macro name in order to give a better indication of the
sensor location.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index a5756f6..a542cb3 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -55,8 +55,8 @@
 #define HI3660_TEMP_STEP		(205)
 #define HI3660_TEMP_LAG			(4000)
 
-#define HI6220_DEFAULT_SENSOR		2
-#define HI3660_DEFAULT_SENSOR		1
+#define HI6220_CLUSTER0_SENSOR		2
+#define HI3660_BIG_SENSOR		1
 
 struct hisi_thermal_data;
 
@@ -406,7 +406,7 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 	if (!data->sensor)
 		return -ENOMEM;
 
-	data->sensor[0].id = HI6220_DEFAULT_SENSOR;
+	data->sensor[0].id = HI6220_CLUSTER0_SENSOR;
 	data->sensor[0].data = data;
 	data->nr_sensors = 1;
 
@@ -422,7 +422,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 	if (!data->sensor)
 		return -ENOMEM;
 
-	data->sensor[0].id = HI3660_DEFAULT_SENSOR;
+	data->sensor[0].id = HI3660_BIG_SENSOR;
 	data->sensor[0].data = data;
 	data->nr_sensors = 1;
 
-- 
2.7.4


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

* [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (6 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-10-15 16:28   ` Rob Herring
  2018-09-25  9:03 ` [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname Daniel Lezcano
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval
  Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui,
	Rob Herring, Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT

Add the interrupt names for the sensors, so the code can rely on them
instead of dealing with index which are prone to error.

The name comes from the Hisilicon documentation found on internet.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 .../bindings/thermal/hisilicon-thermal.txt         |  3 ++
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi          | 63 +++++++++++-----------
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  1 +
 3 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
index cef716a..3edfae3 100644
--- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
@@ -7,6 +7,7 @@
   region.
 - interrupt: The interrupt number to the cpu. Defines the interrupt used
   by /SOCTHERM/tsensor.
+- interrupt-names: The interrupt names for the different sensors
 - clock-names: Input clock name, should be 'thermal_clk'.
 - clocks: phandles for clock specified in "clock-names" property.
 - #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
@@ -18,6 +19,7 @@ for Hi6220:
 		compatible = "hisilicon,tsensor";
 		reg = <0x0 0xf7030700 0x0 0x1000>;
 		interrupts = <0 7 0x4>;
+		interrupt-names = "tsensor_intr";
 		clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
 		clock-names = "thermal_clk";
 		#thermal-sensor-cells = <1>;
@@ -28,5 +30,6 @@ for Hi3660:
 		compatible = "hisilicon,hi3660-tsensor";
 		reg = <0x0 0xfff30000 0x0 0x1000>;
 		interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tsensor_a73";
 		#thermal-sensor-cells = <1>;
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index f432b0a..bf8a479 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -1081,46 +1081,47 @@
 			compatible = "hisilicon,hi3660-tsensor";
 			reg = <0x0 0xfff30000 0x0 0x1000>;
 			interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tsensor_a73";
 			#thermal-sensor-cells = <1>;
 		};
 
-		thermal-zones {
+                thermal-zones {
 
-			cls0: cls0 {
-				polling-delay = <1000>;
-				polling-delay-passive = <100>;
-				sustainable-power = <4500>;
+                        cls0: cls0 {
+                                polling-delay = <1000>;
+                                polling-delay-passive = <100>;
+                                sustainable-power = <4500>;
 
-				/* sensor ID */
-				thermal-sensors = <&tsensor 1>;
+                                /* sensor ID */
+                                thermal-sensors = <&tsensor 1>;
 
-				trips {
-					threshold: trip-point@0 {
-						temperature = <65000>;
-						hysteresis = <1000>;
-						type = "passive";
-					};
+                                trips {
+                                        threshold: trip-point@0 {
+                                                temperature = <65000>;
+                                                hysteresis = <1000>;
+                                                type = "passive";
+                                        };
 
-					target: trip-point@1 {
-						temperature = <75000>;
-						hysteresis = <1000>;
-						type = "passive";
-					};
-				};
+                                        target: trip-point@1 {
+                                                temperature = <75000>;
+                                                hysteresis = <1000>;
+                                                type = "passive";
+                                        };
+                                };
 
-				cooling-maps {
+                                cooling-maps {
 					map0 {
-						trip = <&target>;
-						contribution = <1024>;
-						cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
-					};
+                                                trip = <&target>;
+                                                contribution = <1024>;
+                                                cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+                                        };
 					map1 {
-						trip = <&target>;
-						contribution = <512>;
-						cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
-					};
-				};
-			};
-		};
+                                                trip = <&target>;
+                                                contribution = <512>;
+                                                cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+                                        };
+                                };
+                        };
+                };
 	};
 };
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
index 247024d..9eae986 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi
@@ -841,6 +841,7 @@
 			compatible = "hisilicon,tsensor";
 			reg = <0x0 0xf7030700 0x0 0x1000>;
 			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tsensor_intr";
 			clocks = <&sys_ctrl 22>;
 			clock-names = "thermal_clk";
 			#thermal-sensor-cells = <1>;
-- 
2.7.4


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

* [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (7 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Daniel Lezcano
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

As we have the interrupt names defines, replace platform_get_irq() by
platform_get_irq_byname(), so no confusion can be made when getting
the interrupt with the sensor id.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index a542cb3..941c2c4 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -63,6 +63,7 @@ struct hisi_thermal_data;
 struct hisi_thermal_sensor {
 	struct hisi_thermal_data *data;
 	struct thermal_zone_device *tzd;
+	const char *irq_name;
 	uint32_t id;
 	uint32_t thres_temp;
 };
@@ -407,6 +408,7 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
 		return -ENOMEM;
 
 	data->sensor[0].id = HI6220_CLUSTER0_SENSOR;
+	data->sensor[0].irq_name = "tsensor_intr";
 	data->sensor[0].data = data;
 	data->nr_sensors = 1;
 
@@ -423,6 +425,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 		return -ENOMEM;
 
 	data->sensor[0].id = HI3660_BIG_SENSOR;
+	data->sensor[0].irq_name = "tsensor_a73";
 	data->sensor[0].data = data;
 	data->nr_sensors = 1;
 
@@ -576,13 +579,13 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 			return ret;
 		}
 
-		data->irq = platform_get_irq(pdev, 0);
+		data->irq = platform_get_irq_byname(pdev, sensor->irq_name);
 		if (data->irq < 0)
 			return data->irq;
 
 		ret = devm_request_threaded_irq(dev, data->irq, NULL,
 						hisi_thermal_alarm_irq_thread,
-						IRQF_ONESHOT, "hisi_thermal",
+						IRQF_ONESHOT, sensor->irq_name,
 						sensor);
 		if (ret < 0) {
 			dev_err(dev, "failed to request alarm irq: %d\n", ret);
-- 
2.7.4


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

* [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (8 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-10-15 16:31   ` Rob Herring
  2018-09-25  9:03 ` [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field Daniel Lezcano
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval
  Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui,
	Rob Herring, Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT

Add the missing interrupts for the temperature sensors as well as
their names.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi                       | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
index 3edfae3..4cb8add 100644
--- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
@@ -29,7 +29,11 @@ for Hi3660:
 	tsensor: tsensor@fff30000 {
 		compatible = "hisilicon,hi3660-tsensor";
 		reg = <0x0 0xfff30000 0x0 0x1000>;
-		interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
-		interrupt-names = "tsensor_a73";
+		interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tsensor_a73", "tsensor_a53",
+				  "tsensor_g3d", "tsensor_modem";
 		#thermal-sensor-cells = <1>;
 	};
diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index bf8a479..dd398cb 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -1080,8 +1080,12 @@
 		tsensor: tsensor@fff30000 {
 			compatible = "hisilicon,hi3660-tsensor";
 			reg = <0x0 0xfff30000 0x0 0x1000>;
-			interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
-			interrupt-names = "tsensor_a73";
+			interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>,
+			             <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>,
+			             <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>,
+			             <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "tsensor_a73", "tsensor_a53",
+			                  "tsensor_g3d", "tsensor_modem";
 			#thermal-sensor-cells = <1>;
 		};
 
-- 
2.7.4


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

* [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (9 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel Daniel Lezcano
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

The irq field in the data structure is pointless as the scope of its
usage is just to request the interrupt. It can be replaced by a local
variable.

Use the 'ret' variable to get the interrupt number.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 941c2c4..87d8a13 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -83,7 +83,6 @@ struct hisi_thermal_data {
 	struct clk *clk;
 	void __iomem *regs;
 	int nr_sensors;
-	int irq;
 };
 
 /*
@@ -579,16 +578,16 @@ static int hisi_thermal_probe(struct platform_device *pdev)
 			return ret;
 		}
 
-		data->irq = platform_get_irq_byname(pdev, sensor->irq_name);
-		if (data->irq < 0)
-			return data->irq;
+		ret = platform_get_irq_byname(pdev, sensor->irq_name);
+		if (ret < 0)
+			return ret;
 
-		ret = devm_request_threaded_irq(dev, data->irq, NULL,
+		ret = devm_request_threaded_irq(dev, ret, NULL,
 						hisi_thermal_alarm_irq_thread,
 						IRQF_ONESHOT, sensor->irq_name,
 						sensor);
 		if (ret < 0) {
-			dev_err(dev, "failed to request alarm irq: %d\n", ret);
+			dev_err(dev, "Failed to request alarm irq: %d\n", ret);
 			return ret;
 		}
 
-- 
2.7.4


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

* [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (10 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors " Daniel Lezcano
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

Add the sensor channels id for the little, g3d and modem.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 87d8a13..ba89cb9 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -56,7 +56,12 @@
 #define HI3660_TEMP_LAG			(4000)
 
 #define HI6220_CLUSTER0_SENSOR		2
+#define HI6220_CLUSTER1_SENSOR		1
+
+#define HI3660_LITTLE_SENSOR		0
 #define HI3660_BIG_SENSOR		1
+#define HI3660_G3D_SENSOR		2
+#define HI3660_MODEM_SENSOR		3
 
 struct hisi_thermal_data;
 
-- 
2.7.4


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

* [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (11 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  2018-09-25  9:03 ` [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors " Daniel Lezcano
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval
  Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Wei Xu,
	Rob Herring, Mark Rutland,
	moderated list:ARM/HISILICON SOC SUPPORT,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS

Add a thermal zone for the little cluster, so we can handle two
sensors managing each a cluster on the SoC.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 97 ++++++++++++++++++++-----------
 1 file changed, 63 insertions(+), 34 deletions(-)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index dd398cb..6df7d9f 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -1090,42 +1090,71 @@
 		};
 
                 thermal-zones {
+			tz_a53: tz_a53 {
+				polling-delay = <1000>;
+				polling-delay-passive = <100>;
+				sustainable-power = <4500>;
+
+				/* sensor ID */
+				thermal-sensors = <&tsensor 0>;
+
+				trips {
+					a53_temp_threshold: trip-point@0 {
+						temperature = <65000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+
+					a53_temp_target: trip-point@1 {
+						temperature = <75000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+				};
 
-                        cls0: cls0 {
-                                polling-delay = <1000>;
-                                polling-delay-passive = <100>;
-                                sustainable-power = <4500>;
-
-                                /* sensor ID */
-                                thermal-sensors = <&tsensor 1>;
-
-                                trips {
-                                        threshold: trip-point@0 {
-                                                temperature = <65000>;
-                                                hysteresis = <1000>;
-                                                type = "passive";
-                                        };
-
-                                        target: trip-point@1 {
-                                                temperature = <75000>;
-                                                hysteresis = <1000>;
-                                                type = "passive";
-                                        };
-                                };
-
-                                cooling-maps {
+				cooling-maps {
 					map0 {
-                                                trip = <&target>;
-                                                contribution = <1024>;
-                                                cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
-                                        };
-					map1 {
-                                                trip = <&target>;
-                                                contribution = <512>;
-                                                cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
-                                        };
-                                };
-                        };
+						trip = <&a53_temp_target>;
+						contribution = <512>;
+						cooling-device = <&cpu0
+							THERMAL_NO_LIMIT
+							THERMAL_NO_LIMIT>;
+					};
+				};
+			};
+
+			tz_a73: tz_a73 {
+				polling-delay = <1000>;
+				polling-delay-passive = <100>;
+				sustainable-power = <4500>;
+
+				/* sensor ID */
+				thermal-sensors = <&tsensor 1>;
+
+				trips {
+					a73_temp_threshold: trip-point@0 {
+						temperature = <65000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+
+					a73_temp_target: trip-point@1 {
+						temperature = <75000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+				};
+
+				cooling-maps {
+					map0 {
+						trip = <&a73_temp_target>;
+						contribution = <1024>;
+						cooling-device = <&cpu4
+							THERMAL_NO_LIMIT
+							THERMAL_NO_LIMIT>;
+					};
+				};
+			};
                 };
 	};
 };
-- 
2.7.4


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

* [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors for hi3660
  2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
                   ` (12 preceding siblings ...)
  2018-09-25  9:03 ` [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Daniel Lezcano
@ 2018-09-25  9:03 ` Daniel Lezcano
  13 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-09-25  9:03 UTC (permalink / raw)
  To: edubezval; +Cc: linux-kernel, linux-pm, daniel.lezcano, leo.yan, Zhang Rui

The code is ready to support multiple sensors on the hi3660. The DT
defines a thermal zone per cluster.

Add the little cluster sensor and let it bind with the thermal zone.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/hisi_thermal.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index ba89cb9..c4111a9 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -424,14 +424,20 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
 	struct platform_device *pdev = data->pdev;
 	struct device *dev = &pdev->dev;
 
-	data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL);
+	data->nr_sensors = 2;
+
+	data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) *
+				    data->nr_sensors, GFP_KERNEL);
 	if (!data->sensor)
 		return -ENOMEM;
 
 	data->sensor[0].id = HI3660_BIG_SENSOR;
 	data->sensor[0].irq_name = "tsensor_a73";
 	data->sensor[0].data = data;
-	data->nr_sensors = 1;
+
+	data->sensor[1].id = HI3660_LITTLE_SENSOR;
+	data->sensor[1].irq_name = "tsensor_a53";
+	data->sensor[1].data = data;
 
 	return 0;
 }
@@ -443,8 +449,8 @@ static int hisi_thermal_get_temp(void *__data, int *temp)
 
 	*temp = data->ops->get_temp(sensor);
 
-	dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n",
-		sensor->id, *temp, sensor->thres_temp);
+	dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n",
+		sensor->tzd, sensor->id, *temp, sensor->thres_temp);
 
 	return 0;
 }
-- 
2.7.4


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

* Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name
  2018-09-25  9:03 ` [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Daniel Lezcano
@ 2018-10-15 16:28   ` Rob Herring
  2018-10-15 18:01     ` Daniel Lezcano
  0 siblings, 1 reply; 21+ messages in thread
From: Rob Herring @ 2018-10-15 16:28 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: edubezval, linux-kernel, linux-pm, leo.yan, Zhang Rui,
	Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT

On Tue, Sep 25, 2018 at 11:03:06AM +0200, Daniel Lezcano wrote:
> Add the interrupt names for the sensors, so the code can rely on them
> instead of dealing with index which are prone to error.
> 
> The name comes from the Hisilicon documentation found on internet.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  .../bindings/thermal/hisilicon-thermal.txt         |  3 ++
>  arch/arm64/boot/dts/hisilicon/hi3660.dtsi          | 63 +++++++++++-----------
>  arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  1 +
>  3 files changed, 36 insertions(+), 31 deletions(-)

Lots of whitespace errors reported by checkpatch.pl.

> 
> diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
> index cef716a..3edfae3 100644
> --- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
> @@ -7,6 +7,7 @@
>    region.
>  - interrupt: The interrupt number to the cpu. Defines the interrupt used
>    by /SOCTHERM/tsensor.
> +- interrupt-names: The interrupt names for the different sensors

Need to define what the names are.

>  - clock-names: Input clock name, should be 'thermal_clk'.
>  - clocks: phandles for clock specified in "clock-names" property.
>  - #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
> @@ -18,6 +19,7 @@ for Hi6220:
>  		compatible = "hisilicon,tsensor";
>  		reg = <0x0 0xf7030700 0x0 0x1000>;
>  		interrupts = <0 7 0x4>;
> +		interrupt-names = "tsensor_intr";

That name seems pretty pointless.

>  		clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
>  		clock-names = "thermal_clk";
>  		#thermal-sensor-cells = <1>;
> @@ -28,5 +30,6 @@ for Hi3660:
>  		compatible = "hisilicon,hi3660-tsensor";
>  		reg = <0x0 0xfff30000 0x0 0x1000>;
>  		interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-names = "tsensor_a73";

Just 'a73' is sufficient.

>  		#thermal-sensor-cells = <1>;
>  	};

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

* Re: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors
  2018-09-25  9:03 ` [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Daniel Lezcano
@ 2018-10-15 16:31   ` Rob Herring
  2018-10-15 18:01     ` Daniel Lezcano
  0 siblings, 1 reply; 21+ messages in thread
From: Rob Herring @ 2018-10-15 16:31 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: edubezval, linux-kernel, linux-pm, leo.yan, Zhang Rui,
	Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT

On Tue, Sep 25, 2018 at 11:03:08AM +0200, Daniel Lezcano wrote:
> Add the missing interrupts for the temperature sensors as well as
> their names.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--

Combine this and the previous binding change to 1 patch.

>  arch/arm64/boot/dts/hisilicon/hi3660.dtsi                       | 8 ++++++--
>  2 files changed, 12 insertions(+), 4 deletions(-)

And more checkpatch whitespace errors in this.

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

* Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name
  2018-10-15 16:28   ` Rob Herring
@ 2018-10-15 18:01     ` Daniel Lezcano
  2018-10-16 14:44       ` Rob Herring
  0 siblings, 1 reply; 21+ messages in thread
From: Daniel Lezcano @ 2018-10-15 18:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: edubezval, linux-kernel, linux-pm, leo.yan, Zhang Rui,
	Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT


Hi Rob,

thanks for the review.

On 15/10/2018 18:28, Rob Herring wrote:
> On Tue, Sep 25, 2018 at 11:03:06AM +0200, Daniel Lezcano wrote:
>> Add the interrupt names for the sensors, so the code can rely on them
>> instead of dealing with index which are prone to error.
>>
>> The name comes from the Hisilicon documentation found on internet.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
>>  .../bindings/thermal/hisilicon-thermal.txt         |  3 ++
>>  arch/arm64/boot/dts/hisilicon/hi3660.dtsi          | 63 +++++++++++-----------
>>  arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  1 +
>>  3 files changed, 36 insertions(+), 31 deletions(-)
> 
> Lots of whitespace errors reported by checkpatch.pl.

Yeah, I don't know why but I have something bad with my emacs
configuration when changing DT files. Will look at this.

>> diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
>> index cef716a..3edfae3 100644
>> --- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
>> +++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt
>> @@ -7,6 +7,7 @@
>>    region.
>>  - interrupt: The interrupt number to the cpu. Defines the interrupt used
>>    by /SOCTHERM/tsensor.
>> +- interrupt-names: The interrupt names for the different sensors
> 
> Need to define what the names are.
> 
>>  - clock-names: Input clock name, should be 'thermal_clk'.
>>  - clocks: phandles for clock specified in "clock-names" property.
>>  - #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
>> @@ -18,6 +19,7 @@ for Hi6220:
>>  		compatible = "hisilicon,tsensor";
>>  		reg = <0x0 0xf7030700 0x0 0x1000>;
>>  		interrupts = <0 7 0x4>;
>> +		interrupt-names = "tsensor_intr";
> 
> That name seems pretty pointless.
> 
>>  		clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
>>  		clock-names = "thermal_clk";
>>  		#thermal-sensor-cells = <1>;
>> @@ -28,5 +30,6 @@ for Hi3660:
>>  		compatible = "hisilicon,hi3660-tsensor";
>>  		reg = <0x0 0xfff30000 0x0 0x1000>;
>>  		interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
>> +		interrupt-names = "tsensor_a73";
> 
> Just 'a73' is sufficient.

This is the name defined in the board documentation to give a name to
the interrupt when requesting it. This one appears in /proc/interrupts.

I can replace the 'tsensor_intr' by 'tsensor', but if 'tsensor_a73' is
replaced by 'a73' that may looks odd in /proc/interrupts to see an
interrupts line with the 'a73' name.

However this is the preparation for the multiple sensors support so we
will have more interrupt names.

Is it possible to keep these names ?

 - tsensor
 - tsensor_a73
 - tsensor_a57
 - tsensor_gpu




-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors
  2018-10-15 16:31   ` Rob Herring
@ 2018-10-15 18:01     ` Daniel Lezcano
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-10-15 18:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: edubezval, linux-kernel, linux-pm, leo.yan, Zhang Rui,
	Mark Rutland, Wei Xu,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/HISILICON SOC SUPPORT

On 15/10/2018 18:31, Rob Herring wrote:
> On Tue, Sep 25, 2018 at 11:03:08AM +0200, Daniel Lezcano wrote:
>> Add the missing interrupts for the temperature sensors as well as
>> their names.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
>>  Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--
> 
> Combine this and the previous binding change to 1 patch.

Ok.

>>  arch/arm64/boot/dts/hisilicon/hi3660.dtsi                       | 8 ++++++--
>>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> And more checkpatch whitespace errors in this.
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name
  2018-10-15 18:01     ` Daniel Lezcano
@ 2018-10-16 14:44       ` Rob Herring
  2018-10-16 15:12         ` Daniel Lezcano
  0 siblings, 1 reply; 21+ messages in thread
From: Rob Herring @ 2018-10-16 14:44 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Eduardo Valentin, linux-kernel, open list:THERMAL, Leo Yan,
	Zhang Rui, Mark Rutland, Wei Xu, devicetree,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Mon, Oct 15, 2018 at 1:01 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
>
> Hi Rob,
>
> thanks for the review.
>
> On 15/10/2018 18:28, Rob Herring wrote:
> > On Tue, Sep 25, 2018 at 11:03:06AM +0200, Daniel Lezcano wrote:
> >> Add the interrupt names for the sensors, so the code can rely on them
> >> instead of dealing with index which are prone to error.

[...]

> >> +            interrupt-names = "tsensor_intr";
> >
> > That name seems pretty pointless.
> >
> >>              clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
> >>              clock-names = "thermal_clk";
> >>              #thermal-sensor-cells = <1>;
> >> @@ -28,5 +30,6 @@ for Hi3660:
> >>              compatible = "hisilicon,hi3660-tsensor";
> >>              reg = <0x0 0xfff30000 0x0 0x1000>;
> >>              interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
> >> +            interrupt-names = "tsensor_a73";
> >
> > Just 'a73' is sufficient.
>
> This is the name defined in the board documentation to give a name to
> the interrupt when requesting it. This one appears in /proc/interrupts.
>
> I can replace the 'tsensor_intr' by 'tsensor', but if 'tsensor_a73' is
> replaced by 'a73' that may looks odd in /proc/interrupts to see an
> interrupts line with the 'a73' name.

Sounds like a Linux problem, not DT...

The thing is that any *-names property is supposed to be a local to
block name. For example, a UART may have a TX irq. It's local name is
just "TX IRQ", but then upstream at the interrupt controller it may be
"UART1 TX IRQ". If you have multiple instances, the local names are
the same.

If we lose the node name from /proc/interrupts when interrupt-names is
used, then we should fix that.

>
> However this is the preparation for the multiple sensors support so we
> will have more interrupt names.
>
> Is it possible to keep these names ?
>
>  - tsensor
>  - tsensor_a73
>  - tsensor_a57
>  - tsensor_gpu
>
>
>
>
> --
>  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
>

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

* Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name
  2018-10-16 14:44       ` Rob Herring
@ 2018-10-16 15:12         ` Daniel Lezcano
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2018-10-16 15:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: Eduardo Valentin, linux-kernel, open list:THERMAL, Leo Yan,
	Zhang Rui, Mark Rutland, Wei Xu, devicetree,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On 16/10/2018 16:44, Rob Herring wrote:
> On Mon, Oct 15, 2018 at 1:01 PM Daniel Lezcano
> <daniel.lezcano@linaro.org> wrote:
>>
>>
>> Hi Rob,
>>
>> thanks for the review.
>>
>> On 15/10/2018 18:28, Rob Herring wrote:
>>> On Tue, Sep 25, 2018 at 11:03:06AM +0200, Daniel Lezcano wrote:
>>>> Add the interrupt names for the sensors, so the code can rely on them
>>>> instead of dealing with index which are prone to error.
> 
> [...]
> 
>>>> +            interrupt-names = "tsensor_intr";
>>>
>>> That name seems pretty pointless.
>>>
>>>>              clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
>>>>              clock-names = "thermal_clk";
>>>>              #thermal-sensor-cells = <1>;
>>>> @@ -28,5 +30,6 @@ for Hi3660:
>>>>              compatible = "hisilicon,hi3660-tsensor";
>>>>              reg = <0x0 0xfff30000 0x0 0x1000>;
>>>>              interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
>>>> +            interrupt-names = "tsensor_a73";
>>>
>>> Just 'a73' is sufficient.
>>
>> This is the name defined in the board documentation to give a name to
>> the interrupt when requesting it. This one appears in /proc/interrupts.
>>
>> I can replace the 'tsensor_intr' by 'tsensor', but if 'tsensor_a73' is
>> replaced by 'a73' that may looks odd in /proc/interrupts to see an
>> interrupts line with the 'a73' name.
> 
> Sounds like a Linux problem, not DT...
> 
> The thing is that any *-names property is supposed to be a local to
> block name. For example, a UART may have a TX irq. It's local name is
> just "TX IRQ", but then upstream at the interrupt controller it may be
> "UART1 TX IRQ". If you have multiple instances, the local names are
> the same.
> 
> If we lose the node name from /proc/interrupts when interrupt-names is
> used, then we should fix that.

Ah, ok. It makes more sense for me now. Thanks for the explanation, .


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

end of thread, other threads:[~2018-10-16 15:12 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25  9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
2018-09-25  9:02 ` [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Daniel Lezcano
2018-09-25  9:03 ` [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented Daniel Lezcano
2018-09-25  9:03 ` [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer Daniel Lezcano
2018-09-25  9:03 ` [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions Daniel Lezcano
2018-09-25  9:03 ` [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Daniel Lezcano
2018-09-25  9:03 ` [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Daniel Lezcano
2018-09-25  9:03 ` [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Daniel Lezcano
2018-09-25  9:03 ` [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Daniel Lezcano
2018-10-15 16:28   ` Rob Herring
2018-10-15 18:01     ` Daniel Lezcano
2018-10-16 14:44       ` Rob Herring
2018-10-16 15:12         ` Daniel Lezcano
2018-09-25  9:03 ` [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname Daniel Lezcano
2018-09-25  9:03 ` [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Daniel Lezcano
2018-10-15 16:31   ` Rob Herring
2018-10-15 18:01     ` Daniel Lezcano
2018-09-25  9:03 ` [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field Daniel Lezcano
2018-09-25  9:03 ` [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel Daniel Lezcano
2018-09-25  9:03 ` [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Daniel Lezcano
2018-09-25  9:03 ` [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors " Daniel Lezcano

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