diff options
author | Michal Simek <michal.simek@xilinx.com> | 2018-08-02 12:58:54 +0200 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2018-08-07 11:03:43 +0200 |
commit | 312dd1c55cbb4f090a1f3ba25709779550c0f50c (patch) | |
tree | 1933b98dbb10071de43b38887b03416e470493c5 /drivers | |
parent | ac7f061398ba48904e2900f1f9df93f35f5c88c8 (diff) | |
download | u-boot-312dd1c55cbb4f090a1f3ba25709779550c0f50c.tar.gz u-boot-312dd1c55cbb4f090a1f3ba25709779550c0f50c.tar.xz u-boot-312dd1c55cbb4f090a1f3ba25709779550c0f50c.zip |
gpio: xilinx: Add support for using label property
Add support for reading label property from DT and set up bank name
based on that. If label property is not present full device node name is
used.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/xilinx_gpio.c | 10 | ||||
-rw-r--r-- | drivers/gpio/zynq_gpio.c | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c index fc460c343e..2389abee37 100644 --- a/drivers/gpio/xilinx_gpio.c +++ b/drivers/gpio/xilinx_gpio.c @@ -241,8 +241,16 @@ static int xilinx_gpio_probe(struct udevice *dev) struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); struct xilinx_gpio_privdata *priv = dev_get_priv(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + const void *label_ptr; - uc_priv->bank_name = dev->name; + label_ptr = dev_read_prop(dev, "label", NULL); + if (label_ptr) { + uc_priv->bank_name = strdup(label_ptr); + if (!uc_priv->bank_name) + return -ENOMEM; + } else { + uc_priv->bank_name = dev->name; + } uc_priv->gpio_count = platdata->bank_max[0] + platdata->bank_max[1]; diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c index 6fbaafb3fa..55a5cba068 100644 --- a/drivers/gpio/zynq_gpio.c +++ b/drivers/gpio/zynq_gpio.c @@ -336,8 +336,16 @@ static int zynq_gpio_probe(struct udevice *dev) { struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + const void *label_ptr; - uc_priv->bank_name = dev->name; + label_ptr = dev_read_prop(dev, "label", NULL); + if (label_ptr) { + uc_priv->bank_name = strdup(label_ptr); + if (!uc_priv->bank_name) + return -ENOMEM; + } else { + uc_priv->bank_name = dev->name; + } if (platdata->p_data) uc_priv->gpio_count = platdata->p_data->ngpio; |