From patchwork Thu Mar 2 13:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13157356 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 86D47C678D4 for ; Thu, 2 Mar 2023 13:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbjCBNtk (ORCPT ); Thu, 2 Mar 2023 08:49:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbjCBNta (ORCPT ); Thu, 2 Mar 2023 08:49:30 -0500 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 4DAB6166D5 for ; Thu, 2 Mar 2023 05:49:27 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id j17so17622170ljq.11 for ; Thu, 02 Mar 2023 05:49: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=DFDandIs/wWW0RZ0s4trhSYP6hO5Cu+0LMuOOdJjn54=; b=fXbfjLWD5wow0IgUIsNvtmgvsgvdaB+VuwBS8lvjPc9Lx2VeB4mNsRb9vqa/bnJYay SbpWcIAMNi27+vEfM8hjGIha5uuKybpDkJyt5r8v06Oj6Xa0HVL/2JuQ60O7B1bcSc5f cplg3BMrFPEGJ7q+C70RFKNoVB0FgDZUn99JM= 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=DFDandIs/wWW0RZ0s4trhSYP6hO5Cu+0LMuOOdJjn54=; b=c+pvyjYPt7LaXs3cxNmpQwkHWgOYK+2siPLjiUg6tlY8hVWnnkfJLhDqTKrW/x2wzU qEqnT8DhHUXx6ikg0bHjVttclgkuJ4zPGNZ8/R2E++61Ma81cMHOHDbXxSF8ceIAO9mm MNbuszoA2BeGTkOkLt9YOs2dUx7RNml7f7b3VFVJ8F4nLnw7wjS9d9I0fVYnfHObuEnb Q4Ju49hyJdRABB9zVG9n7rLVGNycov6XgeH0UNARSuWAWrF3Q0hw+nh0W7sYSksNQ94O 5d/G6OLgCstIZSCa6ypzRnzryl+BZks4bXie9qHbXT2YlCuHacZg6FxgFkCl0yT2qXct ejTQ== X-Gm-Message-State: AO0yUKULXfqoOXaI+qwZQI3j989IC65LjHsWs6bO3q3fWipTXVlyCCmM U7cJE8WB2aIdT63sZ5NockfYDw== X-Google-Smtp-Source: AK7set+rPBpimAvdVXmPhPHeTOmkunGsxjRFqhQJkRhWtDUaTFnVVjkkOLQHCXKF7WgltoOLCkJf3Q== X-Received: by 2002:a2e:90d6:0:b0:295:c333:2a24 with SMTP id o22-20020a2e90d6000000b00295c3332a24mr3176109ljg.19.1677764965697; Thu, 02 Mar 2023 05:49:25 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id s16-20020ac25ff0000000b004cb3e97bff8sm2139088lfg.284.2023.03.02.05.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 05:49:25 -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 1/2] dt-bindings: iio: ad74413r: allow setting sink current for digital input Date: Thu, 2 Mar 2023 14:49:20 +0100 Message-Id: <20230302134922.1120217-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> References: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 --- .../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 9eb3ecc8bbc8..fcae300182f7 100644 --- a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml @@ -101,6 +101,16 @@ patternProperties: When not configured as a comparator, the GPO will be treated as an output-only GPIO. + drive-strength-microamp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + For channels configured as digital input, this configures the sink + current. + minimum: 0 + maximum: 1800 + default: 0 + multipleOf: 120 + required: - reg From patchwork Thu Mar 2 13:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13157357 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 3CE86C7EE33 for ; Thu, 2 Mar 2023 13:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjCBNtl (ORCPT ); Thu, 2 Mar 2023 08:49:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjCBNtb (ORCPT ); Thu, 2 Mar 2023 08:49:31 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 859CD18164 for ; Thu, 2 Mar 2023 05:49:28 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id f16so17651672ljq.10 for ; Thu, 02 Mar 2023 05:49: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=g+ofG8dUGNkU80FPnV9zgYPR7u97jlgEvn4xxyg8nqc=; b=FjTnBw/d3uK0G5/Bu5xpEc3T16eLRNS45XsXzqBA/NMTjVt8E3FCPFH/Px+NCN1Tv2 3FfBr12gK6XmyNZFNcjfMeQ6mYgXJCJrHjKNDZWAXJ+hNBj+tq8fvpLoBbrCvii6vCoZ 1FyGU17ZZ5ifnaW2xjNHknJPgQL7vJJtp6t/o= 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=g+ofG8dUGNkU80FPnV9zgYPR7u97jlgEvn4xxyg8nqc=; b=1eq5ZcaHBXWMrWj5wpDN4TFoBvUjOX7EhVUIlDjmSqKSTGM1fgGBdSm0Fcrs4VHf44 5tOy6+pxX2C355w4/bqsO33gO1x2jCds3XnyyLiu8zzFvGZso/u/U4dDZsxmePy9Pwui KQKVy5RHdeOTk1XXqMsvjSovJaguhPtTApVyPPR4IQJLD0acTlD3auP+EW//qfIJ9dp0 3sLL3kFXZ/wBOdAApqKyM2OE+x/Qh2Ib2u5HgT5JfGVxvcn0bG/BQE9/JkFejZe9uxtO ghlcsvfUM5+a25yR2d4G+ApWY8SvSTqibA09SQuc5f73q7F6qKJZEFx5M9KmIkN0ool0 btkA== X-Gm-Message-State: AO0yUKUg3v639ciDkl48RWk7SyGX6F5zzKUnx73zJAlLygPSAzMbLm+l FsLZ7fkqTrTK+OneIcMo57xsRg== X-Google-Smtp-Source: AK7set/O8Ekt9ie7aM7GDWhsjBP5dvMfJdAo29xBF3dJcnaylSSOtFq2jwnvQZpTT12Xegj//2LX7g== X-Received: by 2002:a2e:9415:0:b0:291:90bf:1cc4 with SMTP id i21-20020a2e9415000000b0029190bf1cc4mr2841936ljh.26.1677764966880; Thu, 02 Mar 2023 05:49:26 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id s16-20020ac25ff0000000b004cb3e97bff8sm2139088lfg.284.2023.03.02.05.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 05:49:26 -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 2/2] iio: ad74413r: wire up support for drive-strength-microamp property Date: Thu, 2 Mar 2023 14:49:21 +0100 Message-Id: <20230302134922.1120217-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> References: <20230302134922.1120217-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index f32c8c2fb26d..cbf0f66fdc74 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -39,6 +39,7 @@ struct ad74413r_chip_info { 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) #define AD74413R_REG_DAC_CODE_X(x) (0x16 + (x)) #define AD74413R_DAC_CODE_MAX GENMASK(12, 0) @@ -261,6 +263,19 @@ static int ad74413r_set_comp_debounce(struct ad74413r_state *st, val); } +static int ad74413r_set_comp_drive_strength(struct ad74413r_state *st, + unsigned int offset, + unsigned int strength) +{ + if (strength > 1800) + strength = 1800; + + 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 +1205,9 @@ static int ad74413r_parse_channel_config(struct iio_dev *indio_dev, config->gpo_comparator = fwnode_property_read_bool(channel_node, "adi,gpo-comparator"); + fwnode_property_read_u32(channel_node, "drive-strength-microamp", + &config->drive_strength); + if (!config->gpo_comparator) st->num_gpo_gpios++; @@ -1269,6 +1287,7 @@ static int ad74413r_setup_gpios(struct ad74413r_state *st) unsigned int gpo_gpio_i = 0; unsigned int i; u8 gpo_config; + u32 strength; int ret; for (i = 0; i < AD74413R_CHANNEL_MAX; i++) { @@ -1285,6 +1304,11 @@ static int ad74413r_setup_gpios(struct ad74413r_state *st) config->func == CH_FUNC_DIGITAL_INPUT_LOOP_POWER) st->comp_gpio_offsets[comp_gpio_i++] = i; + strength = config->drive_strength; + ret = ad74413r_set_comp_drive_strength(st, i, strength); + if (ret) + return ret; + ret = ad74413r_set_gpo_config(st, i, gpo_config); if (ret) return ret;