From patchwork Thu Feb 28 12:21:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 159363 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp577061jad; Thu, 28 Feb 2019 04:27:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IanEGhD7QVkvDTik+9CaL3r7WyUW4pqV0KJqhINW6iE7U8Y+qsg6aUIsK/XahSv59StiIL/ X-Received: by 2002:a65:5788:: with SMTP id b8mr8025652pgr.8.1551356874870; Thu, 28 Feb 2019 04:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551356874; cv=none; d=google.com; s=arc-20160816; b=D7MSKRjSTfGrVE9VU2xjVGdeZ5hcaH98GcEX0wNdfoGML55xShC+1oDzQBAmR8/1zv MtuMeCWw9NGNy6pmFrmI7EtkpygChOtvFtc8EK/yTseeOKluLXk5FpwT9Hj3YjwCkjv9 YjBi+vgQFWfA2LZgchzNx1R31to+H5uUpME5BhEhWwvw9e5rhVeHhYnnZpbYyemGepkl nGB2NQWfI2+br9k7WfQDAfi9h5HzeTaOlUq9FmzicyyFMvsYDKX2ToHzAfJkJl+Z776n xalqMfL6nq+69TB/eEspfc7f+YbLrkfM6YaN+845NGjdlnlnw4K0M5FVLLuALP1rnO+m bKLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=vXTkCN9XQrYDU1nAIhEf80bjP3QRImM0rvZgjdrLpoM=; b=LF+3mcFpqtH8nweqso9RqRJCSwsIg0Wh+RSUIp11ZNVBtoj3dXowCuyXTEkYDUa9AC OXn0QGAY/Rnh9WOK824zawq4b62CWUn7pJdd0yGth3EbRRENdzq0DpWQOrPB6bwSPKWb SVEe8tMcKi7X8jCOQCJzTH1yayW29ExTw9gZaag0DHCX45JnddPOGfkhDZQi3QzO950U at9tQeonn4NTLv1VM2+pnr9mfLnELcWoMb7bg6XSRNzhfJQMHZTQPxpaoFeCxM4Ws6pN CFd1T9jO0pJa7CXudCAdogWyoVzjw1s1ThmbTgjSZVEeYR0U2Fys3bItMgPpliLnO/Mp Geuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zViCAUkU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si16739390pgv.512.2019.02.28.04.27.54; Thu, 28 Feb 2019 04:27:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=zViCAUkU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731621AbfB1M1y (ORCPT + 15 others); Thu, 28 Feb 2019 07:27:54 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40354 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731883AbfB1M1x (ORCPT ); Thu, 28 Feb 2019 07:27:53 -0500 Received: by mail-wm1-f67.google.com with SMTP id g20so7976552wmh.5 for ; Thu, 28 Feb 2019 04:27:52 -0800 (PST) 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=vXTkCN9XQrYDU1nAIhEf80bjP3QRImM0rvZgjdrLpoM=; b=zViCAUkUGygwrPh5ryUIoZlVVC4rFdcAkF9mQh026jMdmcKlqDw0Gkc9YphIoocF3O yQodupvAqYJ9DU95uatT7LlRfsD20zkOeIO1bN+VjNXtlRJ/V5B7OdClNCgYioqWkFew iyld1qAKnJWsahbkbKAuCwA+s9qSvB6kwe8qW6ZPAl3Cib0/KfDByadChrUuOuHdWdea 1BjemG1bV3mz5GTay4F+ViN2RhRBPwvVi+7kF++z4Gz6tdND7ys/GXX/qyiURMFIUDKC Q9iPM1NDXRHyPmH85PhPNfVPOx6Bwvh8j25bu+Pb8nNjQ+9O0FtdWonazejuTbMDf+zs r7aA== 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=vXTkCN9XQrYDU1nAIhEf80bjP3QRImM0rvZgjdrLpoM=; b=XwWA6zJ7wYuCn3PPT/942kpFHnGRnEP3R8n9Y0aVMTwZXMNCYfQYZ9fKIemuv2odXR hX1rkJVzsccEtEROb8g0W02qprGhRwt6pbdC/sefHgcoN+7OWt64nl3tNNhEeJD826mj ChCbjqp6X/Ugnefe3wrpY+KcWfV3ALwhsEsqaXkQ+MfbvXaIceUf9ADwv6mIrwIjbD9t HM6PNA7QrofA59L68A4HcgmWKHAAI65aU+5agn2CuEw2WO0i5DFJggFHc8hasuighE0j Y2ivm0RRRcE/TKG2oHBVEYSqRa9+HaIuu32LK9rLZlMBJHS27eSRT+W1zYSIEJGwSw00 YqRQ== X-Gm-Message-State: AHQUAubWPD1DbQv5uQ8qn9AKOupYz6Skqe97THTTTn1eukxyQYbhSaii m/o28+oC52b0Ch7uIbWOhnF/XA== X-Received: by 2002:a1c:2885:: with SMTP id o127mr2953084wmo.135.1551356871384; Thu, 28 Feb 2019 04:27:51 -0800 (PST) Received: from localhost ([49.248.54.130]) by smtp.gmail.com with ESMTPSA id f196sm10214686wme.36.2019.02.28.04.27.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 04:27:50 -0800 (PST) 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: [PATCH v2 19/24] drivers: thermal: tsens: Common get_temp() learns to do ADC conversion Date: Thu, 28 Feb 2019 17:51:09 +0530 Message-Id: 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 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(-) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 7bab0e640806..5db1aa441910 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; }