Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp664518pxb; Tue, 14 Sep 2021 06:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUeoPsjoeQuc9MmcHS/bB0XnqC/3XK0lUNwO4L5mzO+Fll+Cz8u9qcDVJg1LkgC7mtrjDd X-Received: by 2002:a2e:9607:: with SMTP id v7mr14807723ljh.405.1631625249136; Tue, 14 Sep 2021 06:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631625249; cv=none; d=google.com; s=arc-20160816; b=tyoEOejM5IbB/XcU70IdxgJOrdmymUdwer+hP4sqoN3d/knmS6RfaChLZcntwzfUSQ Kh6GHUI5V5Jf6cv+PM73zOGqQShvg43V+1/nFQPde1OQhmmEL3Kwgkyo7YDFIPegDOzs ipwLUpqwh2eYxDEOP6BuJsdtjgdh8VLzbdb5TRG+pQ9nsjdr+z5u4ark2nCZqMzB66yV fG9wCZ84gkQJvonHopOd1bobHO0pSE3UeO7wFpDY16bIBe2sXJogAxVEUoot2pbHZ49r Wtj0IUbg3Zqh5XoI31eISDEvw0FEQml/mKarhof6VaskLkT7o4YPj38l6cOAKE+FckxP X5lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=i+uW4iTyKQxad6ASnXK2iDVIpn6sbgBB164bG8x26UA=; b=z4CVkeidrAqePXyO74AEL5vzKQNa16U9j7HEUAN9yDdXS4BoJJrBZvATlN/yKDy4sZ 6e5R3obrMXBmfTVhXHyffM2y0jRok8mKrh/f3uQBpZfOGCFkigqVyWQ3np2G31FDXhgf vCqsUavhta5s+B/YyTy6wZRUBZfrm3Y/LqW32kHA22tZnp3ujzZQWEne0UCUw7R6P0rl 7J/W0dTthYdYo/R4lYQUr/cFxZ/iW6eu2kQDJPMStzCCPLhutJ+ekCzCVsKvSnDvZqkk 6JH3wJV6H5lG+GyqElv21NEIG1cZEsL0ptdSXzJTBtbNHrwLOyuRi1DNx3R+/FW8HUqr m08g== 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 b23si14070625lfv.204.2021.09.14.06.13.40; Tue, 14 Sep 2021 06:14:09 -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 S233196AbhINNK2 (ORCPT + 99 others); Tue, 14 Sep 2021 09:10:28 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:54082 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233181AbhINNK1 (ORCPT ); Tue, 14 Sep 2021 09:10:27 -0400 X-UUID: e25a2e7b24f04b85b1f5a00088249fda-20210914 X-UUID: e25a2e7b24f04b85b1f5a00088249fda-20210914 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 2145518149; Tue, 14 Sep 2021 21:09:06 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 14 Sep 2021 21:09:05 +0800 Received: from localhost.localdomain (10.17.3.154) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 14 Sep 2021 21:09:04 +0800 From: Hui Liu To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH] iio: mtk-auxadc: update case IIO_CHAN_INFO_PROCESSED Date: Tue, 14 Sep 2021 21:09:01 +0800 Message-ID: <20210914130901.1716-2-hui.liu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210914130901.1716-1-hui.liu@mediatek.com> References: <20210914130901.1716-1-hui.liu@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert raw data to processed data. Fixes: ace4cdfe67be ("iio: adc: mt2701: Add Mediatek auxadc driver for mt2701.") 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.25.1