From patchwork Thu May 19 12:44:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thermal-bot for Julien Panis X-Patchwork-Id: 574445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2BCCC433F5 for ; Thu, 19 May 2022 12:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232306AbiESMoc (ORCPT ); Thu, 19 May 2022 08:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238013AbiESMo1 (ORCPT ); Thu, 19 May 2022 08:44:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4F82BA994 for ; Thu, 19 May 2022 05:44:26 -0700 (PDT) Date: Thu, 19 May 2022 12:44:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652964265; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=suax0WGdvOF77muuGYOxN06FHR8YInAvVrBuUSBT9LQ=; b=MiO4iMj2WYVfhQnIGb0DJg/1yG05+sWmRy9n2YIjuKSow6pfQlH0gQjUrYuwthGQVFerZj 7JHiA0Y2GXGLqwdrf2XomyRp+SJh0mxrqHxPpi6VZrhENMBOs4FdkG7KUoAEDBQRRaX2xG yFKggL0A2Ock5yHN0ce5vaE+eicOb9200KYqs1sJPscT4Glc0Js5JfNdb9b2SDQ0etfQhT GgPekVyLn1AM+YP/wlZL1UwiN7lOTm0DfYFs/ft+RTOQAoON+UuY2Fq3Fuka2C06nk8Igr PVI3B3H3skvTQGczM4PKdV0MrgNZFeG2L/jD5OERFm/ZbUaIOj98mWPJjuPbFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652964265; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=suax0WGdvOF77muuGYOxN06FHR8YInAvVrBuUSBT9LQ=; b=pekwr9MuB7/56VVHGfeOH9ws0Q9JR+nS8i8BqBkmNoN8NfjXsGeVRihfvM/P0VEGMATAJK x1A1WXSwRG27F4CQ== From: "thermal-bot for Jishnu Prakash" Sender: tip-bot2@linutronix.de Reply-to: linux-pm@vger.kernel.org To: linux-pm@vger.kernel.org Subject: [thermal: thermal/next] iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM Cc: Jishnu Prakash , Jonathan Cameron , Daniel Lezcano , rui.zhang@intel.com, amitk@kernel.org In-Reply-To: <1648991869-20899-3-git-send-email-quic_jprakash@quicinc.com> References: <1648991869-20899-3-git-send-email-quic_jprakash@quicinc.com> MIME-Version: 1.0 Message-ID: <165296426440.4207.8401342073909749449.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The following commit has been merged into the thermal/next branch of thermal: Commit-ID: 238e34ad7d5ce36939ac1442c98c7cbb7771f4de Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//238e34ad7d5ce36939ac1442c98c7cbb7771f4de Author: Jishnu Prakash AuthorDate: Sun, 03 Apr 2022 18:47:47 +05:30 Committer: Daniel Lezcano CommitterDate: Thu, 19 May 2022 12:11:51 +02:00 iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM Add reverse scaling function for PMIC5 Gen2 ADC_TM, to convert temperature to raw ADC code, for setting thresholds for thermistor channels. Signed-off-by: Jishnu Prakash Acked-by: Jonathan Cameron Link: https://lore.kernel.org/r/1648991869-20899-3-git-send-email-quic_jprakash@quicinc.com Signed-off-by: Daniel Lezcano --- drivers/iio/adc/qcom-vadc-common.c | 11 +++++++++++ include/linux/iio/adc/qcom-vadc-common.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index 6c6aec8..d5209f3 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -677,6 +677,17 @@ u16 qcom_adc_tm5_temp_volt_scale(unsigned int prescale_ratio, } EXPORT_SYMBOL(qcom_adc_tm5_temp_volt_scale); +u16 qcom_adc_tm5_gen2_temp_res_scale(int temp) +{ + int64_t resistance; + + resistance = qcom_vadc_map_temp_voltage(adcmap7_100k, + ARRAY_SIZE(adcmap7_100k), temp); + + return div64_s64(resistance * RATIO_MAX_ADC7, resistance + R_PU_100K); +} +EXPORT_SYMBOL(qcom_adc_tm5_gen2_temp_res_scale); + int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, unsigned int prescale_ratio, const struct adc5_data *data, diff --git a/include/linux/iio/adc/qcom-vadc-common.h b/include/linux/iio/adc/qcom-vadc-common.h index ce78d48..aa21b03 100644 --- a/include/linux/iio/adc/qcom-vadc-common.h +++ b/include/linux/iio/adc/qcom-vadc-common.h @@ -152,6 +152,8 @@ int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, u16 qcom_adc_tm5_temp_volt_scale(unsigned int prescale_ratio, u32 full_scale_code_volt, int temp); +u16 qcom_adc_tm5_gen2_temp_res_scale(int temp); + int qcom_adc5_prescaling_from_dt(u32 num, u32 den); int qcom_adc5_hw_settle_time_from_dt(u32 value, const unsigned int *hw_settle);