From nobody Sat Apr 11 05:40:17 2026 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 88EA6C61DA4 for ; Mon, 6 Mar 2023 09:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbjCFJnR (ORCPT ); Mon, 6 Mar 2023 04:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjCFJnM (ORCPT ); Mon, 6 Mar 2023 04:43:12 -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 7544CB44D for ; Mon, 6 Mar 2023 01:43:09 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id d36so8709508lfv.8 for ; Mon, 06 Mar 2023 01:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1678095788; 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=8K7TxC9ujka7az5qWZ0Yj+PA8VwUCDcIymczB4ue3v8=; b=aFKS2vQ/9k+skY1++q3trAV5GuR0ux9uZmknr0vtFJDh6nWnD0FSxSSDBtPnpTLnOg pt2BVDnb7VuMXz1DPWdBFErXAgWf3Si4T6OwMmEl6y4c06N1si5jafB9WnZ1+dpvpAI1 FiMpjCX7zSDiHPkWObq+IZwD4Dggjsk4+xHWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678095788; 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=8K7TxC9ujka7az5qWZ0Yj+PA8VwUCDcIymczB4ue3v8=; b=VDEXXt5yJVxalT4jDgcU6B4aLoT7xrmmCMLzz9+M69vjRIqqRRgfhhYwhnQPcLzz1Y m2jyApMz9v3BbHWJXJe/DF1FaHK+wSpm2STuc1E7CIfv2KoQ3mwG/dJcowO+EGt9LsMo znMPEMapkuvV1P5FCrDnhHjgNdVFtvdpigJ8cWDaRyirGNyNPhLDe6dD0+rykw8dODhZ qa4XaUQqiSgW/crzlfUUBWTVjHt4VV+lulh2tyzesY2A1+uGhs6+Mxs5++jTNz4osz6g V3vXtrpVlV27tO+H0Q+Q5UhCi9T4HxluJxZGW/q+frOjtxdeHwQvocQTnqcgPywwXhxr 7gPw== X-Gm-Message-State: AO0yUKVyTfRGPUWftsThHEwefrwdc3GLzLdn3QS4QQSIwGBHYLLJWGNa EOTOvanGquDTE155vOf9O7Ydjg== X-Google-Smtp-Source: AK7set/EEjtZWbShl/9cou4SP3WB9m8PCl7zwjvqbkD4+okPV4JvEgzxiJnpwFXfPLHEOV7WcGNXjw== X-Received: by 2002:ac2:547c:0:b0:4b5:b06d:4300 with SMTP id e28-20020ac2547c000000b004b5b06d4300mr2766340lfn.29.1678095787838; Mon, 06 Mar 2023 01:43:07 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id a22-20020a2e9816000000b002934ed148afsm1620091ljj.52.2023.03.06.01.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 01:43:07 -0800 (PST) From: Rasmus Villemoes To: Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: iio: ad74413r: allow setting sink current for digital input Date: Mon, 6 Mar 2023 10:43:00 +0100 Message-Id: <20230306094301.1357543-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230306094301.1357543-1-linux@rasmusvillemoes.dk> References: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> <20230306094301.1357543-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Depending on the actual hardware wired up to a digital input channel, it may be necessary to configure the ad74413r to sink a small current. For example, in the case of a simple mechanical switch, the charge on the external 68 nF capacitor (cf. the data sheet's Figure 34) will keep the channel as reading high even after the switch is turned off again. Signed-off-by: Rasmus Villemoes Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/iio/addac/adi,ad74413r.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml = b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml index 9eb3ecc8bbc8..590ea7936ad7 100644 --- a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml @@ -101,6 +101,15 @@ patternProperties: When not configured as a comparator, the GPO will be treated as = an output-only GPIO. =20 + drive-strength-microamp: + description: | + For channels configured as digital input, this configures the si= nk + current. + minimum: 0 + maximum: 1800 + default: 0 + multipleOf: 120 + required: - reg =20 --=20 2.37.2 From nobody Sat Apr 11 05:40:17 2026 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 3121AC61DA4 for ; Mon, 6 Mar 2023 09:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbjCFJn1 (ORCPT ); Mon, 6 Mar 2023 04:43:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjCFJnO (ORCPT ); Mon, 6 Mar 2023 04:43:14 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D0D21A21 for ; Mon, 6 Mar 2023 01:43:10 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id b13so8945410ljf.6 for ; Mon, 06 Mar 2023 01:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1678095789; 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=zmz2nBmbaTO3qG2SmBLPZDQGKtRO+Ieydz7Ye8FP4As=; b=AvTMfeE/Sh6nyegcz8yd+g1v/9paXcicB1uPpofJwnbvMQyAlt7cBCR8azL8NTTpaX 3/LNu8m+KawTxRa1AAlYWkPCX9viBpSIceGoQaeV+TqMVaYZao7zTjIaFnmjqtwmTfcy Hmw9mlQu0XaZlACc8SoMglt1BlDV8OpzJJoEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678095789; 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=zmz2nBmbaTO3qG2SmBLPZDQGKtRO+Ieydz7Ye8FP4As=; b=hugeEPoDlygYAtxbzKZyNWq+3RX7JHURJHOnN9Cz20hjZoXBYbWaAkmHZO4j3lUm0i A92MCWr/PAzJYbqQ/7q/mRVmshw+2HCHX4UhKkjfuoBY9GrnU41oJQAjN0gpo/vjM5eC IZ0iTb6KbOlT5P2HY0OOVTNv5gyrCqm3nM54QvP03m44gw3uiOujJSPrC9PqEbEe8Wfk O4tinkwM9Yh4uKEp0RHeW2wfannvrqLorg1dktYvu1rjmOv6dIGcJROr7DfkudJAUoUP aNCcojk0I5mZ1O0OCPDMUE9HkbLZ4igCy5KE29cUBGxlJY+ws5VZwZCqRs2+G0D3kbBw dQog== X-Gm-Message-State: AO0yUKXkheZQW9f2y+nDHsanzBApUvrbWQ3TWQnTnLoMWWI7pfzSO00R dXnzt7yfmUKAygoStCmYgL1JKA== X-Google-Smtp-Source: AK7set/pXVTPqmW95TTuDKezJ3g8v2qM1LMEWSb93i6C5mD8Y/D4z3Xo+hq6TQN0mrhY9LP5UzwdMQ== X-Received: by 2002:a2e:1505:0:b0:295:ba28:a42 with SMTP id s5-20020a2e1505000000b00295ba280a42mr3214076ljd.20.1678095788912; Mon, 06 Mar 2023 01:43:08 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id a22-20020a2e9816000000b002934ed148afsm1620091ljj.52.2023.03.06.01.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 01:43:08 -0800 (PST) From: Rasmus Villemoes To: Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron Cc: devicetree@vger.kernel.org, Rob Herring , Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] iio: ad74413r: wire up support for drive-strength-microamp property Date: Mon, 6 Mar 2023 10:43:01 +0100 Message-Id: <20230306094301.1357543-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230306094301.1357543-1-linux@rasmusvillemoes.dk> References: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> <20230306094301.1357543-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use the value specified in the channel configuration node to populate the DIN_SINK field of the DIN_CONFIGx register. Signed-off-by: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index f32c8c2fb26d..4395758dbaa6 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -39,6 +39,7 @@ struct ad74413r_chip_info { =20 struct ad74413r_channel_config { u32 func; + u32 drive_strength; bool gpo_comparator; bool initialized; }; @@ -111,6 +112,7 @@ struct ad74413r_state { #define AD74413R_REG_DIN_CONFIG_X(x) (0x09 + (x)) #define AD74413R_DIN_DEBOUNCE_MASK GENMASK(4, 0) #define AD74413R_DIN_DEBOUNCE_LEN BIT(5) +#define AD74413R_DIN_SINK_MASK GENMASK(9, 6) =20 #define AD74413R_REG_DAC_CODE_X(x) (0x16 + (x)) #define AD74413R_DAC_CODE_MAX GENMASK(12, 0) @@ -261,6 +263,18 @@ static int ad74413r_set_comp_debounce(struct ad74413r_= state *st, val); } =20 +static int ad74413r_set_comp_drive_strength(struct ad74413r_state *st, + unsigned int offset, + unsigned int strength) +{ + strength =3D min(strength, 1800U); + + return regmap_update_bits(st->regmap, AD74413R_REG_DIN_CONFIG_X(offset), + AD74413R_DIN_SINK_MASK, + FIELD_PREP(AD74413R_DIN_SINK_MASK, strength / 120)); +} + + static void ad74413r_gpio_set(struct gpio_chip *chip, unsigned int offset, int val) { @@ -1190,6 +1204,9 @@ static int ad74413r_parse_channel_config(struct iio_d= ev *indio_dev, config->gpo_comparator =3D fwnode_property_read_bool(channel_node, "adi,gpo-comparator"); =20 + fwnode_property_read_u32(channel_node, "drive-strength-microamp", + &config->drive_strength); + if (!config->gpo_comparator) st->num_gpo_gpios++; =20 @@ -1269,6 +1286,7 @@ static int ad74413r_setup_gpios(struct ad74413r_state= *st) unsigned int gpo_gpio_i =3D 0; unsigned int i; u8 gpo_config; + u32 strength; int ret; =20 for (i =3D 0; i < AD74413R_CHANNEL_MAX; i++) { @@ -1285,6 +1303,11 @@ static int ad74413r_setup_gpios(struct ad74413r_stat= e *st) config->func =3D=3D CH_FUNC_DIGITAL_INPUT_LOOP_POWER) st->comp_gpio_offsets[comp_gpio_i++] =3D i; =20 + strength =3D config->drive_strength; + ret =3D ad74413r_set_comp_drive_strength(st, i, strength); + if (ret) + return ret; + ret =3D ad74413r_set_gpo_config(st, i, gpo_config); if (ret) return ret; --=20 2.37.2