]> git.sur5r.net Git - u-boot/blobdiff - drivers/gpio/omap_gpio.c
mtd: nand: mxs_nand: use self init
[u-boot] / drivers / gpio / omap_gpio.c
index cd960dc013f0f128be8d625aab83996e3863eb65..d128f942a0681da211648e2cb55caa9f3ef16320 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2009 Wind River Systems, Inc.
  * Tom Rix <Tom.Rix@windriver.com>
  *
- * 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
@@ -23,7 +22,7 @@
 #include <fdtdec.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <malloc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -299,28 +298,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 +344,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 */