Skip to contentSkip to conversation

thermal/drivers/hi3660: Dual cluster sensors support

PATCH In review Daniel Lezcano 2 participants 21 messages Sep 25, 2018 – Oct 16, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover thermal/drivers/hi3660: Dual cluster sensors support

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(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/14 thermal/drivers/hisi: Change the platform data pointer to sensor ops

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.

---
 drivers/thermal/hisi_thermal.c | 60 ++++++++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 26 deletions(-)
drivers/thermal/hisi_thermal.c +34 -26
index 761d055..9794cfe 100644
@@ -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
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/14 thermal/drivers/hisi: Change the driver to be sensor oriented

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 72 ++++++++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 30 deletions(-)
drivers/thermal/hisi_thermal.c +42 -30
index 9794cfe..1fdda55 100644
@@ -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
 
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/14 thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/thermal/hisi_thermal.c +4 -5
index 1fdda55..567fde6 100644
@@ -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);
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/14 thermal/drivers/hisi: Factor out the probe functions

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)
drivers/thermal/hisi_thermal.c +12 -27
index 567fde6..7287818 100644
@@ -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;
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/14 thermal/drivers/hisi: Prepare to support multiple sensors

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)
drivers/thermal/hisi_thermal.c +28 -13
index 7287818..87b82fb 100644
@@ -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
 
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/14 thermal/drivers/hisi: Add multiple sensors support

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 79 +++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 32 deletions(-)
drivers/thermal/hisi_thermal.c +47 -32
index 87b82fb..a5756f6 100644
@@ -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
 
Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/14 thermal/drivers/hisi: Replace macro name with relevant sensor location

In reply to Daniel Lezcano

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

---
 drivers/thermal/hisi_thermal.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/hisi_thermal.c +4 -4
index a5756f6..a542cb3 100644
@@ -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;
 
Signature · 1 line
2.7.4
#8 lore raw

PATCH 8/14 ARM64: dts: hisilicon: Add tsensor interrupt name

In reply to Daniel Lezcano

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.

---
 .../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(-)
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +3 -0
index cef716a..3edfae3 100644
@@ -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>;
 	};
arch/arm64/boot/dts/hisilicon/hi3660.dtsi +32 -31

78 lines not on this page · raw message

arch/arm64/boot/dts/hisilicon/hi6220.dtsi +1 -0
index 247024d..9eae986 100644
@@ -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>;
Signature · 1 line
2.7.4
maintainer
#9 lore raw

Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name

Quoted 11 lines · Daniel Lezcano

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.

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

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
index cef716a..3edfae3 100644
@@ -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.

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi6220: · line 22

Quoted 8 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
 - 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.

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi3660: · line 33

Quoted 8 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
 		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.

Quoted 2 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +0 -0
 		#thermal-sensor-cells = <1>;
 	};
#10 lore raw

Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name

Hi Rob,

thanks for the review.

Quoted 6 lines · Rob Herring
Quoted 5 lines · Daniel Lezcano

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.

Quoted 8 lines
Quoted 6 lines
---
 .../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.

Quoted 23 lines

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt line 10

Quoted 9 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
index cef716a..3edfae3 100644
@@ -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.

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi6220: · line 22

Quoted 8 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
 - 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.

Quoted 10 lines

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi3660: · line 33

Quoted 8 lines
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
 		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

Signature · 5 lines
 <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
maintainer
#11 lore raw

Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name

Quoted 10 lines · Daniel Lezcano

Hi Rob,

thanks for the review.

Quoted 3 lines · Rob Herring
Quoted 2 lines · Daniel Lezcano

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

[...]

Quoted 15 lines
Quoted 4 lines
Quoted 1 line

+ interrupt-names = "tsensor_intr";

That name seems pretty pointless.

Quoted 10 lines

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi3660: · line 33

Quoted 8 lines
             clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
             clock-names = "thermal_clk";
             #thermal-sensor-cells = <1>;
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
@@ -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.

Quoted 6 lines

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.

Quoted 21 lines

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

#12 lore raw

