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: 10861713 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 9C3ED139A for ; Wed, 20 Mar 2019 13:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B30629B83 for ; Wed, 20 Mar 2019 13:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F18929BF1; Wed, 20 Mar 2019 13:20:21 +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=unavailable 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 16BF529B83 for ; Wed, 20 Mar 2019 13:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728343AbfCTNTo (ORCPT ); Wed, 20 Mar 2019 09:19:44 -0400 Received: from mail-pf1-f172.google.com ([209.85.210.172]:46268 "EHLO mail-pf1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727736AbfCTNTn (ORCPT ); Wed, 20 Mar 2019 09:19:43 -0400 Received: by mail-pf1-f172.google.com with SMTP id 9so1675165pfj.13 for ; Wed, 20 Mar 2019 06:19:42 -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=Byp4IVP8Jb/8IVerS8QPkRAKnB+jqBqssBnPo0VA8R6fVD05bLbog3L0ua+2GmSQov DWLov5xrcYyMn5Zb8kF+CuDlR8Qpu/4vMh7LkRgf5HjPEL/MSBHy8aZa+MtdnJxqr+d0 6sHeu+vl4zhoZeanmhFGJoAwRYtd706bDhw1NVw3fTyZWkxBbfHHb6vDFvXoQkqcuPVq ulMGFAw/Fa43D+VBrvfWNBnd2IKmtVG//PhVIzagpcqlsEMsjA8+Ot4BEva+mkJJZ+qm iTtb7VtVqpkIXje1YLucNpDnoszNQEZkk4Gng1kNiOhY++uvyifeMC+1RNjYq1w0XUQl zzjg== X-Gm-Message-State: APjAAAV1oSY6MCZg5rUiATekt6ij6l04h8zfv4VYUEh/u9fc51GR5cnf WNxpayH5ogosK+9s5xJt/8GQnA== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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; }