From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: "Wangtao (Kevin, Kirin)" <kevin.wangtao@hisilicon.com>,
rui.zhang@intel.com, edubezval@gmail.com, robh+dt@kernel.org,
mark.rutland@arm.com, xuwei5@hisilicon.com,
catalin.marinas@arm.com, will.deacon@arm.com
Cc: leo.yan@linaro.org, kevin.wangtao@linaro.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, sunzhaosheng@hisilicon.com,
gengyanping@hisilicon.com
Subject: Re: [PATCH v4 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660
Date: Mon, 4 Sep 2017 13:06:39 +0200 [thread overview]
Message-ID: <8fe3ad22-59db-40c6-18db-7b6859f05a95@linaro.org> (raw)
In-Reply-To: <b884f2ca-86e1-0df3-0cbf-99b13232ee03@hisilicon.com>
Hi Kevin,
On 04/09/2017 09:56, Wangtao (Kevin, Kirin) wrote:
>
>
> 在 2017/9/1 5:17, Daniel Lezcano 写道:
>>
>> Hi Kevin,
>>
>>
>> On 29/08/2017 10:17, Tao Wang wrote:
>>> From: Tao Wang <kevin.wangtao@linaro.org>
>>>
>>> This patch adds the support for thermal sensor of Hi3660 SoC.
>>
>> for the Hi3660 SoC thermal sensor.
>>
>>> this will register sensors for thermal framework and use device
>>> tree to bind cooling device.
>>
>> Is it possible to give a pointer to some documentation or to describe
>> the hardware?
> Yes, there used to be on patch V3, I removed it on V4.
>>
>> An explanation of the adc min max coef[] range[] conversion would be
>> nice.
> OK
>>
>> In addition, having the rational behind the average and the max would be
>> nice. Do we really need both avg and max as virtual sensor?
> We only need max currently.
>>
>>> Signed-off-by: Tao Wang <kevin.wangtao@linaro.org>
>>> Signed-off-by: Leo Yan <leo.yan@linaro.org>
>>> ---
>>> drivers/thermal/Kconfig | 13 +++
>>> drivers/thermal/Makefile | 1 +
>>> drivers/thermal/hisi_tsensor.c | 209
>>> +++++++++++++++++++++++++++++++++++++++++
>>
>>
>> IMO, we don't need a new file, but merge this code with the current
>> hisi_thermal.c driver. BTW, the hi6220 has also a tsensor which is
>> different from this one.
>>
>> I suggest to base the hi3660 thermal driver on top of the cleanup I sent
>> for the hi6220.
> The tsensor of hi3660 is a different one, merging the code with hi6220
> will need a lot of change.
Have a look at the hisi_thermal.c at:
https://git.linaro.org/people/daniel.lezcano/linux.git/tree/drivers/thermal/hisi_thermal.c?h=thermal/hikey-4.14
after the cleanup I recently sent.
I'm pretty sure, with a little effort, we can merge both.
Especially if the virtual things is separated.
At the end, what do we do ? Read a register.
>>> 3 files changed, 223 insertions(+)
>>> create mode 100644 drivers/thermal/hisi_tsensor.c
>>>
>>> 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.
>>
>> s/Compitable/Compatible/
> OK
>>
>>> +
>>> 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 <kevin.wangtao@linaro.org>
>>> + * 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 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);
>>
>> That looks a bit fuzzy. Why not create a get_temp for physical sensor
>> and another one for the virtual? So there will be a clear distinction
>> between both.
> make sense
After thinking about it. I think it virtual sensor should be a separate
driver.
[ ... ]
>> Do we really need a max sensor definition in the DT? Isn't it something
>> we can deduce by looping with platform_get_resource below ?
>>
>> eg.
>>
>> while ((res = platform_get_resource(..., num_sensor++)) {
>> ...
>> }
>>
>> That said, I think we can assume there are 3 sensors always, no?
> If we have three CPU cluster or two cluster share the same sensor in
> future, that number is certain on hi3660
Do you mean, it is always 3 ?
>>> + data->sensors = devm_kzalloc(dev,
>>> + sizeof(*data->sensors) * (max_sensor + VIRTUAL_SENSORS),
>>> + GFP_KERNEL);
>>> + if (IS_ERR(data->sensors)) {
[ ... ]
>>> + }
>>> + }
>>> +
>>> + sensor->id = i;
>>
>> How can we deal with holes in the DT?Do you mean the holes of sensor id?
Yes.
[ ... ]
-- Daniel
--
<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
next prev parent reply other threads:[~2017-09-04 11:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 3:40 [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang
2017-06-20 3:40 ` [PATCH 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang
[not found] ` <1497930035-60894-2-git-send-email-kevin.wangtao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-06-20 10:31 ` Wei Xu
[not found] ` <5948F983.5060902-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-06-21 2:21 ` Wangtao (Kevin, Kirin)
2017-06-21 2:29 ` Leo Yan
2017-06-20 3:40 ` [PATCH 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang
2017-06-20 7:38 ` Guodong Xu
2017-06-20 8:32 ` Wangtao (Kevin, Kirin)
[not found] ` <7abe5b01-c728-accd-d6bb-05d9ceee2176-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-06-21 1:58 ` Guodong Xu
2017-06-22 3:42 ` [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang
2017-06-22 3:42 ` [Patch v2 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang
[not found] ` <1498102923-68481-2-git-send-email-kevin.wangtao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-07-01 3:04 ` Eduardo Valentin
2017-07-04 11:24 ` Wangtao (Kevin, Kirin)
2017-06-22 3:42 ` [Patch v2 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang
2017-07-01 3:06 ` Eduardo Valentin
[not found] ` <20170701030613.GC11424-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-07-04 10:50 ` 答复: " Wangtao (Kevin, Kirin)
2017-07-01 3:05 ` [Patch v2 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Eduardo Valentin
[not found] ` <20170701030534.GB11424-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-07-04 11:03 ` Wangtao (Kevin, Kirin)
2017-08-10 8:32 ` [PATCH v3 0/3] thermal: add thermal sensor driver for Hi3660 Tao Wang
2017-08-10 8:32 ` [PATCH v3 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang
2017-08-17 15:10 ` Rob Herring
2017-08-21 2:17 ` Wangtao (Kevin, Kirin)
2017-08-29 8:17 ` [PATCH v4 0/3] thermal: add thermal sensor driver for Hi3660 Tao Wang
2017-08-29 8:17 ` [PATCH v4 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Tao Wang
2017-08-31 18:24 ` Daniel Lezcano
2017-09-04 6:39 ` Wangtao (Kevin, Kirin)
[not found] ` <38fdf052-97be-1b54-5e7d-9dd0bc11e9b4-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-09-04 10:36 ` Daniel Lezcano
2017-08-29 8:17 ` [PATCH v4 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang
2017-08-31 21:17 ` Daniel Lezcano
2017-09-04 7:56 ` Wangtao (Kevin, Kirin)
2017-09-04 11:06 ` Daniel Lezcano [this message]
[not found] ` <8fe3ad22-59db-40c6-18db-7b6859f05a95-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-04 15:06 ` Leo Yan
2017-09-05 7:56 ` Wangtao (Kevin, Kirin)
2017-08-29 8:17 ` [PATCH v4 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang
2017-08-31 21:13 ` Daniel Lezcano
2017-09-04 8:11 ` Wangtao (Kevin, Kirin)
[not found] ` <1502353935-92924-1-git-send-email-kevin.wangtao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
2017-08-10 8:32 ` [PATCH v3 2/3] thermal: hisilicon: add thermal sensor driver for Hi3660 Tao Wang
2017-08-10 8:32 ` [PATCH v3 3/3] arm64: dts: register Hi3660's thermal sensor Tao Wang
2017-06-20 10:27 ` [PATCH 1/3] dt-bindings: Document the hi3660 thermal sensor bindings Wei Xu
2017-06-21 2:10 ` Wangtao (Kevin, Kirin)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8fe3ad22-59db-40c6-18db-7b6859f05a95@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=edubezval@gmail.com \
--cc=gengyanping@hisilicon.com \
--cc=kevin.wangtao@hisilicon.com \
--cc=kevin.wangtao@linaro.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=rui.zhang@intel.com \
--cc=sunzhaosheng@hisilicon.com \
--cc=will.deacon@arm.com \
--cc=xuwei5@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).