[U-Boot] [PATCH 1/5] dm: gpio: add BCM6345 gpio driver
Simon Glass
sjg at chromium.org
Thu May 4 16:50:33 UTC 2017
Hi Alvaro,
On 3 May 2017 at 07:07, Álvaro Fernández Rojas <noltari at gmail.com> wrote:
> This driver is based on linux/arch/mips/bcm63xx/gpio.c, simplified to allow
> defining one or two independent banks for each Broadcom SoC.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
> ---
> drivers/gpio/Kconfig | 6 +++
> drivers/gpio/Makefile | 1 +
> drivers/gpio/bcm6345_gpio.c | 125 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 132 insertions(+)
> create mode 100644 drivers/gpio/bcm6345_gpio.c
Reviewed-by: Simon Glass <sjg at chromium.org>
[...]
> +static int bcm6345_gpio_probe(struct udevice *dev)
> +{
> + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> + struct bcm6345_gpio_priv *priv = dev_get_priv(dev);
> + fdt_addr_t data_addr, dirout_addr;
> + fdt_size_t data_size, dirout_size;
> +
> + dirout_addr = dev_get_addr_size_index(dev, 0, &dirout_size);
> + if (dirout_addr == FDT_ADDR_T_NONE)
> + return -EINVAL;
> +
> + data_addr = dev_get_addr_size_index(dev, 1, &data_size);
> + if (data_addr == FDT_ADDR_T_NONE)
> + return -EINVAL;
> +
> + priv->reg_data = ioremap(data_addr, data_size);
> + priv->reg_dirout = ioremap(dirout_addr, dirout_size);
> +
> + uc_priv->gpio_count = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
> + "ngpios", 32);
> + uc_priv->bank_name = strdup(dev->name);
I don't think you need strdup(). If you do want this, you should add a
remove() function to free it.
> +
> + return 0;
> +}
> +
> +static const struct udevice_id bcm6345_gpio_ids[] = {
> + { .compatible = "brcm,bcm6345-gpio" },
> + { /* sentinel */ }
> +};
> +
> +U_BOOT_DRIVER(bcm6345_gpio) = {
> + .name = "bcm6345-gpio",
> + .id = UCLASS_GPIO,
> + .of_match = bcm6345_gpio_ids,
> + .ops = &bcm6345_gpio_ops,
> + .probe = bcm6345_gpio_probe,
> + .priv_auto_alloc_size = sizeof(struct bcm6345_gpio_priv),
> +};
> --
> 2.1.4
>
More information about the U-Boot
mailing list