Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4210073pxb; Mon, 30 Aug 2021 22:44:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRac7ms8jMAWDlnGxHbfH0h6PcLEWOTe6l7G7aIIggmfifVQyCxPy0kMy7TVR/d4RUifKW X-Received: by 2002:a6b:a06:: with SMTP id z6mr14857983ioi.146.1630388656151; Mon, 30 Aug 2021 22:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630388656; cv=none; d=google.com; s=arc-20160816; b=qdIw1fW6EBHbByzxZWNI9xDf3ceMO4osKAOjOhUaqErSAYpdGU+cOQuqIpAvoWN/jp XzgqRSWdHincxZhLaIgKDF8w6431ezIY/8aCja5faVuSaJ8/+vYcRfx8Pt0EXJOlsfEW TiNfCB0hKefo8mFIcCSMd+pzILFBbPg0BNTGYVrAOKGIzUQz5xvoYSyaFed9GWm49WW2 xi7HUiTReE7oTZ/tH0s7HaxV6LEtzye0io8RzJ5oXpSpJVEwY4drIT9ghwWWtQ/ujQKG +vES3OsC1ZA6d3U60R8R92kZuJYuqfouf42NNrmE267wR1PM9ag7058E3yIGwzuJj/oo 8vgg== 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=mXa3IRpPn0csG86Se2Ys77VCnEQeBswPyfqADhZpRxo=; b=0doigGUFZHnvMhTddazP/JyO5vGufhC+O90TLyA9nqpZHc9RHye18svp7FlO5y1CdG V2wgWuK8lW1AfhzRWOSCvdN/ah0ua+nhQeotb6wy3XFl0WRyFzUgnWnmMJTf46mZ9gb0 vYKeLwbLvcps2leASIrPCqCSI9YUBw4Xj6aau0/Y8MyMeTLh9eG2m9TKQPXLYru3K5VX MKKiL0dhl9YLcVr4Cj+K8NtC9ORvoXUo60piZmcX9cKbxCpuUv4jZsy1qezqaSevhkP6 xWqHV86nZbqlCT5urKhdZ7fzzmxzuPP4mM8L6/nvohOqqa98FmESmf69ryefQIAfrf9a KWQQ== 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 t10si10565628iof.42.2021.08.30.22.44.03; Mon, 30 Aug 2021 22:44:16 -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 S238567AbhHaFnS (ORCPT + 99 others); Tue, 31 Aug 2021 01:43:18 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:45024 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231537AbhHaFnR (ORCPT ); Tue, 31 Aug 2021 01:43:17 -0400 X-UUID: b99fd11d34b1416bbf87eb586268cf6e-20210831 X-UUID: b99fd11d34b1416bbf87eb586268cf6e-20210831 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1443729322; Tue, 31 Aug 2021 13:42:18 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 31 Aug 2021 13:42:17 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 31 Aug 2021 13:42:16 +0800 From: Hui Liu To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH v2 1/1] iio: mtk-auxadc: update case IIO_CHAN_INFO_PROCESSED Date: Tue, 31 Aug 2021 13:42:07 +0800 Message-ID: <20210831054207.13236-2-hui.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210831054207.13236-1-hui.liu@mediatek.com> References: <20210831054207.13236-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 Convert raw data to processed data, the processed data is input voltage. 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 79c1dd68b909..d4fccd52ef08 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -82,6 +82,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; @@ -191,6 +195,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