All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio
@ 2022-05-22 17:20 Andrei Lalaev
  2022-05-22 21:26 ` Andre Przywara
  0 siblings, 1 reply; 5+ messages in thread
From: Andrei Lalaev @ 2022-05-22 17:20 UTC (permalink / raw)
  To: wens, jernej.skrabec, samuel
  Cc: krzysztof.kozlowski+dt, robh+dt, devicetree, linux-sunxi, Andrei Lalaev

Without this property the next node can't be hogged:
&r_pio {
	test_hog {
		gpio-hog;
		gpios = <0 6 GPIO_ACTIVE_HIGH>;
		output-high;
	};
};
And the appropriate error message:
"requesting hog GPIO test_hog (chip 1f02c00.pinctrl, offset 6) failed, -517"

This problem occurs because the "pinctrl-sunxi" calls
"gpiochip_add_data" that parses "gpio-ranges"
(using "of_gpiochip_add_pin_range") and registers hogs
(using "of_gpiochip_scan_gpios").
So when the gpiolib tries to register hogs it can't find any ranges and
fails.

Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index d7e9f977f986..4193bf962b7d 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -404,6 +404,9 @@ pio: pinctrl@1c20800 {
 			#gpio-cells = <3>;
 			interrupt-controller;
 			#interrupt-cells = <3>;
+			gpio-ranges = <&pio 0 0 22>, <&pio 64 64 17>,
+				      <&pio 96 96 18>, <&pio 128 128 16>,
+				      <&pio 160 160 7>, <&pio 192 192 14>;
 
 			csi_pins: csi-pins {
 				pins = "PE0", "PE2", "PE3", "PE4", "PE5",
@@ -937,6 +940,7 @@ r_pio: pinctrl@1f02c00 {
 			#gpio-cells = <3>;
 			interrupt-controller;
 			#interrupt-cells = <3>;
+			gpio-ranges = <&r_pio 0 352 12>;
 
 			r_ir_rx_pin: r-ir-rx-pin {
 				pins = "PL11";
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio
  2022-05-22 17:20 [PATCH] arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio Andrei Lalaev
@ 2022-05-22 21:26 ` Andre Przywara
  2022-05-23  5:55   ` Andrei Lalaev
  2022-05-23 19:19   ` Andrei Lalaev
  0 siblings, 2 replies; 5+ messages in thread
From: Andre Przywara @ 2022-05-22 21:26 UTC (permalink / raw)
  To: Andrei Lalaev
  Cc: wens, jernej.skrabec, samuel, krzysztof.kozlowski+dt, robh+dt,
	devicetree, linux-sunxi

On Sun, 22 May 2022 20:20:19 +0300
Andrei Lalaev <andrey.lalaev@gmail.com> wrote:

