diff mbox series

pinctrl: single: Fix probe failure getting register area size

Message ID 20210507091034.8496-1-vigneshr@ti.com
State Accepted
Commit 1e7879045f6c20f68ce2c6fcce7ec187e8844b51
Delegated to: Tom Rini
Headers show
Series pinctrl: single: Fix probe failure getting register area size | expand

Commit Message

Raghavendra, Vignesh May 7, 2021, 9:10 a.m. UTC
If reg property of pinctrl-single node requires address translation then
probe fails with following message:

single-pinctrl pinctrl@4301c000: failed to get base register size

This is because driver uses dev_read_addr_size() to get size which also
tries to fetch untranslated addr and fails.
Fix this by using dev_read_addr_size_index() which takes care of address
translation and also makes following dev_read_addr() call redundant.

This fixes Ethernet failures on TI's AM654 based EVMs due to lack of
pinmux configuration.

Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API")
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/pinctrl/pinctrl-single.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Tom Rini May 17, 2021, 8:15 p.m. UTC | #1
On Fri, May 07, 2021 at 02:40:34PM +0530, Vignesh Raghavendra wrote:

> If reg property of pinctrl-single node requires address translation then
> probe fails with following message:
> 
> single-pinctrl pinctrl@4301c000: failed to get base register size
> 
> This is because driver uses dev_read_addr_size() to get size which also
> tries to fetch untranslated addr and fails.
> Fix this by using dev_read_addr_size_index() which takes care of address
> translation and also makes following dev_read_addr() call redundant.
> 
> This fixes Ethernet failures on TI's AM654 based EVMs due to lack of
> pinmux configuration.
> 
> Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API")
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index ebb7602dde..7af6c5f0b0 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -509,19 +509,13 @@ static int single_of_to_plat(struct udevice *dev)
>  		return -EINVAL;
>  	}
>  
> -	addr = dev_read_addr_size(dev, "reg", &size);
> +	addr = dev_read_addr_size_index(dev, 0, &size);
>  	if (addr == FDT_ADDR_T_NONE) {
> -		dev_err(dev, "failed to get base register size\n");
> +		dev_err(dev, "failed to get base register address\n");
>  		return -EINVAL;
>  	}
>  
>  	pdata->offset = size - pdata->width / BITS_PER_BYTE;
> -
> -	addr = dev_read_addr(dev);
> -	if (addr == FDT_ADDR_T_NONE) {
> -		dev_dbg(dev, "no valid base register address\n");
> -		return -EINVAL;
> -	}
>  	pdata->base = addr;
>  
>  	ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask);

Dario, since this has a fixes tag for a commit of yours, comments?
Thanks!
Dario Binacchi May 18, 2021, 4:16 p.m. UTC | #2
Hi,

> Il 17/05/2021 22:15 Tom Rini <trini@konsulko.com> ha scritto:
> 
>  
> On Fri, May 07, 2021 at 02:40:34PM +0530, Vignesh Raghavendra wrote:
> 
> > If reg property of pinctrl-single node requires address translation then
> > probe fails with following message:
> > 
> > single-pinctrl pinctrl@4301c000: failed to get base register size
> > 
> > This is because driver uses dev_read_addr_size() to get size which also
> > tries to fetch untranslated addr and fails.
> > Fix this by using dev_read_addr_size_index() which takes care of address
> > translation and also makes following dev_read_addr() call redundant.
> > 
> > This fixes Ethernet failures on TI's AM654 based EVMs due to lack of
> > pinmux configuration.
> > 
> > Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API")
> > Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> > ---
> >  drivers/pinctrl/pinctrl-single.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> > index ebb7602dde..7af6c5f0b0 100644
> > --- a/drivers/pinctrl/pinctrl-single.c
> > +++ b/drivers/pinctrl/pinctrl-single.c
> > @@ -509,19 +509,13 @@ static int single_of_to_plat(struct udevice *dev)
> >  		return -EINVAL;
> >  	}
> >  
> > -	addr = dev_read_addr_size(dev, "reg", &size);
> > +	addr = dev_read_addr_size_index(dev, 0, &size);
> >  	if (addr == FDT_ADDR_T_NONE) {
> > -		dev_err(dev, "failed to get base register size\n");
> > +		dev_err(dev, "failed to get base register address\n");
> >  		return -EINVAL;
> >  	}
> >  
> >  	pdata->offset = size - pdata->width / BITS_PER_BYTE;
> > -
> > -	addr = dev_read_addr(dev);
> > -	if (addr == FDT_ADDR_T_NONE) {
> > -		dev_dbg(dev, "no valid base register address\n");
> > -		return -EINVAL;
> > -	}
> >  	pdata->base = addr;
> >  
> >  	ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask);
> 
> Dario, since this has a fixes tag for a commit of yours, comments?
> Thanks!
> 

I applied the patch and tested it on my beaglebone black. 
It is OK. As well the tests I had developed in the sandbox configuration for pinmux passed.

Thanks and regards,
Dario

> -- 
> Tom
Tom Rini May 27, 2021, 11:41 a.m. UTC | #3
On Fri, May 07, 2021 at 02:40:34PM +0530, Vignesh Raghavendra wrote:

> If reg property of pinctrl-single node requires address translation then
> probe fails with following message:
> 
> single-pinctrl pinctrl@4301c000: failed to get base register size
> 
> This is because driver uses dev_read_addr_size() to get size which also
> tries to fetch untranslated addr and fails.
> Fix this by using dev_read_addr_size_index() which takes care of address
> translation and also makes following dev_read_addr() call redundant.
> 
> This fixes Ethernet failures on TI's AM654 based EVMs due to lack of
> pinmux configuration.
> 
> Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API")
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index ebb7602dde..7af6c5f0b0 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -509,19 +509,13 @@  static int single_of_to_plat(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	addr = dev_read_addr_size(dev, "reg", &size);
+	addr = dev_read_addr_size_index(dev, 0, &size);
 	if (addr == FDT_ADDR_T_NONE) {
-		dev_err(dev, "failed to get base register size\n");
+		dev_err(dev, "failed to get base register address\n");
 		return -EINVAL;
 	}
 
 	pdata->offset = size - pdata->width / BITS_PER_BYTE;
-
-	addr = dev_read_addr(dev);
-	if (addr == FDT_ADDR_T_NONE) {
-		dev_dbg(dev, "no valid base register address\n");
-		return -EINVAL;
-	}
 	pdata->base = addr;
 
 	ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask);