Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6103997ybl; Tue, 14 Jan 2020 21:59:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyC81HvvLEuR2Rksp3HiAwM3gWfG/ZjJ8uGYt2P5sVmSqw7JqfsXW7/QXe17dICeoJ8fiUg X-Received: by 2002:a05:6830:158:: with SMTP id j24mr1619061otp.316.1579067962495; Tue, 14 Jan 2020 21:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579067962; cv=none; d=google.com; s=arc-20160816; b=WFJ8r1FxCwEcAsBhRnzwVFyuh4e76/cYDv1WyaZ+XUzMIgqOp+DIJamURkyJ90KJz9 Ju10gDO5TebzbZa6rkxac71y/ee47G4fFSOAmV610kSPPDsnET1foAd7wK1AbSt3foOt sBTWxsQU4QhrJQXRzjkmUBnOhoR0Z6PsZo1DXpF9htLvKTpvP169Q5fbHdeeObFLigfZ hb2a9e5rCvsVEl1FXz0zSFcl+KnUW+eHErhnUG+UvnJqjxESPm2jnxf3r+6Uo1vexnsu uBAiNmiiZ+o2QxmxkR1hinF6iRdyyTbnCjCgn5XRdn/rc5GtDU08ZeGqgSqbkMh2ng09 la3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e5xJRkqeZeVuqWjzuTjcTAvJI4fzZrcr+Isw3uqYLKg=; b=nsmkjFfEHsfMW3fPUJsHtDj1TKkMFOEEAohzUeAFE3UaQAsVazLLWIVYoMKBzbSSFV JNEt2pBZCbrOMrytP2g8Yw3zkVxbsViEHeobIYdNr/cAtNO/hZU2FXcJU0uHkVz5uBVf 40CVYco8Ewms42gY/ni1JeJuQD1C5jLKEv2HzmJzsYgflMCAWjXlJpIwHa+WZA3oUfjD 6+UaPLaEUCdrT95x012sYXrT8p+nMGa2DqiiV13CvrjI/DvRjkGUCllecO+PSP0wPqr+ XsP0hdhlyRnyW/rQVXkn9q+CQ+09IwjGZxy7SaERvuHExZJYUW77lrjvU4sPS4zgGpMH iNYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=o+vsV3oM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x24si10284495oto.255.2020.01.14.21.59.11; Tue, 14 Jan 2020 21:59:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=o+vsV3oM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgAOF6P (ORCPT + 99 others); Wed, 15 Jan 2020 00:58:15 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:41216 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgAOF6O (ORCPT ); Wed, 15 Jan 2020 00:58:14 -0500 Received: by mail-ua1-f67.google.com with SMTP id f7so5795087uaa.8 for ; Tue, 14 Jan 2020 21:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e5xJRkqeZeVuqWjzuTjcTAvJI4fzZrcr+Isw3uqYLKg=; b=o+vsV3oMBFRJ1mv7DjQiU8XPXWxqrhMJgML2HsKufa6V56I+MLrFTdPDjwZPSsgTGb RPljyQh7++xAIXl+sjGHAcqYF7B8DzcB6Oo1DobaDz5W3DISZkeQpCFAmjS/FVTzaYfX Lv4sSGxgPS+oxOZUR98FZokoBK0xXYuvPjAG/rV/Q+TOE5lOD9un0NuMfpcsCn3ySND0 AihW5IkU4QPEm66XCcNbaNWP82U5XaVpK/uGPVa4LI14xAFQVafishSL6JyPxtozxAgL 5lw5wlrwYUp0QXBNutVanw8TNPbMb5mYYPFGp1yOm9cZ2Inl7eOyR6eD7frdc9XswOGW sY4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e5xJRkqeZeVuqWjzuTjcTAvJI4fzZrcr+Isw3uqYLKg=; b=pxI3KGPP5RmrX1F3Tll/sMaZil4wbUvYPOW9zbUpfsFD7/kJXsvQQsVCxjx8vwEhK9 ZV2tNPLp2q5+5wi+6RwME2YK4PVkwOzMIyUMYV37HMkEdtkuirwDgawPVSog+ZJfT6Ey jfc8HToUD8hMYxyregcvtAsG1z2WERsVXioFj3hj3GkvNqgkFe7IOfqYSYWCeywt61XO WFWwvnkiaVR6vsgZP010RlF/lyeg5xeRPwdeo1QWGhvvbno2CG4J1RVRWFCqkpF6YwgX dMeIhzVATOQ54gng9SsOvcFcYW/O33437mhuSpGRyxprPTbFNx7MiQ6pdNEef8CpV+ub iqiw== X-Gm-Message-State: APjAAAVcvBLJy5CzQzYVrIKcFMyDzAD8j8/oUXIYdxEA3JTLntRXPsEx 5ldv3M9WHoBMJRpXpMhXj3yVSH86PD/hUQKGQiURBw== X-Received: by 2002:ab0:2252:: with SMTP id z18mr12952463uan.60.1579067893051; Tue, 14 Jan 2020 21:58:13 -0800 (PST) MIME-Version: 1.0 References: <20200114190607.29339-1-f.fainelli@gmail.com> <20200114190607.29339-2-f.fainelli@gmail.com> In-Reply-To: <20200114190607.29339-2-f.fainelli@gmail.com> From: Amit Kucheria Date: Wed, 15 Jan 2020 11:28:02 +0530 Message-ID: Subject: Re: [PATCH v3 1/6] thermal: brcmstb_thermal: Do not use DT coefficients To: Florian Fainelli Cc: LKML , Daniel Lezcano , Markus Mayer , "maintainer:BROADCOM STB AVS TMON DRIVER" , Zhang Rui , Rob Herring , Mark Rutland , "open list:BROADCOM STB AVS TMON DRIVER" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 12:36 AM Florian Fainelli 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 Reviewed-by: Amit Kucheria > --- > 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 >