Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1670234 > unrolled thread

[PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

Started byTao Wang <kevin.wangtao@hisilicon.com>
First post2017-06-20 05:50 +0200
Last post2017-06-21 04:20 +0200
Articles 16 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-20 05:50 +0200
    [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-20 05:50 +0200
      Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for  Hi3660 Wei Xu <xuwei5@hisilicon.com> - 2017-06-20 12:40 +0200
        Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for  Hi3660 "Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com> - 2017-06-21 04:30 +0200
      Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for  Hi3660 Leo Yan <leo.yan@linaro.org> - 2017-06-21 04:40 +0200
    [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-20 05:50 +0200
      Re: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor "Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com> - 2017-06-20 10:40 +0200
        Re: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor Guodong Xu <guodong.xu@linaro.org> - 2017-06-21 04:00 +0200
      [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-22 05:50 +0200
        Re: [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for  Hi3660 Eduardo Valentin <edubezval@gmail.com> - 2017-07-01 05:10 +0200
      [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-22 05:50 +0200
        [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang <kevin.wangtao@hisilicon.com> - 2017-06-22 05:50 +0200
          Re: [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor Eduardo Valentin <edubezval@gmail.com> - 2017-07-01 05:10 +0200
        Re: [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor  bindings Eduardo Valentin <edubezval@gmail.com> - 2017-07-01 05:10 +0200
    Re: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor  bindings Wei Xu <xuwei5@hisilicon.com> - 2017-06-20 12:30 +0200
      Re: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor  bindings "Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com> - 2017-06-21 04:20 +0200

#1670234 — [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-20 05:50 +0200
Subject[PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings
Message-ID<tUikV-3gU-3@gated-at.bofh.it>
This adds documentation of device tree bindings for the
thermal sensor controller of hi3660 SoC.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
---
 .../devicetree/bindings/thermal/hi3660-thermal.txt |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/hi3660-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
new file mode 100644
index 0000000..c034670
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
@@ -0,0 +1,17 @@
+* Temperature Sensor on hisilicon hi3660 SoC
+
+** Required properties :
+
+- compatible: "hisilicon,thermal-hi3660".
+- reg: physical base address of thermal sensor and length of memory mapped
+  region.
+- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
+
+Example :
+
+	tsensor: tsensor {
+		compatible = "hisilicon,thermal-hi3660";
+		reg = <0x0 0xfff30000 0x0 0x1000>;
+		#thermal-sensor-cells = <1>;
+		status = "ok";
+	 };
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1670235 — [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-20 05:50 +0200
Subject[PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tUikV-3gU-1@gated-at.bofh.it>
In reply to#1670234
This patch adds the support for thermal sensor of Hi3660 SoC.
this will register sensors for thermal framework and use device
tree to bind cooling device.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 drivers/thermal/Kconfig          |   10 ++
 drivers/thermal/Makefile         |    1 +
 drivers/thermal/hi3660_thermal.c |  198 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 drivers/thermal/hi3660_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index b5b5fac..3e7fa95 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -203,6 +203,16 @@ config HISI_THERMAL
 	  thermal framework. cpufreq is used as the cooling device to throttle
 	  CPUs when the passive trip is crossed.
 
+config HI3660_THERMAL
+	tristate "Hi3660 thermal driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on OF
+	default y
+	help
+	  Enable this to plug Hi3660 thermal driver into the Linux thermal
+	  framework.
+
 config IMX_THERMAL
 	tristate "Temperature sensor driver for Freescale i.MX SoCs"
 	depends on (ARCH_MXC && CPU_THERMAL) || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 094d703..f29d0a5 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_INTEL_PCH_THERMAL)	+= intel_pch_thermal.o
 obj-$(CONFIG_ST_THERMAL)	+= st/
 obj-$(CONFIG_QCOM_TSENS)	+= qcom/
 obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
+obj-$(CONFIG_HI3660_THERMAL)	+= hi3660_thermal.o
 obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
 obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
 obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
new file mode 100644
index 0000000..a538721
--- /dev/null
+++ b/drivers/thermal/hi3660_thermal.c
@@ -0,0 +1,198 @@
+/*
+ *  linux/drivers/thermal/hi3660_thermal.c
+ *
+ *  Copyright (c) 2017 Hisilicon Limited.
+ *  Copyright (c) 2017 Linaro Limited.
+ *
+ *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
+ *  Author: Leo Yan <leo.yan@linaro.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+#define HW_MAX_SENSORS			4
+#define HISI_MAX_SENSORS		6
+#define SENSOR_MAX			4
+#define SENSOR_AVG			5
+
+#define ADC_MIN		116
+#define ADC_MAX		922
+
+/* hi3660 Thermal Sensor Dev Structure */
+struct hi3660_thermal_sensor {
+	struct hi3660_thermal_data *thermal;
+	struct thermal_zone_device *tzd;
+
+	uint32_t id;
+};
+
+struct hi3660_thermal_data {
+	struct platform_device *pdev;
+	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
+	void __iomem *thermal_base;
+};
+
+unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
+
+
+static int hi3660_thermal_get_temp(void *_sensor, int *temp)
+{
+	struct hi3660_thermal_sensor *sensor = _sensor;
+	struct hi3660_thermal_data *data = sensor->thermal;
+	unsigned int idx;
+	int val, average = 0, max = 0;
+
+	if (sensor->id < HW_MAX_SENSORS) {
+		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
+		val = clamp_val(val, ADC_MIN, ADC_MAX);
+	} else {
+		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
+			val = readl(data->thermal_base
+					+ sensor_reg_offset[idx]);
+			val = clamp_val(val, ADC_MIN, ADC_MAX);
+			average += val;
+			if (val > max)
+				max = val;
+		}
+
+		if (sensor->id == SENSOR_MAX)
+			val = max;
+		else if (sensor->id == SENSOR_AVG)
+			val = average / HW_MAX_SENSORS;
+	}
+
+	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;
+
+	return 0;
+}
+
+static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
+	.get_temp = hi3660_thermal_get_temp,
+};
+
+static int hi3660_thermal_register_sensor(struct platform_device *pdev,
+		struct hi3660_thermal_data *data,
+		struct hi3660_thermal_sensor *sensor,
+		int index)
+{
+	int ret = 0;
+
+	sensor->id = index;
+	sensor->thermal = data;
+
+	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
+				sensor->id, sensor, &hi3660_of_thermal_ops);
+	if (IS_ERR(sensor->tzd)) {
+		ret = PTR_ERR(sensor->tzd);
+		sensor->tzd = NULL;
+	}
+
+	return ret;
+}
+
+static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
+				       bool on)
+{
+	struct thermal_zone_device *tzd = sensor->tzd;
+
+	tzd->ops->set_mode(tzd,
+		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
+}
+
+static int hi3660_thermal_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct hi3660_thermal_data *data;
+	struct resource *res;
+	int ret = 0;
+	int i;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->pdev = pdev;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	data->thermal_base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(data->thermal_base)) {
+		dev_err(dev, "failed get reg base\n");
+		return -ENOMEM;
+	}
+
+	platform_set_drvdata(pdev, data);
+
+	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
+		ret = hi3660_thermal_register_sensor(pdev, data,
+						     &data->sensors[i], i);
+		if (ret)
+			dev_err(&pdev->dev,
+				"failed to register thermal sensor%d: %d\n",
+				i, ret);
+		else
+			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
+	}
+
+	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");
+	return 0;
+}
+
+static int hi3660_thermal_exit(struct platform_device *pdev)
+{
+	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
+	int i;
+
+	for (i = 0; i < HISI_MAX_SENSORS; i++) {
+		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
+
+		if (!sensor->tzd)
+			continue;
+
+		hi3660_thermal_toggle_sensor(sensor, false);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id hi3660_thermal_id_table[] = {
+	{ .compatible = "hisilicon,thermal-hi3660" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
+
+static struct platform_driver hi3660_thermal_driver = {
+	.probe = hi3660_thermal_probe,
+	.remove = hi3660_thermal_exit,
+	.driver = {
+		.name = "hi3660_thermal",
+		.of_match_table = hi3660_thermal_id_table,
+	},
+};
+
+module_platform_driver(hi3660_thermal_driver);
+
+MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
+MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
+MODULE_DESCRIPTION("hi3660 thermal driver");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1670654 — Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

FromWei Xu <xuwei5@hisilicon.com>
Date2017-06-20 12:40 +0200
SubjectRe: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tUoJI-7ry-9@gated-at.bofh.it>
In reply to#1670235
Hi Tao Wang,

On 2017/6/20 4:40, Tao Wang wrote:
> This patch adds the support for thermal sensor of Hi3660 SoC.
> this will register sensors for thermal framework and use device
> tree to bind cooling device.
> 
> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  drivers/thermal/Kconfig          |   10 ++
>  drivers/thermal/Makefile         |    1 +
>  drivers/thermal/hi3660_thermal.c |  198 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 209 insertions(+)
>  create mode 100644 drivers/thermal/hi3660_thermal.c
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index b5b5fac..3e7fa95 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -203,6 +203,16 @@ config HISI_THERMAL
>  	  thermal framework. cpufreq is used as the cooling device to throttle
>  	  CPUs when the passive trip is crossed.
>  
> +config HI3660_THERMAL

Please keep alphabet order and swap the order
between HI3660_THERMAL and HISI_THERMAL.

Thanks!

BR,
Wei

> +	tristate "Hi3660 thermal driver"
> +	depends on ARCH_HISI || COMPILE_TEST
> +	depends on HAS_IOMEM
> +	depends on OF
> +	default y
> +	help
> +	  Enable this to plug Hi3660 thermal driver into the Linux thermal
> +	  framework.
> +
>  config IMX_THERMAL
>  	tristate "Temperature sensor driver for Freescale i.MX SoCs"
>  	depends on (ARCH_MXC && CPU_THERMAL) || COMPILE_TEST
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 094d703..f29d0a5 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_INTEL_PCH_THERMAL)	+= intel_pch_thermal.o
>  obj-$(CONFIG_ST_THERMAL)	+= st/
>  obj-$(CONFIG_QCOM_TSENS)	+= qcom/
>  obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
> +obj-$(CONFIG_HI3660_THERMAL)	+= hi3660_thermal.o
>  obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
>  obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
>  obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
> diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
> new file mode 100644
> index 0000000..a538721
> --- /dev/null
> +++ b/drivers/thermal/hi3660_thermal.c
> @@ -0,0 +1,198 @@
> +/*
> + *  linux/drivers/thermal/hi3660_thermal.c
> + *
> + *  Copyright (c) 2017 Hisilicon Limited.
> + *  Copyright (c) 2017 Linaro Limited.
> + *
> + *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
> + *  Author: Leo Yan <leo.yan@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; version 2 of the License.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#include "thermal_core.h"
> +
> +#define HW_MAX_SENSORS			4
> +#define HISI_MAX_SENSORS		6
> +#define SENSOR_MAX			4
> +#define SENSOR_AVG			5
> +
> +#define ADC_MIN		116
> +#define ADC_MAX		922
> +
> +/* hi3660 Thermal Sensor Dev Structure */
> +struct hi3660_thermal_sensor {
> +	struct hi3660_thermal_data *thermal;
> +	struct thermal_zone_device *tzd;
> +
> +	uint32_t id;
> +};
> +
> +struct hi3660_thermal_data {
> +	struct platform_device *pdev;
> +	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
> +	void __iomem *thermal_base;
> +};
> +
> +unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
> +
> +
> +static int hi3660_thermal_get_temp(void *_sensor, int *temp)
> +{
> +	struct hi3660_thermal_sensor *sensor = _sensor;
> +	struct hi3660_thermal_data *data = sensor->thermal;
> +	unsigned int idx;
> +	int val, average = 0, max = 0;
> +
> +	if (sensor->id < HW_MAX_SENSORS) {
> +		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
> +		val = clamp_val(val, ADC_MIN, ADC_MAX);
> +	} else {
> +		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
> +			val = readl(data->thermal_base
> +					+ sensor_reg_offset[idx]);
> +			val = clamp_val(val, ADC_MIN, ADC_MAX);
> +			average += val;
> +			if (val > max)
> +				max = val;
> +		}
> +
> +		if (sensor->id == SENSOR_MAX)
> +			val = max;
> +		else if (sensor->id == SENSOR_AVG)
> +			val = average / HW_MAX_SENSORS;
> +	}
> +
> +	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;
> +
> +	return 0;
> +}
> +
> +static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
> +	.get_temp = hi3660_thermal_get_temp,
> +};
> +
> +static int hi3660_thermal_register_sensor(struct platform_device *pdev,
> +		struct hi3660_thermal_data *data,
> +		struct hi3660_thermal_sensor *sensor,
> +		int index)
> +{
> +	int ret = 0;
> +
> +	sensor->id = index;
> +	sensor->thermal = data;
> +
> +	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
> +				sensor->id, sensor, &hi3660_of_thermal_ops);
> +	if (IS_ERR(sensor->tzd)) {
> +		ret = PTR_ERR(sensor->tzd);
> +		sensor->tzd = NULL;
> +	}
> +
> +	return ret;
> +}
> +
> +static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
> +				       bool on)
> +{
> +	struct thermal_zone_device *tzd = sensor->tzd;
> +
> +	tzd->ops->set_mode(tzd,
> +		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
> +}
> +
> +static int hi3660_thermal_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct hi3660_thermal_data *data;
> +	struct resource *res;
> +	int ret = 0;
> +	int i;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->pdev = pdev;
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	data->thermal_base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(data->thermal_base)) {
> +		dev_err(dev, "failed get reg base\n");
> +		return -ENOMEM;
> +	}
> +
> +	platform_set_drvdata(pdev, data);
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
> +		ret = hi3660_thermal_register_sensor(pdev, data,
> +						     &data->sensors[i], i);
> +		if (ret)
> +			dev_err(&pdev->dev,
> +				"failed to register thermal sensor%d: %d\n",
> +				i, ret);
> +		else
> +			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
> +	}
> +
> +	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");
> +	return 0;
> +}
> +
> +static int hi3660_thermal_exit(struct platform_device *pdev)
> +{
> +	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
> +	int i;
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; i++) {
> +		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
> +
> +		if (!sensor->tzd)
> +			continue;
> +
> +		hi3660_thermal_toggle_sensor(sensor, false);
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id hi3660_thermal_id_table[] = {
> +	{ .compatible = "hisilicon,thermal-hi3660" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
> +
> +static struct platform_driver hi3660_thermal_driver = {
> +	.probe = hi3660_thermal_probe,
> +	.remove = hi3660_thermal_exit,
> +	.driver = {
> +		.name = "hi3660_thermal",
> +		.of_match_table = hi3660_thermal_id_table,
> +	},
> +};
> +
> +module_platform_driver(hi3660_thermal_driver);
> +
> +MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
> +MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
> +MODULE_DESCRIPTION("hi3660 thermal driver");
> +MODULE_LICENSE("GPL v2");
> 

[toc] | [prev] | [next] | [standalone]


#1671292 — Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

From"Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com>
Date2017-06-21 04:30 +0200
SubjectRe: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tUDz3-8w0-1@gated-at.bofh.it>
In reply to#1670654

e( 2017/6/20 18:31, Wei Xu ei:
> Hi Tao Wang,
> 
> On 2017/6/20 4:40, Tao Wang wrote:
>> This patch adds the support for thermal sensor of Hi3660 SoC.
>> this will register sensors for thermal framework and use device
>> tree to bind cooling device.
>>
>> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
>> Signed-off-by: Leo Yan <leo.yan@linaro.org>
>> ---
>>   drivers/thermal/Kconfig          |   10 ++
>>   drivers/thermal/Makefile         |    1 +
>>   drivers/thermal/hi3660_thermal.c |  198 ++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 209 insertions(+)
>>   create mode 100644 drivers/thermal/hi3660_thermal.c
>>
>> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
>> index b5b5fac..3e7fa95 100644
>> --- a/drivers/thermal/Kconfig
>> +++ b/drivers/thermal/Kconfig
>> @@ -203,6 +203,16 @@ config HISI_THERMAL
>>   	  thermal framework. cpufreq is used as the cooling device to throttle
>>   	  CPUs when the passive trip is crossed.
>>   
>> +config HI3660_THERMAL
> 
> Please keep alphabet order and swap the order
> between HI3660_THERMAL and HISI_THERMAL.
OK
> 
> Thanks!
> 
> BR,
> Wei
> 
>> +	tristate "Hi3660 thermal driver"
>> +	depends on ARCH_HISI || COMPILE_TEST
>> +	depends on HAS_IOMEM
>> +	depends on OF
>> +	default y
>> +	help
>> +	  Enable this to plug Hi3660 thermal driver into the Linux thermal
>> +	  framework.
>> +
>>   config IMX_THERMAL
>>   	tristate "Temperature sensor driver for Freescale i.MX SoCs"
>>   	depends on (ARCH_MXC && CPU_THERMAL) || COMPILE_TEST
>> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
>> index 094d703..f29d0a5 100644
>> --- a/drivers/thermal/Makefile
>> +++ b/drivers/thermal/Makefile
>> @@ -55,6 +55,7 @@ obj-$(CONFIG_INTEL_PCH_THERMAL)	+= intel_pch_thermal.o
>>   obj-$(CONFIG_ST_THERMAL)	+= st/
>>   obj-$(CONFIG_QCOM_TSENS)	+= qcom/
>>   obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
>> +obj-$(CONFIG_HI3660_THERMAL)	+= hi3660_thermal.o
>>   obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
>>   obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
>>   obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
>> diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
>> new file mode 100644
>> index 0000000..a538721
>> --- /dev/null
>> +++ b/drivers/thermal/hi3660_thermal.c
>> @@ -0,0 +1,198 @@
>> +/*
>> + *  linux/drivers/thermal/hi3660_thermal.c
>> + *
>> + *  Copyright (c) 2017 Hisilicon Limited.
>> + *  Copyright (c) 2017 Linaro Limited.
>> + *
>> + *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
>> + *  Author: Leo Yan <leo.yan@linaro.org>
>> + *
>> + *  This program is free software; you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License as published by
>> + *  the Free Software Foundation; version 2 of the License.
>> + *
>> + *  This program is distributed in the hope that it will be useful,
>> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + *  GNU General Public License for more details.
>> + *
>> + *  You should have received a copy of the GNU General Public License
>> + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/device.h>
>> +#include <linux/err.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/of.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/thermal.h>
>> +
>> +#include "thermal_core.h"
>> +
>> +#define HW_MAX_SENSORS			4
>> +#define HISI_MAX_SENSORS		6
>> +#define SENSOR_MAX			4
>> +#define SENSOR_AVG			5
>> +
>> +#define ADC_MIN		116
>> +#define ADC_MAX		922
>> +
>> +/* hi3660 Thermal Sensor Dev Structure */
>> +struct hi3660_thermal_sensor {
>> +	struct hi3660_thermal_data *thermal;
>> +	struct thermal_zone_device *tzd;
>> +
>> +	uint32_t id;
>> +};
>> +
>> +struct hi3660_thermal_data {
>> +	struct platform_device *pdev;
>> +	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
>> +	void __iomem *thermal_base;
>> +};
>> +
>> +unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
>> +
>> +
>> +static int hi3660_thermal_get_temp(void *_sensor, int *temp)
>> +{
>> +	struct hi3660_thermal_sensor *sensor = _sensor;
>> +	struct hi3660_thermal_data *data = sensor->thermal;
>> +	unsigned int idx;
>> +	int val, average = 0, max = 0;
>> +
>> +	if (sensor->id < HW_MAX_SENSORS) {
>> +		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
>> +		val = clamp_val(val, ADC_MIN, ADC_MAX);
>> +	} else {
>> +		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
>> +			val = readl(data->thermal_base
>> +					+ sensor_reg_offset[idx]);
>> +			val = clamp_val(val, ADC_MIN, ADC_MAX);
>> +			average += val;
>> +			if (val > max)
>> +				max = val;
>> +		}
>> +
>> +		if (sensor->id == SENSOR_MAX)
>> +			val = max;
>> +		else if (sensor->id == SENSOR_AVG)
>> +			val = average / HW_MAX_SENSORS;
>> +	}
>> +
>> +	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;
>> +
>> +	return 0;
>> +}
>> +
>> +static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
>> +	.get_temp = hi3660_thermal_get_temp,
>> +};
>> +
>> +static int hi3660_thermal_register_sensor(struct platform_device *pdev,
>> +		struct hi3660_thermal_data *data,
>> +		struct hi3660_thermal_sensor *sensor,
>> +		int index)
>> +{
>> +	int ret = 0;
>> +
>> +	sensor->id = index;
>> +	sensor->thermal = data;
>> +
>> +	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
>> +				sensor->id, sensor, &hi3660_of_thermal_ops);
>> +	if (IS_ERR(sensor->tzd)) {
>> +		ret = PTR_ERR(sensor->tzd);
>> +		sensor->tzd = NULL;
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
>> +				       bool on)
>> +{
>> +	struct thermal_zone_device *tzd = sensor->tzd;
>> +
>> +	tzd->ops->set_mode(tzd,
>> +		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
>> +}
>> +
>> +static int hi3660_thermal_probe(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct hi3660_thermal_data *data;
>> +	struct resource *res;
>> +	int ret = 0;
>> +	int i;
>> +
>> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>> +	if (!data)
>> +		return -ENOMEM;
>> +
>> +	data->pdev = pdev;
>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +	data->thermal_base = devm_ioremap_resource(dev, res);
>> +	if (IS_ERR(data->thermal_base)) {
>> +		dev_err(dev, "failed get reg base\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	platform_set_drvdata(pdev, data);
>> +
>> +	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
>> +		ret = hi3660_thermal_register_sensor(pdev, data,
>> +						     &data->sensors[i], i);
>> +		if (ret)
>> +			dev_err(&pdev->dev,
>> +				"failed to register thermal sensor%d: %d\n",
>> +				i, ret);
>> +		else
>> +			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
>> +	}
>> +
>> +	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");
>> +	return 0;
>> +}
>> +
>> +static int hi3660_thermal_exit(struct platform_device *pdev)
>> +{
>> +	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
>> +	int i;
>> +
>> +	for (i = 0; i < HISI_MAX_SENSORS; i++) {
>> +		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
>> +
>> +		if (!sensor->tzd)
>> +			continue;
>> +
>> +		hi3660_thermal_toggle_sensor(sensor, false);
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct of_device_id hi3660_thermal_id_table[] = {
>> +	{ .compatible = "hisilicon,thermal-hi3660" },
>> +	{}
>> +};
>> +MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
>> +
>> +static struct platform_driver hi3660_thermal_driver = {
>> +	.probe = hi3660_thermal_probe,
>> +	.remove = hi3660_thermal_exit,
>> +	.driver = {
>> +		.name = "hi3660_thermal",
>> +		.of_match_table = hi3660_thermal_id_table,
>> +	},
>> +};
>> +
>> +module_platform_driver(hi3660_thermal_driver);
>> +
>> +MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
>> +MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
>> +MODULE_DESCRIPTION("hi3660 thermal driver");
>> +MODULE_LICENSE("GPL v2");
>>
> 
> 
> .
> 

[toc] | [prev] | [next] | [standalone]


#1671294 — Re: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

FromLeo Yan <leo.yan@linaro.org>
Date2017-06-21 04:40 +0200
SubjectRe: [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tUDIJ-9t-1@gated-at.bofh.it>
In reply to#1670235
Hi Rui, Eduardo,

On Tue, Jun 20, 2017 at 11:40:34AM +0800, Tao Wang wrote:

[...]

> diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
> new file mode 100644
> index 0000000..a538721
> --- /dev/null
> +++ b/drivers/thermal/hi3660_thermal.c
> @@ -0,0 +1,198 @@
> +/*
> + *  linux/drivers/thermal/hi3660_thermal.c
> + *
> + *  Copyright (c) 2017 Hisilicon Limited.
> + *  Copyright (c) 2017 Linaro Limited.
> + *
> + *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
> + *  Author: Leo Yan <leo.yan@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; version 2 of the License.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#include "thermal_core.h"
> +
> +#define HW_MAX_SENSORS			4
> +#define HISI_MAX_SENSORS		6
> +#define SENSOR_MAX			4
> +#define SENSOR_AVG			5
> +
> +#define ADC_MIN		116
> +#define ADC_MAX		922
> +
> +/* hi3660 Thermal Sensor Dev Structure */
> +struct hi3660_thermal_sensor {
> +	struct hi3660_thermal_data *thermal;
> +	struct thermal_zone_device *tzd;
> +
> +	uint32_t id;
> +};
> +
> +struct hi3660_thermal_data {
> +	struct platform_device *pdev;
> +	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
> +	void __iomem *thermal_base;
> +};
> +
> +unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
> +
> +
> +static int hi3660_thermal_get_temp(void *_sensor, int *temp)
> +{
> +	struct hi3660_thermal_sensor *sensor = _sensor;
> +	struct hi3660_thermal_data *data = sensor->thermal;
> +	unsigned int idx;
> +	int val, average = 0, max = 0;
> +
> +	if (sensor->id < HW_MAX_SENSORS) {
> +		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
> +		val = clamp_val(val, ADC_MIN, ADC_MAX);
> +	} else {
> +		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
> +			val = readl(data->thermal_base
> +					+ sensor_reg_offset[idx]);
> +			val = clamp_val(val, ADC_MIN, ADC_MAX);
> +			average += val;
> +			if (val > max)
> +				max = val;
> +		}
> +
> +		if (sensor->id == SENSOR_MAX)
> +			val = max;
> +		else if (sensor->id == SENSOR_AVG)
> +			val = average / HW_MAX_SENSORS;
> +	}

I think here have one thing it's better to check with you ahead and
want your suggestions.

Tao adds two 'software' sensors, one is sensor 4 which is used to
present the maximum temperature value crossing from sensor 0 ~ 3; and
another sensor 4 is used to present the average temperature value.

Does this make sense for you?

> +	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;
> +
> +	return 0;
> +}
> +
> +static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
> +	.get_temp = hi3660_thermal_get_temp,
> +};
> +
> +static int hi3660_thermal_register_sensor(struct platform_device *pdev,
> +		struct hi3660_thermal_data *data,
> +		struct hi3660_thermal_sensor *sensor,
> +		int index)
> +{
> +	int ret = 0;
> +
> +	sensor->id = index;
> +	sensor->thermal = data;
> +
> +	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
> +				sensor->id, sensor, &hi3660_of_thermal_ops);
> +	if (IS_ERR(sensor->tzd)) {
> +		ret = PTR_ERR(sensor->tzd);
> +		sensor->tzd = NULL;
> +	}
> +
> +	return ret;
> +}
> +
> +static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
> +				       bool on)
> +{
> +	struct thermal_zone_device *tzd = sensor->tzd;
> +
> +	tzd->ops->set_mode(tzd,
> +		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
> +}
> +
> +static int hi3660_thermal_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct hi3660_thermal_data *data;
> +	struct resource *res;
> +	int ret = 0;
> +	int i;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->pdev = pdev;
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	data->thermal_base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(data->thermal_base)) {
> +		dev_err(dev, "failed get reg base\n");
> +		return -ENOMEM;
> +	}
> +
> +	platform_set_drvdata(pdev, data);
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
> +		ret = hi3660_thermal_register_sensor(pdev, data,
> +						     &data->sensors[i], i);
> +		if (ret)
> +			dev_err(&pdev->dev,
> +				"failed to register thermal sensor%d: %d\n",
> +				i, ret);
> +		else
> +			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
> +	}
> +
> +	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");
> +	return 0;
> +}
> +
> +static int hi3660_thermal_exit(struct platform_device *pdev)
> +{
> +	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
> +	int i;
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; i++) {
> +		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
> +
> +		if (!sensor->tzd)
> +			continue;
> +
> +		hi3660_thermal_toggle_sensor(sensor, false);
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id hi3660_thermal_id_table[] = {
> +	{ .compatible = "hisilicon,thermal-hi3660" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
> +
> +static struct platform_driver hi3660_thermal_driver = {
> +	.probe = hi3660_thermal_probe,
> +	.remove = hi3660_thermal_exit,
> +	.driver = {
> +		.name = "hi3660_thermal",
> +		.of_match_table = hi3660_thermal_id_table,
> +	},
> +};
> +
> +module_platform_driver(hi3660_thermal_driver);
> +
> +MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
> +MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
> +MODULE_DESCRIPTION("hi3660 thermal driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 1.7.9.5
> 

[toc] | [prev] | [next] | [standalone]


#1670242 — [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-20 05:50 +0200
Subject[PATCH 3/3] arm64: dts: register Hi3660's thermal sensor
Message-ID<tUikW-3gU-17@gated-at.bofh.it>
In reply to#1670234
Bind thermal sensor driver for Hi3660.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index 3983086..cc67958 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -156,5 +156,12 @@
 			clock-names = "uartclk", "apb_pclk";
 			status = "disabled";
 		};
+
+		tsensor: tsensor {
+			compatible = "hisilicon,thermal-hi3660";
+			reg = <0x0 0xfff30000 0x0 0x1000>;
+			#thermal-sensor-cells = <1>;
+			status = "ok";
+		};
 	};
 };
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1670428 — Re: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor

From"Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com>
Date2017-06-20 10:40 +0200
SubjectRe: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor
Message-ID<tUmRA-6dE-17@gated-at.bofh.it>
In reply to#1670242

在 2017/6/20 15:38, Guodong Xu 写道:
> 
> 
> 2017年6月20日 上午11:49,"Tao Wang" <kevin.wangtao@hisilicon.com <mailto:kevin.wangtao@hisilicon.com>>写道:
> 
>     Bind thermal sensor driver for Hi3660.
> 
>     Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com <mailto:kevin.wangtao@hisilicon.com>>
>     Signed-off-by: Leo Yan <leo.yan@linaro.org <mailto:leo.yan@linaro.org>>
>     ---
>       arch/arm64/boot/dts/hisilicon/hi3660.dtsi |    7 +++++++
>       1 file changed, 7 insertions(+)
> 
>     diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>     index 3983086..cc67958 100644
>     --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>     +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>     @@ -156,5 +156,12 @@
> 
> 
> i am wondering which tree this patch should be applied to. Actually Olof Johansson olof@lixom.net <mailto:olof@lixom.net> just merged hi3660 dts into his tree. You should better rebase you dts patch onto that.
Can you share me the git path?
> 
> 
>                              clock-names = "uartclk", "apb_pclk";
>                              status = "disabled";
>                      };
>     +
>     +               tsensor: tsensor {
>     +                       compatible = "hisilicon,thermal-hi3660";
>     +                       reg = <0x0 0xfff30000 0x0 0x1000>;
>     +                       #thermal-sensor-cells = <1>;
>     +                       status = "ok";
> 
> 
> please remove status ok. that's default. redundant.
ok
> 
>     +               };
>              };
>       };
>     --
>     1.7.9.5
> 
> 
>     _______________________________________________
>     linux-arm-kernel mailing list
>     linux-arm-kernel@lists.infradead.org <mailto:linux-arm-kernel@lists.infradead.org>
>     http://lists.infradead.org/mailman/listinfo/linux-arm-kernel <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>
> 
> 

[toc] | [prev] | [next] | [standalone]


#1671285 — Re: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor

FromGuodong Xu <guodong.xu@linaro.org>
Date2017-06-21 04:00 +0200
SubjectRe: [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor
Message-ID<tUD61-81B-3@gated-at.bofh.it>
In reply to#1670428
On Tue, Jun 20, 2017 at 4:32 PM, Wangtao (Kevin, Kirin)
<kevin.wangtao@hisilicon.com> wrote:
>
>
> 在 2017/6/20 15:38, Guodong Xu 写道:
>>
>>
>>
>> 2017年6月20日 上午11:49,"Tao Wang" <kevin.wangtao@hisilicon.com
>> <mailto:kevin.wangtao@hisilicon.com>>写道:
>>
>>     Bind thermal sensor driver for Hi3660.
>>
>>     Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com
>> <mailto:kevin.wangtao@hisilicon.com>>
>>     Signed-off-by: Leo Yan <leo.yan@linaro.org
>> <mailto:leo.yan@linaro.org>>
>>     ---
>>       arch/arm64/boot/dts/hisilicon/hi3660.dtsi |    7 +++++++
>>       1 file changed, 7 insertions(+)
>>
>>     diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>> b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>>     index 3983086..cc67958 100644
>>     --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>>     +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
>>     @@ -156,5 +156,12 @@
>>
>>
>> i am wondering which tree this patch should be applied to. Actually Olof
>> Johansson olof@lixom.net <mailto:olof@lixom.net> just merged hi3660 dts into
>> his tree. You should better rebase you dts patch onto that.
>
> Can you share me the git path?

As of this morning, it has shown up in linux next tag: next-20170620

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/hisilicon?h=next-20170620

-Guodong


>>
>>
>>
>>                              clock-names = "uartclk", "apb_pclk";
>>                              status = "disabled";
>>                      };
>>     +
>>     +               tsensor: tsensor {
>>     +                       compatible = "hisilicon,thermal-hi3660";
>>     +                       reg = <0x0 0xfff30000 0x0 0x1000>;
>>     +                       #thermal-sensor-cells = <1>;
>>     +                       status = "ok";
>>
>>
>> please remove status ok. that's default. redundant.
>
> ok
>>
>>
>>     +               };
>>              };
>>       };
>>     --
>>     1.7.9.5
>>
>>
>>     _______________________________________________
>>     linux-arm-kernel mailing list
>>     linux-arm-kernel@lists.infradead.org
>> <mailto:linux-arm-kernel@lists.infradead.org>
>>     http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>> <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>
>>
>>
>

