linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, andersson@kernel.org,
	agross@kernel.org, krzysztof.kozlowski@linaro.org,
	marijn.suijten@somainline.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: Re: [RFC PATCH 1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins
Date: Tue, 31 Jan 2023 00:50:36 +0100	[thread overview]
Message-ID: <f3f70ac2-d097-b6ee-22d3-92fcfdd7c53f@linaro.org> (raw)
In-Reply-To: <CACRpkdZjAyLUg3V7ZTzeMfUOTrndLrRX_gTFdO+amSmZkzB72Q@mail.gmail.com>



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

  reply	other threads:[~2023-01-30 23:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 16:54 [RFC PATCH 1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins Konrad Dybcio
2023-01-30 16:54 ` [RFC PATCH 2/2] pinctrl: pinconf-generic: Add an overridable way to set bias property Konrad Dybcio
2023-01-30 23:10 ` [RFC PATCH 1/2] dt-bindings: pincfg-node: Introduce an overridable way to set bias on pins Linus Walleij
2023-01-30 23:50   ` Konrad Dybcio [this message]
2023-01-31 13:21     ` Linus Walleij
2023-02-01  1:57       ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3f70ac2-d097-b6ee-22d3-92fcfdd7c53f@linaro.org \
    --to=konrad.dybcio@linaro.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).