[RFC,1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins
Message ID | 20230130165435.2347569-1-konrad.dybcio@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2290180wrn; Mon, 30 Jan 2023 09:03:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXuU2eWN8Q+cEhZtM8aiR8nTWiOZZwfpxVkN+0AyFWFny1jw913Lumjj3nF4HTXw+5WMjeQq X-Received: by 2002:a05:6402:3786:b0:492:609a:f148 with SMTP id et6-20020a056402378600b00492609af148mr57765943edb.3.1675098189823; Mon, 30 Jan 2023 09:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675098189; cv=none; d=google.com; s=arc-20160816; b=tl6CI6gFBgSBUgJ9iAcFp0jJzqFbr6utLqpKJYEBU7miAYLqKjYU5gwpoB1KM2Ium3 8GEjVJ/VhOvZxjuZsXCZaV+beUKGXQH96izWCfGtRXWXMcg9c9sVFi8wvvgYNBGaQmcJ ZsHREahwunJ9TH9Ww/MUz0K89flvy3jYwI2Ti6Lr0qFxvf6Fp7/p0qq+HpQOKNfx1twa MyDL64ZygcrFbHvAs+XOLjTcz5kBMiPhCvlIoSNOczuv31RQxEodcJe65wmqf2afdRly zb019DUlbtCmFTiyD+ys6X1X0ZzBngpUKE4Qsj8/uztYXqOXhVRP/7LzzjeZnSkGv2zw qzyg== 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=LXg0vcX33DnXDRl4Qdi6ZDWogrA8s0G2Rrxf8IO1PKs=; b=omDle/cKds1KI4LloJkOe1zliUP2w3mng2LcEdW8jlXLrMeL0f6zJH+6MN9KkfkdLi uJOAprFmrZXsRsAZwIZ43Dvk78zFAeNMTGYTjNKmqrEFXahYAea2bau3AiZdtiE5J4HB NWLjopHwhAlUAaiB5sB9YAVdxGPDpSvyVrBcnQtqnDEzsKxUglNU5QXbTR4/3WGAoRqE L32lHQXxiNrwOK9cdtE3xshJLaGzqDZ5HBzgnQ0X7Z3WM9IZ79SPAF5qwqCs58a/qq0L Mvon4vZc6HKKSJcR6RvKjoKiDw8UvFsqXas4Ue98bGJNz6a/N3Doc3F2sR1FYNkORe4U WTQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QbEicjF7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a170906018c00b008860178387bsi6591994ejb.911.2023.01.30.09.02.39; Mon, 30 Jan 2023 09:03:09 -0800 (PST) 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=@linaro.org header.s=google header.b=QbEicjF7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236017AbjA3Qys (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Mon, 30 Jan 2023 11:54:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235730AbjA3Qyq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 30 Jan 2023 11:54:46 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BF53D92D for <linux-kernel@vger.kernel.org>; Mon, 30 Jan 2023 08:54:45 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id kt14so33655218ejc.3 for <linux-kernel@vger.kernel.org>; Mon, 30 Jan 2023 08:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LXg0vcX33DnXDRl4Qdi6ZDWogrA8s0G2Rrxf8IO1PKs=; b=QbEicjF7YmF13ezulDFfNuz727VQByALrw9uuIPZvtZlKMsoG+jKaOarkL4iXLFKTG M0d6hNOY6JOUyW1OrmRyichUnqhw1kBkVBj0LApPmSnftNSC8johSQ78djllzPoCumbP KOd3H32nWwAcGVcTBDzQpq/8ZHGB8vg9dmTqpZYpQxcSQgiP1cAI2AjgfSPJiazPGZl1 wxFm74achDIccqe7q6gGhas3ePdnaoHCZLqbcWoTFz16gQOpPV2Di3ZmnB9dc01SgKNY /ckAetNlwTU+YT3b2tGaxVSjfp7t2vt0DQJWAVym52nNEYWv3LPl04ChAPzvthnsLTsJ Jz6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LXg0vcX33DnXDRl4Qdi6ZDWogrA8s0G2Rrxf8IO1PKs=; b=2hx57+JXG2hhiGoglLIxMUY4+o+ITVV4EC0VHiQGOgVFjwr0vh25XUoov+3fJaxzcS I/obzm+OaTwyWI+7IpFVYFRa+hBo92z7jDGX9n/EH+eKTORQOAU4I02KawY9NKRT2qQZ m/yWUzLNNNY7LfFH6uc56BPHsJFcBVI1nYGS1pL/vC+5p2CaXTsalQ58Cps/VWl8nQkP dOpNhSKUyd6b+Gq+0JMMfgp2lxP/nk1VmKkTVOJZi36PWlB4eJefBJxB8zu6ZqpkR4s4 91QgeUFONOC0ms6XnuMKwR9/tC0VdtMr9norArLgGar/Um+CxwxQmB0JEia6hZwLZszm PvCg== X-Gm-Message-State: AO0yUKWRlOH2R9FIs64vJfuwWAAJy6bLNLukja93N/vyWzQHMEPeE5gC NsYd79mVf0DaySsJBUqHiS+C3g== X-Received: by 2002:a17:907:3c16:b0:889:daeb:5532 with SMTP id gh22-20020a1709073c1600b00889daeb5532mr2195829ejc.47.1675097684236; Mon, 30 Jan 2023 08:54:44 -0800 (PST) Received: from localhost.localdomain (abyl20.neoplus.adsl.tpnet.pl. [83.9.31.20]) by smtp.gmail.com with ESMTPSA id lj14-20020a170906f9ce00b0088744fc7084sm2590651ejb.38.2023.01.30.08.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 08:54:43 -0800 (PST) From: Konrad Dybcio <konrad.dybcio@linaro.org> To: linux-arm-msm@vger.kernel.org, andersson@kernel.org, agross@kernel.org, krzysztof.kozlowski@linaro.org Cc: marijn.suijten@somainline.org, Konrad Dybcio <konrad.dybcio@linaro.org>, Linus Walleij <linus.walleij@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins Date: Mon, 30 Jan 2023 17:54:34 +0100 Message-Id: <20230130165435.2347569-1-konrad.dybcio@linaro.org> X-Mailer: git-send-email 2.39.1 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 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?1756467759297806006?= X-GMAIL-MSGID: =?utf-8?q?1756467759297806006?= |
Series |
[RFC,1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins
|
|
Commit Message
Konrad Dybcio
Jan. 30, 2023, 4:54 p.m. UTC
We came to a point where we sometimes we support a few dozen boards
with a given SoC. Sometimes, we have to take into consideration
configurations which deviate rather significatly from the reference
or most common designs. In the context of pinctrl, this often comes
down to wildly different pin configurations. While pins, function and
drive-strength are easily overridable, the (mostly) boolean properties
associated with setting bias, aren't. This wouldn't be much of a
problem if they didn't differ between boards so often, preventing us
from having a "nice" baseline setup without inevitably having to go
with an ugly /delete-property/. Introduce bias-type, a bias-type-
specific property and clone the pinconf-generic type enum into
dt-bindings to allow for setting the bias in an easily overridable
manner such as:
// SoC DT
i2c0_pin: i2c0-pin-state {
pins = "gpio10";
function = "gpio";
bias-type = <BIAS_PULL_UP>;
};
// Deviant board DT
&i2c0_pin {
bias-type = <BIAS_HIGH_IMPEDANCE>;
};
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
.../bindings/pinctrl/pincfg-node.yaml | 4 ++
include/dt-bindings/pinctrl/pinconf-generic.h | 40 +++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 include/dt-bindings/pinctrl/pinconf-generic.h
Comments
On Mon, Jan 30, 2023 at 5:54 PM Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > We came to a point where we sometimes we support a few dozen boards > with a given SoC. Sometimes, we have to take into consideration > configurations which deviate rather significatly from the reference > or most common designs. In the context of pinctrl, this often comes > down to wildly different pin configurations. While pins, function and > drive-strength are easily overridable, the (mostly) boolean properties > associated with setting bias, aren't. This wouldn't be much of a > problem if they didn't differ between boards so often, preventing us > from having a "nice" baseline setup without inevitably having to go > with an ugly /delete-property/. I see what the problem is. Have you considered pulling out *all* the pin config for a certain reference design into its own .dtsi file, simply? And then not include that to the next product. This pattern is pretty common. > Introduce bias-type, a bias-type- > specific property and clone the pinconf-generic type enum into > dt-bindings to allow for setting the bias in an easily overridable > manner such as: > > // SoC DT > i2c0_pin: i2c0-pin-state { > pins = "gpio10"; > function = "gpio"; > bias-type = <BIAS_PULL_UP>; > }; > > // Deviant board DT > &i2c0_pin { > bias-type = <BIAS_HIGH_IMPEDANCE>; > }; > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> The idea is pretty straight-forward. But it applies to systems already using the bool flags. So what do we do the day we manage to have: { bias-type = <BIAS_HIGH_IMPEDANCE>; bias-pull-up; }; As you see this makes it necessary to author some really nasty YAML to make sure this cannot happen or everyone has to make a runtime check for it. Another problem is that I was just discussing with Bjorn for some specific i2c pull-up, was actually using the argument for bias-pull-up with a parameter: bias-pull-up = <8000000>; // 8kOhm pull-up Not to mention that other platforms than qcom use this and qcom use it for drive-strength I think? +#define DRIVE_STRENGTH 9 +#define DRIVE_STRENGTH_UA 10 drive-strength = <8>; // 8mA drive strength bias-type = <DRIVE_STRENGTH>; OK where do I put my 8 mA now? Yours, Linus Walleij
On 31.01.2023 00:10, Linus Walleij wrote: > On Mon, Jan 30, 2023 at 5:54 PM Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > >> We came to a point where we sometimes we support a few dozen boards >> with a given SoC. Sometimes, we have to take into consideration >> configurations which deviate rather significatly from the reference >> or most common designs. In the context of pinctrl, this often comes >> down to wildly different pin configurations. While pins, function and >> drive-strength are easily overridable, the (mostly) boolean properties >> associated with setting bias, aren't. This wouldn't be much of a >> problem if they didn't differ between boards so often, preventing us >> from having a "nice" baseline setup without inevitably having to go >> with an ugly /delete-property/. > > I see what the problem is. > > Have you considered pulling out *all* the pin config for a certain > reference design into its own .dtsi file, simply? And then not include > that to the next product. > > This pattern is pretty common. It's *a* solution, but we already have some soc-pmics.dtsi-s which include PMICs and reference regulator-to-peripherals assignments. Adding another soc-reference-pins.dtsi would open the doors for other soc-abcxyz.dtsi-s which would in turn lead to exchanging the problem of redefining the same sets of properties 50 times to having to include 20 device trees for each and every device. Allow that and we basically have msm-3.10 except in torvalds/linux. Adding to that, some devices are 98% compliant with the reference designs, but randomly swap out one pin etc. > >> Introduce bias-type, a bias-type- >> specific property and clone the pinconf-generic type enum into >> dt-bindings to allow for setting the bias in an easily overridable >> manner such as: >> >> // SoC DT >> i2c0_pin: i2c0-pin-state { >> pins = "gpio10"; >> function = "gpio"; >> bias-type = <BIAS_PULL_UP>; >> }; >> >> // Deviant board DT >> &i2c0_pin { >> bias-type = <BIAS_HIGH_IMPEDANCE>; >> }; >> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > > The idea is pretty straight-forward. > > But it applies to systems already using the bool flags. So what do > we do the day we manage to have: > > { > bias-type = <BIAS_HIGH_IMPEDANCE>; > bias-pull-up; > }; > > As you see this makes it necessary to author some really nasty > YAML to make sure this cannot happen or everyone has to make > a runtime check for it. oneOf: - bias-type - enum: - bias-pull-down - bias-... Doesn't seem really nasty to me.. And a runtime check is basically in place, as I made sure the code in 2/2 prefers bias-type and falls back to the existing mechanism if it's not found. > > Another problem is that I was just discussing with Bjorn for some > specific i2c pull-up, was actually using the argument for > bias-pull-up with a parameter: > > bias-pull-up = <8000000>; // 8kOhm pull-up This is an easy fix. Count the elements and if there's more than one, pass the second one as a value. Both of these things already have common of_ functions made just for that. > > Not to mention that other platforms than qcom use this and > qcom use it for drive-strength I think? > > +#define DRIVE_STRENGTH 9 > +#define DRIVE_STRENGTH_UA 10 > > drive-strength = <8>; // 8mA drive strength > > bias-type = <DRIVE_STRENGTH>; > > OK where do I put my 8 mA now? If you look at the 2/2 patch, this property only reads BIAS_ values, which can't coexist anyway. I copied the entire enum for completeness. But if we were to go with this approach, having one for (in|out)put-*, where only having one of them at a time makes sense could be beneficial too.. Konrad > > Yours, > Linus Walleij
On Tue, Jan 31, 2023 at 12:50 AM Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > +#define DRIVE_STRENGTH 9 > > +#define DRIVE_STRENGTH_UA 10 > > > > drive-strength = <8>; // 8mA drive strength > > > > bias-type = <DRIVE_STRENGTH>; > > > > OK where do I put my 8 mA now? > > > If you look at the 2/2 patch, this property only reads BIAS_ > values, which can't coexist anyway. Well the DT bindings have to be consistent and clear on their own, no matter how Linux implements it. But I'm sure you can make YAML verification such that it is impossible to use both schemes at the same time, and it's not like I don't understand what you're getting at. What I need as input is mainly the DT bindings people opinion on introducing another orthogonal way of doing something that is already possible to do another way, just more convenient. Because that is essentially what is happening here. Yours, Linus Walleij
On Tue, Jan 31, 2023 at 02:21:38PM +0100, Linus Walleij wrote: > On Tue, Jan 31, 2023 at 12:50 AM Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > > > +#define DRIVE_STRENGTH 9 > > > +#define DRIVE_STRENGTH_UA 10 > > > > > > drive-strength = <8>; // 8mA drive strength > > > > > > bias-type = <DRIVE_STRENGTH>; > > > > > > OK where do I put my 8 mA now? > > > > > If you look at the 2/2 patch, this property only reads BIAS_ > > values, which can't coexist anyway. > > Well the DT bindings have to be consistent and clear on their > own, no matter how Linux implements it. > > But I'm sure you can make YAML verification such that it is > impossible to use both schemes at the same time, and it's not > like I don't understand what you're getting at. We already don't enforce mutually exclusive combinations. Perhaps someone wants to fix that first? > What I need as input is mainly the DT bindings people opinion > on introducing another orthogonal way of doing something > that is already possible to do another way, just more convenient. > Because that is essentially what is happening here. It's really a 3rd way we're adding because the existing properties have 2 forms which IMO is worse than 2 disjoint ways of doing it. And since this new way can't represent some cases, I don't think it is an improvement. Rob
diff --git a/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml b/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml index be81ed22a036..d4ea563d283e 100644 --- a/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml +++ b/Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml @@ -51,6 +51,10 @@ properties: description: use pin-default pull state. Takes as optional argument on hardware supporting it the pull strength in Ohm. + bias-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Use the specified bias type. + drive-push-pull: oneOf: - type: boolean diff --git a/include/dt-bindings/pinctrl/pinconf-generic.h b/include/dt-bindings/pinctrl/pinconf-generic.h new file mode 100644 index 000000000000..7d9c7d8f9105 --- /dev/null +++ b/include/dt-bindings/pinctrl/pinconf-generic.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2011 ST-Ericsson SA + * Written on behalf of Linaro for ST-Ericsson + * + * Author: Linus Walleij <linus.walleij@linaro.org> + */ + +#ifndef _DT_BINDINGS_PINCTRL_PINCONF_GENERIC_H +#define _DT_BINDINGS_PINCTRL_PINCONF_GENERIC_H + +#define BIAS_BUS_HOLD 0 +#define BIAS_DISABLE 1 +#define BIAS_HIGH_IMPEDANCE 2 +#define BIAS_PULL_DOWN 3 +#define BIAS_PULL_PIN_DEFAULT 4 +#define BIAS_PULL_UP 5 +#define DRIVE_OPEN_DRAIN 6 +#define DRIVE_OPEN_SOURCE 7 +#define DRIVE_PUSH_PULL 8 +#define DRIVE_STRENGTH 9 +#define DRIVE_STRENGTH_UA 10 +#define INPUT_DEBOUNCE 11 +#define INPUT_ENABLE 12 +#define INPUT_SCHMITT 13 +#define INPUT_SCHMITT_ENABLE 14 +#define MODE_LOW_POWER 15 +#define MODE_PWM 16 +#define OUTPUT 17 +#define OUTPUT_ENABLE 18 +#define OUTPUT_IMPEDANCE_OHMS 19 +#define PERSIST_STATE 20 +#define POWER_SOURCE 21 +#define SKEW_DELAY 22 +#define SLEEP_HARDWARE_STATE 23 +#define SLEW_RATE 24 +#define PIN_CONFIG_END 0x7F +#define PIN_CONFIG_MAX 0xFF + +#endif