Devicetree
 help / color / mirror / Atom feed
From: Conor Dooley <conor.dooley@microchip.com>
To: Changhuang Liang <changhuang.liang@starfivetech.com>
Cc: Conor Dooley <conor@kernel.org>,
	Linus Walleij <linusw@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Paul Walmsley <pjw@kernel.org>, Albert Ou <aou@eecs.berkeley.edu>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Bartosz Golaszewski <brgl@kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	Lianfeng Ouyang <lianfeng.ouyang@starfivetech.com>
Subject: Re: [PATCH v2 03/22] pinctrl: pinctrl-generic: Make the "function" property optional
Date: Fri, 15 May 2026 10:47:19 +0100	[thread overview]
Message-ID: <20260515-bounce-lather-23de8e36754c@wendy> (raw)
In-Reply-To: <ZQ4PR01MB1202D30B108C4562242C1ED8F2042@ZQ4PR01MB1202.CHNPR01.prod.partner.outlook.cn>

[-- Attachment #1: Type: text/plain, Size: 9366 bytes --]

On Fri, May 15, 2026 at 08:23:55AM +0000, Changhuang Liang wrote:
> > On Fri, May 15, 2026 at 05:55:48AM +0000, Changhuang Liang wrote:
> > > > On Thu, May 14, 2026 at 04:11:59AM -0700, Changhuang Liang wrote:
> > > > > Some pinctrl subnodes only need to configure pin properties (e.g.,
> > > > > power-source, bias, drive strength) without assigning any mux function.
> > > > >
> > > > > Currently, the driver requires a valid "function" property for all
> > > > > pinctrl subnodes. This forces the addition of dummy or redundant
> > > > > "function" entries when only pin configuration is needed.
> > > > >
> > > > > Example use case:
> > > > > gpios-configs {
> > > > >     config {
> > > > >         pins = <0 1 2 3>;
> > > > >         power-source = <0>;
> > > > >     };
> > > > > };
> > > > >
> > > > > Make the "function" property optional. If it is missing, skip
> > > > > adding the mux map and only process the pin configuration.
> > > >
> > > > I looked through the series though and all controllers appear to
> > > > have pins and functions, is it the case that gpio is the default for
> > > > these pins, so you are omitting the functions property when you are using
> > the pin in gpio mode?
> > > > Saying that the functions property is "redudant" makes it seem like
> > > > this might be the case?
> > > >
> > > > I've got some feedback here, but I can't really provide it without
> > > > knowing the answer to that question.
> > >
> > >
> > > "From v1, copying Linus's suggestion:
> > >
> > > > +  This domain contains 4 IO groups which support voltage levels
> > > > + 1.8V and 3.3V  gpioe-spi - comprises PAD_GPIO_C0 through
> > PAD_GPIO_C4.
> > > > +  gpioe-qspi0 - comprises PAD_GPIO_C5 through PAD_GPIO_C11.
> > > > +  gpioe-qspi1 - comprises PAD_GPIO_C12 through PAD_GPIO_C19.
> > > > +  gpioe-qspi2 - comprises PAD_GPIO_C20 through PAD_GPIO_C27.
> > > > +
> > > > +  Each of the above IO groups must be configured with a voltage
> > > > + setting that matches the external  voltage level provided to the IO
> > group.
> > >
> > > So your hardware has groups and support some properties on the group
> > level.
> > >
> > > So expose these groups and make these properties configurable per
> > > group instead of inventing per-group properties.
> > >
> > > > +  gpioe-spi-vref:
> > > > +  gpioe-qspi0-vref:
> > > > +  gpioe-qspi1-vref:
> > > > +  gpioe-qspi2-vref:
> > >
> > > Create proper groups in the pin controller then use the standard
> > > pincfg property power-source = <...>; for this.
> > >
> > > Example for a simple default hog:
> > >
> > > pinctrl {
> > >     /* Hog the QSPI pins */
> > >     pinctrl-names = "default";
> > >     pinctrl-0 = <&qspi_default>;
> > >
> > >     qspi_default: pinctrl-qspi {
> > >         config {
> > >             groups = "gpioe-qspi-pins";
> > >             power-source = <2>;
> > >         };
> > >     };
> > > };
> > >
> > > The groups can be orthogonal to other pin handling, that's fine.
> > > Implement .pin_config_group_set in struct pinconf_ops.
> > >
> > > However, I found that pinctrl_generic_pins_function_dt_node_to_map()
> > > does not handle the groups property,
> > 
> > That's kind of the whole point of the function, see the comment about
> > it:
> > /*
> >  * For platforms that do not define groups or functions in the driver, but
> >  * instead use the devicetree to describe them. This function will, unlike
> >  * pinconf_generic_dt_node_to_map() etc which rely on driver defined
> > groups
> >  * and functions, create them in addition to parsing pinconf properties and
> >  * adding mappings.
> >  */
> > 
> > If you have the groups property in your devicetree, it contains strings that the
> > driver uses to match against the groups it has defined in it.
> > See my recently added microchip,pic64gx-pinctrl-gpio2 for an example of that
> > if you like.
> > 
> > However, if you are using the pins or pinmux properties, the groups are not
> > defined in the driver, and need to be created at runtime. That's what
> > pinctrl_generic_pins_function_dt_node_to_map() is for - it creates the groups
> > at runtime when using the *pins* and *function* properties.
> > It's in the name!
> > 
> > Judging by your drivers, and how many structures you have that look very like
> > groups from a quick glance, probably you can still make use of the groups
> > property. The equivalent function to
> > pinctrl_generic_pins_function_dt_node_to_map() when you're using driver
> > defined groups is pinconf_generic_dt_node_to_map().
> 
> I feel that for the current platform, initializing pin voltage is suitable for using `pinconf_generic_dt_node_to_map()`, 
> and configuring pin mux is suitable for using `pinctrl_generic_pins_function_dt_node_to_map()`. Should I use both 
> of them at the same time?

No, pick either groups or pins across the board and then use the
appropriate function after that. Mixing and matching just adds
complication for no real reason.

> > Also, I notice that you never actually answered the question that I
> > asked:
> > > > I looked through the series though and all controllers appear to
> > > > have pins and functions, is it the case that gpio is the default for
> > > > these pins, so you are omitting the functions property when you are using
> > the pin in gpio mode?
> > > > Saying that the functions property is "redudant" makes it seem like
> > > > this might be the case?
> > 
> > Are you omitting the functions property from your nodes when they're using
> > gpio because it is a default, or is there some other reason why you're omitting
> > the functions property sometimes?
> 
> Sorry, I missed that question. What I meant by making 'functions' optional is that I 
> don't care whether the current pin's default value is GPIO or some other function. 
> Here, I just want to initialize the default voltage of these pins, not configure their 
> pin function.

You're making them gpios in all the cases that I saw, so I think you're
best served by using the "gpio" function and thereby being able to have
function as a required property. Unless the pins are unused, you need to
set the function anyway, and if they're unused and survived on the
values set by reset or prior boot stages, why do you need to set the
voltage anyway?

Looking at this node, it looks completely wrong to me:
+&pinctrl_sys2 {
+	gpiow0_configs: gpiow0-hog-grp {
+		gpiow0-hog-pins {
+			pins = <PADNUM_SYS2_GPIO_A36
+				PADNUM_SYS2_GPIO_A37
+				PADNUM_SYS2_GPIO_A38
+				PADNUM_SYS2_GPIO_A39>;
+			power-source = <JHB100_PINVREF_3_3V>;
+		};
+	};
+
+	gpiow_inner_configs: gpiow-inner-hog-grp {
+		gpiow-inner-hog-pins {
+			pins = <PADNUM_SYS2_GPIO_A40
+				PADNUM_SYS2_GPIO_A41
+				PADNUM_SYS2_GPIO_A42
+				PADNUM_SYS2_GPIO_A43>;
+			power-source = <JHB100_PINVREF_3_3V>;
+		};
+	};
+
+	uart6_pins: uart6-grp {
+		uart6-tx-pins {
+			pins = <PADNUM_SYS2_GPIO_A38>;
+			function = "uart";
+		};
+
+		uart6-rx-pins {
+			pins = <PADNUM_SYS2_GPIO_A39>;
+			function = "uart";
+			input-enable;
+		};
+	};
+};

The pins used by uart appear also in your hog node and...

> This part of the voltage configuration only has one register, but it applies to many 
> pins, so currently it seems I can only use pinctrl hog to initialize it.

...I think that relates to the point you make here. If a setting for the
power-source applies across an entire set of pins, there's no need to
preemptively apply this across the whole set. It's usually sufficient to
just set the power-source in the nodes that describe pins that are actually
in use, for example:

| &pinctrl_sys2 {
| 	uart6_pins: uart6-grp {
| 		uart6-tx-pins {
| 			pins = <PADNUM_SYS2_GPIO_A38>;
| 			function = "uart";
| 			power-source = <JHB100_PINVREF_3_3V>;
| 		};
| 
| 		uart6-rx-pins {
| 			pins = <PADNUM_SYS2_GPIO_A39>;
| 			function = "uart";
| 			input-enable;
| 			power-source = <JHB100_PINVREF_3_3V>;
| 		};
| 	};
| };

The fact that you also are having to do
+&pinctrl_sys2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&gpiow0_configs
+		     &gpiow_inner_configs>;
+};
and have this sys2 pin controller use its own pinctrl state to apply
your hogs is another reason this looks wrong to me. I wouldn't be happy
to accept this dts.
It's also hardly a "hog" since it isn't actually hogging anything at all,
given uart6 also uses some of the pins.

