Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3964447pjo; Tue, 3 Mar 2020 10:11:31 -0800 (PST) X-Google-Smtp-Source: ADFU+vt+tIqbYaMVraUvqqqPMI5+SPDEOqKFtjy4J81YW/wsGR/8ZaiV/tUg26LRr/Jsjth/O0cQ X-Received: by 2002:aca:ed86:: with SMTP id l128mr3382066oih.75.1583259090987; Tue, 03 Mar 2020 10:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583259090; cv=none; d=google.com; s=arc-20160816; b=T2//8cG/I1FSGeYvKGLXzvLTcebusah+8F8lsx86WoN3bGMX0U99sLG2MVskxG970C RGlJHGulq38v+/hx4crqDeMBOYlSNChuWUqCSdIvM6avU6L3JbzHJTqdhyDnolMs9DfJ lsU6NN4rDu9CIZNGcIj2dq9nIrarGMkr3l928JPXq7F+fP6ngp49tpzjbDJkAV9H52PY v2hZy3POus7Iz8FtUa3FEn44z1EN3Gf5KIvc/M6EGfo3ibjmQrgw9yCk9WX98F0qOaqb 169/V+NC2wHURSU4VaouRJpMg1PIL1+n2+6K+/tvxhOq+Pbj8gXFUNbw6GeIjDyJxtjE eYYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a6oCY6BBE+pN58O2OxC5cF/jYYXxUAYkl6dRt/kek0A=; b=az6dCHLFi8+nlCeOmfDr3qMs4IUgIiEGNhWSG4q/deUWswd+GE/H0JsiheIbYRQ+CV ELZvljRVDnqt9S1wlSQtZv663yC6iWWeUWsvjXwT1IftzhxwQZKGNVqyE5VXg5EkZH3q cw6AbDSU4QEIJ3hi9oJT3xY5Ptk5R6akz2sTbai+RBygQDpxs0DBEGnvog3a2DrNdo4g GdFpN0fzyM/5wMNQ0tIErD3HHlQojt9ZMmvN0QmEr2TQYR72F+AxozVDzb4c6YKcw/6b ntDDN4zJ9j4+FnQkl5Oo1wD4GgLfGUARDoY4vIyZt5SsfWHBJ8b1Qy6gZzvEOJDk5uuQ aBKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lHootr17; 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 v19si3721110otq.57.2020.03.03.10.11.16; Tue, 03 Mar 2020 10:11:30 -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=@kernel.org header.s=default header.b=lHootr17; 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 S1732643AbgCCSJe (ORCPT + 99 others); Tue, 3 Mar 2020 13:09:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:60538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730562AbgCCRwO (ORCPT ); Tue, 3 Mar 2020 12:52:14 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AA4120CC7; Tue, 3 Mar 2020 17:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257932; bh=nSQ2JwEEUlpH+KtDNU/5jZzofFq9d1NFcnnlpJQLjAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHootr17igh5pkxxq6dbgJ78HSWt2vWf7YIVrjkeDwKYsC/K6jQyn94raJzWNGnaj IFXJEJz11uCYNtgUh1UmVTLIs3Bwipl/RxfTeya3yFsdKDKRc9ZK/6y+zQ1+LHSImQ HSxsQ6/UQo4/bRcq0a6CblvtkW7HJIa1juOFg+YM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Amit Kucheria , Daniel Lezcano Subject: [PATCH 5.5 163/176] thermal: brcmstb_thermal: Do not use DT coefficients Date: Tue, 3 Mar 2020 18:43:47 +0100 Message-Id: <20200303174323.076645343@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174304.593872177@linuxfoundation.org> References: <20200303174304.593872177@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli commit e1ff6fc22f19e2af8adbad618526b80067911d40 upstream. 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 Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20200114190607.29339-2-f.fainelli@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/broadcom/brcmstb_thermal.c | 31 ++++++++--------------------- 1 file changed, 9 insertions(+), 22 deletions(-) --- 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( 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)