From: Jishnu Prakash <quic_jprakash@quicinc.com>
To: <agross@kernel.org>, <bjorn.andersson@linaro.org>,
<devicetree@vger.kernel.org>, <mka@chromium.org>,
<dmitry.baryshkov@linaro.org>, <robh+dt@kernel.org>,
<knaack.h@gmx.de>, <lars@metafoo.de>, <pmeerw@pmeerw.net>,
<manivannan.sadhasivam@linaro.org>, <linus.walleij@linaro.org>,
<quic_kgunda@quicinc.com>, <quic_aghayal@quicinc.com>,
<daniel.lezcano@linaro.org>, <rui.zhang@intel.com>,
<quic_subbaram@quicinc.com>, <jic23@kernel.org>,
<Jonathan.Cameron@huawei.com>, <amitk@kernel.org>,
Jishnu Prakash <quic_jprakash@quicinc.com>,
<linux-arm-msm@vger.kernel.org>, <linux-iio@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <linux-arm-msm-owner@vger.kernel.org>, <linux-pm@vger.kernel.org>
Subject: [PATCH V2 2/3] iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM
Date: Tue, 26 Oct 2021 21:34:34 +0530 [thread overview]
Message-ID: <1635264275-12530-3-git-send-email-quic_jprakash@quicinc.com> (raw)
In-Reply-To: <1635264275-12530-1-git-send-email-quic_jprakash@quicinc.com>
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 <quic_jprakash@quicinc.com>
---
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 1472389..194d7c3 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 33f60f4..598a5d2 100644
--- a/include/linux/iio/adc/qcom-vadc-common.h
+++ b/include/linux/iio/adc/qcom-vadc-common.h
@@ -161,6 +161,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);
--
2.7.4
next prev parent reply other threads:[~2021-10-26 16:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-26 16:04 [PATCH V2 0/3] thermal: qcom: Add support for PMIC5 Gen2 ADC_TM Jishnu Prakash
2021-10-26 16:04 ` [PATCH V2 1/3] dt-bindings: thermal: qcom: add PMIC5 Gen2 ADC_TM bindings Jishnu Prakash
2021-10-27 17:51 ` Jonathan Cameron
2021-11-23 5:43 ` Jishnu Prakash
2021-10-26 16:04 ` Jishnu Prakash [this message]
2021-10-27 17:53 ` [PATCH V2 2/3] iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM Jonathan Cameron
2021-10-26 16:04 ` [PATCH V2 3/3] thermal: qcom: add support for PMIC5 Gen2 ADCTM Jishnu Prakash
2021-10-27 2:34 ` Dmitry Baryshkov
2021-11-23 5:41 ` Jishnu Prakash
2021-10-27 18:05 ` Jonathan Cameron
2021-11-23 5:45 ` Jishnu Prakash
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1635264275-12530-3-git-send-email-quic_jprakash@quicinc.com \
--to=quic_jprakash@quicinc.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=agross@kernel.org \
--cc=amitk@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-msm-owner@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mka@chromium.org \
--cc=pmeerw@pmeerw.net \
--cc=quic_aghayal@quicinc.com \
--cc=quic_kgunda@quicinc.com \
--cc=quic_subbaram@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).