devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Icenowy Zheng <uwu@icenowy.me>
To: E Shattow <e@freeshell.de>,
	Emil Renner Berthing <kernel@esmil.dk>,
	 Jianlong Huang <jianlong.huang@starfivetech.com>,
	Hal Feng <hal.feng@starfivetech.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins
Date: Fri, 25 Apr 2025 16:43:56 +0800	[thread overview]
Message-ID: <460048c49b82684af0759520ec8dcac057ad2857.camel@icenowy.me> (raw)
In-Reply-To: <60891c52-eeca-4358-8f38-789533016495@freeshell.de>

在 2025-04-24星期四的 01:15 -0700,E Shattow写道:
> On 4/23/25 23:20, Icenowy Zheng wrote:
> > The JH7110 SoC could support internal GPI signals to be routed to
> > not
> > external GPIO but internal low/high levels.
> > 
> > Add two macros, PAD_INTERNAL_LOW and PAD_INTERNAL_HIGH, as two
> > virtual
> > "pads" to represent internal GPI sources with fixed low/high
> > levels.
> > 
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h
> > b/include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h
> > index 3865f01396395..3cca874b2bef7 100644
> > --- a/include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h
> > +++ b/include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h
> > @@ -126,6 +126,10 @@
> >  #define        PAD_GMAC0_TXEN          18
> >  #define        PAD_GMAC0_TXC           19
> >  
> > +/* virtual pins for forcing GPI */
> > +#define PAD_INTERNAL_LOW       254
> > +#define PAD_INTERNAL_HIGH      255
> > +
> >  #define GPOUT_LOW              0
> >  #define GPOUT_HIGH             1
> >  
> 
> Asking about the choice of 255 and 254 values for virtual high/low
> pins,
> here. There's not much result when grep Linux source for 'virtual
> pin'
> to compare with. Are these the best values for this approach?

These two values are picked because the following reasons:

- The pin field has 8 bits (see the comments of jh7110_pinmux_din() in
pinctrl-starfive-jh7110.c)
- We are already using values 0 and 1 for GPIO0/GPIO1

If we're designing from scratch, it's possible to have another practice
by using 0 and 1 for internal low/high and 2 for gpio0 so on.

> 
> What happens when devicetree has in it to route PAD_INTERNAL_LOW to
> PAD_INTERNAL_HIGH and other unlikely combinations?  Or a devicetree
> blob
> with this computed value is paired to Linux kernel that does not have
> the code to handle these virtual pins, for compatibility concern?

I think it's not supported for newer DTs to be compatible with old
kernels, but I analyzed the code, a read-out-of-bound could happen in
jh7110_set_function() in pinctrl-starfive-jh7110-sys.c . Well this is
unfortunate, but we can do few things to fix old kernels -- we can fix
the problem in newer kernels.

And even picking other values cannot make things better...

> 
> Do we know yet if JH8100 will share some of this design?

We don't know yet whether JH8100 can exist.

> 
> -E


  reply	other threads:[~2025-04-25  8:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24  6:20 [PATCH v2 0/3] pinctrl: starfive: jh7110: support force inputs Icenowy Zheng
2025-04-24  6:20 ` [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins Icenowy Zheng
2025-04-24  8:15   ` E Shattow
2025-04-25  8:43     ` Icenowy Zheng [this message]
2025-04-24  8:51   ` Linus Walleij
2025-04-24  9:38     ` Icenowy Zheng
2025-04-24 10:30       ` Linus Walleij
2025-04-24 12:25         ` Icenowy Zheng
2025-04-28 14:18           ` Linus Walleij
2025-04-28  7:20   ` Krzysztof Kozlowski
2025-04-28  8:40     ` Icenowy Zheng
2025-04-29  7:31       ` Krzysztof Kozlowski
2025-04-29  9:00         ` Icenowy Zheng
2025-04-30  7:21           ` Krzysztof Kozlowski
2025-04-24  6:20 ` [PATCH v2 2/3] pinctrl: starfive: jh7110: add support for PAD_INTERNAL_* for GPI Icenowy Zheng
2025-04-24  7:57   ` E Shattow
2025-05-06  8:10   ` Icenowy Zheng
2025-04-24  6:21 ` [PATCH v2 3/3] riscv: dts: starfive: jh7110-pine64-star64: force no USB overcurrent Icenowy Zheng
2025-04-25  9:22   ` kernel test robot

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=460048c49b82684af0759520ec8dcac057ad2857.camel@icenowy.me \
    --to=uwu@icenowy.me \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=e@freeshell.de \
    --cc=hal.feng@starfivetech.com \
    --cc=jianlong.huang@starfivetech.com \
    --cc=kernel@esmil.dk \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=robh@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).