Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4157192rwd; Tue, 30 May 2023 01:03:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NW8TvrC9IlYYhcibwnA7nklMZnDSWJIt1ZSbyrca8zf2GANw21Kzt77z2xbYeYqVFjGYF X-Received: by 2002:a17:903:32c7:b0:19c:dbce:dce8 with SMTP id i7-20020a17090332c700b0019cdbcedce8mr1811365plr.15.1685433812311; Tue, 30 May 2023 01:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685433812; cv=none; d=google.com; s=arc-20160816; b=RyL6fBnbfL0cLAFSiMDDYgVXYG78LTRJLmuhekOYdRwXk3oQDmEqIZGk6MkSFWRY82 btOlLo27djTeqJbCo57YAS+CKMoUR3EfpHo3hzCVJvspJQtlopKyjhfZDnxisO4ZY4CN R0MfBbpbYsgwuQ+s6Pau3rKAijbNxePwsjF9iqYaRK+nvA2/p3udCGREfKS0Wgt4tGrs RoWYqZzU/FqhBhUpChVwzRWKQP3z4G/nydzZgYyDFPzua3WXqOC35hw3jc81z9L4H3+c Yl1h1C6Kz6E13LqlqRSQATYBD5Bxyf2eAGYkHyPrO31goWGAfwMWCpqPKUN7VhawLlao cNtQ== 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 :dkim-signature; bh=ZkbCQOnKS0MEzWaipfWc4DGGonHwiuGiYcvsGowmXvU=; b=hmtK/Qq1TKBaeObCM+k0Jxe/Xo/h/yoUIesJN5mTc0+HQCJ3/SjBgGESJEvoVyTuSd KF2592L9F7RI19EQcakjuwBIfVUEOodbwzxI/uBSDHbfwA3GBgvoQYg3yaf2VP3GjYXv DabPU0z0/kWnJXTJuwQVzodg39/SSjxZOAsFExsmVqR+RXLpihTy6/9O8CSDqXE+XWOS fEHh4XqW7sl+a0kj2BH9fXx8na6DgJnWS3xWc6/Gy2rDPfV7je9zdGD0lwTyMrZCn6Lo WBdP2QckHqa2bLNrV16kPSDSpFxKjTAfkZ9pV+T/wjvszQRChHGKryri6LbTWeRAj2VO kmKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="spBov/dT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a170903018200b001a6e1b073cdsi1321639plg.639.2023.05.30.01.03.17; Tue, 30 May 2023 01:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="spBov/dT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjE3Hxq (ORCPT + 99 others); Tue, 30 May 2023 03:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbjE3Hxg (ORCPT ); Tue, 30 May 2023 03:53:36 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A244990; Tue, 30 May 2023 00:53:34 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f60e536250so34227175e9.1; Tue, 30 May 2023 00:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685433213; x=1688025213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZkbCQOnKS0MEzWaipfWc4DGGonHwiuGiYcvsGowmXvU=; b=spBov/dTKnPQTzEzpMhXigoTX7X/8Uy9+xEi+2SGTI4nYTjx17cEVPOwNm4X9ikPH1 Qh0x7NptMwnX20XnhL/QATaCJ6TQZoVFb6dmIoUKhOymbyiBtWFHlePHn1N6p5nec3hv J1Khu3np4XVmYgPNIdRROtvsEVeHsLWQ+CGgGMApjBLtbjht1hd5TvPd3rLoXAauJmuU /cZNNPZCZtHyZASgWKJEimYxGxzKt4teB4H6hHL8WLKj3BJmYqqmKzXuoXuh/FOnAg3D quC+3OPRwDRP3yZzNmA9lFEn42YPk2kaYQw2bmvH2gPa6Mvz21HOwTgmW5bF2ebwTg/b PnjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685433213; x=1688025213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZkbCQOnKS0MEzWaipfWc4DGGonHwiuGiYcvsGowmXvU=; b=fl0n5WddDCBZuIpHN1jCAgDQpi1Y0AD+sb47JahwL829ZvCf1XEvEwGu5tzhJm0HUT TVeC3+Y9FgX3HLtj3JRQFdCVsHW//F4jhTFRiBBJ+EHC9rP+RdtYRyZRdL1yYrfX75Uh l8MAmF3qtoKP2kKXl/vWwJ6+qF1H8+wm+WTu0UBplh4Qb0OcewBgxV1pmHY56r2od6KA 8hOyEYn5oT12FzPRSVqBu4l8L8xwHbb6+Y6lPx+Cnl/S6vajCuVlYy0xnOVWTqlsOOh/ mx+q8UhFOC+e+dgZI1HaCFN0+KEhmWneFOvrh1JlJGxrrrYdITCU/BXGUMn/EdiNOXza QmXg== X-Gm-Message-State: AC+VfDwP+nIwPBjg9jfL22FtahUYFtJ2M0IVWtvj8zDfT27Og8DHqGq6 P1NDCzX0JDqCh61JDqjal0E= X-Received: by 2002:a05:600c:19ca:b0:3f7:2da:8fb4 with SMTP id u10-20020a05600c19ca00b003f702da8fb4mr3522438wmq.17.1685433213186; Tue, 30 May 2023 00:53:33 -0700 (PDT) Received: from PC-UT2.ad.ennebielettronica.com ([78.152.97.130]) by smtp.gmail.com with ESMTPSA id x21-20020a05600c21d500b003f6041f5a6csm16561275wmj.12.2023.05.30.00.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 00:53:32 -0700 (PDT) From: fl.scratchpad@gmail.com To: jic23@kernel.org, Lars-Peter Clausen , Michael Hennerich , Alexandru Tachici , Liam Girdwood , Mark Brown Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Fabrizio Lamarque , Jonathan Cameron Subject: [PATCH v3 3/5] iio: adc: ad7192: Use VRef instead of AVdd as reference voltage source Date: Tue, 30 May 2023 09:53:09 +0200 Message-Id: <20230530075311.400686-4-fl.scratchpad@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530075311.400686-1-fl.scratchpad@gmail.com> References: <20230530075311.400686-1-fl.scratchpad@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrizio Lamarque Add missing vref-supply and fix avdd-supply used as if it were vref. AD7192 requires three independent voltage sources, digital supply (on pin DVdd), analog supply (on AVdd) and reference voltage (VRef on alternate pin pair REFIN1 or REFIN2). Emit a warning message when AVdd is used in place of VRef for backwards compatibility. Fixes: b581f748cce0 ("staging: iio: adc: ad7192: move out of staging") Signed-off-by: Fabrizio Lamarque --- drivers/iio/adc/ad7192.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index 5a9c8898f8af..bc41323ea810 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -177,6 +177,7 @@ struct ad7192_chip_info { struct ad7192_state { const struct ad7192_chip_info *chip_info; struct regulator *avdd; + struct regulator *vref; struct clk *mclk; u16 int_vref_mv; u32 fclk; @@ -1014,11 +1015,31 @@ static int ad7192_probe(struct spi_device *spi) if (ret) return ret; + st->vref = devm_regulator_get_optional(&spi->dev, "vref"); + if (!IS_ERR(st->vref)) { + ret = regulator_enable(st->vref); + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to enable specified VRef supply\n"); + + ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->vref); + if (ret) + return ret; + } else if (PTR_ERR(st->vref) != -ENODEV) { + return PTR_ERR(st->vref); + } + ret = devm_regulator_get_enable(&spi->dev, "dvdd"); if (ret) return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n"); - ret = regulator_get_voltage(st->avdd); + + if (!IS_ERR(st->vref)) { + ret = regulator_get_voltage(st->vref); + } else { + dev_warn(&spi->dev, "Using AVdd in place of VRef. Likely an old DTS\n"); + ret = regulator_get_voltage(st->avdd); + } if (ret < 0) { dev_err(&spi->dev, "Device tree error, reference voltage undefined\n"); return ret; -- 2.34.1