diff mbox series

[1/2] pinctrl: probe pinctrl drivers during post-bind

Message ID 20220506180140.141049-1-robert.marko@sartura.hr
State Accepted
Commit f9ec791b5e24378b71590877499f8683d5f54dac
Delegated to: Stefan Roese
Headers show
Series [1/2] pinctrl: probe pinctrl drivers during post-bind | expand

Commit Message

Robert Marko May 6, 2022, 6:01 p.m. UTC
Currently, pinctrl drivers only get probed if pinconf is actually being
used, however on SoC-s like Armada 3720 pinctrl driver is a also the GPIO
driver.

So, if the pinctrl driver doesn't get probed GPIO-s won't get registered
and thus they cannot be used.

This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s
and without them being registered networking won't work as it only has
one SFP slot and the TX disable GPIO is on the SB controller.

So, probe the pinctrl drivers using DM_FLAG_PROBE_AFTER_BIND like LED
uclass does.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
 drivers/pinctrl/pinctrl-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Pali Rohár May 7, 2022, 1:37 p.m. UTC | #1
On Friday 06 May 2022 20:01:39 Robert Marko wrote:
> Currently, pinctrl drivers only get probed if pinconf is actually being
> used, however on SoC-s like Armada 3720 pinctrl driver is a also the GPIO
> driver.
> 
> So, if the pinctrl driver doesn't get probed GPIO-s won't get registered
> and thus they cannot be used.
> 
> This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s
> and without them being registered networking won't work as it only has
> one SFP slot and the TX disable GPIO is on the SB controller.
> 
> So, probe the pinctrl drivers using DM_FLAG_PROBE_AFTER_BIND like LED
> uclass does.
> 
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>

Seems that there is no better solution.

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  drivers/pinctrl/pinctrl-uclass.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
> index 4462ed20e2..38ce2b5e0a 100644
> --- a/drivers/pinctrl/pinctrl-uclass.c
> +++ b/drivers/pinctrl/pinctrl-uclass.c
> @@ -402,6 +402,13 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
>  {
>  	const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
>  
> +	/*
> +	 * Make sure that the pinctrl driver gets probed after binding
> +	 * as some pinctrl drivers also register the GPIO driver during
> +	 * probe, and if they are not probed GPIO-s are not registered.
> +	 */
> +	dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
> +
>  	if (!ops) {
>  		dev_dbg(dev, "ops is not set.  Do not bind.\n");
>  		return -EINVAL;
> -- 
> 2.35.1
>
Stefan Roese May 16, 2022, 6:40 a.m. UTC | #2
On 06.05.22 20:01, Robert Marko wrote:
> Currently, pinctrl drivers only get probed if pinconf is actually being
> used, however on SoC-s like Armada 3720 pinctrl driver is a also the GPIO
> driver.
> 
> So, if the pinctrl driver doesn't get probed GPIO-s won't get registered
> and thus they cannot be used.
> 
> This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s
> and without them being registered networking won't work as it only has
> one SFP slot and the TX disable GPIO is on the SB controller.
> 
> So, probe the pinctrl drivers using DM_FLAG_PROBE_AFTER_BIND like LED
> uclass does.
> 
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   drivers/pinctrl/pinctrl-uclass.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
> index 4462ed20e2..38ce2b5e0a 100644
> --- a/drivers/pinctrl/pinctrl-uclass.c
> +++ b/drivers/pinctrl/pinctrl-uclass.c
> @@ -402,6 +402,13 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
>   {
>   	const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
>   
> +	/*
> +	 * Make sure that the pinctrl driver gets probed after binding
> +	 * as some pinctrl drivers also register the GPIO driver during
> +	 * probe, and if they are not probed GPIO-s are not registered.
> +	 */
> +	dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
> +
>   	if (!ops) {
>   		dev_dbg(dev, "ops is not set.  Do not bind.\n");
>   		return -EINVAL;

Viele Grüße,
Stefan Roese
Stefan Roese May 17, 2022, 7:54 a.m. UTC | #3
On 06.05.22 20:01, Robert Marko wrote:
> Currently, pinctrl drivers only get probed if pinconf is actually being
> used, however on SoC-s like Armada 3720 pinctrl driver is a also the GPIO
> driver.
> 
> So, if the pinctrl driver doesn't get probed GPIO-s won't get registered
> and thus they cannot be used.
> 
> This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s
> and without them being registered networking won't work as it only has
> one SFP slot and the TX disable GPIO is on the SB controller.
> 
> So, probe the pinctrl drivers using DM_FLAG_PROBE_AFTER_BIND like LED
> uclass does.
> 
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   drivers/pinctrl/pinctrl-uclass.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
> index 4462ed20e2..38ce2b5e0a 100644
> --- a/drivers/pinctrl/pinctrl-uclass.c
> +++ b/drivers/pinctrl/pinctrl-uclass.c
> @@ -402,6 +402,13 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
>   {
>   	const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
>   
> +	/*
> +	 * Make sure that the pinctrl driver gets probed after binding
> +	 * as some pinctrl drivers also register the GPIO driver during
> +	 * probe, and if they are not probed GPIO-s are not registered.
> +	 */
> +	dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
> +
>   	if (!ops) {
>   		dev_dbg(dev, "ops is not set.  Do not bind.\n");
>   		return -EINVAL;

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 4462ed20e2..38ce2b5e0a 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -402,6 +402,13 @@  static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
 {
 	const struct pinctrl_ops *ops = pinctrl_get_ops(dev);
 
+	/*
+	 * Make sure that the pinctrl driver gets probed after binding
+	 * as some pinctrl drivers also register the GPIO driver during
+	 * probe, and if they are not probed GPIO-s are not registered.
+	 */
+	dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	if (!ops) {
 		dev_dbg(dev, "ops is not set.  Do not bind.\n");
 		return -EINVAL;