Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp228067pxt; Wed, 11 Aug 2021 19:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKrP3ZVkVFwAXP8X1ckeUkUa74lPZFKtFh8zjI0OdE/Hit8vBxuynP1U7d+roLxcjLqoRV X-Received: by 2002:a05:6402:d5c:: with SMTP id ec28mr2624660edb.3.1628735322980; Wed, 11 Aug 2021 19:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628735322; cv=none; d=google.com; s=arc-20160816; b=RrXKkTX7+gp1XABljknpMAyClZNrB9LiP6BeMSTxLzpeuKs4ryX5jCEK6HqHSmVW/J /jcm3YERay1Y2fVRCdC76O7IQSgwxoohQKQb5sd+Xp7ikOlY6szXKVBfPqX45BlsK+Oj F3+t5sFvohYkNBtoI++RUCqEgFX4prM0fKEuYvkWzFp5EVBhPrVYVeyB6rUlUBkx377V ghSOT85JhJb1ipaVkA7f8pXwxtGvbObYfjAeyjeoB4ax+lnA758mV9mnTpdqJvq9zqSs WgsZ/lnGaUoxHr/IgVQvKqHyNftCPFD07KalVkh6SiNlM/nsSGbs7O2X1CrBry3wHXDB Hiyg== 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; bh=ep0YcTHLGnNUM6DlYpB+B4kkHe2SynYOm51CrCu/FUs=; b=VWRYIwj6zLmw+T8Wl9xMfQcB/4spfvtS6DeoFKTYIpCaPcggiptQhaQSxWdZFlGHiV z3Ur8g/OHMAC4hF1ifl3m4z4GJzX1N0jUXlUjHF4Ic9gNtLfZYQmCbbos22SEg/AsD0U 5sbJyq1uO4f1mRLsjhjWbukI/UBljoGYxsw5MdpH1GARhAUfdhoBO9iM3DFh58PDlFNP IrW7hb799BvDoFyz/c8NcSp9P52SBrkbuqJBJlSMvAb16+PPUx4CoTz2hCPT+GcVQhSQ lUIYA1J/DOGOXkSbphHSxLk1IMVk77Czuad1HnWtQFbaCwLJymhS6STHzToPoXGDarpj zTuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si1233003edr.219.2021.08.11.19.28.19; Wed, 11 Aug 2021 19:28:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233622AbhHLCYs (ORCPT + 99 others); Wed, 11 Aug 2021 22:24:48 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:56084 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229729AbhHLCYp (ORCPT ); Wed, 11 Aug 2021 22:24:45 -0400 X-UUID: fec819cb61bf4a4bb39af694e654bd07-20210812 X-UUID: fec819cb61bf4a4bb39af694e654bd07-20210812 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 998655441; Thu, 12 Aug 2021 10:24:18 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 12 Aug 2021 10:24:17 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 12 Aug 2021 10:24:16 +0800 From: Hui Liu To: , , , CC: , , , , , , , , , , , , Subject: [PATCH 2/2] iio: mtk-auxadc: update case IIO_CHAN_INFO_PROCESSED Date: Thu, 12 Aug 2021 10:23:42 +0800 Message-ID: <20210812022342.29092-2-hui.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210812022342.29092-1-hui.liu@mediatek.com> References: <20210812022342.29092-1-hui.liu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Covert raw data to processed data. Signed-off-by: Hui Liu --- drivers/iio/adc/mt6577_auxadc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index e995d43287b2..cda03a653269 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -83,6 +83,10 @@ static const struct iio_chan_spec mt6577_auxadc_iio_channels[] = { MT6577_AUXADC_CHANNEL(15), }; +/* For Voltage calculation */ +#define VOLTAGE_FULL_RANGE 1500 /* VA voltage */ +#define AUXADC_PRECISE 4096 /* 12 bits */ + static int mt_auxadc_get_cali_data(int rawdata, bool enable_cali) { return rawdata; @@ -205,6 +209,10 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, } if (adc_dev->dev_comp->sample_data_cali) *val = mt_auxadc_get_cali_data(*val, true); + + /* Convert adc raw data to voltage: 0 - 1500 mV */ + *val = *val * VOLTAGE_FULL_RANGE / AUXADC_PRECISE; + return IIO_VAL_INT; default: -- 2.18.0