X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fgpio%2Fomap_gpio.c;h=651f6994e41a6a609add5c9eb82964212ae2b576;hb=1703fbefd9183fffd76f4744a73f5ca9daef6313;hp=559f29b8018ce832253b484e9d2330c1a183cd24;hpb=b0af10443afcb9e0dcfe18a7b8a013b230df9e39;p=u-boot diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index 559f29b801..651f6994e4 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2009 Wind River Systems, Inc. * Tom Rix * - * SPDX-License-Identifier: GPL-2.0 - * * This work is derived from the linux 2.6.27 kernel source * To fetch, use the kernel repository * git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git @@ -289,14 +288,21 @@ static int omap_gpio_probe(struct udevice *dev) struct gpio_bank *bank = dev_get_priv(dev); struct omap_gpio_platdata *plat = dev_get_platdata(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + int banknum; + char name[18], *str; - uc_priv->bank_name = plat->port_name; + banknum = plat->bank_index; + sprintf(name, "GPIO%d_", banknum + 1); + str = strdup(name); + if (!str) + return -ENOMEM; + uc_priv->bank_name = str; uc_priv->gpio_count = GPIO_PER_BANK; bank->base = (void *)plat->base; - return 0; } +#if !CONFIG_IS_ENABLED(OF_CONTROL) static int omap_gpio_bind(struct udevice *dev) { struct omap_gpio_platdata *plat = dev_get_platdata(dev); @@ -329,6 +335,7 @@ static int omap_gpio_bind(struct udevice *dev) return 0; } +#endif static const struct udevice_id omap_gpio_ids[] = { { .compatible = "ti,omap3-gpio" }, @@ -337,12 +344,33 @@ static const struct udevice_id omap_gpio_ids[] = { { } }; +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int omap_gpio_ofdata_to_platdata(struct udevice *dev) +{ + struct omap_gpio_platdata *plat = dev_get_platdata(dev); + fdt_addr_t addr; + + addr = devfdt_get_addr(dev); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; + + plat->base = addr; + return 0; +} +#endif + U_BOOT_DRIVER(gpio_omap) = { .name = "gpio_omap", .id = UCLASS_GPIO, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = of_match_ptr(omap_gpio_ofdata_to_platdata), + .bind = dm_scan_fdt_dev, + .platdata_auto_alloc_size = sizeof(struct omap_gpio_platdata), +#else + .bind = omap_gpio_bind, +#endif .ops = &gpio_omap_ops, .of_match = omap_gpio_ids, - .bind = omap_gpio_bind, .probe = omap_gpio_probe, .priv_auto_alloc_size = sizeof(struct gpio_bank), .flags = DM_FLAG_PRE_RELOC,