X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fgpio%2Fomap_gpio.c;h=559f29b8018ce832253b484e9d2330c1a183cd24;hb=8e14ba7bd524;hp=cd960dc013f0f128be8d625aab83996e3863eb65;hpb=7c0e5d865ff0b86dfce492b656238919c659d756;p=u-boot diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index cd960dc013..559f29b801 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -299,28 +299,32 @@ static int omap_gpio_probe(struct udevice *dev) static int omap_gpio_bind(struct udevice *dev) { - struct omap_gpio_platdata *plat = dev->platdata; + struct omap_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t base_addr; if (plat) return 0; - base_addr = dev_get_addr(dev); + base_addr = devfdt_get_addr(dev); if (base_addr == FDT_ADDR_T_NONE) - return -ENODEV; + return -EINVAL; /* * TODO: * When every board is converted to driver model and DT is * supported, this can be done by auto-alloc feature, but * not using calloc to alloc memory for platdata. + * + * For example am33xx_gpio uses platform data rather than device tree. + * + * NOTE: DO NOT COPY this code if you are using device tree. */ plat = calloc(1, sizeof(*plat)); if (!plat) return -ENOMEM; plat->base = base_addr; - plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL); + plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); dev->platdata = plat; return 0; @@ -341,6 +345,7 @@ U_BOOT_DRIVER(gpio_omap) = { .bind = omap_gpio_bind, .probe = omap_gpio_probe, .priv_auto_alloc_size = sizeof(struct gpio_bank), + .flags = DM_FLAG_PRE_RELOC, }; #endif /* CONFIG_DM_GPIO */