linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>
Cc: linux-pm@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 1/2] thermal: db8500: Finalize device tree conversion
Date: Thu, 22 Aug 2019 08:16:03 +0200	[thread overview]
Message-ID: <47cb523f-60ad-750e-4374-6563f8230593@linaro.org> (raw)
In-Reply-To: <20190717063222.5902-1-linus.walleij@linaro.org>

On 17/07/2019 08:32, Linus Walleij wrote:
> At some point there was an attempt to convert the DB8500
> thermal sensor to device tree: a probe path was added
> and the device tree was augmented for the Snowball board.
> The switchover was never completed: instead the thermal
> devices came from from the PRCMU MFD device and the probe
> on the Snowball was confused as another set of configuration
> appeared from the device tree.
> 
> Move over to a device-tree only approach, as we fixed up
> the device trees.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Lee: it'd be great if you could ACK this, it is a file
> with low change rate so we should likely not see any
> collisions.
> ---
>  drivers/mfd/db8500-prcmu.c                   | 53 +-------------------
>  drivers/thermal/Kconfig                      |  2 +-
>  drivers/thermal/db8500_thermal.c             | 30 +++++------
>  include/linux/platform_data/db8500_thermal.h | 29 -----------
>  4 files changed, 17 insertions(+), 97 deletions(-)
>  delete mode 100644 include/linux/platform_data/db8500_thermal.h
> 
> diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
> index 3f21e26b8d36..a1e09bf06977 100644
> --- a/drivers/mfd/db8500-prcmu.c
> +++ b/drivers/mfd/db8500-prcmu.c
> @@ -36,7 +36,6 @@
>  #include <linux/regulator/db8500-prcmu.h>
>  #include <linux/regulator/machine.h>
>  #include <linux/platform_data/ux500_wdt.h>
> -#include <linux/platform_data/db8500_thermal.h>
>  #include "dbx500-prcmu-regs.h"
>  
>  /* Index of different voltages to be used when accessing AVSData */
> @@ -2982,53 +2981,6 @@ static struct ux500_wdt_data db8500_wdt_pdata = {
>  	.timeout = 600, /* 10 minutes */
>  	.has_28_bits_resolution = true,
>  };
> -/*
> - * Thermal Sensor
> - */
> -
> -static struct resource db8500_thsens_resources[] = {
> -	{
> -		.name = "IRQ_HOTMON_LOW",
> -		.start  = IRQ_PRCMU_HOTMON_LOW,
> -		.end    = IRQ_PRCMU_HOTMON_LOW,
> -		.flags  = IORESOURCE_IRQ,
> -	},
> -	{
> -		.name = "IRQ_HOTMON_HIGH",
> -		.start  = IRQ_PRCMU_HOTMON_HIGH,
> -		.end    = IRQ_PRCMU_HOTMON_HIGH,
> -		.flags  = IORESOURCE_IRQ,
> -	},
> -};
> -
> -static struct db8500_thsens_platform_data db8500_thsens_data = {
> -	.trip_points[0] = {
> -		.temp = 70000,
> -		.type = THERMAL_TRIP_ACTIVE,
> -		.cdev_name = {
> -			[0] = "thermal-cpufreq-0",
> -		},
> -	},
> -	.trip_points[1] = {
> -		.temp = 75000,
> -		.type = THERMAL_TRIP_ACTIVE,
> -		.cdev_name = {
> -			[0] = "thermal-cpufreq-0",
> -		},
> -	},
> -	.trip_points[2] = {
> -		.temp = 80000,
> -		.type = THERMAL_TRIP_ACTIVE,
> -		.cdev_name = {
> -			[0] = "thermal-cpufreq-0",
> -		},
> -	},
> -	.trip_points[3] = {
> -		.temp = 85000,
> -		.type = THERMAL_TRIP_CRITICAL,
> -	},
> -	.num_trips = 4,
> -};

I've been through the DT and I don't understand why there is:

	[ ... ]
        trip0-temp = <70000>;
        trip0-type = "active";
        trip0-cdev-num = <1>;
        trip0-cdev-name0 = "thermal-cpufreq-0";
	[ ... ]

Those bindings already exists for the thermal no?

Why not create a thermal-zone node and then add the values above?

Another point is there are too many trip points, two should be enough,
one for throttling and one for critical, the governor will handle that
properly by stepping the opps.

And one last point is the trip point should be passive, not active.


