Skip to contentSkip to conversation

pinctrl: starfive: jh7110: support force inputs

PATCH In review Icenowy Zheng 5 participants 19 messages Apr 24, 2025 – May 6, 2025

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: starfive: jh7110: support force inputs

The input signals inside the JH7110 SoC (to be routed by the pin controller) could be routed to GPIOs and internal fixed low/high levels. As the total GPIO count of JH7110 is not very high, it's sometime feasible to omit some hardwiring outside the SoC and do them in the pin controller. One such example is the USB overcurrent_n signal, which defaults to low at SoC reset, needs to be high for the USB controller to correctly work (the _n means low indicates overcurrent situation) and gets omitted on the Pine64 Star64 board.

Add the support for hardwiring GPI signals inside the JH7110 pin controllers, via two virtual "pins" which mean fixed low/high.

Changes in v2:
- Use virtual pins instead of special properties.
- No longer RFC.

Icenowy Zheng (3):
dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins
pinctrl: starfive: jh7110: add support for PAD_INTERNAL_* for GPI
riscv: dts: starfive: jh7110-pine64-star64: force no USB overcurrent

 .../dts/starfive/jh7110-pine64-star64.dts     |  7 ++++
 .../starfive/pinctrl-starfive-jh7110.c        | 41 +++++++++++++++----
 .../pinctrl/starfive,jh7110-pinctrl.h         |  4 ++
 3 files changed, 45 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/3 dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +4 -0
index 3865f01396395..3cca874b2bef7 100644
@@ -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
 
Signature · 7 lines
2.49.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 16 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
index 3865f01396395..3cca874b2bef7 100644

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 135

Quoted 10 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +4 -0
@@ -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?

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?

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

-E

#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 29 lines · 在 2025-04-24星期四的 01:15 -0700,E Shattow写道:
Quoted 28 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++

 1 file changed, 4 insertions(+)
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
index 3865f01396395..3cca874b2bef7 100644
@@ -126,6 +126,10 @@
  #define        PAD_GMAC0_TXEN          18
  #define        PAD_GMAC0_TXC           19

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +4 -0
+/* virtual pins for forcing GPI */
+#define PAD_INTERNAL_LOW       254
+#define PAD_INTERNAL_HIGH      255
+

 #define GPOUT_LOW              0

Quoted 8 lines
Quoted 2 lines

 #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.

Quoted 6 lines

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...

Quoted 2 lines

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

We don't know yet whether JH8100 can exist.

Quoted 2 lines

-E

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

In reply to Icenowy Zheng
Quoted 7 lines · Icenowy Zheng

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.

As per my other reply in the previous post, I think this should be handled internal in the kernel instead using a tighter integration between the GPIO and pin control parts of the driver and utilizing the gpio-specific struct pinmux_ops callbacks.

This solution looks like software configuration disguised as hardware configuration.

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 11 lines · 在 2025-04-24星期四的 10:51 +0200,Linus Walleij写道:
Quoted 9 lines · Icenowy Zheng

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.

Quoted 7 lines
Quoted 1 line

As per my other reply in the previous post, I think this should be handled internal in the kernel instead using a tighter integration between
the GPIO and pin control parts of the driver and utilizing the gpio-specific struct pinmux_ops callbacks.

