From patchwork Thu Apr 18 07:15:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 10906587 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E79CD14DB for ; Thu, 18 Apr 2019 07:15:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C75702766D for ; Thu, 18 Apr 2019 07:15:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6E1528C05; Thu, 18 Apr 2019 07:15:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85882766D for ; Thu, 18 Apr 2019 07:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731317AbfDRHPV (ORCPT ); Thu, 18 Apr 2019 03:15:21 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:32856 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729497AbfDRHPU (ORCPT ); Thu, 18 Apr 2019 03:15:20 -0400 Received: from penelope.horms.nl (astrasbourg-652-1-77-110.w109-217.abo.wanadoo.fr [109.217.202.110]) by kirsty.vergenet.net (Postfix) with ESMTPA id D9C0E25AEB1; Thu, 18 Apr 2019 17:15:18 +1000 (AEST) Received: by penelope.horms.nl (Postfix, from userid 7100) id 60AC8E22049; Thu, 18 Apr 2019 09:15:15 +0200 (CEST) From: Simon Horman To: Zhang Rui , Eduardo Valentin Cc: Magnus Damm , linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Kaneko , Simon Horman Subject: [PATCH repost] thermal: rcar_thermal: update calculation formula for E3 Date: Thu, 18 Apr 2019 09:15:14 +0200 Message-Id: <20190418071514.13027-1-horms+renesas@verge.net.au> X-Mailer: git-send-email 2.11.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yoshihiro Kaneko HW manual changes temperature calculation formula for E3: - When CTEMP is less than 24 T = CTEMP[5:0] * 5.5 - 72 - When CTEMP is equal to/greater than 24 T = CTEMP[5:0] * 5 - 60 This was inspired by a patch in the BSP by Van Do Signed-off-by: Yoshihiro Kaneko Tested-by: Simon Horman Acked-by: Wolfram Sang Signed-off-by: Simon Horman Reviewed-by: Niklas Söderlund --- drivers/thermal/rcar_thermal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 97462e9b40d8..11df0cc63bed 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -52,6 +52,7 @@ struct rcar_thermal_chip { unsigned int irq_per_ch : 1; unsigned int needs_suspend_resume : 1; unsigned int nirqs; + unsigned int ctemp_bands; }; static const struct rcar_thermal_chip rcar_thermal = { @@ -60,6 +61,7 @@ static const struct rcar_thermal_chip rcar_thermal = { .irq_per_ch = 0, .needs_suspend_resume = 0, .nirqs = 1, + .ctemp_bands = 1, }; static const struct rcar_thermal_chip rcar_gen2_thermal = { @@ -68,6 +70,7 @@ static const struct rcar_thermal_chip rcar_gen2_thermal = { .irq_per_ch = 0, .needs_suspend_resume = 0, .nirqs = 1, + .ctemp_bands = 1, }; static const struct rcar_thermal_chip rcar_gen3_thermal = { @@ -80,6 +83,7 @@ static const struct rcar_thermal_chip rcar_gen3_thermal = { * interrupts to detect a temperature change, rise or fall. */ .nirqs = 2, + .ctemp_bands = 2, }; struct rcar_thermal_priv { @@ -263,7 +267,12 @@ static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv, return ret; mutex_lock(&priv->lock); - tmp = MCELSIUS((priv->ctemp * 5) - 65); + if (priv->chip->ctemp_bands == 1) + tmp = MCELSIUS((priv->ctemp * 5) - 65); + else if (priv->ctemp < 24) + tmp = MCELSIUS(((priv->ctemp * 55) - 720) / 10); + else + tmp = MCELSIUS((priv->ctemp * 5) - 60); mutex_unlock(&priv->lock); if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) {