Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1864550rdb; Thu, 7 Dec 2023 10:42:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjWqgQ0KvniVze3iLjB/CoWxBz3O+yI8dcSdMAANi7tc3FNM1c5bkr9CwqY2pBAVbaGmc+ X-Received: by 2002:a05:6a20:2303:b0:18c:8d0f:a794 with SMTP id n3-20020a056a20230300b0018c8d0fa794mr2205060pzc.19.1701974535477; Thu, 07 Dec 2023 10:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701974535; cv=none; d=google.com; s=arc-20160816; b=Bfj1peSDJONMk0Z3R95W22yhZ5oezFsPfpnbgWgPl5YIlCzVC51JZ13ttJ+TryAJwX eDhn632JWrdPbcJKSvjJO872fHVGyxlKGBCABRaQrukO3BaTuMg7lyv8dKqooJpzBWBX 8y8a0GL/WtnIhyncSiiTQmUPLAgaDlRM2AJ3SMSkpb+NCnIYtnumzTKgfHA2kXmydY/q fh+jNkkIflrF4lkGvp0hlVMqcI5Cstf7rqU2cfUybp+F8oCy4TnF1LIner7v4S/lPXSG nRYbnF1Zg81WRJK9sKIpS3IZTePaOIypXyCEE8ud53bOffNYgzD1NoJ8CRqa1pQ/acHt wmDg== 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=flAwFEe+OB9Et/RURKXXHOGoPIdDuKWkxx9Ca4UgcH8=; fh=EXgg9YqnApgKKZYhZSosPcHJkz7G44hkaqfseiwxB60=; b=as2kVSwya26o4dMeKmXS/7ooVcK8qSpVs43TvU7++HFSDUFZSp5Gvz3gSUCELGSgO6 Xbm2sDex/kURWpl1geq+bWaWY8Hg/ijSyqyvNJC+rQ7nSPcO6PwWBESBmeS45z5JJR6Y iB6GuyoflmcA7ynY5Nyaspwdo67zsScn8Kc2mhXHXdCUtJJr5lZ8uKv1AhyQhLY8eJd/ ylSm0FiEfg1Gxmcsdy3xDYbduG8/+eSPoZH7JExRrYrZ5HTla1BVv0x3YMoAo+1o1/o8 sRnsIgk+FX2srXSwZt8ICjNg/msMA0GsHEjBWlYjGReNu/kQ+xaWaD6wcyfysqwc86H/ +z0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g28-20020a63201c000000b005b8f0ca2e5asi124854pgg.79.2023.12.07.10.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 10:42:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0F4148026ADF; Thu, 7 Dec 2023 10:42:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379589AbjLGSmA (ORCPT + 99 others); Thu, 7 Dec 2023 13:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233102AbjLGSl7 (ORCPT ); Thu, 7 Dec 2023 13:41:59 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D00391720; Thu, 7 Dec 2023 10:42:05 -0800 (PST) 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 3B7F6YCJ008116; Thu, 7 Dec 2023 13:41:47 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3utd13spct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Dec 2023 13:41:46 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 3B7Ifjk0024710 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 7 Dec 2023 13:41:45 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) 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; Thu, 7 Dec 2023 13:41:44 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 7 Dec 2023 13:41:44 -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 3B7IfP2U015375; Thu, 7 Dec 2023 13:41:28 -0500 From: Marcelo Schmitt To: , , , , , , , , , , , , CC: , , Subject: [PATCH v3 08/13] iio: adc: ad7091r: Enable internal vref if external vref is not supplied Date: Thu, 7 Dec 2023 15:41:25 -0300 Message-ID: <0c71001f4c1eba169230caee6640661cec4b979b.1701971344.git.marcelo.schmitt1@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: qU_7KtquRmM1r1sw3EKpQ34SV8WISxd2 X-Proofpoint-GUID: qU_7KtquRmM1r1sw3EKpQ34SV8WISxd2 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 lowpriorityscore=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=863 suspectscore=0 bulkscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312070156 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 10:42:13 -0800 (PST) The ADC needs a voltage reference to work correctly. Enable AD7091R internal voltage reference if no external vref is supplied. Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad7091r-base.c | 9 ++++++--- drivers/iio/adc/ad7091r-base.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index f2cb638b8d77..59a7ec44955d 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -215,10 +215,13 @@ int ad7091r_probe(struct device *dev, const char *name, iio_dev->channels = st->chip_info->channels; st->vref = devm_regulator_get_optional(dev, "vref"); - if (IS_ERR(st->vref)) { - if (PTR_ERR(st->vref) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (IS_ERR_OR_NULL(st->vref)) { + /* Enable internal vref */ st->vref = NULL; + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, + AD7091R_REG_CONF_INT_VREF, BIT(0)); + if (ret) + return ret; } 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 9546d0bf1da7..e153c2d7deb5 100644 --- a/drivers/iio/adc/ad7091r-base.h +++ b/drivers/iio/adc/ad7091r-base.h @@ -20,6 +20,7 @@ #define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) /* AD7091R_REG_CONF */ +#define AD7091R_REG_CONF_INT_VREF BIT(0) #define AD7091R_REG_CONF_ALERT_EN BIT(4) #define AD7091R_REG_CONF_AUTO BIT(8) #define AD7091R_REG_CONF_CMD BIT(10) -- 2.42.0