From patchwork Tue Nov 15 09:55:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 20278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2622878wru; Tue, 15 Nov 2022 02:05:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf428h/qNj5fNUNlsdGjynlcXdEsnII08u8XaRIhlWwMCH3ll5Irb4OZA0bL8GvQsTaZzvtX X-Received: by 2002:a17:906:1441:b0:7ad:b97e:283a with SMTP id q1-20020a170906144100b007adb97e283amr12837403ejc.567.1668506721911; Tue, 15 Nov 2022 02:05:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668506721; cv=none; d=google.com; s=arc-20160816; b=Qsyd+YZ3DQ/Khgly5KPub9WZLmRym4+Uwk11eyPNnpP+XKlfs0NE9Jt2paNJMwzw8i h11rplhKMrS6SGiwuEZ0ngnlML9m5mUaituNBnqKXjvv1NTvqI6pDWnhVF/3BUIt5Q8W WQoAc9diWaGTlIhvak66l9hc+I0iWCFB2dVhejLNnLGpxjb3WX6qpA/RCCthko9Eacwy ICp6uKIQAyfHRkK9ujgj6UTNuCfY+fhsEWiZPSwqlH6OpGCWMrQC8R7oVarxh7j3ypqm PGlUeStQADrzPxWS04CVd894KnIm8vmoTPOC3kiAVvHK/hYmrwi6caQGjkYEiFUts9xx xOBg== 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=JFlivsWSV6gGZ5OdvJQQ5Tn1kiYEgUjLp6Dm1aK7LCc=; b=jL5Urbm/l+VAj0AzZH6/uLPyIYVpCu156RUdlgsfnKW+pZ2dVnwyt5ZA9rrrdgi621 bfHMBY29LUChUNWHMr5DBsDbvboHmEWZvQ1CSftG1ROktVJk6WoZzsKxhV9S6SdDHgXk GvI2TpQcuTfBRnwMRwjp5HJAwJOWshAUCoee0smC4Oc8JVECkqjzzVV3oJ07vKvgQw+R 35fE62MDOWAxQvTd9fzt6IGRH/FOMyDJd1uvCMV+8eUueAl62aMU4YguREWmgi0lQ19Z 52/wAV2tabyZ9M6Fq39iTB7e85kTb146yit2+BZhMafR4l6CtyGU6/V7M+kDddiusvDo fQfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=eB62TXKb; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a50fb87000000b0046272b487cesi9789464edq.331.2022.11.15.02.04.56; Tue, 15 Nov 2022 02:05:21 -0800 (PST) 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=@rasmusvillemoes.dk header.s=google header.b=eB62TXKb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbiKOJzh (ORCPT + 99 others); Tue, 15 Nov 2022 04:55:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiKOJz0 (ORCPT ); Tue, 15 Nov 2022 04:55:26 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCCD413E36 for ; Tue, 15 Nov 2022 01:55:24 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id b3so23606537lfv.2 for ; Tue, 15 Nov 2022 01:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; 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=JFlivsWSV6gGZ5OdvJQQ5Tn1kiYEgUjLp6Dm1aK7LCc=; b=eB62TXKbmv90jFuho+MH8RtJRleXtoV19wJ7lGofTJHZeRStYtOauYc9z0Yeset8ya Y6D0LaESdNpj4/uAX0bCSzGjpzNCbsoq9SE+agzNE33PM4yRUwBJgLsA6FjL6u38WcGm gW/l9cNOxVi9KzPWqCMhvurVobFyld3FNuY0o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=JFlivsWSV6gGZ5OdvJQQ5Tn1kiYEgUjLp6Dm1aK7LCc=; b=Tls84zA5s1eq2bNEaNhgQ30DMBavUzEi2swyjMBlxtQRk8AEVGKi+CqhGodjmN59uV YHYxoFjDqsakKGJiPQ80qOYmcODRHZa9sqxhM2UQiLc4MmwPdG5wNpjG++nBu11fdgpu n7nhJWW4tVbEp5w0OQL29UAqx41HXSkeDdsyuBKiBMqT+RPH2eJi7UXkbRByQRt2RZuW 1zXCeIllg15KR2hzZt0r5yHZy5qvKFGyEn1ISyuYjI/TnqJQfZ/6ajRLn1vibrnTgjYd GhrRWH/KtHpWLj6irFkrUcxBzdtOcLPaXBA5koMuGgelxt363ZbTf4S+BUCSFd+GoQdC tzQg== X-Gm-Message-State: ANoB5pmCsVRZjZ7vTkNrFBo9Tn6ZxEzr+if/1gazcHcNTeEX7hEQ1NL7 Q5or6e6Ur5LQCiH0Efn7rg6ryQ== X-Received: by 2002:ac2:44d9:0:b0:4a6:fa2a:275b with SMTP id d25-20020ac244d9000000b004a6fa2a275bmr5384240lfm.87.1668506124311; Tue, 15 Nov 2022 01:55:24 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id q3-20020a19f203000000b00493014c3d7csm2148598lfh.309.2022.11.15.01.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 01:55:23 -0800 (PST) From: Rasmus Villemoes To: Rob Herring , Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron Cc: devicetree@vger.kernel.org, Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] iio: addac: ad74413r: add support for reset-gpio Date: Tue, 15 Nov 2022 10:55:17 +0100 Message-Id: <20221115095517.1008632-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221115095517.1008632-1-linux@rasmusvillemoes.dk> References: <20221111143921.742194-1-linux@rasmusvillemoes.dk> <20221115095517.1008632-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749211981022590176?= X-GMAIL-MSGID: =?utf-8?q?1749556104578973470?= We have a board where the reset pin of the ad74412 is connected to a gpio, but also pulled low (i.e., asserted) by default. Hence to get the chip out of reset, the driver needs to know about that gpio and deassert the reset signal before attempting to communicate with the chip. When a reset-gpio is given in device tree, use that instead of the software reset. According to the data sheet, the two methods are functionally equivalent. Signed-off-by: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index a157f2247a50..313c279173f2 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -71,6 +71,7 @@ struct ad74413r_state { struct regmap *regmap; struct device *dev; struct iio_trigger *trig; + struct gpio_desc *reset_gpio; size_t adc_active_channels; struct spi_message adc_samples_msg; @@ -393,6 +394,13 @@ static int ad74413r_reset(struct ad74413r_state *st) { int ret; + if (st->reset_gpio) { + gpiod_set_value_cansleep(st->reset_gpio, 1); + fsleep(50); + gpiod_set_value_cansleep(st->reset_gpio, 0); + return 0; + } + ret = regmap_write(st->regmap, AD74413R_REG_CMD_KEY, AD74413R_CMD_KEY_RESET1); if (ret) @@ -1322,6 +1330,10 @@ static int ad74413r_probe(struct spi_device *spi) if (IS_ERR(st->regmap)) return PTR_ERR(st->regmap); + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(st->reset_gpio)) + return PTR_ERR(st->reset_gpio); + st->refin_reg = devm_regulator_get(st->dev, "refin"); if (IS_ERR(st->refin_reg)) return dev_err_probe(st->dev, PTR_ERR(st->refin_reg),