[toc] | [prev] | [next] | [standalone]


#1672282 — [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-22 05:50 +0200
Subject[Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tV1i2-7t5-1@gated-at.bofh.it>
In reply to#1670242
This patch adds the support for thermal sensor of Hi3660 SoC.
this will register sensors for thermal framework and use device
tree to bind cooling device.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
Changes in v2:
- correct alphabet order
- correct compatible name

 drivers/thermal/Kconfig          |   10 ++
 drivers/thermal/Makefile         |    1 +
 drivers/thermal/hi3660_thermal.c |  198 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 insertions(+)
 create mode 100644 drivers/thermal/hi3660_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index b5b5fac..ed22a90 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -192,6 +192,16 @@ config THERMAL_EMULATION
 	  because userland can easily disable the thermal policy by simply
 	  flooding this sysfs node with low temperature values.
 
+config HI3660_THERMAL
+	tristate "Hi3660 thermal driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on OF
+	default y
+	help
+	  Enable this to plug Hi3660 thermal driver into the Linux thermal
+	  framework.
+
 config HISI_THERMAL
 	tristate "Hisilicon thermal driver"
 	depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 094d703..f29d0a5 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_INTEL_PCH_THERMAL)	+= intel_pch_thermal.o
 obj-$(CONFIG_ST_THERMAL)	+= st/
 obj-$(CONFIG_QCOM_TSENS)	+= qcom/
 obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
