From patchwork Tue Aug 29 08:17:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangtao \(Kevin, Kirin\)" X-Patchwork-Id: 111197 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp986974qge; Tue, 29 Aug 2017 01:24:18 -0700 (PDT) X-Received: by 10.84.131.47 with SMTP id 44mr148757pld.142.1503995058056; Tue, 29 Aug 2017 01:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503995058; cv=none; d=google.com; s=arc-20160816; b=dwbez6vZJbrJsJ96rJXh5dizxQ6l9O5H+v+4BiHgigy69yFNxAx5npW/j1TMTqZo7a SSP4M3LdhuefukdJh4huxZzauct+9XmdL85AsfaxvKuxRApiKS8AEGtGDp1Arcxig/dJ i2SbyzVCJs5tgrDnXZ7e1FtTl2mW8cWSpR7PKfvDq7pBjjQWfCA3LWHHp+hCuG4BuTu2 ZvxxUAmFYqWj/ol7bm8HuLyaBwXlHQqWd/wap/dPv2ybssEG7jd0dIQdW6shDV+1qCiK dkuQNA/jT59HeKvx+SX7+PGWXYOzFlqx0XYhWT1Vn93wuv9oYxqv1xgu4wUYbKseBa8Z e86w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=nKGSHi4hL5XqqZz0lOVcwaxGNPBeJPYaotesuVMljss=; b=m8qWnL+Vc6GFfQNIguTi6HTclV5CHVc9JCVksA849KXiQeGVGQG2CVsIv0W7617Db9 PLEH8RVRSgNkT9rRiSDLO0HGvjy2Re/u8jZ5SFEEcV5NlZnSEiYLROSbDuMPV7s2FyBt Da9TWJ88xlzXgfGGbO7O4Fcg6zL5Q80JuJHg4NCde94HGrQMMeG4bJoe6BOvuqheuxDC I1fINlGK8D6kPGPOEcvvqqxa9IWfdwCqR8VccTan7ZvKeZa6mABfWnVIc0rguuwrAoVT fZ8MOjsmjO/sFfx/PUIcUSKJKGI0g8plrymnm5X7T0JrCsvh+HEafplvVpdWDkrMnrck WzuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si1829944pfg.508.2017.08.29.01.24.17; Tue, 29 Aug 2017 01:24:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbdH2IYO (ORCPT + 26 others); Tue, 29 Aug 2017 04:24:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5482 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbdH2IYG (ORCPT ); Tue, 29 Aug 2017 04:24:06 -0400 Received: from 172.30.72.59 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGC68823; Tue, 29 Aug 2017 16:24:04 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.301.0; Tue, 29 Aug 2017 16:23:54 +0800 From: Tao Wang To: , , , , , , CC: , , , , , , , Subject: [PATCH v4 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Date: Tue, 29 Aug 2017 16:17:44 +0800 Message-ID: <1503994666-13954-2-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.59A524A4.0059, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: bc4b412c19a7039dd17be252292c34a6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Wang This adds documentation of device tree bindings for the thermal sensor controller of hi3660 SoC. Signed-off-by: Tao Wang --- .../devicetree/bindings/thermal/hisi-tsensor.txt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/hisi-tsensor.txt -- 2.8.1 diff --git a/Documentation/devicetree/bindings/thermal/hisi-tsensor.txt b/Documentation/devicetree/bindings/thermal/hisi-tsensor.txt new file mode 100644 index 0000000..4643dbe --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/hisi-tsensor.txt @@ -0,0 +1,37 @@ +* Temperature Sensor on hisilicon SoC + +Hisilicon SoC supplies temperature sensor feature, each CPU cluster and G3D +area contains a temperture sensor. The temperture sensor produces an output +value which has a linear relationship with the temperture of the area. + +for Hi3660, +sensor0 monitors the temperture of A53; +sensor1 monitors the temperture of A72; +sensor2 monitors the temperture of GPU; +sensor3 is a virtual sensor, which produces the maximum value of all sensors; +sensor4 is a virtual sensor, which produces the average value of all sensors. + +** Required properties : +- compatible: "hisilicon,thermal-tsensor". +- reg: physical reg address of thermal sensor and length of memory mapped + region. +- hisi,tsensors: number of hardware tsensors +- hisi,coef: An array of integers (one signed cell) containing + coefficients to turn adc value to temperture. +- hisi,adc-range: adc value range, minimum value is followed by maximum value. +- #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description. + +Example : +Hi3660: +tsensor: tsensor@fff30000 { + compatible = "hisilicon,hi3660-tsensor"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x0 0xfff3001c 0x0 0x4>, + <0x0 0xfff3005c 0x0 0x4>, + <0x0 0xfff3009c 0x0 0x4>; + hisi,tsensors = ; + hisi,coef = <165000 (-40000)>; + hisi,adc-range = <0x74 0x39A>; + #thermal-sensor-cells = <1>; +}; From patchwork Tue Aug 29 08:17:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangtao \(Kevin, Kirin\)" X-Patchwork-Id: 111199 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp987516qge; Tue, 29 Aug 2017 01:24:56 -0700 (PDT) X-Received: by 10.84.233.133 with SMTP id l5mr120353plk.7.1503995096618; Tue, 29 Aug 2017 01:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503995096; cv=none; d=google.com; s=arc-20160816; b=sWrsGIRYnfMOwP/vXSEJ23mIag6yRSuDBSZusONAqnysLyZh7giElXVx0SL1H7UueV IsW46umGcHblpQXcor53OpCH0SN0Zgln+cjkeweyR3IHzZNB4xvscRcCZm7fcczl7AQE 9FaUGKDWe56v7bQbAg7rHwbI87aZ4WjjANwzhsjitRfQzZy1UzJzC5433o1QkXXCHTpR BE8/SxXEXHcFwCSCGET5DT/lFZVtDSCr/IkyBtj4sKxp7VfQDT8r7K4mGpgOVojUo/PO shv0BV6cX79LcftyO73WMnSEzGEhwWTM4qaCtaG5ES7gk8WVIayt1Z2+LoPc2WGcSYC3 rzmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=RYQWgBB0yIabKe7Dy+WCG5ah2tQFxxSzX1ZUfl7P/7c=; b=nCPTmNUauEBKM3P8o/7zF7rTLO/qgU6txW+UIW6HIKeoKDEyNK0xD7siWuv6ZE2GG+ Bc7qqa0YHpMReFQQ1lUm1ld1sqwo2MPkV5QGPYitV1TYoIoPbkL8mOfXswrOep2nhX1J UdSrIY5iyS6czupGar+vFasmN15C2NBHFixioPD/uqzpBW6+U8RR7Is/COn4xVFXG620 xtr4F3zLeJIZf8ezM/h24/FLWzU+Co70jHylZteCPxsu8Wm6oaXZYVLVVYrrDlbPMzJm DwZqburMAHC5G4O6DXySTqb/8Ovl1WnVLW72l8AaSRNQmen1IwnOvoKDHTRj6+XUakle EYXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si1963752pff.4.2017.08.29.01.24.56; Tue, 29 Aug 2017 01:24:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751419AbdH2IYM (ORCPT + 26 others); Tue, 29 Aug 2017 04:24:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5484 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751375AbdH2IYH (ORCPT ); Tue, 29 Aug 2017 04:24:07 -0400 Received: from 172.30.72.59 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGC68827; Tue, 29 Aug 2017 16:24:04 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.301.0; Tue, 29 Aug 2017 16:23:56 +0800 From: Tao Wang To: , , , , , , CC: , , , , , , , Subject: [PATCH v4 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Date: Tue, 29 Aug 2017 16:17:45 +0800 Message-ID: <1503994666-13954-3-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.59A524A5.001D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f21e80b3360e7858a282ccae167718d0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Wang 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 Signed-off-by: Leo Yan --- drivers/thermal/Kconfig | 13 +++ drivers/thermal/Makefile | 1 + drivers/thermal/hisi_tsensor.c | 209 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 drivers/thermal/hisi_tsensor.c -- 2.8.1 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index b5b5fac..32f582d 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -203,6 +203,19 @@ config HISI_THERMAL thermal framework. cpufreq is used as the cooling device to throttle CPUs when the passive trip is crossed. +config HISI_TSENSOR + tristate "Hisilicon tsensor driver" + depends on ARCH_HISI || COMPILE_TEST + depends on HAS_IOMEM + depends on OF + default y + help + Enable this to plug Hisilicon's tsensor driver into the Linux thermal + framework. Besides all the hardware sensors, this also support two + virtual sensors, one for maximum of all the hardware sensor, and + one for average of all the hardware sensor. + Compitable with Hi3660 or higher. + 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..8a16bd4 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_ST_THERMAL) += st/ obj-$(CONFIG_QCOM_TSENS) += qcom/ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra/ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o +obj-$(CONFIG_HISI_TSENSOR) += hisi_tsensor.o obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_ZX2967_THERMAL) += zx2967_thermal.o diff --git a/drivers/thermal/hisi_tsensor.c b/drivers/thermal/hisi_tsensor.c new file mode 100644 index 0000000..34cf2ba --- /dev/null +++ b/drivers/thermal/hisi_tsensor.c @@ -0,0 +1,209 @@ +/* + * linux/drivers/thermal/hisi_tsensor.c + * + * Copyright (c) 2017 Hisilicon Limited. + * Copyright (c) 2017 Linaro Limited. + * + * Author: Tao Wang + * Author: Leo Yan + * + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "thermal_core.h" + +#define VIRTUAL_SENSORS 2 + +/* hisi Thermal Sensor Dev Structure */ +struct hisi_thermal_sensor { + struct hisi_thermal_data *thermal; + struct thermal_zone_device *tzd; + void __iomem *sensor_reg; + unsigned int id; +}; + +struct hisi_thermal_data { + struct platform_device *pdev; + struct hisi_thermal_sensor *sensors; + unsigned int range[2]; + unsigned int coef[2]; + unsigned int max_hw_sensor; +}; + +static int hisi_thermal_get_temp(void *_sensor, int *temp) +{ + struct hisi_thermal_sensor *sensor = _sensor; + struct hisi_thermal_data *data = sensor->thermal; + unsigned int idx, adc_min, adc_max, max_sensor; + int val, average = 0, max = 0; + + adc_min = data->range[0]; + adc_max = data->range[1]; + max_sensor = data->max_hw_sensor; + + if (sensor->id < max_sensor) { + val = readl(sensor->sensor_reg); + val = clamp_val(val, adc_min, adc_max); + } else { + for (idx = 0; idx < max_sensor; idx++) { + val = readl(data->sensors[idx].sensor_reg); + val = clamp_val(val, adc_min, adc_max); + average += val; + if (val > max) + max = val; + } + + if (sensor->id == max_sensor) + val = max; + else + val = average / max_sensor; + } + + *temp = ((val - adc_min) * data->coef[0]) / (adc_max - adc_min) + + data->coef[1]; + + return 0; +} + +static struct thermal_zone_of_device_ops hisi_of_thermal_ops = { + .get_temp = hisi_thermal_get_temp, +}; + +static void hisi_thermal_toggle_sensor(struct hisi_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 hisi_thermal_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct hisi_thermal_data *data; + struct hisi_thermal_sensor *sensor; + struct resource *res; + unsigned int max_sensor; + int ret, i; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->pdev = pdev; + ret = of_property_read_u32(np, "hisi,tsensors", &max_sensor); + if (ret < 0) { + dev_err(dev, "failed to get max sensor\n"); + return -EINVAL; + } + data->max_hw_sensor = max_sensor; + + data->sensors = devm_kzalloc(dev, + sizeof(*data->sensors) * (max_sensor + VIRTUAL_SENSORS), + GFP_KERNEL); + if (IS_ERR(data->sensors)) { + dev_err(dev, "failed to alloc sensors\n"); + return -ENOMEM; + } + + ret = of_property_read_u32_array(np, "hisi,coef", data->coef, 2); + if (ret < 0) { + dev_err(dev, "failed to get coef\n"); + return -EINVAL; + } + + ret = of_property_read_u32_array(np, "hisi,adc-range", data->range, 2); + if (ret < 0) { + dev_err(dev, "failed to get range\n"); + return -EINVAL; + } + + platform_set_drvdata(pdev, data); + + for (i = 0; i < max_sensor + VIRTUAL_SENSORS; ++i) { + sensor = &data->sensors[i]; + if (i < max_sensor) { + res = platform_get_resource(pdev, IORESOURCE_MEM, i); + sensor->sensor_reg = devm_ioremap_resource(dev, res); + if (IS_ERR(sensor->sensor_reg)) { + dev_err(dev, "failed to get reg base\n"); + return -ENOMEM; + } + } + + sensor->id = i; + sensor->thermal = data; + sensor->tzd = thermal_zone_of_sensor_register(dev, + i, sensor, &hisi_of_thermal_ops); + if (IS_ERR(sensor->tzd)) { + sensor->tzd = NULL; + } else { + hisi_thermal_toggle_sensor(sensor, true); + dev_info(dev, "thermal sensor%d registered\n", i); + } + } + + return 0; +} + +static int hisi_thermal_exit(struct platform_device *pdev) +{ + struct hisi_thermal_data *data = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < data->max_hw_sensor + VIRTUAL_SENSORS; i++) { + struct hisi_thermal_sensor *sensor = &data->sensors[i]; + + if (!sensor->tzd) + continue; + + hisi_thermal_toggle_sensor(sensor, false); + thermal_zone_of_sensor_unregister(&pdev->dev, sensor->tzd); + } + + return 0; +} + +static const struct of_device_id hisi_thermal_id_table[] = { + { .compatible = "hisilicon,hi3660-tsensor" }, + {} +}; +MODULE_DEVICE_TABLE(of, hisi_thermal_id_table); + +static struct platform_driver hisi_thermal_driver = { + .probe = hisi_thermal_probe, + .remove = hisi_thermal_exit, + .driver = { + .name = "hisi_tsensor", + .of_match_table = hisi_thermal_id_table, + }, +}; + +module_platform_driver(hisi_thermal_driver); + +MODULE_AUTHOR("Tao Wang "); +MODULE_AUTHOR("Leo Yan "); +MODULE_DESCRIPTION("hisi tsensor driver"); +MODULE_LICENSE("GPL v2"); From patchwork Tue Aug 29 08:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangtao \(Kevin, Kirin\)" X-Patchwork-Id: 111198 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp987018qge; Tue, 29 Aug 2017 01:24:21 -0700 (PDT) X-Received: by 10.98.166.151 with SMTP id r23mr3081803pfl.168.1503995061659; Tue, 29 Aug 2017 01:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503995061; cv=none; d=google.com; s=arc-20160816; b=zvpWFdZmmKlxmnG5/RE7zMIpQqKV7ZKj5awYdMx6x5fxCk3HVef6CTzHBa5SPc+3s2 UohBXKU4O1+YN83CfBNyA3pqWZnvHO2IHL+x+JJlQeo7/isppeJLmDlnKpbrvWWfMvls 21Mdal71YnKpwg2JnKuB1m+0KpEggU7DXUh23z1im/i2fUxYPdPLuPz51B4bjHrdaVuP c9Cc8M463HWXe2TPdvDn+2y3sjK41OCeikSb75YJkuBz5ywMQc11YSlJ4qItrFC/yOT8 6zxlAsTfwKrA86SkTP554cUL4823AZHU5gh5RyZQSdnYujkcdZO0OzoR3sDrurW8qdMP 8WFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=wBoxBM221326V9vy0ECcWRQowrIlWduFIH/PBQUiefI=; b=nCXWS2iacunoY346zPXl8dcd7XrtM2X2oXn8vjUwfgEuQZhCFEMQF1PM9J8IoBAUgL AppeiOs3V8ujKv+e8GmuO1l6sfVhhuRJLGtpiWlPyU1l7PxU/1w9dDVV69BfN1nloRF5 k7jKoQ4kGPGnGaumljLl6R5NhMi9xb4Yqd+kUzaeztBdUQeRXlHfhHpOjFSFaH7mVeiq 2/UCxijwFqRMcWBPew531/RXtpsajW73iYo7+P/WJctqZZzjcD/mukffp9sDEo6vXn4D 1Ars2vze5GzYr22MGpQz+Z0JKf3Awl50mIEQYxpjxhOXCDtWLbgdDFA2+LbInhx9JUza cZ8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si1963752pff.4.2017.08.29.01.24.21; Tue, 29 Aug 2017 01:24:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751496AbdH2IYQ (ORCPT + 26 others); Tue, 29 Aug 2017 04:24:16 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5483 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbdH2IYH (ORCPT ); Tue, 29 Aug 2017 04:24:07 -0400 Received: from 172.30.72.59 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGC68826; Tue, 29 Aug 2017 16:24:04 +0800 (CST) Received: from HSH1000038028.huawei.com (10.177.161.152) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.301.0; Tue, 29 Aug 2017 16:23:58 +0800 From: Tao Wang To: , , , , , , CC: , , , , , , , Subject: [PATCH v4 3/3] arm64: dts: register Hi3660's thermal sensor Date: Tue, 29 Aug 2017 16:17:46 +0800 Message-ID: <1503994666-13954-4-git-send-email-kevin.wangtao@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> References: <1503994666-13954-1-git-send-email-kevin.wangtao@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.177.161.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.59A524A4.0078, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 83ca64707c145ce5072af9384a504cbe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Wang Bind thermal sensor driver for Hi3660. Signed-off-by: Tao Wang Signed-off-by: Leo Yan --- arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 14 +++++++++++++ include/dt-bindings/thermal/hi3660-thermal.h | 31 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 include/dt-bindings/thermal/hi3660-thermal.h -- 2.8.1 diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index c6a1961..1ee6084 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -6,6 +6,7 @@ #include #include +#include / { compatible = "hisilicon,hi3660"; @@ -848,5 +849,18 @@ &sdio_cfg_func>; status = "disabled"; }; + + tsensor: tsensor@fff30000 { + compatible = "hisilicon,hi3660-tsensor"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x0 0xfff3001c 0x0 0x4>, + <0x0 0xfff3005c 0x0 0x4>, + <0x0 0xfff3009c 0x0 0x4>; + hisi,tsensors = ; + hisi,coef = <165000 (-40000)>; + hisi,adc-range = <0x74 0x39A>; + #thermal-sensor-cells = <1>; + }; }; }; diff --git a/include/dt-bindings/thermal/hi3660-thermal.h b/include/dt-bindings/thermal/hi3660-thermal.h new file mode 100644 index 0000000..d9d9b6a --- /dev/null +++ b/include/dt-bindings/thermal/hi3660-thermal.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Hisilicon Limited. + * Copyright (c) 2017 Linaro Limited. + * + * 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 . + */ + +#ifndef __DTS_HI3660_THERMAL_H +#define __DTS_HI3660_THERMAL_H + +/* sensor id */ +#define LITTLE_CPU_TEMP 0 +#define BIG_CPU_TEMP 1 +#define GPU_TEMP 2 +#define MAX_TEMP 3 +#define AVG_TEMP 4 + +#define HISI_MAX_TSENSORS 3 +#define THERMAL_NO_LIMIT (~0) + +#endif