Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3459875pxb; Mon, 4 Apr 2022 17:40:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3RDYdilJRnyOKszzIjSlHrUnX8DKWtzxpOwJHCW6RkdMsUQJ833qo0yKtCT7vr9kPe6fv X-Received: by 2002:a05:6a00:16c7:b0:4f7:e497:69b8 with SMTP id l7-20020a056a0016c700b004f7e49769b8mr1019529pfc.6.1649119246597; Mon, 04 Apr 2022 17:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649119246; cv=none; d=google.com; s=arc-20160816; b=zqoDPemsLgl5BYhP/b64qH5s1YQSwDmHeEhyrepX9Yk+GldIzzyPq5oOCpwyPkWV9l ejQRNUc7DxZn8XFOZqbvhm+vmkvFYosv8ZlVlL4QDt2lqb62Un77aKEopfuaKl2cRM6H XtTFcH254ziDsfNRUxR79iwPy29jKNfcsV9mCHD0GInkeSHNfpwdsmf8KwMWrpagsI+3 STvRtKTLFUQJ2D75fTozkbaxNaNHS0ayiafjmZTl2WZE7NjKpptc+n46ybk5xOf7GwPJ ESppSkEotCOOA4yBeIJcT4QaM8auX9nocn/sDpM0k01iPHcSbo6sDRjhybgIA2rFa5Op BQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=02jKCSFUrWcNdgliBGzyvoi3mQqWkLT055iJwDV45LQ=; b=FcGNEKuwGwG7szj5rADbeilAjrTxrbGAHgrGWStnX7GUjqHX+PPHdktvmWPbtS99iV FDvNO0n2/HctNryP7rejn3R934diAD3R6j8/43QObD5Nq30vFBSNyd3Bt3pS2zrvpE9C b0LtG3i/UKxob5z3J1UjwDwnLOB/+PX3V3d2A1L965yPP7syF3Bgq1LuvBtIW7SLADH4 t02f+ChMiffj7S9or3fRovn/QftIbXMLuuiqK2iZPfonCCOa2/pmhKQKVFeDNFa6J6aE +SXOEJL6brCdrxDga6faBEvmHaD0b0S28pouzI/21Ri5am6LUvKpNXjxvQ2G7Ri85a6s c9fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=cOACwBuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e16-20020a056a001a9000b004fa3a8dffb5si11191575pfv.108.2022.04.04.17.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=cOACwBuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 018FF9157B; Mon, 4 Apr 2022 16:54:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357792AbiDCNUf (ORCPT + 99 others); Sun, 3 Apr 2022 09:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358868AbiDCNUU (ORCPT ); Sun, 3 Apr 2022 09:20:20 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC29A286E1; Sun, 3 Apr 2022 06:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1648991905; x=1680527905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=02jKCSFUrWcNdgliBGzyvoi3mQqWkLT055iJwDV45LQ=; b=cOACwBukWzlAGu5YrnVOdE4H2Ky/SWHGQcHpQcVEbfy9Og5PLFNPVFW3 qBprWr9pfO4bRtuyO/LlumzdGe31mrJplyGnKavwoLTXV1Lc+ng4QVkSd FEIGKejPWLLfAkru/o6MYjq1JXNSK3yZBLQEW9aUgstnyd4uxAnedGMQN 0=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 03 Apr 2022 06:18:24 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2022 06:18:23 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Sun, 3 Apr 2022 06:18:23 -0700 Received: from jprakash-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Sun, 3 Apr 2022 06:18:18 -0700 From: Jishnu Prakash To: , , , , , , , , , , , , , Lars-Peter Clausen , Jishnu Prakash , , , CC: , Subject: [RESEND PATCH V5 2/4] iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM Date: Sun, 3 Apr 2022 18:47:47 +0530 Message-ID: <1648991869-20899-3-git-send-email-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1648991869-20899-1-git-send-email-quic_jprakash@quicinc.com> References: <1648991869-20899-1-git-send-email-quic_jprakash@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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