From patchwork Wed Mar 20 13:17:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 10861695 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 025C817E0 for ; Wed, 20 Mar 2019 13:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDBAF28A93 for ; Wed, 20 Mar 2019 13:19:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D17BA29B78; Wed, 20 Mar 2019 13:19:46 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB 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 825AE28A93 for ; Wed, 20 Mar 2019 13:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbfCTNTo (ORCPT ); Wed, 20 Mar 2019 09:19:44 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:45841 "EHLO mail-pf1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728324AbfCTNTn (ORCPT ); Wed, 20 Mar 2019 09:19:43 -0400 Received: by mail-pf1-f176.google.com with SMTP id v21so1902970pfm.12 for ; Wed, 20 Mar 2019 06:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eZLwZQ47wxuBvZ6q3TSPmW1vGKe2aF0HDy1rDpmd+Ss=; b=MPJczgOjJmUhBYQKoKbU9bSLhArNwopkax7JT3vEzUuzHHXtHc5SqXNp4Z/+WxqfJT Q2ear0E8F0Jh/QdKFj5Aw2KrlqV91QxPI2IY9JDfIJMJykPADdp35v4LHhdalnzTe/kM ti+gcvVNMljW1LQhXZctmSGj46N4QAsWwMXdLoqYwOL5KsACR1sFtG1kuEUmQIcPD4wo zYiDYIJxgsxzPHWlOIsygC+2KQYlvYIlw07eQgPGxor6O6hEh1mZFuPVgVitFE9Hd7SZ Phakx9HpIn4g3zI7iYyXMDvM/F73ZcV47wEnZRaLe2cNiWpp23DCG4hgkEl7kyCfl4L4 p67w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eZLwZQ47wxuBvZ6q3TSPmW1vGKe2aF0HDy1rDpmd+Ss=; b=XNz7q9t3CY7JugFeOkbLk7kT8a7SgWEQ9YbqUkDFsdLK0XEdBAfI9daBmE0V7e2/Hz WLHRD73/XTwaHaUbb8Y8teQLex4Jq65pXYDlXT2jgGf3yT1kcFzX8jLKqsn4OVkKmJXF lgZV4jZq/fo71G3rFMw42xt6A58UBwneWlOO+DWr8qtzT7+7TRE4ybatqFLtVV0yTEi7 hKArKHOf5fzTjvBRY7hpIH5ukfo+pAeDFgqYTNpsXv7Ykl9H7Fl8DU/NgEpP/Z0B2Guc DIQnqp1TBMD5KT58+qjP0m7jWYqJIEWc3VCyXiKVS0STnW7L3cmY4T/WPqSGTuZ9trLH Yy0A== X-Gm-Message-State: APjAAAXpDWxxLKmtWyajmXXvSj7S9izPCt4gjGgrxEXU9GG5pZJCeWtn encdYVfrCjQPPh/3BpgTzKf7kw== X-Google-Smtp-Source: APXvYqxbu6+O95110vR8QmoKmdIL1pQ6g1MzuFd/rLIhIf6GM+j37/boX7XzYhSTL49hS9hssBIkbQ== X-Received: by 2002:a65:5281:: with SMTP id y1mr7598678pgp.59.1553087982607; Wed, 20 Mar 2019 06:19:42 -0700 (PDT) Received: from localhost ([114.143.122.221]) by smtp.gmail.com with ESMTPSA id a24sm2690021pfn.85.2019.03.20.06.19.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 06:19:41 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCHv3 18/23] drivers: thermal: tsens: Common get_temp() learns to do ADC conversion Date: Wed, 20 Mar 2019 18:47:58 +0530 Message-Id: <389f9e70f715e2884418d77c9ff06fad6878eacc.1553086065.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP get_temp() learns to return temperature regardless of whether it is returned as ADC code or direct temperature. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 5adbf1a2e0fb..92747ccb2850 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -129,10 +129,15 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) if (ret) return ret; - mask = GENMASK(priv->fields[LAST_TEMP_0].msb, - priv->fields[LAST_TEMP_0].lsb); - /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + if (priv->feat->adc) { + /* Convert temperature from ADC code to milliCelsius */ + *temp = code_to_degc(last_temp, s) * 1000; + } else { + mask = GENMASK(priv->fields[LAST_TEMP_0].msb, + priv->fields[LAST_TEMP_0].lsb); + /* Convert temperature from deciCelsius to milliCelsius */ + *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + } return 0; }