>  static const struct mfd_cell common_prcmu_devs[] = {
>  	{
> @@ -3052,10 +3004,7 @@ static const struct mfd_cell db8500_prcmu_devs[] = {
>  	},
>  	{
>  		.name = "db8500-thermal",
> -		.num_resources = ARRAY_SIZE(db8500_thsens_resources),
> -		.resources = db8500_thsens_resources,
> -		.platform_data = &db8500_thsens_data,
> -		.pdata_size = sizeof(db8500_thsens_data),
> +		.of_compatible = "stericsson,db8500-thermal",
>  	},
>  };
>  
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index 9966364a6deb..001a21abcc28 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -310,7 +310,7 @@ config DOVE_THERMAL
>  
>  config DB8500_THERMAL
>  	tristate "DB8500 thermal management"
> -	depends on MFD_DB8500_PRCMU
> +	depends on MFD_DB8500_PRCMU && OF
>  	default y
>  	help
>  	  Adds DB8500 thermal management implementation according to the thermal
> diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
> index b71a999d17d6..d650ae5fdf2a 100644
> --- a/drivers/thermal/db8500_thermal.c
> +++ b/drivers/thermal/db8500_thermal.c
> @@ -13,13 +13,24 @@
>  #include <linux/mfd/dbx500-prcmu.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> -#include <linux/platform_data/db8500_thermal.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/thermal.h>
>  
>  #define PRCMU_DEFAULT_MEASURE_TIME	0xFFF
>  #define PRCMU_DEFAULT_LOW_TEMP		0
> +#define COOLING_DEV_MAX 8
> +
> +struct db8500_trip_point {
> +	unsigned long temp;
> +	enum thermal_trip_type type;
> +	char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH];
> +};
> +
> +struct db8500_thsens_platform_data {
> +	struct db8500_trip_point trip_points[THERMAL_MAX_TRIPS];
> +	int num_trips;
> +};
>  
>  struct db8500_thermal_zone {
>  	struct thermal_zone_device *therm_dev;
> @@ -301,7 +312,6 @@ static void db8500_thermal_work(struct work_struct *work)
>  	dev_dbg(&pzone->therm_dev->device, "thermal work finished.\n");
>  }
>  
> -#ifdef CONFIG_OF
>  static struct db8500_thsens_platform_data*
>  		db8500_thermal_parse_dt(struct platform_device *pdev)
>  {
> @@ -370,13 +380,6 @@ static struct db8500_thsens_platform_data*
>  	dev_err(&pdev->dev, "Parsing device tree data error.\n");
>  	return NULL;
>  }
> -#else
> -static inline struct db8500_thsens_platform_data*
> -		db8500_thermal_parse_dt(struct platform_device *pdev)
> -{
> -	return NULL;
> -}
> -#endif
>  
>  static int db8500_thermal_probe(struct platform_device *pdev)
>  {
> @@ -386,11 +389,10 @@ static int db8500_thermal_probe(struct platform_device *pdev)
>  	int low_irq, high_irq, ret = 0;
>  	unsigned long dft_low, dft_high;
>  
> -	if (np)
> -		ptrips = db8500_thermal_parse_dt(pdev);
> -	else
> -		ptrips = dev_get_platdata(&pdev->dev);
> +	if (!np)
> +		return -EINVAL;
>  
> +	ptrips = db8500_thermal_parse_dt(pdev);
>  	if (!ptrips)
>  		return -EINVAL;
>  
> @@ -498,13 +500,11 @@ static int db8500_thermal_resume(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_OF
>  static const struct of_device_id db8500_thermal_match[] = {
>  	{ .compatible = "stericsson,db8500-thermal" },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, db8500_thermal_match);
> -#endif
>  
>  static struct platform_driver db8500_thermal_driver = {
>  	.driver = {
> diff --git a/include/linux/platform_data/db8500_thermal.h b/include/linux/platform_data/db8500_thermal.h
> deleted file mode 100644
> index 55e55750a165..000000000000
> --- a/include/linux/platform_data/db8500_thermal.h
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-or-later */
> -/*
> - * db8500_thermal.h - DB8500 Thermal Management Implementation
> - *
> - * Copyright (C) 2012 ST-Ericsson
> - * Copyright (C) 2012 Linaro Ltd.
> - *
> - * Author: Hongbo Zhang <hongbo.zhang@linaro.com>
> - */
> -
> -#ifndef _DB8500_THERMAL_H_
> -#define _DB8500_THERMAL_H_
> -
> -#include <linux/thermal.h>
> -
> -#define COOLING_DEV_MAX 8
> -
> -struct db8500_trip_point {
> -	unsigned long temp;
> -	enum thermal_trip_type type;
> -	char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH];
> -};
> -
> -struct db8500_thsens_platform_data {
> -	struct db8500_trip_point trip_points[THERMAL_MAX_TRIPS];
> -	int num_trips;
> -};
> -
> -#endif /* _DB8500_THERMAL_H_ */
> 


-- 
 <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


  parent reply	other threads:[~2019-08-22  6:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17  6:32 [PATCH 1/2] thermal: db8500: Finalize device tree conversion Linus Walleij
2019-07-17  6:32 ` [PATCH 2/2] thermal: db8500: Use dev helper variable Linus Walleij
2019-07-25 12:21 ` [PATCH 1/2] thermal: db8500: Finalize device tree conversion Lee Jones
2019-08-03 13:58 ` Linus Walleij
2019-08-11 22:21   ` Linus Walleij
2019-08-22  6:16 ` Daniel Lezcano [this message]
2019-08-27 11:21   ` Linus Walleij
2019-08-27 13:24     ` Daniel Lezcano
2019-08-27 13:07   ` Linus Walleij
2019-08-27 13:54     ` Daniel Lezcano
2019-08-28  8:57       ` Linus Walleij
2019-08-28  9:04         ` Daniel Lezcano
2019-08-28 12:20           ` Linus Walleij

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=47cb523f-60ad-750e-4374-6563f8230593@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.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).