> Without this property the next node can't be hogged:
> &r_pio {
> 	test_hog {
> 		gpio-hog;
> 		gpios = <0 6 GPIO_ACTIVE_HIGH>;
> 		output-high;
> 	};
> };
> And the appropriate error message:
> "requesting hog GPIO test_hog (chip 1f02c00.pinctrl, offset 6) failed, -517"
> 
> This problem occurs because the "pinctrl-sunxi" calls
> "gpiochip_add_data" that parses "gpio-ranges"
> (using "of_gpiochip_add_pin_range") and registers hogs
> (using "of_gpiochip_scan_gpios").
> So when the gpiolib tries to register hogs it can't find any ranges and
> fails.
> 
> Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
> ---
>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> index d7e9f977f986..4193bf962b7d 100644
> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> @@ -404,6 +404,9 @@ pio: pinctrl@1c20800 {
>  			#gpio-cells = <3>;
>  			interrupt-controller;
>  			#interrupt-cells = <3>;
> +			gpio-ranges = <&pio 0 0 22>, <&pio 64 64 17>,
> +				      <&pio 96 96 18>, <&pio 128 128 16>,
> +				      <&pio 160 160 7>, <&pio 192 192 14>;

But this is somewhat redundant information, because the pinctrl driver
knows about those values, as they are derived from the big struct
sunxi_desc_pin definition.
So wouldn't it be smarter to put a call to
gpiochip_add_pingroup_range() somewhere into the sunxi pinctrl driver,
so that it would automatically work for all SoCs?

Cheers,
Andre

>  
>  			csi_pins: csi-pins {
>  				pins = "PE0", "PE2", "PE3", "PE4", "PE5",
> @@ -937,6 +940,7 @@ r_pio: pinctrl@1f02c00 {
>  			#gpio-cells = <3>;
>  			interrupt-controller;
>  			#interrupt-cells = <3>;
> +			gpio-ranges = <&r_pio 0 352 12>;
>  
>  			r_ir_rx_pin: r-ir-rx-pin {
>  				pins = "PL11";


^ permalink raw reply	[flat|nested] 5+ messages in thread

* arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio
  2022-05-22 21:26 ` Andre Przywara
@ 2022-05-23  5:55   ` Andrei Lalaev
  2022-05-23 19:19   ` Andrei Lalaev
  1 sibling, 0 replies; 5+ messages in thread
From: Andrei Lalaev @ 2022-05-23  5:55 UTC (permalink / raw)
  To: andre.przywara
  Cc: wens, jernej.skrabec, samuel, krzysztof.kozlowski+dt, robh+dt,
	devicetree, linux-sunxi, Andrei Lalaev

On Sun, 22 May 2022 22:26:30 +0100
Andre Przywara <andre.przywara@arm.com> wrote:

> But this is somewhat redundant information, because the pinctrl driver
> knows about those values, as they are derived from the big struct
> sunxi_desc_pin definition.
> So wouldn't it be smarter to put a call to
> gpiochip_add_pingroup_range() somewhere into the sunxi pinctrl driver,
> so that it would automatically work for all SoCs?

Sorry, I forgot about the other SoCs. I completely agree with you now.
I will try to fix it in another way.

Thank you, Andre!

Best regards,
Andrei Lalaev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio
  2022-05-22 21:26 ` Andre Przywara
  2022-05-23  5:55   ` Andrei Lalaev
@ 2022-05-23 19:19   ` Andrei Lalaev
  2022-07-05  4:28     ` Samuel Holland
  1 sibling, 1 reply; 5+ messages in thread
From: Andrei Lalaev @ 2022-05-23 19:19 UTC (permalink / raw)
  To: andre.przywara
  Cc: wens, jernej.skrabec, samuel, krzysztof.kozlowski+dt, robh+dt,
	devicetree, linux-sunxi, Andrei Lalaev

Andre, I checked the gpiolib API and didn't find any function I can
use to register gpio-hogs specified in DTS.
But I found the similar patch to the qcom driver. Could you please check it?
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20180412190138.12372-1-chunkeey@gmail.com/

What do you think about it? Is it a good idea to impelement
the same changes in "sunxi-pinctrl" driver?

Best regards,
Andrei Lalaev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio
  2022-05-23 19:19   ` Andrei Lalaev
@ 2022-07-05  4:28     ` Samuel Holland
  0 siblings, 0 replies; 5+ messages in thread
From: Samuel Holland @ 2022-07-05  4:28 UTC (permalink / raw)
  To: Andrei Lalaev, andre.przywara
  Cc: wens, jernej.skrabec, krzysztof.kozlowski+dt, robh+dt,
	devicetree, linux-sunxi

Hi Andrei,

On 5/23/22 2:19 PM, Andrei Lalaev wrote:
> Andre, I checked the gpiolib API and didn't find any function I can
> use to register gpio-hogs specified in DTS.
> But I found the similar patch to the qcom driver. Could you please check it?
> https://patchwork.kernel.org/project/linux-arm-kernel/patch/20180412190138.12372-1-chunkeey@gmail.com/
> 
> What do you think about it? Is it a good idea to impelement
> the same changes in "sunxi-pinctrl" driver?

Yes, those are exactly the kind of changes we need.

Regards,
Samuel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-05  4:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22 17:20 [PATCH] arm: dts: sunxi: h3/h5: add gpio-ranges for pio and r_pio Andrei Lalaev
2022-05-22 21:26 ` Andre Przywara
2022-05-23  5:55   ` Andrei Lalaev
2022-05-23 19:19   ` Andrei Lalaev
2022-07-05  4:28     ` Samuel Holland

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.