linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Amit Kucheria <amit.kucheria@verdurent.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
	<devicetree@vger.kernel.org>,
	"open list:BROADCOM STB AVS TMON DRIVER"
	<linux-pm@vger.kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	"maintainer:BROADCOM STB AVS TMON DRIVER"
	<bcm-kernel-feedback-list@broadcom.com>,
	Markus Mayer <mmayer@broadcom.com>,
	Zhang Rui <rui.zhang@intel.com>,
	"moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 1/6] thermal: brcmstb_thermal: Do not use DT coefficients
Date: Wed, 15 Jan 2020 11:28:02 +0530	[thread overview]
Message-ID: <CAHLCerO1OARY9OMDpGudSfBdmtRfeP_pYaE9=-Sn-10ZVjgXKA@mail.gmail.com> (raw)
In-Reply-To: <20200114190607.29339-2-f.fainelli@gmail.com>

On Wed, Jan 15, 2020 at 12:36 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> At the time the brcmstb_thermal driver and its binding were merged, the
> DT binding did not make the coefficients properties a mandatory one,
> therefore all users of the brcmstb_thermal driver out there have a non
> functional implementation with zero coefficients. Even if these
> properties were provided, the formula used for computation is incorrect.
>
> The coefficients are entirely process specific (right now, only 28nm is
> supported) and not board or SoC specific, it is therefore appropriate to
> hard code them in the driver given the compatibility string we are
> probed with which has to be updated whenever a new process is
> introduced.
>
> We remove the existing coefficients definition since subsequent patches
> are going to add support for a new process and will introduce new
> coefficients as well.
>
> Fixes: 9e03cf1b2dd5 ("thermal: add brcmstb AVS TMON driver")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>

> ---
>  drivers/thermal/broadcom/brcmstb_thermal.c | 31 +++++++---------------
>  1 file changed, 9 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c
> index 5825ac581f56..680f1a070606 100644
> --- a/drivers/thermal/broadcom/brcmstb_thermal.c
> +++ b/drivers/thermal/broadcom/brcmstb_thermal.c
> @@ -49,7 +49,7 @@
>  #define AVS_TMON_TP_TEST_ENABLE                0x20
>
>  /* Default coefficients */
> -#define AVS_TMON_TEMP_SLOPE            -487
> +#define AVS_TMON_TEMP_SLOPE            487
>  #define AVS_TMON_TEMP_OFFSET           410040
>
>  /* HW related temperature constants */
> @@ -108,23 +108,12 @@ struct brcmstb_thermal_priv {
>         struct thermal_zone_device *thermal;
>  };
>
> -static void avs_tmon_get_coeffs(struct thermal_zone_device *tz, int *slope,
> -                               int *offset)
> -{
> -       *slope = thermal_zone_get_slope(tz);
> -       *offset = thermal_zone_get_offset(tz);
> -}
> -
>  /* Convert a HW code to a temperature reading (millidegree celsius) */
>  static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz,
>                                         u32 code)
>  {
> -       const int val = code & AVS_TMON_TEMP_MASK;
> -       int slope, offset;
> -
> -       avs_tmon_get_coeffs(tz, &slope, &offset);
> -
> -       return slope * val + offset;
> +       return (AVS_TMON_TEMP_OFFSET -
> +               (int)((code & AVS_TMON_TEMP_MAX) * AVS_TMON_TEMP_SLOPE));
>  }
>
>  /*
> @@ -136,20 +125,18 @@ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz,
>  static inline u32 avs_tmon_temp_to_code(struct thermal_zone_device *tz,
>                                         int temp, bool low)
>  {
> -       int slope, offset;
> -
>         if (temp < AVS_TMON_TEMP_MIN)
> -               return AVS_TMON_TEMP_MAX; /* Maximum code value */
> -
> -       avs_tmon_get_coeffs(tz, &slope, &offset);
> +               return AVS_TMON_TEMP_MAX;       /* Maximum code value */
>
> -       if (temp >= offset)
> +       if (temp >= AVS_TMON_TEMP_OFFSET)
>                 return 0;       /* Minimum code value */
>
>         if (low)
> -               return (u32)(DIV_ROUND_UP(offset - temp, abs(slope)));
> +               return (u32)(DIV_ROUND_UP(AVS_TMON_TEMP_OFFSET - temp,
> +                                         AVS_TMON_TEMP_SLOPE));
>         else
> -               return (u32)((offset - temp) / abs(slope));
> +               return (u32)((AVS_TMON_TEMP_OFFSET - temp) /
> +                             AVS_TMON_TEMP_SLOPE);
>  }
>
>  static int brcmstb_get_temp(void *data, int *temp)
> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-01-15  5:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 19:06 [PATCH v3 0/6] brcmstb_thermal updates for new processes Florian Fainelli
2020-01-14 19:06 ` [PATCH v3 1/6] thermal: brcmstb_thermal: Do not use DT coefficients Florian Fainelli
2020-01-15  5:58   ` Amit Kucheria [this message]
2020-01-14 19:06 ` [PATCH v3 2/6] thermal: brcmstb_thermal: Prepare to support a different process Florian Fainelli
2020-01-15  5:59   ` Amit Kucheria
2020-01-14 19:06 ` [PATCH v3 3/6] dt-bindings: thermal: Define BCM7216 thermal sensor compatible Florian Fainelli
2020-01-14 19:06 ` [PATCH v3 4/6] thermal: brcmstb_thermal: Add 16nm process thermal parameters Florian Fainelli
2020-01-14 19:06 ` [PATCH v3 5/6] thermal: brcmstb_thermal: Restructure interrupt registration Florian Fainelli
2020-01-14 19:06 ` [PATCH v3 6/6] thermal: brcmstb_thermal: Register different ops per process Florian Fainelli
2020-01-15 13:16 ` [PATCH v3 0/6] brcmstb_thermal updates for new processes 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='CAHLCerO1OARY9OMDpGudSfBdmtRfeP_pYaE9=-Sn-10ZVjgXKA@mail.gmail.com' \
    --to=amit.kucheria@verdurent.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --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=mmayer@broadcom.com \
    --cc=robh+dt@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).