From patchwork Tue Nov 15 09:55:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13043390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CB1FC4167D for ; Tue, 15 Nov 2022 09:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbiKOJz1 (ORCPT ); Tue, 15 Nov 2022 04:55:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiKOJzY (ORCPT ); Tue, 15 Nov 2022 04:55:24 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 204CBDF0C for ; Tue, 15 Nov 2022 01:55:23 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id l12so23597737lfp.6 for ; Tue, 15 Nov 2022 01:55:23 -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=23t4Te+yw+Hqm+0pjO3fcF8NMLCFiSBxJI+O+j/PQU0=; b=WGBR5LG3Z/5OspOwwBLwL/f4DQt3EbSb2GSsCAq4/4Rw17LYljrtFT1mtEQ3fRFSJk 2WMtRjfQ0B1/i/6BDPZzrgWNOY6nEpC4+rafytXiULnV9L7/txmaey99VFWBIgLG+6oi JrR1oXpfymU5E6oWJuu/rAeKeulGAP26vpa4k= 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=23t4Te+yw+Hqm+0pjO3fcF8NMLCFiSBxJI+O+j/PQU0=; b=bYK45qYePqDSomHXfEIQAngDdC7yXgTGtyP2ETVWLMm1pwZCG3iFx4bcnxw5xvSp5g kJMaUCx9uti1WQ3gBT3HQv8dEzp8Ae3n99JuHy7hdnapnJMza8410R2Y5+M8dwW+P5yF 3/zZ2o5nHTelmpQ5JTHCeBKERVIGl5MHMQFSzJb2cehq0b+dDrICV55Cq40+Ns8m/TBl dwCrSqPwuUEPTpjWpuF+zzuubbFHVb6NYnYlILjF38uKj+c4amq8KAzR4/ey2jRG/w3C 46U2mI88JLZ5Bk9hGQ17hOCLwvSaDQMhjCHgBu/jZco4Q/kEYRzeb62Dl7RcryUkWg/q tq4g== X-Gm-Message-State: ANoB5pkm1KFMkRrbYmnSq69LMJUaiOJZ+8HhWNNz1Unksjthl+E2v7Sy 1a506cgcR8mj0jAV1BQgAW8E8Q== X-Google-Smtp-Source: AA0mqf4+RWJc7VzvUBK5tdYcqEuSDHuctvwj/7ftSLOlDEN7QARqcw5/psupBW3/lsazEeVhY0v6bg== X-Received: by 2002:a05:6512:a86:b0:4a4:72b0:9a2b with SMTP id m6-20020a0565120a8600b004a472b09a2bmr5104119lfu.469.1668506121475; Tue, 15 Nov 2022 01:55:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 01:55:20 -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 1/3] iio: addac: ad74413r: add spi_device_id table Date: Tue, 15 Nov 2022 10:55:15 +0100 Message-Id: <20221115095517.1008632-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Silence the run-time warning SPI driver ad74413r has no spi_device_id for adi,ad74412r Signed-off-by: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 899bcd83f40b..a157f2247a50 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -1305,6 +1305,15 @@ static int ad74413r_probe(struct spi_device *spi) st->spi = spi; st->dev = &spi->dev; st->chip_info = device_get_match_data(&spi->dev); + if (!st->chip_info) { + const struct spi_device_id *id = spi_get_device_id(spi); + if (id) + st->chip_info = + (struct ad74413r_chip_info *)id->driver_data; + if (!st->chip_info) + return -EINVAL; + } + mutex_init(&st->lock); init_completion(&st->adc_data_completion); @@ -1457,12 +1466,20 @@ static const struct of_device_id ad74413r_dt_id[] = { }; MODULE_DEVICE_TABLE(of, ad74413r_dt_id); +static const struct spi_device_id ad74413r_spi_id[] = { + { .name = "ad74412r", .driver_data = (kernel_ulong_t)&ad74412r_chip_info_data }, + { .name = "ad74413r", .driver_data = (kernel_ulong_t)&ad74413r_chip_info_data }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad74413r_spi_id); + static struct spi_driver ad74413r_driver = { .driver = { .name = "ad74413r", .of_match_table = ad74413r_dt_id, }, .probe = ad74413r_probe, + .id_table = ad74413r_spi_id, }; module_driver(ad74413r_driver, From patchwork Tue Nov 15 09:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13043389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDAFEC4167B for ; Tue, 15 Nov 2022 09:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236156AbiKOJz0 (ORCPT ); Tue, 15 Nov 2022 04:55:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbiKOJzZ (ORCPT ); Tue, 15 Nov 2022 04:55:25 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FF401131 for ; Tue, 15 Nov 2022 01:55:24 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id a29so23598324lfj.9 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=Rh6bYHIsyDNDTnfvzoAbdszZSJH6gLxzazLnOaj70HA=; b=bSZZJfROZutTxt3595+PfI4ZhtPwBIahanBafiFrPMZPMBHP1Cmv8o6Il/aM2Xp+o/ o71uuAgm14aS6XGge20gAPleiOmWMKad0YaGMNaqXiWzT4y/Xf8ixcz9bpPQbdBHjN/D 29DWsynBrQj9W/80laRWbTMtubp/CHC/kaToM= 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=Rh6bYHIsyDNDTnfvzoAbdszZSJH6gLxzazLnOaj70HA=; b=d86JsSzC2Xwz0IuzzLw2ROk0PntMhuqYbDZ6gISy7EzdM1srnRP2gLJmgE1GahUN26 E5DqEjbN/9VUCt34BX8yr7pAwpdsUdrITuqTtr+JzR1/FA7QZX0vuYwQq9M4xr2Qp4Y+ nhowLaVatG+gUOwTr04FE6u9QR0YzuKIJJaRWwYNEDOvERpK1souOYr2v2fX4ZF77VBO +LTYvqbPh8C+XLqE1wRRoCvFFdshfikATvMZVrJpTuTf5jhvo7kv/3f8OnIhb/ALk/cc RxLy2KrPAsiUVnJ0gRj8vMIRnn4xaFlfLXisVH72lxCbU7GdTDrBB5LTwYKzmqsEEyGN jmaA== X-Gm-Message-State: ANoB5pl2geXbPeZmEC7s6KQygNwk/G8Cv+k6BPXnm46IVTXTTbyNYiVw YyBpUYvU6UjqED3/GUvqv1DIpg== X-Google-Smtp-Source: AA0mqf4IpDdOzB7uHmqouFHDhpeTZ4WG8GgpzIbAK3v260DQIYB187asu3q1m+4TmytYyTGWKJjh+A== X-Received: by 2002:ac2:4f0e:0:b0:4b4:9193:1caf with SMTP id k14-20020ac24f0e000000b004b491931cafmr3920173lfr.300.1668506122988; Tue, 15 Nov 2022 01:55:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 01:55:22 -0800 (PST) From: Rasmus Villemoes To: Rob Herring , Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] dt-bindings: iio: ad74413r: add optional reset-gpios Date: Tue, 15 Nov 2022 10:55:16 +0100 Message-Id: <20221115095517.1008632-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The ad74412 and ad74413 devices have an active-low reset pin. Add a binding allowing one to specify a gpio tied to that. Signed-off-by: Rasmus Villemoes Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml index 03bb90a7f4f8..62f446dbc3d8 100644 --- a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml @@ -51,6 +51,9 @@ properties: Shunt (sense) resistor value in micro-Ohms. default: 100000000 + reset-gpios: + maxItems: 1 + required: - compatible - reg @@ -129,6 +132,7 @@ examples: interrupts = <26 IRQ_TYPE_EDGE_FALLING>; refin-supply = <&ad74413r_refin>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; channel@0 { reg = <0>; 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: 13043392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 180FAC4332F for ; Tue, 15 Nov 2022 09:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237940AbiKOJz2 (ORCPT ); Tue, 15 Nov 2022 04:55:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbiKOJz0 (ORCPT ); Tue, 15 Nov 2022 04:55:26 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E814055AA for ; Tue, 15 Nov 2022 01:55:25 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id a29so23598376lfj.9 for ; Tue, 15 Nov 2022 01:55:25 -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=WDZ1bizhRp9B0D5WiOIbXF98OeQytG/2mr+Al/JldtVjMqIf4AxBhMHkgI+UolyhnU KdDuxm5iR3l/DGKza99j7w6EFT7trvA9toma2b4KATJP3q7w7dC4/OHZFxlr21RIyqvc wlsBFuOoTeU2Djlw1FAdvFbjPu0LwZrz9zfRbkrZsTPh5GSddlWe3I1jUZYbj8maMxyY pCXAYyDlXAeeBIskp6fIVWGLcChZVCcdQsaw6W7DtZPoRPojsnTY51NgY7F231i5yc/G X2EQQTjkGZuDGdrnHO8uYMuCBjGFBrmi9Vf1NQx/l5e+f+AfWWivBcJyRIVq/s7vOjAw 0WUg== X-Gm-Message-State: ANoB5pkeeDAzIfYe5tcJ5n7wcAppOQgKDGXrUGrJTtCuNZ5lrfLmpDlT G8fpUi0UEwgdJd739TSgdl/gBQ== X-Google-Smtp-Source: AA0mqf5Y95D8tO/xmcrREUli7jPVrLMM/oPDXhwa8i/q0SQclJU1quPMKFYiHLjliXfnoxZtB3jWJw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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),