Message ID | 20230503105042.453755-1-linux@rasmusvillemoes.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1255753vqo; Wed, 3 May 2023 04:35:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aQPPLbL20sPrQnAGJZvGTCCJYigzQmxIE7Ve+93l1a9BnNhJ5hYq3ohfFlReuH4QXVF/f X-Received: by 2002:a05:6a00:a13:b0:63b:646d:9165 with SMTP id p19-20020a056a000a1300b0063b646d9165mr29125729pfh.26.1683113712374; Wed, 03 May 2023 04:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683113712; cv=none; d=google.com; s=arc-20160816; b=hgcIssvZFr+Cp1/UoqdJDRBWzxu2EQfqoYixM+j9PZJr+XfLfpr6ZlCAIgoltfD0Ca Gpq24GFb/1y/R17PKZd9qPlgiGshJQxgsU2zgmZh0h7CdFh5tg1IQXivH95PRhKbri7i sEBE8bShkgP7gbdTaDYk9JS/wotGOdzmKVWb3X9o1cweC3HATyroTCDvRoDe7SjFXe3V ZaxbUvyveq2lk2MBHFyBtrA7KXkujg61oNAKIWnh9Yi2oJxxiYlij6B1vB7/jDADbi/S EEVsGh6CvUv9HhCkWNOvCtMjkDdTm/inmraQWWRpwqw8aVkkQqQEw3baGg8UXHHsCSad rEpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Zgj+aUgoJdUUawwjQ6SgSQXM3EvgvrnXKII1glX28tA=; b=fL8XRmY3i2HH3CRja249DZVSWqS3cXGMUNE1PzarwsRx+eLfbjSX7eiVmq6RiV5ppA aWYQy6PZa7PIStfbrMJW85PPAql6aBKwz+3xv3vulGAcidwxiu2RNXpExPACovjENUns uve5D21WG/f33AefKNgnaKhQLNMDlFt2dCOanKpudnt67QN+otwT4CwZBDkph4PZLi2r IQDewsqdf1is77HmvXRUH/Twr6LJGKoxbPnjvDic9y/Sv4lRhgsCIHQ8H2n1VySdbNli SsfFYA7F6H6Fwy0P6mEUfbYQ3Yws6MwrWG2wm9NQ7nNq6LZxn3krzzYi2AtiZ0Jc9R++ 7inA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=XnS7NVz8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020aa7946e000000b0063b895e9781si33365476pfq.138.2023.05.03.04.35.00; Wed, 03 May 2023 04:35:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=XnS7NVz8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjECKuy (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Wed, 3 May 2023 06:50:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjECKuw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 3 May 2023 06:50:52 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196D9B1 for <linux-kernel@vger.kernel.org>; Wed, 3 May 2023 03:50:49 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f00d41df22so3059472e87.1 for <linux-kernel@vger.kernel.org>; Wed, 03 May 2023 03:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1683111047; x=1685703047; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Zgj+aUgoJdUUawwjQ6SgSQXM3EvgvrnXKII1glX28tA=; b=XnS7NVz8zttO1mmcapsD4f8wA0e8bEV1z3wez08PCINAL3k7C7YTNcSfTyrILcy74r Di5jMQfCzg01pGf5tURveH4iEtrBZYukqXzl6fky++6GLhQyYDIPJKX+FXaGzZqQKvCD BHFrHpukkujhe/jjDm+9SjwFj0B4ralYu78Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683111047; x=1685703047; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Zgj+aUgoJdUUawwjQ6SgSQXM3EvgvrnXKII1glX28tA=; b=XgqTZARXn3N49orr5c89kKeUex7Z1mwWNnXK5lE6Flw5DnRm0FVeZBERdRWGhRhPHu RoJ55JWcrjaRW2vCg24SFqgyaeH9/m/Q6Zek+LkUw+WCCKmsbXte+rHYajlynNsQm8Sz 7zQED+Ih+sRmAZRKrZV49IyVtAsLmaHUrOP1r8n47s190oxVMwCS+Ogd16uEYFZ0a7pW qegzgY3nC+tig3iLdrWwG6kI8d9QsGdEiFhdSF4qpGAq2hx9gzaTfe9EihrEgObcMFBb xUVSNdi6je44D2ElegaWYEzj2XbGVdd4pXJ0jTS0HlEzXZjyFtbJ/KzOGd8vMtgbo6sn IjLQ== X-Gm-Message-State: AC+VfDySRwPpOIj9Dx6MYneYSlYsdpagYtnYlgRYzd20v44AIfBtz+ZJ GNaGqlKhpbXaOecZmKJA8WAkFHL4l//WjK6gBNBMgw== X-Received: by 2002:ac2:529a:0:b0:4ef:ebbb:2cf5 with SMTP id q26-20020ac2529a000000b004efebbb2cf5mr467562lfm.17.1683111047318; Wed, 03 May 2023 03:50:47 -0700 (PDT) Received: from prevas-ravi.k200.local ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id j1-20020a19f501000000b004eff0bcb276sm4702776lfb.7.2023.05.03.03.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 03:50:46 -0700 (PDT) From: Rasmus Villemoes <linux@rasmusvillemoes.dk> To: Lars-Peter Clausen <lars@metafoo.de>, Michael Hennerich <Michael.Hennerich@analog.com>, Cosmin Tanislav <cosmin.tanislav@analog.com>, Jonathan Cameron <jic23@kernel.org>, Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: addac: ad74413: don't set DIN_SINK for functions other than digital input Date: Wed, 3 May 2023 12:50:41 +0200 Message-Id: <20230503105042.453755-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764872643956769411?= X-GMAIL-MSGID: =?utf-8?q?1764872643956769411?= |
Series |
iio: addac: ad74413: don't set DIN_SINK for functions other than digital input
|
|
Commit Message
Rasmus Villemoes
May 3, 2023, 10:50 a.m. UTC
Apparently, despite the name Digital Input Configuration Register, the
settings in the DIN_CONFIGx registers also affect other channel
functions. In particular, setting a non-zero value in the DIN_SINK
field breaks the resistance measurement function.
Now, one can of course argue that specifying a drive-strength-microamp
property along with a adi,ch-func which is not one of the digital
input functions is a bug in the device tree. However, we have a rather
complicated setup with instances of ad74412r on external hardware
modules, and have set a default drive-strength-microamp in our DT
fragments describing those, merely modifying the adi,ch-func settings
to reflect however the modules have been wired up. And restricting
this setting to just being done for digital input doesn't make the
driver any more complex.
Fixes: 504eb485589d1 (iio: ad74413r: wire up support for drive-strength-microamp property)
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/iio/addac/ad74413r.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
Comments
Hi Rasmus, Thanks for your patch... Just one comment below On Wed, 2023-05-03 at 12:50 +0200, Rasmus Villemoes wrote: > Apparently, despite the name Digital Input Configuration Register, the > settings in the DIN_CONFIGx registers also affect other channel > functions. In particular, setting a non-zero value in the DIN_SINK > field breaks the resistance measurement function. > > Now, one can of course argue that specifying a drive-strength-microamp > property along with a adi,ch-func which is not one of the digital > input functions is a bug in the device tree. However, we have a rather > complicated setup with instances of ad74412r on external hardware > modules, and have set a default drive-strength-microamp in our DT > fragments describing those, merely modifying the adi,ch-func settings > to reflect however the modules have been wired up. And restricting > this setting to just being done for digital input doesn't make the > driver any more complex. > > Fixes: 504eb485589d1 (iio: ad74413r: wire up support for drive-strength- > microamp property) > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> > --- > drivers/iio/addac/ad74413r.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c > index e3366cf5eb31..6b0e8218f150 100644 > --- a/drivers/iio/addac/ad74413r.c > +++ b/drivers/iio/addac/ad74413r.c > @@ -1317,13 +1317,14 @@ static int ad74413r_setup_gpios(struct ad74413r_state > *st) > } > > if (config->func == CH_FUNC_DIGITAL_INPUT_LOGIC || > - config->func == CH_FUNC_DIGITAL_INPUT_LOOP_POWER) > + 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; > + strength = config->drive_strength; > + ret = ad74413r_set_comp_drive_strength(st, i, > strength); > + if (ret) > + return ret; > + } So, I'm not really that familiar with this part and, at this stage, I'm being lazy to check the datasheet. My concern is about breaking some other users... So, does it make any sense for having drive-strength-microamp in a non digital input at all? Can anyone have a working device by specifying that dt parameter on a non digital channel (or expect something from having that parameter set)? Or the only effect is to actually have some functions misbehaving? It feels to me (from your description) that this property is something that makes sense to be restricted and should also have that dependency stated in the bindings but it might be to late for that (as some users might have validated their devicetrees already). On the driver side, if it's never right to have these settings together, then the patch is valid since if someone has this, his configuration is broken anyways (maybe that's also a valid point for the bindings)... - Nuno Sá
On 04/05/2023 09.28, Nuno Sá wrote: > Hi Rasmus, > > So, I'm not really that familiar with this part and, at this stage, I'm being > lazy to check the datasheet. Well, the data sheet is not particularly helpful here, which is why I ended up with this mess. > My concern is about breaking some other users... I highly doubt there are users yet (other than my customer); this binding+driver implementation only just landed. > So, does it make any sense for having drive-strength-microamp in a non digital > input at all? That's the problem with the data sheet, it doesn't really say that the DIN_SINK register has any effect whatsoever when the channel function is set to something other than digital input (either flavor). Perhaps it does hint that setting it to something non-zero is probably not a good idea, because DIN_SINK is automatically set to 0 whenever the channel function is set/changed, so one needs a good reason to change DIN_SINK afterwards. We just experimentally found out that when we added the DIN_SINK to fix the digital input functions, when we got around to testing the resistance measurement function that ended up broken due to the non-zero DIN_SINK. > Can anyone have a working device by specifying that dt parameter > on a non digital channel (or expect something from having that parameter set)? > Or the only effect is to actually have some functions misbehaving? The data sheet doesn't say that the DIN_SINK should have any effect for other functions, so I'm pretty sure it's only the latter: some functions misbehave. > On the driver side, if it's never right to have > these settings together, then the patch is valid since if someone has this, his > configuration is broken anyways (maybe that's also a valid point for the > bindings)... Yes, I do believe that it's a broken description (whether or not the bindings specify that), and drivers don't need to go out of their way to validate or fixup such brokenness. But in this particular case, there's really no extra burden on the driver to not put garbage in DIN_SINK when a not-digital-input function has been chosen (the patch is a two-liner with 'git show -w'). Rasmus
On Thu, 4 May 2023 12:08:53 +0200 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote: > On 04/05/2023 09.28, Nuno Sá wrote: > > Hi Rasmus, > > > > > So, I'm not really that familiar with this part and, at this stage, I'm being > > lazy to check the datasheet. > > Well, the data sheet is not particularly helpful here, which is why I > ended up with this mess. > > > My concern is about breaking some other users... > > I highly doubt there are users yet (other than my customer); this > binding+driver implementation only just landed. > > > So, does it make any sense for having drive-strength-microamp in a non digital > > input at all? > > That's the problem with the data sheet, it doesn't really say that the > DIN_SINK register has any effect whatsoever when the channel function is > set to something other than digital input (either flavor). Perhaps it > does hint that setting it to something non-zero is probably not a good > idea, because DIN_SINK is automatically set to 0 whenever the channel > function is set/changed, so one needs a good reason to change DIN_SINK > afterwards. > > We just experimentally found out that when we added the DIN_SINK to fix > the digital input functions, when we got around to testing the > resistance measurement function that ended up broken due to the non-zero > DIN_SINK. > > > Can anyone have a working device by specifying that dt parameter > > on a non digital channel (or expect something from having that parameter set)? > > Or the only effect is to actually have some functions misbehaving? > > The data sheet doesn't say that the DIN_SINK should have any effect for > other functions, so I'm pretty sure it's only the latter: some functions > misbehave. > > > On the driver side, if it's never right to have > > these settings together, then the patch is valid since if someone has this, his > > configuration is broken anyways (maybe that's also a valid point for the > > bindings)... > > Yes, I do believe that it's a broken description (whether or not the > bindings specify that), and drivers don't need to go out of their way to > validate or fixup such brokenness. But in this particular case, there's > really no extra burden on the driver to not put garbage in DIN_SINK when > a not-digital-input function has been chosen (the patch is a two-liner > with 'git show -w'). If we can tighten the DT binding to rule out something that should not be set than that would be good. Tightening bindings is fine - we don't mind validation of bindings failing on peoples DTs as long as we didn't 'break' them actually working. Jonathan > > Rasmus >
On 06/05/2023 20.16, Jonathan Cameron wrote: > On Thu, 4 May 2023 12:08:53 +0200 > Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote: > >> On 04/05/2023 09.28, Nuno Sá wrote: >>> Can anyone have a working device by specifying that dt parameter >>> on a non digital channel (or expect something from having that parameter set)? >>> Or the only effect is to actually have some functions misbehaving? >> >> The data sheet doesn't say that the DIN_SINK should have any effect for >> other functions, so I'm pretty sure it's only the latter: some functions >> misbehave. >> >>> On the driver side, if it's never right to have >>> these settings together, then the patch is valid since if someone has this, his >>> configuration is broken anyways (maybe that's also a valid point for the >>> bindings)... >> >> Yes, I do believe that it's a broken description (whether or not the >> bindings specify that), and drivers don't need to go out of their way to >> validate or fixup such brokenness. But in this particular case, there's >> really no extra burden on the driver to not put garbage in DIN_SINK when >> a not-digital-input function has been chosen (the patch is a two-liner >> with 'git show -w'). > > If we can tighten the DT binding to rule out something that should not be > set than that would be good. Tightening bindings is fine - we don't mind > validation of bindings failing on peoples DTs as long as we didn't 'break' > them actually working. Well, I'm afraid I don't have any idea how to spell that constraint in the yaml-language (help appreciated). And I assume a dt binding update would be a separate patch anyway, so could you please consider applying this patch? Thanks, Rasmus
On Mon, 22 May 2023 10:44:11 +0200 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote: > On 06/05/2023 20.16, Jonathan Cameron wrote: > > On Thu, 4 May 2023 12:08:53 +0200 > > Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote: > > > >> On 04/05/2023 09.28, Nuno Sá wrote: > > >>> Can anyone have a working device by specifying that dt parameter > >>> on a non digital channel (or expect something from having that parameter set)? > >>> Or the only effect is to actually have some functions misbehaving? > >> > >> The data sheet doesn't say that the DIN_SINK should have any effect for > >> other functions, so I'm pretty sure it's only the latter: some functions > >> misbehave. > >> > >>> On the driver side, if it's never right to have > >>> these settings together, then the patch is valid since if someone has this, his > >>> configuration is broken anyways (maybe that's also a valid point for the > >>> bindings)... > >> > >> Yes, I do believe that it's a broken description (whether or not the > >> bindings specify that), and drivers don't need to go out of their way to > >> validate or fixup such brokenness. But in this particular case, there's > >> really no extra burden on the driver to not put garbage in DIN_SINK when > >> a not-digital-input function has been chosen (the patch is a two-liner > >> with 'git show -w'). > > > > If we can tighten the DT binding to rule out something that should not be > > set than that would be good. Tightening bindings is fine - we don't mind > > validation of bindings failing on peoples DTs as long as we didn't 'break' > > them actually working. > > Well, I'm afraid I don't have any idea how to spell that constraint in > the yaml-language (help appreciated). Lots of examples in tree of this sort of thing. Look for a : false with something other than additionalProperties or unevaluatedProperties Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml for example. In short you have an allOf block containing a list of rules, one of which is a match on particular conditions to set particular properties to 'false' which means that any attempt to have them set when that condition is met results in an error from the dts checking scripts. > > And I assume a dt binding update would be a separate patch anyway, so > could you please consider applying this patch? Fair enough. Applied to the fixes-togreg branch of iio.git. Thanks, Jonathan > > Thanks, > Rasmus >
diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index e3366cf5eb31..6b0e8218f150 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -1317,13 +1317,14 @@ static int ad74413r_setup_gpios(struct ad74413r_state *st) } if (config->func == CH_FUNC_DIGITAL_INPUT_LOGIC || - config->func == CH_FUNC_DIGITAL_INPUT_LOOP_POWER) + 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; + 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)