+obj-$(CONFIG_HI3660_THERMAL)	+= hi3660_thermal.o
 obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
 obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
 obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
new file mode 100644
index 0000000..68fa9018
--- /dev/null
+++ b/drivers/thermal/hi3660_thermal.c
@@ -0,0 +1,198 @@
+/*
+ *  linux/drivers/thermal/hi3660_thermal.c
+ *
+ *  Copyright (c) 2017 Hisilicon Limited.
+ *  Copyright (c) 2017 Linaro Limited.
+ *
+ *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
+ *  Author: Leo Yan <leo.yan@linaro.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/thermal.h>
+
+#include "thermal_core.h"
+
+#define HW_MAX_SENSORS			4
+#define HISI_MAX_SENSORS		6
+#define SENSOR_MAX			4
+#define SENSOR_AVG			5
+
+#define ADC_MIN		116
+#define ADC_MAX		922
+
+/* hi3660 Thermal Sensor Dev Structure */
+struct hi3660_thermal_sensor {
+	struct hi3660_thermal_data *thermal;
+	struct thermal_zone_device *tzd;
+
+	uint32_t id;
+};
+
+struct hi3660_thermal_data {
+	struct platform_device *pdev;
+	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
+	void __iomem *thermal_base;
+};
+
+unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
+
+
+static int hi3660_thermal_get_temp(void *_sensor, int *temp)
+{
+	struct hi3660_thermal_sensor *sensor = _sensor;
+	struct hi3660_thermal_data *data = sensor->thermal;
+	unsigned int idx;
+	int val, average = 0, max = 0;
+
+	if (sensor->id < HW_MAX_SENSORS) {
+		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
+		val = clamp_val(val, ADC_MIN, ADC_MAX);
+	} else {
+		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
+			val = readl(data->thermal_base
+					+ sensor_reg_offset[idx]);
+			val = clamp_val(val, ADC_MIN, ADC_MAX);
+			average += val;
+			if (val > max)
+				max = val;
+		}
+
+		if (sensor->id == SENSOR_MAX)
+			val = max;
+		else if (sensor->id == SENSOR_AVG)
+			val = average / HW_MAX_SENSORS;
+	}
+
+	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;
+
+	return 0;
+}
+
+static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
+	.get_temp = hi3660_thermal_get_temp,
+};
+
+static int hi3660_thermal_register_sensor(struct platform_device *pdev,
+		struct hi3660_thermal_data *data,
+		struct hi3660_thermal_sensor *sensor,
+		int index)
+{
+	int ret = 0;
+
+	sensor->id = index;
+	sensor->thermal = data;
+
+	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
+				sensor->id, sensor, &hi3660_of_thermal_ops);
+	if (IS_ERR(sensor->tzd)) {
+		ret = PTR_ERR(sensor->tzd);
+		sensor->tzd = NULL;
+	}
+
+	return ret;
+}
+
+static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
+				       bool on)
+{
+	struct thermal_zone_device *tzd = sensor->tzd;
+
+	tzd->ops->set_mode(tzd,
+		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
+}
+
+static int hi3660_thermal_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct hi3660_thermal_data *data;
+	struct resource *res;
+	int ret = 0;
+	int i;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->pdev = pdev;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	data->thermal_base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(data->thermal_base)) {
+		dev_err(dev, "failed get reg base\n");
+		return -ENOMEM;
+	}
+
+	platform_set_drvdata(pdev, data);
+
+	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
+		ret = hi3660_thermal_register_sensor(pdev, data,
+						     &data->sensors[i], i);
+		if (ret)
+			dev_err(&pdev->dev,
+				"failed to register thermal sensor%d: %d\n",
+				i, ret);
+		else
+			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
+	}
+
+	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");
+	return 0;
+}
+
+static int hi3660_thermal_exit(struct platform_device *pdev)
+{
+	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
+	int i;
+
+	for (i = 0; i < HISI_MAX_SENSORS; i++) {
+		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
+
+		if (!sensor->tzd)
+			continue;
+
+		hi3660_thermal_toggle_sensor(sensor, false);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id hi3660_thermal_id_table[] = {
+	{ .compatible = "hisilicon,hi3660-thermal" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
+
+static struct platform_driver hi3660_thermal_driver = {
+	.probe = hi3660_thermal_probe,
+	.remove = hi3660_thermal_exit,
+	.driver = {
+		.name = "hi3660_thermal",
+		.of_match_table = hi3660_thermal_id_table,
+	},
+};
+
+module_platform_driver(hi3660_thermal_driver);
+
+MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
+MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
+MODULE_DESCRIPTION("hi3660 thermal driver");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1679253 — Re: [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660

FromEduardo Valentin <edubezval@gmail.com>
Date2017-07-01 05:10 +0200
SubjectRe: [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Message-ID<tYgXf-5I0-9@gated-at.bofh.it>
In reply to#1672282
Hey Tao,

On Thu, Jun 22, 2017 at 11:42:02AM +0800, Tao Wang wrote:
> This patch adds the support for thermal sensor of Hi3660 SoC.
> this will register sensors for thermal framework and use device
> tree to bind cooling device.
> 
> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
> Changes in v2:
> - correct alphabet order
> - correct compatible name
> 
>  drivers/thermal/Kconfig          |   10 ++
>  drivers/thermal/Makefile         |    1 +
>  drivers/thermal/hi3660_thermal.c |  198 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 209 insertions(+)
>  create mode 100644 drivers/thermal/hi3660_thermal.c
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index b5b5fac..ed22a90 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -192,6 +192,16 @@ config THERMAL_EMULATION
>  	  because userland can easily disable the thermal policy by simply
>  	  flooding this sysfs node with low temperature values.
>  
> +config HI3660_THERMAL
> +	tristate "Hi3660 thermal driver"
> +	depends on ARCH_HISI || COMPILE_TEST
> +	depends on HAS_IOMEM
> +	depends on OF
> +	default y
> +	help
> +	  Enable this to plug Hi3660 thermal driver into the Linux thermal
> +	  framework.
> +
>  config HISI_THERMAL
>  	tristate "Hisilicon thermal driver"
>  	depends on ARCH_HISI || COMPILE_TEST
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 094d703..f29d0a5 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_INTEL_PCH_THERMAL)	+= intel_pch_thermal.o
>  obj-$(CONFIG_ST_THERMAL)	+= st/
>  obj-$(CONFIG_QCOM_TSENS)	+= qcom/
>  obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
> +obj-$(CONFIG_HI3660_THERMAL)	+= hi3660_thermal.o
>  obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
>  obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
>  obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
> diff --git a/drivers/thermal/hi3660_thermal.c b/drivers/thermal/hi3660_thermal.c
> new file mode 100644
> index 0000000..68fa9018
> --- /dev/null
> +++ b/drivers/thermal/hi3660_thermal.c
> @@ -0,0 +1,198 @@
> +/*
> + *  linux/drivers/thermal/hi3660_thermal.c
> + *
> + *  Copyright (c) 2017 Hisilicon Limited.
> + *  Copyright (c) 2017 Linaro Limited.
> + *
> + *  Author: Tao Wang <kevin.wangtao@hisilicon.com>
> + *  Author: Leo Yan <leo.yan@linaro.org>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; version 2 of the License.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/thermal.h>
> +
> +#include "thermal_core.h"
> +
> +#define HW_MAX_SENSORS			4
> +#define HISI_MAX_SENSORS		6
> +#define SENSOR_MAX			4
> +#define SENSOR_AVG			5
> +
> +#define ADC_MIN		116
> +#define ADC_MAX		922
> +
> +/* hi3660 Thermal Sensor Dev Structure */
> +struct hi3660_thermal_sensor {
> +	struct hi3660_thermal_data *thermal;
> +	struct thermal_zone_device *tzd;
> +
> +	uint32_t id;
> +};
> +
> +struct hi3660_thermal_data {
> +	struct platform_device *pdev;
> +	struct hi3660_thermal_sensor sensors[HISI_MAX_SENSORS];
> +	void __iomem *thermal_base;
> +};
> +
> +unsigned int sensor_reg_offset[HW_MAX_SENSORS] = { 0x1c, 0x5c, 0x9c, 0xdc };
> +
> +
> +static int hi3660_thermal_get_temp(void *_sensor, int *temp)
> +{
> +	struct hi3660_thermal_sensor *sensor = _sensor;
> +	struct hi3660_thermal_data *data = sensor->thermal;
> +	unsigned int idx;
> +	int val, average = 0, max = 0;
> +
> +	if (sensor->id < HW_MAX_SENSORS) {
> +		val = readl(data->thermal_base + sensor_reg_offset[sensor->id]);
> +		val = clamp_val(val, ADC_MIN, ADC_MAX);
> +	} else {
> +		for (idx = 0; idx < HW_MAX_SENSORS; idx++) {
> +			val = readl(data->thermal_base
> +					+ sensor_reg_offset[idx]);
> +			val = clamp_val(val, ADC_MIN, ADC_MAX);
> +			average += val;
> +			if (val > max)
> +				max = val;
> +		}
> +
> +		if (sensor->id == SENSOR_MAX)
> +			val = max;
> +		else if (sensor->id == SENSOR_AVG)
> +			val = average / HW_MAX_SENSORS;
> +	}
> +
> +	*temp = ((val - ADC_MIN) * 165000) / (ADC_MAX - ADC_MIN) - 40000;

Where do these constants come from (165000 and 40000) can these some how
be rearranged and described in DT (coefficients) and using the offset and slope fields?

> +
> +	return 0;
> +}
> +
> +static struct thermal_zone_of_device_ops hi3660_of_thermal_ops = {
> +	.get_temp = hi3660_thermal_get_temp,
> +};
> +
> +static int hi3660_thermal_register_sensor(struct platform_device *pdev,
> +		struct hi3660_thermal_data *data,
> +		struct hi3660_thermal_sensor *sensor,
> +		int index)
> +{
> +	int ret = 0;
> +
> +	sensor->id = index;
> +	sensor->thermal = data;
> +
> +	sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
> +				sensor->id, sensor, &hi3660_of_thermal_ops);
> +	if (IS_ERR(sensor->tzd)) {
> +		ret = PTR_ERR(sensor->tzd);
> +		sensor->tzd = NULL;
> +	}
> +
> +	return ret;
> +}
> +
> +static void hi3660_thermal_toggle_sensor(struct hi3660_thermal_sensor *sensor,
> +				       bool on)
> +{
> +	struct thermal_zone_device *tzd = sensor->tzd;
> +
> +	tzd->ops->set_mode(tzd,
> +		on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED);
> +}
> +
> +static int hi3660_thermal_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct hi3660_thermal_data *data;
> +	struct resource *res;
> +	int ret = 0;
> +	int i;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->pdev = pdev;
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	data->thermal_base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(data->thermal_base)) {
> +		dev_err(dev, "failed get reg base\n");
> +		return -ENOMEM;
> +	}
> +
> +	platform_set_drvdata(pdev, data);
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; ++i) {
> +		ret = hi3660_thermal_register_sensor(pdev, data,
> +						     &data->sensors[i], i);
> +		if (ret)
> +			dev_err(&pdev->dev,
> +				"failed to register thermal sensor%d: %d\n",
> +				i, ret);

Do you really want to continue if some of the sensors fail to register?

> +		else
> +			hi3660_thermal_toggle_sensor(&data->sensors[i], true);
> +	}
> +
> +	dev_info(&pdev->dev, "Thermal Sensor Loaded\n");

Do you really need the above info in the kernel log?

> +	return 0;
> +}
> +
> +static int hi3660_thermal_exit(struct platform_device *pdev)
> +{
> +	struct hi3660_thermal_data *data = platform_get_drvdata(pdev);
> +	int i;
> +
> +	for (i = 0; i < HISI_MAX_SENSORS; i++) {
> +		struct hi3660_thermal_sensor *sensor = &data->sensors[i];
> +
> +		if (!sensor->tzd)
> +			continue;

Why are you considering a valid case of not registering all expected
sensors?
> +
> +		hi3660_thermal_toggle_sensor(sensor, false);
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id hi3660_thermal_id_table[] = {
> +	{ .compatible = "hisilicon,hi3660-thermal" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, hi3660_thermal_id_table);
> +
> +static struct platform_driver hi3660_thermal_driver = {
> +	.probe = hi3660_thermal_probe,
> +	.remove = hi3660_thermal_exit,
> +	.driver = {
> +		.name = "hi3660_thermal",
> +		.of_match_table = hi3660_thermal_id_table,
> +	},
> +};
> +
> +module_platform_driver(hi3660_thermal_driver);
> +
> +MODULE_AUTHOR("Tao Wang <kevin.wangtao@hisilicon.com>");
> +MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
> +MODULE_DESCRIPTION("hi3660 thermal driver");
> +MODULE_LICENSE("GPL v2");
> -- 
> 1.7.9.5
> 

[toc] | [prev] | [next] | [standalone]


#1672284 — [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-22 05:50 +0200
Subject[Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings
Message-ID<tV1i2-7t5-3@gated-at.bofh.it>
In reply to#1670242
This adds documentation of device tree bindings for the
thermal sensor controller of hi3660 SoC.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
---
Changes in v2:
- remove redundant property

 .../devicetree/bindings/thermal/hi3660-thermal.txt |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/hi3660-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
new file mode 100644
index 0000000..f3dddcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
@@ -0,0 +1,16 @@
+* Temperature Sensor on hisilicon hi3660 SoC
+
+** Required properties :
+
+- compatible: "hisilicon,thermal-hi3660".
+- reg: physical base address of thermal sensor and length of memory mapped
+  region.
+- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
+
+Example :
+
+	tsensor: tsensor {
+		compatible = "hisilicon,thermal-hi3660";
+		reg = <0x0 0xfff30000 0x0 0x1000>;
+		#thermal-sensor-cells = <1>;
+	 };
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1672285 — [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor

FromTao Wang <kevin.wangtao@hisilicon.com>
Date2017-06-22 05:50 +0200
Subject[Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor
Message-ID<tV1i2-7t5-9@gated-at.bofh.it>
In reply to#1672284
Bind thermal sensor driver for Hi3660.

Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
Changes in v2:
- rebase changes on linux next

 arch/arm64/boot/dts/hisilicon/hi3660.dtsi |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index c6a1961..a6a1e01 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -848,5 +848,11 @@
 				     &sdio_cfg_func>;
 			status = "disabled";
 		};
+
+		tsensor: tsensor {
+			compatible = "hisilicon,hi3660-thermal";
+			reg = <0x0 0xfff30000 0x0 0x1000>;
+			#thermal-sensor-cells = <1>;
+		};
 	};
 };
-- 
1.7.9.5

[toc] | [prev] | [next] | [standalone]


#1679254 — Re: [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor

FromEduardo Valentin <edubezval@gmail.com>
Date2017-07-01 05:10 +0200
SubjectRe: [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor
Message-ID<tYgXf-5I0-7@gated-at.bofh.it>
In reply to#1672285
On Thu, Jun 22, 2017 at 11:42:03AM +0800, Tao Wang wrote:
> Bind thermal sensor driver for Hi3660.
> 
> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
> Changes in v2:
> - rebase changes on linux next
> 
>  arch/arm64/boot/dts/hisilicon/hi3660.dtsi |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
> index c6a1961..a6a1e01 100644
> --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
> +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
> @@ -848,5 +848,11 @@
>  				     &sdio_cfg_func>;
>  			status = "disabled";
>  		};
> +
> +		tsensor: tsensor {
> +			compatible = "hisilicon,hi3660-thermal";
> +			reg = <0x0 0xfff30000 0x0 0x1000>;
> +			#thermal-sensor-cells = <1>;
> +		};

Are you planning to also add thermal zone entries?

>  	};
>  };
> -- 
> 1.7.9.5
> 

[toc] | [prev] | [next] | [standalone]


#1679255 — Re: [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

FromEduardo Valentin <edubezval@gmail.com>
Date2017-07-01 05:10 +0200
SubjectRe: [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings
Message-ID<tYgXf-5I0-11@gated-at.bofh.it>
In reply to#1672284
On Thu, Jun 22, 2017 at 11:42:01AM +0800, Tao Wang wrote:
> This adds documentation of device tree bindings for the
> thermal sensor controller of hi3660 SoC.
> 
> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
> ---
> Changes in v2:
> - remove redundant property
> 
>  .../devicetree/bindings/thermal/hi3660-thermal.txt |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> 
> diff --git a/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> new file mode 100644
> index 0000000..f3dddcf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> @@ -0,0 +1,16 @@
> +* Temperature Sensor on hisilicon hi3660 SoC
> +

Would you mind add some more description of the sensors/where to find
further hardware documentation?

> +** Required properties :
> +
> +- compatible: "hisilicon,thermal-hi3660".
> +- reg: physical base address of thermal sensor and length of memory mapped
> +  region.
> +- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
> +
> +Example :
> +
> +	tsensor: tsensor {
> +		compatible = "hisilicon,thermal-hi3660";
> +		reg = <0x0 0xfff30000 0x0 0x1000>;
> +		#thermal-sensor-cells = <1>;
> +	 };
> -- 
> 1.7.9.5
> 

[toc] | [prev] | [next] | [standalone]


#1670644 — Re: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

FromWei Xu <xuwei5@hisilicon.com>
Date2017-06-20 12:30 +0200
SubjectRe: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings
Message-ID<tUoA2-7os-3@gated-at.bofh.it>
In reply to#1670234
Hi Tao,

On 2017/6/20 4:40, Tao Wang wrote:
> This adds documentation of device tree bindings for the
> thermal sensor controller of hi3660 SoC.
> 
> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
> ---
>  .../devicetree/bindings/thermal/hi3660-thermal.txt |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> 
> diff --git a/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> new file mode 100644
> index 0000000..c034670
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
> @@ -0,0 +1,17 @@
> +* Temperature Sensor on hisilicon hi3660 SoC
> +
> +** Required properties :
> +
> +- compatible: "hisilicon,thermal-hi3660".

It is better to put the SoC name before the function string.

BR,
Wei

> +- reg: physical base address of thermal sensor and length of memory mapped
> +  region.
> +- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
> +
> +Example :
> +
> +	tsensor: tsensor {
> +		compatible = "hisilicon,thermal-hi3660";
> +		reg = <0x0 0xfff30000 0x0 0x1000>;
> +		#thermal-sensor-cells = <1>;
> +		status = "ok";
> +	 };
> 

[toc] | [prev] | [next] | [standalone]


#1671289 — Re: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings

From"Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com>
Date2017-06-21 04:20 +0200
SubjectRe: [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings
Message-ID<tUDpo-8t6-7@gated-at.bofh.it>
In reply to#1670644

e( 2017/6/20 18:27, Wei Xu ei:
> Hi Tao,
> 
> On 2017/6/20 4:40, Tao Wang wrote:
>> This adds documentation of device tree bindings for the
>> thermal sensor controller of hi3660 SoC.
>>
>> Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
>> ---
>>   .../devicetree/bindings/thermal/hi3660-thermal.txt |   17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
>> new file mode 100644
>> index 0000000..c034670
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/thermal/hi3660-thermal.txt
>> @@ -0,0 +1,17 @@
>> +* Temperature Sensor on hisilicon hi3660 SoC
>> +
>> +** Required properties :
>> +
>> +- compatible: "hisilicon,thermal-hi3660".
> 
> It is better to put the SoC name before the function string.
ok, I will fix it, thank you.
> 
> BR,
> Wei
> 
>> +- reg: physical base address of thermal sensor and length of memory mapped
>> +  region.
>> +- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description.
>> +
>> +Example :
>> +
>> +	tsensor: tsensor {
>> +		compatible = "hisilicon,thermal-hi3660";
>> +		reg = <0x0 0xfff30000 0x0 0x1000>;
>> +		#thermal-sensor-cells = <1>;
>> +		status = "ok";
>> +	 };
>>
> 
> 
> .
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web