Hope that helps?

Conor.


> 
> Best Regards,
> Changhuang
> 
> > 
> > > currently, my node uses pins instead, so it looks like this:
> > >
> > > +&pinctrl_per3 {
> > > +	pinctrl-names = "default";
> > > +	pinctrl-0 = <&gpios_configs>;
> > > +
> > > +	gpios_configs: gpios-hog-grp {
> > > +		gpios-hog-pins {
> > > +			pins = <PADNUM_PER3_GPIO_E0
> > > +				PADNUM_PER3_GPIO_E1
> > > +				PADNUM_PER3_GPIO_E2
> > > +				PADNUM_PER3_GPIO_E3
> > > +				PADNUM_PER3_GPIO_E4
> > > +				PADNUM_PER3_GPIO_E5
> > > +				PADNUM_PER3_GPIO_E6
> > > +				PADNUM_PER3_GPIO_E7
> > > +				PADNUM_PER3_GPIO_E8
> > > +				PADNUM_PER3_GPIO_E9
> > > +				PADNUM_PER3_GPIO_E10>;
> > > +			power-source = <JHB100_PINVREF_1_8V>;
> > > +		};
> > > +	};
> > > +};
> > >
> > > Best regards,
> > > Changhuang
> > >

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-05-15  9:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 11:11 [PATCH v2 00/22] Add basic pinctrl drivers for JHB100 SoC Changhuang Liang
2026-05-14 11:11 ` [PATCH v2 01/22] dt-bindings: pincfg-node: Add property 'input-debounce-nanoseconds' Changhuang Liang
2026-05-14 18:35   ` Conor Dooley
2026-05-14 11:11 ` [PATCH v2 02/22] pinctrl: pinconf-generic: " Changhuang Liang
2026-05-14 11:11 ` [PATCH v2 03/22] pinctrl: pinctrl-generic: Make the "function" property optional Changhuang Liang
2026-05-14 18:46   ` Conor Dooley
2026-05-15  5:55     ` Changhuang Liang
2026-05-15  7:38       ` Conor Dooley
2026-05-15  8:23         ` Changhuang Liang
2026-05-15  9:47           ` Conor Dooley [this message]
2026-05-15 10:30             ` Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 04/22] dt-bindings: pinctrl: Add starfive,jhb100-sys0-pinctrl Changhuang Liang
2026-05-14 18:52   ` Conor Dooley
2026-05-15  6:10     ` Changhuang Liang
2026-05-15  7:22       ` Conor Dooley
2026-05-15  8:53         ` Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 05/22] pinctrl: starfive: Add StarFive JHB100 sys0 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 06/22] dt-bindings: pinctrl: Add starfive,jhb100-sys0h-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 07/22] pinctrl: starfive: Add StarFive JHB100 sys0h controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 08/22] dt-bindings: pinctrl: Add starfive,jhb100-sys1-pinctrl Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 09/22] pinctrl: starfive: Add StarFive JHB100 sys1 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 10/22] dt-bindings: pinctrl: Add starfive,jhb100-sys2-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 11/22] pinctrl: starfive: Add StarFive JHB100 sys2 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 12/22] dt-bindings: pinctrl: Add starfive,jhb100-per0-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 13/22] pinctrl: starfive: Add StarFive JHB100 per0 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 14/22] dt-bindings: pinctrl: Add starfive,jhb100-per1-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 15/22] pinctrl: starfive: Add StarFive JHB100 per1 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 16/22] dt-bindings: pinctrl: Add starfive,jhb100-per2-pinctrl Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 17/22] pinctrl: starfive: Add StarFive JHB100 per2 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 18/22] dt-bindings: pinctrl: Add starfive,jhb100-per2pok-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 19/22] pinctrl: starfive: Add StarFive JHB100 per2pok controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 20/22] dt-bindings: pinctrl: Add starfive,jhb100-per3-pinctrl Changhuang Liang
2026-05-14 13:17   ` Rob Herring (Arm)
2026-05-14 11:12 ` [PATCH v2 21/22] pinctrl: starfive: Add StarFive JHB100 per3 controller driver Changhuang Liang
2026-05-14 11:12 ` [PATCH v2 22/22] riscv: dts: starfive: jhb100: Add pinctrl nodes Changhuang Liang

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=20260515-bounce-lather-23de8e36754c@wendy \
    --to=conor.dooley@microchip.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=brgl@kernel.org \
    --cc=changhuang.liang@starfivetech.com \
    --cc=conor+dt@kernel.org \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@esmil.dk \
    --cc=krzk+dt@kernel.org \
    --cc=lianfeng.ouyang@starfivetech.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.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