All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yao Zi <ziyao@disroot.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	Mingcong Bai <jeffbai@aosc.io>,
	Kexy Biscuit <kexybiscuit@aosc.io>
Subject: Re: [PATCH 1/3] dt-binding: pinctrl: Document Loongson 2K0300 pin controller
Date: Tue, 14 Oct 2025 02:23:23 +0000	[thread overview]
Message-ID: <aO20G22p7OwJq6C-@pie> (raw)
In-Reply-To: <CACRpkdYC6ueVGngC=KMqh9aW8DiMKWyxoa8dqb4N3sEEkpdsFg@mail.gmail.com>

On Tue, Oct 14, 2025 at 12:48:31AM +0200, Linus Walleij wrote:
> On Mon, Aug 11, 2025 at 6:39 PM Yao Zi <ziyao@disroot.org> wrote:
> 
> > The pincontroller integarted in Loongson 2K0300 is able to configure
> > function multiplexing for all the pins. It could also configure drive
> > strength on basis of functions, which means all pins set to the same
> > function share drive-strength setting. Drive-strength configuration
> > isn't available for all functions, either.
> >
> > This binding utilizes two levels of subnodes, where the outer represents
> > function and the inner represents groups. Drive-strength is allowed in
> > the outer since it's shared among all groups configured to the function.
> >
> > Signed-off-by: Yao Zi <ziyao@disroot.org>
> (...)
> > +patternProperties:
> > +  '^func-':
> > +    type: object
> > +
> > +    $ref: pincfg-node.yaml#
> > +
> > +    properties:
> > +      drive-strength:
> > +        description:
> > +          Maximum sink or source current as defined in pincfg-node.yaml. Note
> > +          that drive strength could only be configured on function basis, i.e.,
> > +          all pins multiplexed to the same function share the same
> > +          configuration.
> > +
> > +          This could only be configured for several functions, including jtag,
> > +          dvo, uart, gmac, sdio, spi, i2s, timer, usb and emmc.
> > +        enum: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
> 
> As Rob points out this is really odd, or rather the first time I see
> something like this.
> 
> It is clear from the driver that these are all set by writing bits
> in a 32bit register, with 2 or 3 bits dedicated to each function.
> 
> Its a bit weird, like each function has driver totempoles/stages
> before the mux instead of after (which is the normal). But
> I guess it is engineered like that then!

Yes, it occurs strange to me at the first sight, too.

> 
> It now looks like this:
> 
> +        func-uart {
> +            drive-strength = <2>;
> +
> +            uart0-pins {
> +                pinmux = <((40 << 8) | 0x3)>, <((41 << 8) | 0x3)>;
> +            };
> 
> I think this is better:
> 
> uart0_default: uart0-pins {
>      function = "uart0";
>      drive-strength = <2>;
>      pinmux = <((40 << 8) | 0x3)>, <((41 << 8) | 0x3)>;
>  };
> 
> This is consistent with the bindings if you include both
> $ref: pinmux-node.yaml#
> $ref: pincfg-node.yaml#
> 
> And will configure it all in one go.

To confirm my understanding, would you like to drop the outside node
(which now refers to pincfg-node.yaml) and refer to both
pinmux-node.yaml and pincfg-node.yaml in the single level of subnode?
i.e.

	pinctrl {
		uart0_defaults: uart0-pins {
			function = "uart0";
			drive-strength = <2>;
			pinmux = <...>;
		};
	};

> Sure you need a lookup for the function strings in the driver
> but it's OK.
> 
> It's odd to have "function" without "group" but it seems legal
> and works fine for your usecase. The normal would be to
> skip pinmux, have just pins = <40, 41>; and look up the
> function value for each function for a pin from a table that
> cross-reference in this case "uart0" to 3. But I
> guess you don't wanna do that so pinmux is fine too.

Thanks, glad to hear it's okay.

> <((40 << 8) | 0x3)>, <((41 << 8) | 0x3)> is a bit odd, maybe
> you want to also include an explanatory macro in the bindings.

Sure, I will add a macro like the one included in the DTS change.

> Yours,
> Linus Walleij
> 

Thank you and Rob for the help! Will adapt the suggestions in v2.

Best regards,
Yao Zi

  reply	other threads:[~2025-10-14  2:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-11 16:37 [PATCH 0/3] Support pinctrl for Loongson 2K0300 SoC Yao Zi
2025-08-11 16:37 ` [PATCH 1/3] dt-binding: pinctrl: Document Loongson 2K0300 pin controller Yao Zi
2025-08-18 17:58   ` Rob Herring
2025-08-19 11:37     ` Yao Zi
2025-09-12  8:42       ` Yao Zi
2025-10-10 22:05       ` Rob Herring
2025-10-13 22:48   ` Linus Walleij
2025-10-14  2:23     ` Yao Zi [this message]
2025-10-14 10:38       ` Linus Walleij
2025-08-11 16:37 ` [PATCH 2/3] pinctrl: ls2k0300: Support Loongson 2K0300 SoC Yao Zi
2025-08-14  3:15   ` Yao Zi
2025-08-19 10:02   ` Linus Walleij
2025-08-19 12:40     ` Yao Zi
2025-08-21 11:27       ` Linus Walleij
2025-08-11 16:37 ` [PATCH 3/3] LoongArch: dts: Add pinctrl configuration for Loongson 2K0300 Yao Zi

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=aO20G22p7OwJq6C-@pie \
    --to=ziyao@disroot.org \
    --cc=chenhuacai@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jeffbai@aosc.io \
    --cc=kernel@xen0n.name \
    --cc=kexybiscuit@aosc.io \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.