diff mbox series

[U-Boot,v1,1/3] gpio: dwapb_gpio: fix binding without bank-name property

Message ID 20181029192533.9118-2-simon.k.r.goldschmidt@gmail.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series dts: arm: socfpga: merge gen5 devicetrees from linux | expand

Commit Message

Simon Goldschmidt Oct. 29, 2018, 7:25 p.m. UTC
As a preparation for merging the socfpga gen5 devicetree files
from Linux, this patch makes the dwapb gpio driver work correctly
without the 'bank-name' property on the gpio-controller nodes.

This property is not present in the Linux drivers and thus is not
present in the Linux devicetrees. It is only used to access pins
via bank name.

This fallback is necessary since without it, the driver will
return an error code which will lead to an error in U-Boot
startup.

The bank names will still be added to the default board device
trees in follow-up patch, but other boards using this driver and
not including the bank name should also work with the socfpga.dtsi
without adding the bank-name property.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 drivers/gpio/dwapb_gpio.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Marek Vasut Oct. 30, 2018, 9:38 p.m. UTC | #1
On 10/29/2018 08:25 PM, Simon Goldschmidt wrote:
> As a preparation for merging the socfpga gen5 devicetree files
> from Linux, this patch makes the dwapb gpio driver work correctly
> without the 'bank-name' property on the gpio-controller nodes.
> 
> This property is not present in the Linux drivers and thus is not
> present in the Linux devicetrees. It is only used to access pins
> via bank name.
> 
> This fallback is necessary since without it, the driver will
> return an error code which will lead to an error in U-Boot
> startup.
> 
> The bank names will still be added to the default board device
> trees in follow-up patch, but other boards using this driver and
> not including the bank name should also work with the socfpga.dtsi
> without adding the bank-name property.
> 
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> ---
> 
>  drivers/gpio/dwapb_gpio.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index 68836a7902..e55fb4ac73 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -180,6 +180,13 @@ static int gpio_dwapb_bind(struct udevice *dev)
>  		plat->pins = fdtdec_get_int(blob, node, "snps,nr-gpios", 0);
>  		plat->name = fdt_stringlist_get(blob, node, "bank-name", 0,
>  						NULL);
> +		if (!plat->name) {
> +			/*
> +			 * Fall back to node name. This means accessing pins
> +			 * via bank name won't work.
> +			 */
> +			plat->name = fdt_get_name(blob, node, NULL);
> +		}
>  
>  		ret = device_bind(dev, dev->driver, plat->name,
>  				  plat, -1, &subdev);
> 
Acked-by: Marek Vasut <marex@denx.de>
diff mbox series

Patch

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 68836a7902..e55fb4ac73 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -180,6 +180,13 @@  static int gpio_dwapb_bind(struct udevice *dev)
 		plat->pins = fdtdec_get_int(blob, node, "snps,nr-gpios", 0);
 		plat->name = fdt_stringlist_get(blob, node, "bank-name", 0,
 						NULL);
+		if (!plat->name) {
+			/*
+			 * Fall back to node name. This means accessing pins
+			 * via bank name won't work.
+			 */
+			plat->name = fdt_get_name(blob, node, NULL);
+		}
 
 		ret = device_bind(dev, dev->driver, plat->name,
 				  plat, -1, &subdev);