Well I cannot understand this -- these signals are not GPIOs, totally not related to the GPIO subsystem (because they're only pinmux, not related to GPIOs). This is described in my previous mail.

The pin mux of JH7110 strictly route its inputs to its outputs. For signals from other SoC blocks (to external pins), the registers define how OUT/OEn of IO buffers *are driven by* the signals; however for signals to other SoC blocks (from external pins), the registers define how IN of IO buffers *drive* the signals. (This follows the generic signal-driving rule that one signal can drive multiple signals but cannot be multi-driven).

In addition the situation I am trying to handle here is an addition to the latter part of the previous paragraph -- in addition to 64 inputs corresponding to 64 GPIOs, two extra inputs, one always 0 and another always 1 are available to the pin controller for driving other SoC blocks' input (as output of pin controller).

In fact this is why there is + 2 when calculating ival in jh7110_set_gpiomux() -- the first two possible values are for always 0 and always 1, 3 represents the IN of GPIO0, etc.

Quoted 3 lines

This solution looks like software configuration disguised as hardware configuration.

Well this solution handles these internal wires in the same way as signals from external GPIOs, excepting specifying special GPIO numbers. If you are against the principle, maybe the current already-included GPIOMUX system of the StarFive pinctrl is to be blamed instead of my small extension to it.

I must admit that the current GPIOMUX system isn't a faithful representation of the hardware because it's a pad-centric setup instead of a register-field-centric one, which isn't very natural for input signals. However configurating the mux in such a way is against people reading, and we're not able to break the system because it's already there.

Well in the situation that one GPIO used as input drives multiple internal signals the pinmux looks a little confusing too, e.g. the I2S clock situation I mentioned in my reply in the previous revision of the patchset.

Quoted 3 lines

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 20 lines · Icenowy Zheng
Quoted 11 lines · 在 2025-04-24星期四的 10:51 +0200,Linus Walleij写道:
Quoted 9 lines · Icenowy Zheng

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.

Quoted 7 lines
Quoted 1 line

As per my other reply in the previous post, I think this should be handled internal in the kernel instead using a tighter integration between
the GPIO and pin control parts of the driver and utilizing the gpio-specific struct pinmux_ops callbacks.

Quoted 3 lines

Well I cannot understand this -- these signals are not GPIOs, totally not related to the GPIO subsystem (because they're only pinmux, not related to GPIOs). This is described in my previous mail.

OK sorry if I'm a bit dumb at times :(

I guess I was falling into the common confusion of "something named general purpose" such as your GPI and GPO registers, is also related to GPIO which it is not, at least not always.

Quoted 8 lines

The pin mux of JH7110 strictly route its inputs to its outputs. For signals from other SoC blocks (to external pins), the registers define how OUT/OEn of IO buffers *are driven by* the signals; however for signals to other SoC blocks (from external pins), the registers define how IN of IO buffers *drive* the signals. (This follows the generic signal-driving rule that one signal can drive multiple signals but cannot be multi-driven).

Quoted 5 lines

In addition the situation I am trying to handle here is an addition to the latter part of the previous paragraph -- in addition to 64 inputs corresponding to 64 GPIOs, two extra inputs, one always 0 and another always 1 are available to the pin controller for driving other SoC blocks' input (as output of pin controller).

OK ... maybe I get it now.

Quoted 16 lines
Quoted 2 lines

This solution looks like software configuration disguised as hardware configuration.

Well this solution handles these internal wires in the same way as signals from external GPIOs, excepting specifying special GPIO numbers. If you are against the principle, maybe the current already-included GPIOMUX system of the StarFive pinctrl is to be blamed instead of my small extension to it.

I must admit that the current GPIOMUX system isn't a faithful representation of the hardware because it's a pad-centric setup instead of a register-field-centric one, which isn't very natural for input signals. However configurating the mux in such a way is against people reading, and we're not able to break the system because it's already there.

Quoted 4 lines

Well in the situation that one GPIO used as input drives multiple internal signals the pinmux looks a little confusing too, e.g. the I2S clock situation I mentioned in my reply in the previous revision of the patchset.

I guess what rubs me the wrong way is why the external users (devices, device drivers or even pin hogs) cannot trigger the chain of events leading to this configuration, instead of different "magic" configurations that are just set up in the pin controller itself.

But if you are positively convinced that there is no other way, I guess I have to live with it.

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 31 lines · 在 2025-04-24星期四的 12:30 +0200,Linus Walleij写道:
Quoted 24 lines · Icenowy Zheng
Quoted 15 lines · 在 2025-04-24星期四的 10:51 +0200,Linus Walleij写道:
Quoted 11 lines · Icenowy Zheng

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.

Quoted 7 lines

As per my other reply in the previous post, I think this should be
handled internal in the kernel instead using a tighter integration
between
the GPIO and pin control parts of the driver and utilizing the gpio-specific struct pinmux_ops callbacks.

Quoted 4 lines

Well I cannot understand this -- these signals are not GPIOs, totally
not related to the GPIO subsystem (because they're only pinmux, not related to GPIOs). This is described in my previous mail.

Quoted 5 lines

OK sorry if I'm a bit dumb at times :(

I guess I was falling into the common confusion of "something named general purpose" such as your GPI and GPO registers, is also related to GPIO which it is not, at least not always.

Ah, sorry, these GPI/GPO names are directly taken from the StarFive TRM from the register field names. They CAN be routed to the external GPIOs, but is not required so.

Quoted 52 lines
Quoted 11 lines

The pin mux of JH7110 strictly route its inputs to its outputs. For signals from other SoC blocks (to external pins), the registers define
how OUT/OEn of IO buffers *are driven by* the signals; however for signals to other SoC blocks (from external pins), the registers define
how IN of IO buffers *drive* the signals. (This follows the generic signal-driving rule that one signal can drive multiple signals but cannot be multi-driven).

Quoted 8 lines

In addition the situation I am trying to handle here is an addition to
the latter part of the previous paragraph -- in addition to 64 inputs
corresponding to 64 GPIOs, two extra inputs, one always 0 and another
always 1 are available to the pin controller for driving other SoC blocks' input (as output of pin controller).

OK ... maybe I get it now.

Quoted 23 lines
Quoted 3 lines

This solution looks like software configuration disguised as hardware
configuration.

Well this solution handles these internal wires in the same way as signals from external GPIOs, excepting specifying special GPIO numbers.
If you are against the principle, maybe the current already- included
GPIOMUX system of the StarFive pinctrl is to be blamed instead of my
small extension to it.

I must admit that the current GPIOMUX system isn't a faithful representation of the hardware because it's a pad-centric setup instead
of a register-field-centric one, which isn't very natural for input signals. However configurating the mux in such a way is against people
reading, and we're not able to break the system because it's already
there.

Quoted 6 lines

Well in the situation that one GPIO used as input drives multiple internal signals the pinmux looks a little confusing too, e.g. the I2S
clock situation I mentioned in my reply in the previous revision of the
patchset.

Quoted 5 lines

I guess what rubs me the wrong way is why the external users (devices, device drivers or even pin hogs) cannot trigger the chain of
events leading to this configuration, instead of different "magic" configurations that are just set up in the pin controller itself.

Well I am just extending what's already in use...

Currently it's already supported to route GPIOs to GPI signals, I added the support to route fixed level sources to them, in a similar way.

If any external users ever have the need of banging the internal signals instead of tying it fixedly, maybe switching between different pinctrl configuration sets is enough? (Because this kind of operation could never be as high speed enough as real hardware pins)

Quoted 6 lines

But if you are positively convinced that there is no other way, I guess I have to live with it.

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

On Thu, Apr 24, 2025 at 2:26 PM Icenowy Zheng <[email protected]> wrote:
[Me]

Quoted 8 lines
Quoted 5 lines

I guess what rubs me the wrong way is why the external users (devices, device drivers or even pin hogs) cannot trigger the chain of
events leading to this configuration, instead of different "magic" configurations that are just set up in the pin controller itself.

Well I am just extending what's already in use...

Quoted 7 lines

Currently it's already supported to route GPIOs to GPI signals, I added the support to route fixed level sources to them, in a similar way.

If any external users ever have the need of banging the internal signals instead of tying it fixedly, maybe switching between different pinctrl configuration sets is enough? (Because this kind of operation could never be as high speed enough as real hardware pins)

What I am thinking is that one of the following must be true:

1. The internal pads are always set up the same way for this SoC in which case they should be just hardcoded instead, or at least just implied from the compatible string of the pin controller.

2. The internal pads are routed differently depending on different use cases, in which case they need to be set up or implied from configuration in other DT nodes describing this use.

I guess this binding if for (2)?

Yours,
Linus Walleij

#9 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

In reply to Icenowy Zheng
Quoted 16 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
index 3865f01396395..3cca874b2bef7 100644

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 131

Quoted 6 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +3 -0
@@ -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

Why this cannot be 20 and 21? These are not values for registers, but abstract numbers.

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 15 lines · 在 2025-04-28星期一的 09:20 +0200,Krzysztof Kozlowski写道:
Quoted 14 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++

 1 file changed, 4 insertions(+)
Quoted 15 lines

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 131

Quoted 12 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
index 3865f01396395..3cca874b2bef7 100644
@@ -126,6 +126,10 @@
  #define        PAD_GMAC0_TXEN          18
  #define        PAD_GMAC0_TXC           19

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +3 -0
+/* virtual pins for forcing GPI */
+#define PAD_INTERNAL_LOW       254
+#define PAD_INTERNAL_HIGH      255

Why this cannot be 20 and 21? These are not values for registers, but abstract numbers.

The number must not collide with SYS GPIO pads too.

Using 95 and 96 is okay, but dirty.

Quoted 4 lines

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 32 lines · Icenowy Zheng
Quoted 15 lines · 在 2025-04-28星期一的 09:20 +0200,Krzysztof Kozlowski写道:
Quoted 14 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++

 1 file changed, 4 insertions(+)
Quoted 15 lines

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 131

Quoted 12 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
index 3865f01396395..3cca874b2bef7 100644
@@ -126,6 +126,10 @@
  #define        PAD_GMAC0_TXEN          18
  #define        PAD_GMAC0_TXC           19

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +3 -0
+/* virtual pins for forcing GPI */
+#define PAD_INTERNAL_LOW       254
+#define PAD_INTERNAL_HIGH      255

Why this cannot be 20 and 21? These are not values for registers, but abstract numbers.

Quoted 1 line

The number must not collide with SYS GPIO pads too.

There are no SYS GPIO pads here. Do you understand that this is not value for registers?

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 36 lines · 在 2025-04-29星期二的 09:31 +0200,Krzysztof Kozlowski写道:
Quoted 35 lines · Icenowy Zheng
Quoted 33 lines · 在 2025-04-28星期一的 09:20 +0200,Krzysztof Kozlowski写道:
Quoted 25 lines · Icenowy Zheng

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.

---
 include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h | 4 ++++

 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

pinctrl.h b/include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h index 3865f01396395..3cca874b2bef7 100644

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +0 -0
@@ -126,6 +126,10 @@
  #define        PAD_GMAC0_TXEN          18
  #define        PAD_GMAC0_TXC           19

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 131

Quoted 3 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +3 -0
+/* virtual pins for forcing GPI */
+#define PAD_INTERNAL_LOW       254
+#define PAD_INTERNAL_HIGH      255

Why this cannot be 20 and 21? These are not values for registers, but
abstract numbers.

Quoted 4 lines
Quoted 1 line

The number must not collide with SYS GPIO pads too.

There are no SYS GPIO pads here. Do you understand that this is not value for registers?

Yes I understand.

The situation is that JH7110 has two similar pin mux controllers, one SYSGPIO and one AONGPIO. Despite I listed the values after the AONGPIO pad list, these values should apply to SYSGPIO too (unless you want to let them have different values for these two pinmux controllers), which is the part with comment "sys_iomux pins".

Quoted 3 lines

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v2 1/3] dt-bindings: pinctrl: starfive,jh7110: add PAD_INTERNAL_* virtual pins

Quoted 13 lines · Icenowy Zheng
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h line 131

Quoted 3 lines
include/dt-bindings/pinctrl/starfive,jh7110-pinctrl.h +3 -0
+/* virtual pins for forcing GPI */
+#define PAD_INTERNAL_LOW       254
+#define PAD_INTERNAL_HIGH      255

Why this cannot be 20 and 21? These are not values for registers, but
abstract numbers.

Quoted 4 lines
Quoted 1 line

The number must not collide with SYS GPIO pads too.

There are no SYS GPIO pads here. Do you understand that this is not value for registers?

Quoted 7 lines

Yes I understand.

The situation is that JH7110 has two similar pin mux controllers, one SYSGPIO and one AONGPIO. Despite I listed the values after the AONGPIO pad list, these values should apply to SYSGPIO too (unless you want to let them have different values for these two pinmux controllers), which is the part with comment "sys_iomux pins".

It is fine for me in such case.

Best regards,
Krzysztof

#14 lore raw

PATCH v2 2/3 pinctrl: starfive: jh7110: add support for PAD_INTERNAL_* for GPI

In reply to Icenowy Zheng

The JH7110 SoC's both pin controller support routing GPI signals to internal fixed low/high level.

As we allocated two special "pin" numbers for these situations (PAD_INTERNAL_{LOW,HIGH}), add special handling code for these "pins". The DOEn/DOUT/FUNCTION fields are ignored and the internal input signal specified by the DIN field is routed to fixed low/high level.

---
 .../starfive/pinctrl-starfive-jh7110.c        | 41 +++++++++++++++----
 1 file changed, 34 insertions(+), 7 deletions(-)
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +34 -7
index 1d0d6c224c104..fb18c7974ec86 100644
@@ -291,6 +291,24 @@ void jh7110_set_gpiomux(struct jh7110_pinctrl *sfp, unsigned int pin,
 }
 EXPORT_SYMBOL_GPL(jh7110_set_gpiomux);
 
+static void jh7110_set_gpi(struct jh7110_pinctrl *sfp, u32 gpi, u32 val)
+{
+	u32 offset, shift;
+	u32 reg_val;
+	const struct jh7110_pinctrl_soc_info *info = sfp->info;
+
+	offset = 4 * (gpi / 4);
+	shift  = 8 * (gpi % 4);
+
+	reg_val = readl_relaxed(sfp->base +
+				info->gpi_reg_base + offset);
+	reg_val &= info->gpi_mask << shift;
+	reg_val |= (val & info->gpi_mask) << shift;
+
+	writel_relaxed(reg_val, sfp->base +
+				info->gpi_reg_base + offset);
+}
+
 static int jh7110_set_mux(struct pinctrl_dev *pctldev,
 			  unsigned int fsel, unsigned int gsel)
 {
@@ -307,14 +325,23 @@ static int jh7110_set_mux(struct pinctrl_dev *pctldev,
 	pinmux = group->data;
 	for (i = 0; i < group->grp.npins; i++) {
 		u32 v = pinmux[i];
+		u32 pin = jh7110_pinmux_pin(v);
 
-		if (info->jh7110_set_one_pin_mux)
-			info->jh7110_set_one_pin_mux(sfp,
-					jh7110_pinmux_pin(v),
-					jh7110_pinmux_din(v),
-					jh7110_pinmux_dout(v),
-					jh7110_pinmux_doen(v),
-					jh7110_pinmux_function(v));
+		switch (pin) {
+		case PAD_INTERNAL_LOW:
+		case PAD_INTERNAL_HIGH:
+			jh7110_set_gpi(sfp, jh7110_pinmux_din(v),
+				       pin == PAD_INTERNAL_HIGH);
+			break;
+		default:
+			if (info->jh7110_set_one_pin_mux)
+				info->jh7110_set_one_pin_mux(sfp,
+						jh7110_pinmux_pin(v),
+						jh7110_pinmux_din(v),
+						jh7110_pinmux_dout(v),
+						jh7110_pinmux_doen(v),
+						jh7110_pinmux_function(v));
+		}
 	}
 
 	return 0;
Signature · 7 lines
2.49.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#15 lore raw

Re: [PATCH v2 2/3] pinctrl: starfive: jh7110: add support for PAD_INTERNAL_* for GPI

Quoted 30 lines · Icenowy Zheng

The JH7110 SoC's both pin controller support routing GPI signals to internal fixed low/high level.

As we allocated two special "pin" numbers for these situations (PAD_INTERNAL_{LOW,HIGH}), add special handling code for these "pins". The DOEn/DOUT/FUNCTION fields are ignored and the internal input signal specified by the DIN field is routed to fixed low/high level.

---
 .../starfive/pinctrl-starfive-jh7110.c        | 41 +++++++++++++++----
 1 file changed, 34 insertions(+), 7 deletions(-)
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +8 -0
index 1d0d6c224c104..fb18c7974ec86 100644
@@ -291,6 +291,24 @@ void jh7110_set_gpiomux(struct jh7110_pinctrl *sfp, unsigned int pin,
 }
 EXPORT_SYMBOL_GPL(jh7110_set_gpiomux);
 
 
+static void jh7110_set_gpi(struct jh7110_pinctrl *sfp, u32 gpi, u32 val)
+{
+	u32 offset, shift;
+	u32 reg_val;
+	const struct jh7110_pinctrl_soc_info *info = sfp->info;
+
+	offset = 4 * (gpi / 4);
+	shift  = 8 * (gpi % 4);

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c void jh7110_set_gpiomux(struct jh7110_pinctrl *sfp, unsigned int pin, · line 312

Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +10 -0
+
+	reg_val = readl_relaxed(sfp->base +
+				info->gpi_reg_base + offset);
+	reg_val &= info->gpi_mask << shift;
+	reg_val |= (val & info->gpi_mask) << shift;
+
+	writel_relaxed(reg_val, sfp->base +
+				info->gpi_reg_base + offset);
+}
+

Are there some bit ops masking macros common to Linux that should be used here?

Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +0 -0
 static int jh7110_set_mux(struct pinctrl_dev *pctldev,
 			  unsigned int fsel, unsigned int gsel)

{

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +0 -0
@@ -307,14 +325,23 @@ static int jh7110_set_mux(struct pinctrl_dev *pctldev,
 	pinmux = group->data;
 	for (i = 0; i < group->grp.npins; i++) {

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c static int jh7110_set_mux(struct pinctrl_dev *pctldev, · line 317

Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +1 -7
 		u32 v = pinmux[i];
+		u32 pin = jh7110_pinmux_pin(v);
 
-		if (info->jh7110_set_one_pin_mux)
-			info->jh7110_set_one_pin_mux(sfp,
-					jh7110_pinmux_pin(v),
-					jh7110_pinmux_din(v),
-					jh7110_pinmux_dout(v),
-					jh7110_pinmux_doen(v),
-					jh7110_pinmux_function(v));

I cannot think of any reason why you would need to do it this way:

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c static int jh7110_set_mux(struct pinctrl_dev *pctldev, · line 335

Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +6 -0
+		switch (pin) {
+		case PAD_INTERNAL_LOW:
+		case PAD_INTERNAL_HIGH:
+			jh7110_set_gpi(sfp, jh7110_pinmux_din(v),
+				       pin == PAD_INTERNAL_HIGH);
+			break;

Please, just more readable and let compiler do its job to optimize:

		switch (pin) {
		case PAD_INTERNAL_LOW:
			jh7110_set_gpi(sfp, jh7110_pinmux_din(v), 0);
			break;

		case PAD_INTERNAL_HIGH:
			jh7110_set_gpi(sfp, jh7110_pinmux_din(v), 1);
			break;

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c static int jh7110_set_mux(struct pinctrl_dev *pctldev, · line 347

Quoted 12 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +9 -0
+		default:
+			if (info->jh7110_set_one_pin_mux)
+				info->jh7110_set_one_pin_mux(sfp,
+						jh7110_pinmux_pin(v),
+						jh7110_pinmux_din(v),
+						jh7110_pinmux_dout(v),
+						jh7110_pinmux_doen(v),
+						jh7110_pinmux_function(v));
+		}
 	}
 
 	return 0;

Thank you for your work on this series! -E

#16 lore raw

Re: [PATCH v2 2/3] pinctrl: starfive: jh7110: add support for PAD_INTERNAL_* for GPI

In reply to Icenowy Zheng
Quoted 9 lines · 在 2025-04-24星期四的 14:20 +0800,Icenowy Zheng写道:

The JH7110 SoC's both pin controller support routing GPI signals to internal fixed low/high level.

As we allocated two special "pin" numbers for these situations (PAD_INTERNAL_{LOW,HIGH}), add special handling code for these "pins".
The DOEn/DOUT/FUNCTION fields are ignored and the internal input signal
specified by the DIN field is routed to fixed low/high level.

Oops today I found that this patchset has some problem -- the GPIOMUX macro masks bits 7 and 8 in GPIO number, and it maps GPI_SYS_USB_OVERCURRENT to GPIO63 instead of PAD_INTERNAL_HIGH instead.

When I fixed this, I got

```
[    9.865841] starfive-jh7110-sys-pinctrl 13040000.pinctrl: pin 255 is
not registered so it cannot be requested
[    9.875814] starfive-jh7110-sys-pinctrl 13040000.pinctrl: error -
EINVAL: pin-255 (soc:usb@10100000)
[    9.884882] starfive-jh7110-sys-pinctrl 13040000.pinctrl: error -
EINVAL: could not request pin 255 (non-existing) from group usb0-
0.overcurrent-pins on device 13040000.pinctrl
```

Weird problem, how could I solve this?

Quoted 74 lines

---
 .../starfive/pinctrl-starfive-jh7110.c        | 41 +++++++++++++++-- --

 1 file changed, 34 insertions(+), 7 deletions(-)
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +0 -0
index 1d0d6c224c104..fb18c7974ec86 100644
@@ -291,6 +291,24 @@ void jh7110_set_gpiomux(struct jh7110_pinctrl
 *sfp, unsigned int pin,
  }
  EXPORT_SYMBOL_GPL(jh7110_set_gpiomux);


+static void jh7110_set_gpi(struct jh7110_pinctrl *sfp, u32 gpi, u32 val)

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +17 -0
+{
+       u32 offset, shift;
+       u32 reg_val;
+       const struct jh7110_pinctrl_soc_info *info = sfp->info;
+
+       offset = 4 * (gpi / 4);
+       shift  = 8 * (gpi % 4);
+
+       reg_val = readl_relaxed(sfp->base +
+                               info->gpi_reg_base + offset);
+       reg_val &= info->gpi_mask << shift;
+       reg_val |= (val & info->gpi_mask) << shift;
+
+       writel_relaxed(reg_val, sfp->base +
+                               info->gpi_reg_base + offset);
+}
+

 static int jh7110_set_mux(struct pinctrl_dev *pctldev, unsigned int fsel, unsigned int gsel) {

drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +1 -0
@@ -307,14 +325,23 @@ static int jh7110_set_mux(struct pinctrl_dev
 *pctldev,
         pinmux = group->data;
         for (i = 0; i < group->grp.npins; i++) {
                 u32 v = pinmux[i];
+               u32 pin = jh7110_pinmux_pin(v);


-               if (info->jh7110_set_one_pin_mux)
-                       info->jh7110_set_one_pin_mux(sfp, -                                       jh7110_pinmux_pin(v), -                                       jh7110_pinmux_din(v), -                                       jh7110_pinmux_dout(v), -                                       jh7110_pinmux_doen(v), -                                       jh7110_pinmux_function(v)); +               switch (pin) {
+               case PAD_INTERNAL_LOW:
+               case PAD_INTERNAL_HIGH:
+                       jh7110_set_gpi(sfp, jh7110_pinmux_din(v), +                                      pin == PAD_INTERNAL_HIGH); +                       break;
+               default:
+                       if (info->jh7110_set_one_pin_mux) +                               info->jh7110_set_one_pin_mux(sfp, +                                               jh7110_pinmux_pin(v), +                                               jh7110_pinmux_din(v), +                                               jh7110_pinmux_dout(v) ,
+                                               jh7110_pinmux_doen(v) ,
+                                               jh7110_pinmux_functio n(v));
+               }
        }

        return 0;

#17 lore raw

PATCH v2 3/3 riscv: dts: starfive: jh7110-pine64-star64: force no USB overcurrent

In reply to Icenowy Zheng

The Star64 board has no GPIOs to indicate USB overcurrent, however the USB controller would stop to work if the overcurrent_n signal it gets is low (which means overcurrent situations happening because of the _n).

Use the pin controller to force the overcurrent_n signal to be high in order to ensure stable behavior of the USB controller.

---
This patch depends on [1] for including the necessary header file.

[1] https://lore.kernel.org/linux-riscv/[email protected]/T/#u

 arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts +7 -0
index 31e825be2065a..4fb522d127e21 100644
@@ -91,6 +91,13 @@ GPOEN_ENABLE,
 			input-schmitt-disable;
 			slew-rate = <0>;
 		};
+
+		overcurrent-pins {
+			pinmux = <GPIOMUX(PAD_INTERNAL_HIGH,
+					  GPOUT_LOW,
+					  GPOEN_DISABLE,
+					  GPI_SYS_USB_OVERCURRENT)>;
+		};
 	};
 };
 
Signature · 1 line
2.49.0
#18 lore raw

Re: [PATCH v2 3/3] riscv: dts: starfive: jh7110-pine64-star64: force no USB overcurrent

kernel test robot noticed the following build errors:

Hi Icenowy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next robh/for-next linus/master v6.15-rc3 next-20250424] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Icenowy-Zheng/dt-bindings-pinctrl-starfive-jh7110-add-PAD_INTERNAL_-virtual-pins/20250424-142640
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20250424062154.655128-1-uwu%40icenowy.me
patch subject: [PATCH v2 3/3] riscv: dts: starfive: jh7110-pine64-star64: force no USB overcurrent
config: riscv-randconfig-001-20250425 (https://download.01.org/0day-ci/archive/20250425/[email protected]/config)
compiler: riscv32-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250425/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> Error: arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts:96.87-88 syntax error

FATAL ERROR: Unable to parse input tree

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki