* [PATCH resend] thermal: imx: register as OF sensor
@ 2020-03-13 11:01 Lucas Stach
2020-03-13 12:07 ` Daniel Lezcano
0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2020-03-13 11:01 UTC (permalink / raw)
To: Zhang Rui, Daniel Lezcano, Amit Kucheria
Cc: linux-pm, linux-arm-kernel, kernel, patchwork-lst
To make the internal sensor usable with a thermal zone description
provided via DT, also register out device as a OF sensor.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
drivers/thermal/imx_thermal.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index bb6754a5342c..714be941fe6c 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -202,7 +202,7 @@ static struct thermal_soc_data thermal_imx7d_data = {
struct imx_thermal_data {
struct cpufreq_policy *policy;
- struct thermal_zone_device *tz;
+ struct thermal_zone_device *tz, *sensor;
struct thermal_cooling_device *cdev;
enum thermal_device_mode mode;
struct regmap *tempmon;
@@ -338,6 +338,13 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
return 0;
}
+static int imx_of_sensor_get_temp(void *data, int *temp)
+{
+ struct imx_thermal_data *thermal_data = data;
+
+ return imx_get_temp(thermal_data->tz, temp);
+}
+
static int imx_get_mode(struct thermal_zone_device *tz,
enum thermal_device_mode *mode)
{
@@ -482,6 +489,10 @@ static struct thermal_zone_device_ops imx_tz_ops = {
.set_trip_temp = imx_set_trip_temp,
};
+static const struct thermal_zone_of_device_ops imx_tz_of_ops = {
+ .get_temp = imx_of_sensor_get_temp,
+};
+
static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1)
{
struct imx_thermal_data *data = platform_get_drvdata(pdev);
@@ -816,6 +827,9 @@ static int imx_thermal_probe(struct platform_device *pdev)
goto clk_disable;
}
+ data->sensor = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
+ &imx_tz_of_ops);
+
dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
" critical:%dC passive:%dC\n", data->temp_grade,
data->temp_max / 1000, data->temp_critical / 1000,
@@ -871,6 +885,7 @@ static int imx_thermal_remove(struct platform_device *pdev)
if (!IS_ERR(data->thermal_clk))
clk_disable_unprepare(data->thermal_clk);
+ thermal_zone_of_sensor_unregister(&pdev->dev, data->sensor);
thermal_zone_device_unregister(data->tz);
cpufreq_cooling_unregister(data->cdev);
cpufreq_cpu_put(data->policy);
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH resend] thermal: imx: register as OF sensor
2020-03-13 11:01 [PATCH resend] thermal: imx: register as OF sensor Lucas Stach
@ 2020-03-13 12:07 ` Daniel Lezcano
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2020-03-13 12:07 UTC (permalink / raw)
To: Lucas Stach, Zhang Rui, Amit Kucheria
Cc: linux-pm, linux-arm-kernel, kernel, patchwork-lst
On 13/03/2020 12:01, Lucas Stach wrote:
> To make the internal sensor usable with a thermal zone description
> provided via DT, also register out device as a OF sensor.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Are you calling the DT or non-DT at the same function unconditionally ?
> ---
> drivers/thermal/imx_thermal.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index bb6754a5342c..714be941fe6c 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -202,7 +202,7 @@ static struct thermal_soc_data thermal_imx7d_data = {
>
> struct imx_thermal_data {
> struct cpufreq_policy *policy;
> - struct thermal_zone_device *tz;
> + struct thermal_zone_device *tz, *sensor;
> struct thermal_cooling_device *cdev;
> enum thermal_device_mode mode;
> struct regmap *tempmon;
> @@ -338,6 +338,13 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
> return 0;
> }
>
> +static int imx_of_sensor_get_temp(void *data, int *temp)
> +{
> + struct imx_thermal_data *thermal_data = data;
> +
> + return imx_get_temp(thermal_data->tz, temp);
> +}
> +
> static int imx_get_mode(struct thermal_zone_device *tz,
> enum thermal_device_mode *mode)
> {
> @@ -482,6 +489,10 @@ static struct thermal_zone_device_ops imx_tz_ops = {
> .set_trip_temp = imx_set_trip_temp,
> };
>
> +static const struct thermal_zone_of_device_ops imx_tz_of_ops = {
> + .get_temp = imx_of_sensor_get_temp,
> +};
> +
> static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1)
> {
> struct imx_thermal_data *data = platform_get_drvdata(pdev);
> @@ -816,6 +827,9 @@ static int imx_thermal_probe(struct platform_device *pdev)
> goto clk_disable;
> }
>
> + data->sensor = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
> + &imx_tz_of_ops);
> +
> dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
> " critical:%dC passive:%dC\n", data->temp_grade,
> data->temp_max / 1000, data->temp_critical / 1000,
> @@ -871,6 +885,7 @@ static int imx_thermal_remove(struct platform_device *pdev)
> if (!IS_ERR(data->thermal_clk))
> clk_disable_unprepare(data->thermal_clk);
>
> + thermal_zone_of_sensor_unregister(&pdev->dev, data->sensor);
> thermal_zone_device_unregister(data->tz);
> cpufreq_cooling_unregister(data->cdev);
> cpufreq_cpu_put(data->policy);
>
--
<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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-13 12:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 11:01 [PATCH resend] thermal: imx: register as OF sensor Lucas Stach
2020-03-13 12:07 ` Daniel Lezcano
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).