From patchwork Fri Nov 11 14:39: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: 13040476 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 68CCBC433FE for ; Fri, 11 Nov 2022 14:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234669AbiKKOju (ORCPT ); Fri, 11 Nov 2022 09:39:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234531AbiKKOjg (ORCPT ); Fri, 11 Nov 2022 09:39:36 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A869627F2 for ; Fri, 11 Nov 2022 06:39:27 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id k2so13059189ejr.2 for ; Fri, 11 Nov 2022 06:39:27 -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=3BpIqKmaepR1SpUgklkTdQKDocBg8CsmOhHMlVS5EHA=; b=DrM+gnHh97vdiwSHvs4Vlne0TO7c7w6abdslmDlScfvk00Y2RXCkV1/198Pr+SVcbm n84m7ML0SQY10/bU7IEnnEcKIHqkZ20R7/yCuFd2+jYTc3uRCe18o/7sh7Ix2V05Gdge f0lgC7FK/NGYosoVXQ1uY9SHIUGtr4TPm7JrI= 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=3BpIqKmaepR1SpUgklkTdQKDocBg8CsmOhHMlVS5EHA=; b=dfraVuo00vCFwQs8Z/uOtrUB2kVsYTn/qfH0huKKlsKxNqb5QlbPjX90CY1jWZPowp ONu59heCGg9+7fwSTYAFwOJ0aWnrreMTc/3seBBDNs8V6zoRUuLmiyHeHgc5RlywDHc8 vL5sT1jWq4ymXujiKASHV+PUhLYo2MsxqdFRlES8Yc72EUtfSO7ggZM6vrzgveJyJ/N2 jznKrmjRAGKL7b+rcIMzbUFpvz+OgapeomYj40NO9Umy2+rrjbccr9rwq3UwPYvIqHaD 80UniOrLSF4nqcwwMNOIyRC5gzJihLUwtzBYR0PovL1o6TDsXKawQoF67yfWSpnUUZNM MebA== X-Gm-Message-State: ANoB5plGBYuVViFo4ozjEuq+23MxMeD2hJ1OcFUVO08j8N1AVkihq0Xw FNMfKNPc7kRCKfwlQdhgSgadWw== X-Google-Smtp-Source: AA0mqf7L3DlioxGxsRAlHlmZuxIAKfkei/P6adHOCk7nBRhv6rfyvwNL24gmqVIp5PiVy6hCz3zUyw== X-Received: by 2002:a17:906:388c:b0:7aa:97c7:2c04 with SMTP id q12-20020a170906388c00b007aa97c72c04mr2100956ejd.191.1668177566016; Fri, 11 Nov 2022 06:39:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:39:25 -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 1/5] iio: addac: ad74413r: add spi_device_id table Date: Fri, 11 Nov 2022 15:39:17 +0100 Message-Id: <20221111143921.742194-2-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 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 899bcd83f40b..37485be88a63 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -1457,12 +1457,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 Fri Nov 11 14:39:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13040477 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 D6F06C4332F for ; Fri, 11 Nov 2022 14:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232574AbiKKOjw (ORCPT ); Fri, 11 Nov 2022 09:39:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234655AbiKKOji (ORCPT ); Fri, 11 Nov 2022 09:39:38 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E05D654DB for ; Fri, 11 Nov 2022 06:39:28 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id i10so4339561ejg.6 for ; Fri, 11 Nov 2022 06:39:28 -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=2lxqynGN1zb3SeT8QyXA1+0ZwfAUv0vy1HULeEAsp+0=; b=BY47XsVmK51QERSuv9y2eWZAjkN5DPflYrv9P/kAP1nvo563DsVXnrBG2y65QznhVM SJJXYc3oBd5budwHsKVFz1tIAxtTFQHFuRjvG2Qow3zmfnhU4p6vdjvcEJwBKzhZFQac supnDkrsavwNMIaDcwLsbcfXTXa6D3sSBou3Y= 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=2lxqynGN1zb3SeT8QyXA1+0ZwfAUv0vy1HULeEAsp+0=; b=znXTw4Ntd9Xaocte5qIT/H83q9yob46f9UcJ+MnKk79zWq/kE2zshhT958+4IVvf6F GPqZ5NYuMcHjlYnPc0H/B9xF0FSfJGCEVAL9Y/kj/4vIXEhnqUPiZ1DNRfwzyXCOKPiL SaPQ0TC+2ig5GaWuPMH2CUQTKHTcWFCV3kjQySNPHdZQqLvZ3OEkV6XHmEdbdPzSpQfz NapoYAbWC6ljqbBjp4GnxuwedmUdOIwRJy6MaOqcvOPULRsgYMI3Fd/p7TPq1wn8eG7s /xlys7i8xjJohbXQJ+LgInf+F+fk3MNEv7z0JSzAscHn3KSTB16ajcpDqAbee1eB48wj LTrQ== X-Gm-Message-State: ANoB5pnUEWTDtwrBNctFeDefZgNT+HkTTwZRcNFqbfiKC3c5sOY8QOjj 3KSVyxepaHbCE7SO+xW38kcvMg== X-Google-Smtp-Source: AA0mqf4T+udwGoWTudovo/FSHJ7IAR9wOH9fTJtKpCchExVGoh2RGDgoSsgTqibYqqdzi4ULw93B0w== X-Received: by 2002:a17:906:8cf:b0:7ae:59dd:e3f4 with SMTP id o15-20020a17090608cf00b007ae59dde3f4mr2017438eje.755.1668177567004; Fri, 11 Nov 2022 06:39:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:39:26 -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 2/5] dt-bindings: iio: ad74413r: make refin-supply optional Date: Fri, 11 Nov 2022 15:39:18 +0100 Message-Id: <20221111143921.742194-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The ad74412r/ad74413r has an internal 2.5V reference output, which (by tying the REFOUT pin to the REFIN pin) can be used in lieu of an external 2.5V input reference. So stop marking refin-supply as required. Signed-off-by: Rasmus Villemoes --- Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml index 03bb90a7f4f8..e954d5ae4f4f 100644 --- a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml @@ -56,7 +56,6 @@ required: - reg - spi-max-frequency - spi-cpol - - refin-supply additionalProperties: false From patchwork Fri Nov 11 14:39:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13040478 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 C6EAFC4321E for ; Fri, 11 Nov 2022 14:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234717AbiKKOjy (ORCPT ); Fri, 11 Nov 2022 09:39:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234621AbiKKOjq (ORCPT ); Fri, 11 Nov 2022 09:39:46 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F35B65858 for ; Fri, 11 Nov 2022 06:39:29 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id a5so7865645edb.11 for ; Fri, 11 Nov 2022 06:39:29 -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=NMEYouN33VXJnGj1szjoBs9S5kXWzk4pLlmEmqoZFno=; b=aYLheQpYSAA+nvIa8jyxXle6dr+WMfHP/Q3Xc7+2lnehrlu5Uxzb2AighHNYmghKXh XCQvPKImeoie67r83OOlpg4Jg4N7ZI4I9oCgVyQ/O2crwjrallGtflR058/P8LymOWzZ e+vsF5mXlwN57u+OUIx04kLjRfdzkol9U6gDM= 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=NMEYouN33VXJnGj1szjoBs9S5kXWzk4pLlmEmqoZFno=; b=6IV75PAskC7HMoRe08poeD7zddx0EeU/Lm42lHu8H538yY9X90ALgSFOWzcMedjR3I 8SngEriTas1+bdHzWWy60uQQTpNTmhJpy8Ww4O8CWPFy3xiqRcZNEtLuyoiPeidG7yMt QnUko+i+T9qx5cNIvpSNL164QIe5NagyQldVoGo12P8/KIf82ncNHVl4oLWByyQTC2y+ Ms2+eY+Fl/fEy6Gb22WD7PviLcq90Ook5LeDDiH7EnXRXQi+P9HMldXZQttmejDJ7bYM aCAalmdozaeZ4OOaBq9cvj9h6youfMnPu8UWzSHLsdphor77SzQ+DZJtZmINuhmdlA+v ivvw== X-Gm-Message-State: ANoB5pmB5NOFR3Z5iepLLA3OzGNS15qJ3XrnGAYtGgWcTcFd10vUpe4n CYMOBy3kkftFaL3Lf1aSD6JVOg== X-Google-Smtp-Source: AA0mqf6EZrJe3b/AEPYKxhBsDWFd7mBnEEhN5/HmA8x0PqIa8X/7blYSPJPVgjhCfuRbdElYD/vX3A== X-Received: by 2002:a05:6402:158c:b0:463:19ca:a573 with SMTP id c12-20020a056402158c00b0046319caa573mr1727365edv.31.1668177567955; Fri, 11 Nov 2022 06:39:27 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:39:27 -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 3/5] iio: addac: ad74413r: implement support for optional refin-supply Date: Fri, 11 Nov 2022 15:39:19 +0100 Message-Id: <20221111143921.742194-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The ad74412r/ad74413r has an internal 2.5V reference output, which (by tying the REFOUT pin to the REFIN pin) can be used in lieu of an external 2.5V input reference. Support that case by using devm_regulator_get_optional(), and simply hardcode the 2500000 uV in ad74413r_get_output_current_scale(). I'm not sure this is completely correct, but it's certainly better than the current behaviour, where when refin-supply is not defined in device tree, the regulator framework helpfully does its supply refin not found, using dummy regulator thing. When we then do the regulator_get_voltage(), that dummy regulator of course doesn't support that operation and thus returns -22 (-EINVAL) which is used without being checked. Signed-off-by: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 37485be88a63..9f77d2f514de 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -608,7 +608,10 @@ static int ad74413r_get_output_voltage_scale(struct ad74413r_state *st, static int ad74413r_get_output_current_scale(struct ad74413r_state *st, int *val, int *val2) { - *val = regulator_get_voltage(st->refin_reg); + if (st->refin_reg) + *val = regulator_get_voltage(st->refin_reg); + else + *val = 2500000; *val2 = st->sense_resistor_ohms * AD74413R_DAC_CODE_MAX * 1000; return IIO_VAL_FRACTIONAL; @@ -1313,19 +1316,25 @@ static int ad74413r_probe(struct spi_device *spi) if (IS_ERR(st->regmap)) return PTR_ERR(st->regmap); - 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), - "Failed to get refin regulator\n"); + st->refin_reg = devm_regulator_get_optional(st->dev, "refin"); + if (IS_ERR(st->refin_reg)) { + ret = PTR_ERR(st->refin_reg); + if (ret != -ENODEV) + return dev_err_probe(st->dev, ret, + "Failed to get refin regulator\n"); + st->refin_reg = NULL; + } - ret = regulator_enable(st->refin_reg); - if (ret) - return ret; + if (st->refin_reg) { + ret = regulator_enable(st->refin_reg); + if (ret) + return ret; - ret = devm_add_action_or_reset(st->dev, ad74413r_regulator_disable, + ret = devm_add_action_or_reset(st->dev, ad74413r_regulator_disable, st->refin_reg); - if (ret) - return ret; + if (ret) + return ret; + } st->sense_resistor_ohms = 100000000; device_property_read_u32(st->dev, "shunt-resistor-micro-ohms", From patchwork Fri Nov 11 14:39:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13040480 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 11EEDC43217 for ; Fri, 11 Nov 2022 14:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234699AbiKKOkD (ORCPT ); Fri, 11 Nov 2022 09:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234679AbiKKOjs (ORCPT ); Fri, 11 Nov 2022 09:39:48 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065A765874 for ; Fri, 11 Nov 2022 06:39:30 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id kt23so12993589ejc.7 for ; Fri, 11 Nov 2022 06:39:30 -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=8nUDZC72vgUX/+mjOceon1Lp8omkXG06DLgI5cBosnQ=; b=iFvwZclfbIiKwXP++pqGCXBltsjAlYxG6Eg2T2fA6LMnFCV5dUD1qVPwaeCSWErf33 ekEzJFjqde0fdpIQCgmDy2gvE8PG82AcoO12V0spWo0LUtjPIH7vdyx9dsRZoPmkZNYf 604eIeEENYz2NPWEJYYEBCQKKihY8U4xDLRDE= 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=8nUDZC72vgUX/+mjOceon1Lp8omkXG06DLgI5cBosnQ=; b=7mMlr/4WaoGNidlvNkt5PV7E2yICDTxZgby6oe46VUz/aejwIhEcmQSfw0PJkfcWdZ KSX+BNYTkaRUw1FW+GodlPXuv8vHbpxIw3beG4EKDAGOt+JPwSYFwYxJYRWPbvPsYz23 WD+TeZ9aY+7ben8GjjPrl4lg1sp/Z4FQJoXltjOUUmfQvv9VuuFgATbyAieI02/KPNYH Z9NrS0NCrjehNKxzGljnoWFTss40HbgJR+dH2a0ZJ4EypSDT7b3dR8UGbTHxAAaMMm3o ZH5iiXNG+wcZoW32TNfZchQUkPjunIDoO4SVtmt7dibHZTbe9Id5IOKyXO59v28MiP/t jtPg== X-Gm-Message-State: ANoB5plb4VDg/xibl9PIE/QNEQqt1wT22krWs4vX3/4SQ4e77qX1GEYg nVtwq5S0AwoAkIENLvAVCvZa0w== X-Google-Smtp-Source: AA0mqf5iH//Tm204ldnCOaAvtZbOZb56fKbSpew5u5OxZ4DlhaeYDYvvxEZ6X1G7mx9HpGdqjUNu1A== X-Received: by 2002:a17:906:3d52:b0:7ae:44b2:cb7f with SMTP id q18-20020a1709063d5200b007ae44b2cb7fmr1982156ejf.437.1668177568980; Fri, 11 Nov 2022 06:39:28 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:39:28 -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 4/5] dt-bindings: iio: ad74413r: add optional reset-gpios Date: Fri, 11 Nov 2022 15:39:20 +0100 Message-Id: <20221111143921.742194-5-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 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 --- Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml index e954d5ae4f4f..70f82cc716ae 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 From patchwork Fri Nov 11 14:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13040479 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 9B641C43217 for ; Fri, 11 Nov 2022 14:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234206AbiKKOjz (ORCPT ); Fri, 11 Nov 2022 09:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234680AbiKKOjs (ORCPT ); Fri, 11 Nov 2022 09:39:48 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3393559B for ; Fri, 11 Nov 2022 06:39:31 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id f27so13067541eje.1 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=dWNVTdiiS0xWAknkFSdJFrQuUg608LZSHm3Ar6tVTqf1aaweDxJg4PCoN/uQ7SnnMg nFeePLyoNVeFbdwrd/omsax5FYTY/pHs26kSBnSnEs8gGcR/Jg6bfvPZptfme8ru2H4g 7wMe7W1aFtZg3TimR7zvxVBql8zV9/nb2BsIBJnRpYj64QEQBF4KybxrsZx10xOUOzJD 9GHnMIb+sGUxeeEoWNuZl0fLC1il/G7mPB9/nE0HPpYTpWzWh07LZ1E4Hp/3k49wivpi IjvL3ZzxmYV6qmDSb2GHjZ2w5SbBpXqMkvbDFlomQCAHs0SYaeJR5ZCF4fEBQMwGihGh 0J3g== X-Gm-Message-State: ANoB5plmBKKW1AM4NOXBrm3yyOik5DC45qasc6V2DEi4I/XqIYubH91L Wti/cw4UUJSjKou8Flb2zdHzTw== X-Google-Smtp-Source: AA0mqf6uSSRRx4Q/XNl8iM4CFB+rpwgzG4zqyxc1Y93PWapbVBiCTtJEFTV0LfFQL7WkrlvtCR5YjA== 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 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 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);