Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp163230rdb; Tue, 19 Dec 2023 12:27:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoTIaoEg09uuHeTeFJ3e0IdHxcFD4p2/HkN1xQxT5QcZ4UsOHrHgqPJk/cdmbc2oSvuoBJ X-Received: by 2002:a17:90a:2bc2:b0:285:c2db:4a11 with SMTP id n2-20020a17090a2bc200b00285c2db4a11mr7458619pje.3.1703017661487; Tue, 19 Dec 2023 12:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703017661; cv=none; d=google.com; s=arc-20160816; b=F5F4NsUWi6mLnqLwzCPw5IRmXimblUXB0aCHxfs5VMLMM5YikEHeZe5OyEV+NMd6bG cHgibg513tfPSEkCuLRvqqQYdGuJAYn+yp2MVYUgVBSvB9TyxS66ke7w81eu5Pbrt7Fa Bexsxi7/Ad6l3IuSNUUjJp/MD3PPdSClU2+LhL6C6vuf3bvbchGcXTyULQ6CywYD2mzh jo5NUy4lYop5BX638JhilNIze7J6BjjSDPvTSfMP/T2EwKX5WEyHVQdb1Yll24RtEB0g X6rHj+lsBHo3Y7+HJ15JOmSfzpNM9aIhNpxOfhIhkUBFeZmUkOIYfhh2Bugrees9UCvg HvzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zbR4DEF+WLmHDHExWRF06DaS2ko1mANnhtEF5PIJJpg=; fh=QwEOK/MZnBUTBQAzGwecl0DPfALWXdlHbxPQlQn9VIw=; b=pr+pnMTtyGixt4kkfwNmVmpt7z4pz5g6AWe+654CJhxEWttB5JvsigjiTETsmb4MRH yR7+Kn+b79YMot7iXcZW3UihkFL7kWFsbGtWTCZ1gEvgZmN7tmj2B4jVM2p4q08SiZWN oZktUN2UVFsjyk9XBKr3zs5JOC7tu85Riq2vVJDz6ywI6Pup0dLKjjRAHt6ZQLTGeNVG TasWZy3ZCmj2nFYTRO+sbB8JUoLZSqZbc/EVq1J53InN65+U4TpSF2GgWBMknqeLif23 4efq6T/zAvij7TJ2Rxho2LIf9hQDaTxwkUVuI25z1jCUgR6r6PuAh2ar8/leUmljvyLP wslg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t2-20020a17090a448200b0028bc344db63si860692pjg.170.2023.12.19.12.27.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 12:27:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5E9A2B24728 for ; Tue, 19 Dec 2023 20:27:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DB6439AFF; Tue, 19 Dec 2023 20:27:09 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F8D39AC6; Tue, 19 Dec 2023 20:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BJI4YCn001645; Tue, 19 Dec 2023 15:26:46 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3v3g4ugen3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Dec 2023 15:26:45 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 3BJKQi5r034893 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Dec 2023 15:26:44 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 19 Dec 2023 15:26:43 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 19 Dec 2023 15:26:43 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.129]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 3BJKQRl0030008; Tue, 19 Dec 2023 15:26:30 -0500 From: Marcelo Schmitt To: , , , , , , , , , , , , , CC: , , Subject: [PATCH v5 02/11] iio: adc: ad7091r: Enable internal vref if external vref is not supplied Date: Tue, 19 Dec 2023 17:26:27 -0300 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: c3jlhHCsspZqUrR4hymr4ZirL9PV992_ X-Proofpoint-GUID: c3jlhHCsspZqUrR4hymr4ZirL9PV992_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-02_01,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 priorityscore=1501 phishscore=0 mlxscore=0 mlxlogscore=984 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312190152 The ADC needs a voltage reference to work correctly. Users can provide an external voltage reference or use the chip internal reference to operate the ADC. The availability of an in chip reference for the ADC saves the user from having to supply an external voltage reference, which makes the external reference an optional property as described in the device tree documentation. Though, to use the internal reference, it must be enabled by writing to the configuration register. Enable AD7091R internal voltage reference if no external vref is supplied. Fixes: 260442cc5be4 ("iio: adc: ad7091r5: Add scale and external VREF support") Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 7 +++++++ drivers/iio/adc/ad7091r-base.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 6d93da154810..7ccc9b44dcd8 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -406,7 +406,14 @@ int ad7091r_probe(struct device *dev, const char *name, if (IS_ERR(st->vref)) { if (PTR_ERR(st->vref) == -EPROBE_DEFER) return -EPROBE_DEFER; + st->vref = NULL; + /* Enable internal vref */ + ret = regmap_set_bits(st->map, AD7091R_REG_CONF, + AD7091R_REG_CONF_INT_VREF); + if (ret) + return dev_err_probe(st->dev, ret, + "Error on enable internal reference\n"); } else { ret = regulator_enable(st->vref); if (ret) diff --git a/drivers/iio/adc/ad7091r-base.h b/drivers/iio/adc/ad7091r-base.h index 7a78976a2f80..b9e1c8bf3440 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -8,6 +8,8 @@ #ifndef __DRIVERS_IIO_ADC_AD7091R_BASE_H__ #define __DRIVERS_IIO_ADC_AD7091R_BASE_H__ +#define AD7091R_REG_CONF_INT_VREF BIT(0) + /* AD7091R_REG_CH_LIMIT */ #define AD7091R_HIGH_LIMIT 0xFFF #define AD7091R_LOW_LIMIT 0x0 -- 2.42.0