Re: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name

Quoted 39 lines · Rob Herring
Quoted 10 lines · Daniel Lezcano

Hi Rob,

thanks for the review.

Quoted 3 lines · Rob Herring
Quoted 2 lines · Daniel Lezcano

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

[...]

Quoted 15 lines
Quoted 4 lines
Quoted 1 line

+ interrupt-names = "tsensor_intr";

That name seems pretty pointless.

Quoted 10 lines

Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt for Hi3660: · line 33

Quoted 8 lines
             clocks = <&sys_ctrl HI6220_TSENSOR_CLK>;
             clock-names = "thermal_clk";
             #thermal-sensor-cells = <1>;
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +1 -0
@@ -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.

Quoted 6 lines

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

Quoted 8 lines

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

Signature · 5 lines
 <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
#13 lore raw

PATCH 9/14 thermal/drivers/hisi: Use platform_get_irq_byname

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/thermal/hisi_thermal.c +5 -2
index a542cb3..941c2c4 100644
@@ -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);
Signature · 1 line
2.7.4
#14 lore raw

PATCH 10/14 ARM64: dts: hisilicon: Add interrupt names for the tsensors

In reply to Daniel Lezcano

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

---
 Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi                       | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +6 -2
index 3edfae3..4cb8add 100644
@@ -29,7 +29,11 @@ for Hi3660:
 	tsensor: tsensor at 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>;
 	};
arch/arm64/boot/dts/hisilicon/hi3660.dtsi +6 -2
index bf8a479..dd398cb 100644
@@ -1080,8 +1080,12 @@
 		tsensor: tsensor at 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>;
 		};
 
Signature · 1 line
2.7.4
maintainer
#15 lore raw

Re: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors

Quoted 6 lines · Daniel Lezcano

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

---
 Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--

Combine this and the previous binding change to 1 patch.

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

And more checkpatch whitespace errors in this.

#16 lore raw

Re: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors

Quoted 9 lines · Rob Herring
Quoted 6 lines · Daniel Lezcano

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

---
 Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++--

Combine this and the previous binding change to 1 patch.

Ok.

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

And more checkpatch whitespace errors in this.

Signature · 5 lines
 <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
#17 lore raw

PATCH 11/14 thermal/drivers/hisi: Remove pointless irq field

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/thermal/hisi_thermal.c +5 -6
index 941c2c4..87d8a13 100644
@@ -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;
 		}
 
Signature · 1 line
2.7.4
#18 lore raw

PATCH 12/14 thermal/drivers/hisi: Add more sensors channel

In reply to Daniel Lezcano

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

---
 drivers/thermal/hisi_thermal.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/thermal/hisi_thermal.c +5 -0
index 87d8a13..ba89cb9 100644
@@ -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;
 
Signature · 1 line
2.7.4
#19 lore raw

PATCH 13/14 ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660

In reply to Daniel Lezcano

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

---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 97 ++++++++++++++++++++-----------
 1 file changed, 63 insertions(+), 34 deletions(-)
arch/arm64/boot/dts/hisilicon/hi3660.dtsi +63 -34
index dd398cb..6df7d9f 100644
@@ -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 at 0 {
+						temperature = <65000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+
+					a53_temp_target: trip-point at 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 at 0 {
-                                                temperature = <65000>;
-                                                hysteresis = <1000>;
-                                                type = "passive";
-                                        };
-
-                                        target: trip-point at 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 at 0 {
+						temperature = <65000>;
+						hysteresis = <1000>;
+						type = "passive";
+					};
+
+					a73_temp_target: trip-point at 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>;
+					};
+				};
+			};
                 };
 	};
 };
Signature · 1 line
2.7.4
#20 lore raw

PATCH 14/14 thermal/drivers/hisi: Add the dual clusters sensors for hi3660

In reply to Daniel Lezcano

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.

---
 drivers/thermal/hisi_thermal.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/thermal/hisi_thermal.c +10 -4
index ba89cb9..c4111a9 100644
@@ -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;
 }
Signature · 1 line
2.7.4