From patchwork Fri Jun 23 11:33:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 695969 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 985EFC0015E for ; Fri, 23 Jun 2023 11:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbjFWLdh (ORCPT ); Fri, 23 Jun 2023 07:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbjFWLdg (ORCPT ); Fri, 23 Jun 2023 07:33:36 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDB3AC for ; Fri, 23 Jun 2023 04:33:35 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2b466066950so9295321fa.2 for ; Fri, 23 Jun 2023 04:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1687520014; x=1690112014; 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=ItH4Pg7jxqco9mS/zUwcLIsvKjoWsb65kGsf9QvB3Qs=; b=UOJiSnXVBXDwtiw7hkY3RS495zKUvrRo3305RzR5u/Ea5HWCNy8TZb6T2DYp45BYc1 7Eli8yLXnwF7pmC4Cm253Z1VzQId5Xov5p6hhPu/OO5TXM5rg7pmqSzogWxG5pO0rDs3 RdqUvzIoMuw1zQDKcNCcu2d7pZKca19joPPcs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687520014; x=1690112014; 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=ItH4Pg7jxqco9mS/zUwcLIsvKjoWsb65kGsf9QvB3Qs=; b=i3eOSTFn7c/cJsL6sh1rVWM5XL3U4rLZh6R5v4mT7KyjpPThL/ALQvID4VjID7yuml 3ls/qS09e8EkgzExlobx9opbsTqvzDHrKnId2nrYOlsoIJO4S+ftlNe8mbWyaudYOjfo 73pgvslzfZN+t2jdWuamclr06nISSm13fZyjcnx+/Lr3oEpbRehzu+ZUreyZ5JUAURfm 3JKE/Ub5poJfjUUWLUbMRHu3vaQ2CPelTQl+Ogfw+QzjWoGKnlZULWYIPjhaOn4ontwN Ie55cCklS4ZwwxSf6rI/If+Caecdb2w+uxdnDvB/1GNPHNVBWNeZiOkj+46C9zyNE/dR pUVw== X-Gm-Message-State: AC+VfDxeORDXBCLCzbU/0IjB2wrKEGn4f+RPKuH8jUj69iKthoeD6JnY z2pAOv/eOsjj6cep/NdgqAw87Q== X-Google-Smtp-Source: ACHHUZ7qO4OC1EC6XyojwSPlB9l6hMdD419uyQ/ieDUyzzt51BVNpsgYqiGk9wLIVRh9KzDWj6AWow== X-Received: by 2002:a2e:961a:0:b0:2b5:7af9:f390 with SMTP id v26-20020a2e961a000000b002b57af9f390mr7940759ljh.47.1687520014000; Fri, 23 Jun 2023 04:33:34 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id n10-20020a2e720a000000b002b471efb253sm1711605ljc.46.2023.06.23.04.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 04:33:33 -0700 (PDT) From: Rasmus Villemoes To: Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: devicetree@vger.kernel.org, Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: iio: ad74413r: add binding for digital input threshold Date: Fri, 23 Jun 2023 13:33:25 +0200 Message-Id: <20230623113327.1062170-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230623113327.1062170-1-linux@rasmusvillemoes.dk> References: <20230623113327.1062170-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Allow specifying the threshold for which the channels configured as digital input change state. Signed-off-by: Rasmus Villemoes --- Running dt_binding_check on this with a too small or large value in the example does give me an error, but the multipleOf does not seem to be enforced; the value 1234567 is not flagged. I don't know if that's expected (maybe I have too old versions of something). .../devicetree/bindings/iio/addac/adi,ad74413r.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml index 590ea7936ad7..1f90ce3c7932 100644 --- a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml @@ -51,6 +51,14 @@ properties: Shunt (sense) resistor value in micro-Ohms. default: 100000000 + digital-input-threshold-microvolt: + description: + Comparator threshold used by the channels configured to use the + digital input function. + minimum: 500000 + maximum: 16000000 + multipleOf: 500000 + reset-gpios: maxItems: 1 @@ -143,6 +151,8 @@ examples: refin-supply = <&ad74413r_refin>; reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + digital-input-threshold-microvolt = <4000000>; + channel@0 { reg = <0>; From patchwork Fri Jun 23 11:33:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 695395 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 A6215C001B1 for ; Fri, 23 Jun 2023 11:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbjFWLdk (ORCPT ); Fri, 23 Jun 2023 07:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231543AbjFWLdj (ORCPT ); Fri, 23 Jun 2023 07:33:39 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD37186 for ; Fri, 23 Jun 2023 04:33:38 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b45e347266so9344051fa.0 for ; Fri, 23 Jun 2023 04:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1687520016; x=1690112016; 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=EANxw9UBUzWA7WzQeG9K7sXYK8CnMSeZWX1OlZIav4U=; b=Ix2dqtFrBO5aUTzp+iN7g0CGvt+EuKluKaj3KRVutb8wks84LIrJDwiXxfqZlgNbMk YguVNrMfj90prDQWzbBkDEzAdDHGDvP0DgG0seT0YrCqxWz70Fy30LrPxHAhH9rrPTfr V4svsdUztNIRRO9MNIm+LeTlcGxbjRq4nX/mw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687520016; x=1690112016; 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=EANxw9UBUzWA7WzQeG9K7sXYK8CnMSeZWX1OlZIav4U=; b=aEldEmpFICpX33KqWRfGj35vnlNGpOTsYBm0ixhxWyerekbC0tVBKTg1Xy3sfxNxwD 9YSxQ2MuTpcJJ5dDA+fduWmScNCNciLcyJGSBINtF2oXXSfcPFETBTxzkDBEqlIBtECD MtxUPcR9ggHGSA8R5Ij9OHklaNjvOm7EG8jlw7lGfdW/Ai5TWP1e+gOkpjOldgvuYpvz 1o6//16TuUr9uuj2FrPG6mrWKSDTB101M/myhO9rFj8Zo+coZt9Kjx9SQxwnnPocqvDs 8YgxmxF6/g14qpCaWKpFp/wsnP2oTKZGIfrRfTP7uL/2d0rGiMeYgaAoFEDUM7vDp6Ly sJxQ== X-Gm-Message-State: AC+VfDxFAYUqK05gZjbFMyZ1cS13Atz3hCqxfEIDCUgvFfRLPphF669L pL91JxrAivgiMCmKDt6iNFHiow== X-Google-Smtp-Source: ACHHUZ5qLRdl1/GZ8d6A85W9DZGBD6/3iSjmvHvCKmLac3QS4zT/ikOtVVLSZqYIVfruHpVOybcfYQ== X-Received: by 2002:a2e:7d0f:0:b0:2b5:81bc:43a8 with SMTP id y15-20020a2e7d0f000000b002b581bc43a8mr5965742ljc.0.1687520016335; Fri, 23 Jun 2023 04:33:36 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id n10-20020a2e720a000000b002b471efb253sm1711605ljc.46.2023.06.23.04.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 04:33:36 -0700 (PDT) From: Rasmus Villemoes To: Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Rasmus Villemoes , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] iio: addac: ad74413r: wire up digital-input-threshold-microvolt DT property Date: Fri, 23 Jun 2023 13:33:26 +0200 Message-Id: <20230623113327.1062170-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230623113327.1062170-1-linux@rasmusvillemoes.dk> References: <20230623113327.1062170-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The threshold is common to all channels configured as digital input. So far, we have not seen the settings in the DIN_THRESH affecting functions other than digital input, but with a4cba07e64e6 ("iio: addac: ad74413: don't set DIN_SINK for functions other than digital input") in mind, do not read and apply the digital-input-threshold-microvolt setting unless at least one channel has been configured as one of the digital input variants. Signed-off-by: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index e3366cf5eb31..efdd7fdd7ab9 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -129,6 +129,12 @@ struct ad74413r_state { #define AD74413R_GPO_CONFIG_COMPARATOR 0b011 #define AD74413R_GPO_CONFIG_HIGH_IMPEDANCE 0b100 +#define AD74413R_REG_DIN_THRESH 0x22 +#define AD74413R_DIN_COMP_THRESH_MASK GENMASK(5, 1) +#define AD74413R_DIN_THRESH_MODE BIT(0) +#define AD74413R_DIN_THRESH_MODE_16V BIT(0) +#define AD74413R_DIN_THRESH_MODE_AVDD 0 + #define AD74413R_REG_ADC_CONV_CTRL 0x23 #define AD74413R_CONV_SEQ_MASK GENMASK(9, 8) #define AD74413R_CONV_SEQ_ON 0b00 @@ -1446,6 +1452,20 @@ static int ad74413r_probe(struct spi_device *spi) } if (st->num_comparator_gpios) { + u32 thresh, val, mask; + + if (!device_property_read_u32(st->dev, "digital-input-threshold-microvolt", + &thresh)) { + val = thresh/500000 - 1; + val = FIELD_PREP(AD74413R_DIN_COMP_THRESH_MASK, val); + val |= AD74413R_DIN_THRESH_MODE_16V; + mask = AD74413R_DIN_COMP_THRESH_MASK | AD74413R_DIN_THRESH_MODE; + ret = regmap_update_bits(st->regmap, AD74413R_REG_DIN_THRESH, + mask, val); + if (ret) + return ret; + } + st->comp_gpiochip.owner = THIS_MODULE; st->comp_gpiochip.label = st->chip_info->name; st->comp_gpiochip.base = -1;