Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2240101rwb; Fri, 11 Nov 2022 06:56:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qzSxwPE/UHbQL0YYMN7dpykiScFcsVZabUJ92jMYEkPiuEFgp3D0/fvxlfm0Tb29OEWxu X-Received: by 2002:a17:906:c013:b0:78d:ff14:63f9 with SMTP id e19-20020a170906c01300b0078dff1463f9mr2020200ejz.516.1668178617301; Fri, 11 Nov 2022 06:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668178617; cv=none; d=google.com; s=arc-20160816; b=gVz5E3Ez5+BGgBaRPu8lTtiVYBPTLnOy7JQ1ez+HWFJsW0YvITepgdsZnbYepJYI7H 69GgQrD9KEOcEC2mH6hoNJeDDRwQMqMM8pmTUk7P7kD0tnqj4Wx1wj6K+yKIVloRjnQC z6sxvXW/n54eG2jmqC2I93UZIDukVnKhzdm99ldinSMrWmZzj08w7M/7ckjKu9ldGf2j bygn75Q657gtqhhdSgBBdV62me1jz8R0SuzNXVTbl9X2boM1EzWj474ISMAFT1wvf+I6 3a+egb9E6EqeZzvmPQs3escK19IMoZ0IfFAAve89xUU0tAFQJw35j00u0AHZEg0ws8QZ brIQ== 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=JAMGBaW4DNgnbxHPENr1NAw38Yk5iEpRnIys3RSCUnE=; b=o1fsOUSPpc+CJyxdL7m46CBIB8em/VWoGoJXXxe8F2ODf1z9gPsnjohYtZI2SuK0Jo GNyN8DL2RW3UucE/s4eR85C3Q+YSZLIgft/WsDbwiOzQil4nmDjInI5AX3j2py9aim5l YI5pLVmT8ZHl6/akxUYs+9WTl2gbDjJou2H0TMGZdQGZscZinL5QjYVhXwZaVkP2Bdro Qn2zKYCkNwc1gTq4FkiA7LtaICHFAaez0azO1r2K6y+ZyzFfILTxGx29PeFJHpe6URRy vU7yGATdOEHESB3/BqSmou7FmecFhpKuuZV2TSaur4xnL9tNiz3KUjDTPYpgyJivHg1m Q4CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=DVseHuqQ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dc26-20020a170906c7da00b0077b6ecac099si1537996ejb.287.2022.11.11.06.56.33; Fri, 11 Nov 2022 06:56:57 -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=DVseHuqQ; 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 S234724AbiKKOk2 (ORCPT + 91 others); Fri, 11 Nov 2022 09:40:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234684AbiKKOju (ORCPT ); Fri, 11 Nov 2022 09:39:50 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D378D5CD05 for ; Fri, 11 Nov 2022 06:39:31 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id bj12so12909143ejb.13 for ; Fri, 11 Nov 2022 06:39:31 -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=JAMGBaW4DNgnbxHPENr1NAw38Yk5iEpRnIys3RSCUnE=; b=DVseHuqQ+fdeqFq/cg5i/yOGTG4qIR6mwKQlbApHL7hGPLZtwKD+3PuBn6DEtxZjzU SCj3NzZbHwsYr6cAIdX0AtIDt+EioB8psnFybSyTkN0Os88giBjtV7Je58ZV2J9NqiGM BK8t6Pl/+wsQ9rzJbLDdqP2UxZQGL4OEuiVos= 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=JAMGBaW4DNgnbxHPENr1NAw38Yk5iEpRnIys3RSCUnE=; b=hKFFEURWs/9vi4tV8E6fvLg6YR7cc3LeegBVSTwnWeeWvEgvDiZjF/R98hWwjNjNmb q2icrdku9gcCL81VQ0cipqnoefCifsuO/19BtbGLVxiOb06uHSk8BM3CGmca2/dUn+at niyA9+pNm3rrgWF+rM92THlpqT5SiHTWxVj4bwBZoyh6xvUqhdbZkUiMxyLjvPKH8C6i U8SBSfg/Pw4HKnTIYpwRTJdD69JtHBHig5WtNZddGcYiDwVmQ+Cq/6mAK7tCO9ACpgDd ZZS/FwRZoCZcrfvsbFczCBGswG0duo66V/T4kVvyhNHKw/bpyTa4ugMOYjvS5kxe66n3 u2Eg== X-Gm-Message-State: ANoB5plLetj7yIbP6p9XvzYO7EvFAlpBmb43hazDQhk9aVtXIcsER/vR oyW6loEUJvzkpJh/QE+ISw9J0oEK8qsQB1wjTvQ= X-Received: by 2002:a17:906:f113:b0:78d:addf:67c1 with SMTP id gv19-20020a170906f11300b0078daddf67c1mr2043542ejb.272.1668177569930; Fri, 11 Nov 2022 06:39:29 -0800 (PST) Received: from prevas-ravi.tritech.se ([80.208.71.65]) by smtp.gmail.com with ESMTPSA id jt4-20020a170906dfc400b007a1d4944d45sm945886ejc.142.2022.11.11.06.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:39:29 -0800 (PST) From: Rasmus Villemoes To: Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron Cc: devicetree@vger.kernel.org, Rob Herring , Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Date: Fri, 11 Nov 2022 15:39:21 +0100 Message-Id: <20221111143921.742194-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221111143921.742194-1-linux@rasmusvillemoes.dk> References: <20221111143921.742194-1-linux@rasmusvillemoes.dk> 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,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 We have a board where the reset pin of the ad74412 is connected to a gpio, but also pulled low by default. Hence to get the chip out of reset, the driver needs to know about that gpio and set it high before attempting to communicate with it. 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 9f77d2f514de..af09d43f921c 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) @@ -1316,6 +1324,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_optional(st->dev, "refin"); if (IS_ERR(st->refin_reg)) { ret = PTR_ERR(st->refin_reg); -- 2.37.2