From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Peng Fan <peng.fan@oss.nxp.com>,
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
Peng Fan <peng.fan@nxp.com>,
"rafael@kernel.org" <rafael@kernel.org>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "amitk@kernel.org" <amitk@kernel.org>,
"rui.zhang@intel.com" <rui.zhang@intel.com>,
"andrew.smirnov@gmail.com" <andrew.smirnov@gmail.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
dl-linux-imx <linux-imx@nxp.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Alice Guo <alice.guo@nxp.com>
Subject: Re: [PATCH 2/3] thermal: qoriq_thermal: only enable supported sensors
Date: Thu, 15 Jun 2023 13:48:49 +0200 [thread overview]
Message-ID: <3e397cf5-0ca3-fa10-b5d8-bbc7b1038a37@linaro.org> (raw)
In-Reply-To: <3518a2e7-806d-ad46-a439-ff4a57ed8158@oss.nxp.com>
On 15/06/2023 06:04, Peng Fan wrote:
>
>
> On 6/15/2023 10:53 AM, Sebastian Krzyszkowiak wrote:
>> Caution: This is an external email. Please take care when clicking
>> links or opening attachments. When in doubt, report the message using
>> the 'Report this email' button
>>
>>
>> On czwartek, 15 czerwca 2023 04:29:01 CEST Peng Fan wrote:
>>> On 6/8/2023 3:10 AM, Daniel Lezcano wrote:
>>>>
>>>> [...]
>>>>
>>>> Ok, I misunderstood. I thought that was for failing registered thermal
>>>> zone.
>>>>
>>>> Would enabling the site in ops->change_mode do the trick ?
>>>
>>> No. ops->change_mode not able to do the trick.
>>>
>>> devm_thermal_of_zone_register->thermal_zone_device_enable
>>> ->thermal_zone_device_set_mode->__thermal_zone_device_update.part.0
>>> ->__thermal_zone_get_temp
>>>
>>> The thermal_zone_device_set_mode will call change_mode, if return
>>> fail here, the thermal zone will fail to be registered.
>>>
>>> Thanks,
>>> Peng.
>>
>> I think the idea is not to return a failure in ops->change_mode, but
>> to move
>> enabling the site in REGS_TMR/REGS_V2_TMSR register from
>> qoriq_tmu_register_tmu_zone to ops->change_mode.
>
> But qoriq_tmu_register_tmu_zone will finally call ops->change_mode.
>
> And it is per zone, so we not able to enable TMR_ME here.
>
> This way the site will be
>> enabled only for actually existing thermal zones, since those not
>> described in
>> the device tree won't reach thermal_zone_device_enable.
>
> No. The TMR_ME is the gate for all sites.
What about the following change on top of your series:
diff --git a/drivers/thermal/qoriq_thermal.c
b/drivers/thermal/qoriq_thermal.c
index c710449b0c50..ecf88bf13762 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -107,8 +107,6 @@ static int tmu_get_temp(struct thermal_zone_device
*tz, int *temp)
*/
regmap_read(qdata->regmap, REGS_TMR, &val);
- if (!(val & TMR_ME))
- return -EAGAIN;
if (regmap_read_poll_timeout(qdata->regmap,
REGS_TRITSR(qsensor->id),
@@ -131,14 +129,40 @@ static int tmu_get_temp(struct thermal_zone_device
*tz, int *temp)
return 0;
}
+static int qoriq_tmu_change_mode(struct thermal_zone_device *tz,
+ enum thermal_device_mode mode)
+{
+ struct qoriq_sensor *qsensor = thermal_zone_device_priv(tz);
+ struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
+ unsigned int site;
+ unsigned int value;
+ unsigned int mask;
+
+ if (qdata->ver == TMU_VER1) {
+ site = BIT(15 - qsensor->id);
+ mask = TMR_ME | TMR_ALPF | site;
+ value = mode == THERMAL_DEVICE_ENABLED ? mask : mask & ~site;
+ regmap_update_bits(qdata->regmap, REGS_TMR, mask, value);
+ } else {
+ site = BIT(qsensor->id);
+ mask = TMR_ME | TMR_ALPF_V2 | site;
+ value = mode == THERMAL_DEVICE_ENABLED ? mask : mask & ~site;
+ regmap_update_bits(qdata->regmap, REGS_V2_TMSR, mask, value);
+ regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2);
+ }
+
+ return 0;
+}
+
static const struct thermal_zone_device_ops tmu_tz_ops = {
.get_temp = tmu_get_temp,
+ .change_mode = qoriq_tmu_change_mode,
};
static int qoriq_tmu_register_tmu_zone(struct device *dev,
struct qoriq_tmu_data *qdata)
{
- int id, sites = 0;
+ int id;
for (id = 0; id < SITES_MAX; id++) {
struct thermal_zone_device *tzd;
@@ -158,25 +182,11 @@ static int qoriq_tmu_register_tmu_zone(struct
device *dev,
return ret;
}
- if (qdata->ver == TMU_VER1)
- sites |= 0x1 << (15 - id);
- else
- sites |= 0x1 << id;
-
if (devm_thermal_add_hwmon_sysfs(dev, tzd))
dev_warn(dev,
"Failed to add hwmon sysfs attributes\n");
}
- if (sites) {
- if (qdata->ver == TMU_VER1) {
- regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF | sites);
- } else {
- regmap_write(qdata->regmap, REGS_V2_TMSR, sites);
- regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2);
- }
- }
-
return 0;
}
--
<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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-06-15 11:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 8:37 [PATCH 0/3] thermal: qoriq_thermal: support TMU 2.1 Peng Fan (OSS)
2023-05-16 8:37 ` [PATCH 1/3] thermal: qoriq_thermal: No need to program site adjustment register Peng Fan (OSS)
2023-05-16 8:37 ` [PATCH 2/3] thermal: qoriq_thermal: only enable supported sensors Peng Fan (OSS)
2023-05-31 11:03 ` Daniel Lezcano
2023-05-31 12:05 ` Peng Fan
2023-05-31 12:35 ` Daniel Lezcano
2023-05-31 13:00 ` Peng Fan
2023-06-01 9:52 ` Peng Fan
2023-06-02 13:11 ` Daniel Lezcano
2023-06-07 6:01 ` Sebastian Krzyszkowiak
2023-06-07 8:28 ` Daniel Lezcano
2023-06-07 17:42 ` Sebastian Krzyszkowiak
2023-06-07 19:10 ` Daniel Lezcano
2023-06-15 2:29 ` Peng Fan
2023-06-15 2:53 ` Sebastian Krzyszkowiak
2023-06-15 4:04 ` Peng Fan
2023-06-15 10:36 ` Daniel Lezcano
2023-06-15 11:48 ` Daniel Lezcano [this message]
2023-06-15 12:07 ` Peng Fan
2023-06-15 13:49 ` Daniel Lezcano
2023-06-16 1:06 ` Peng Fan
2023-06-16 9:01 ` Daniel Lezcano
2023-05-16 8:37 ` [PATCH 3/3] thermal: qoriq: support version 2.1 Peng Fan (OSS)
2023-05-23 1:59 ` [PATCH 0/3] thermal: qoriq_thermal: support TMU 2.1 Alice Guo
2023-05-29 3:35 ` Peng Fan
2023-06-16 9:02 ` Daniel Lezcano
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=3e397cf5-0ca3-fa10-b5d8-bbc7b1038a37@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=alice.guo@nxp.com \
--cc=amitk@kernel.org \
--cc=andrew.smirnov@gmail.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=s.hauer@pengutronix.de \
--cc=sebastian.krzyszkowiak@puri.sm \
--cc=shawnguo@kernel.org \
/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).