Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / drivers / core / device.c
index 483f8368f706b3d402299fd0902c475dbc39dc6c..9a46a7bbe5e9dea953629413f35809d92def751e 100644 (file)
@@ -19,6 +19,7 @@
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <dm/platdata.h>
+#include <dm/read.h>
 #include <dm/uclass.h>
 #include <dm/uclass-internal.h>
 #include <dm/util.h>
@@ -29,7 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static int device_bind_common(struct udevice *parent, const struct driver *drv,
                              const char *name, void *platdata,
-                             ulong driver_data, int of_offset,
+                             ulong driver_data, ofnode node,
                              uint of_platdata_size, struct udevice **devp)
 {
        struct udevice *dev;
@@ -60,7 +61,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
        dev->platdata = platdata;
        dev->driver_data = driver_data;
        dev->name = name;
-       dev->of_offset = of_offset;
+       dev->node = node;
        dev->parent = parent;
        dev->driver = drv;
        dev->uclass = uc;
@@ -76,10 +77,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
                 * resolved (and ->seq updated) when the device is probed.
                 */
                if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
-                       if (uc->uc_drv->name && of_offset != -1) {
-                               fdtdec_get_alias_seq(gd->fdt_blob,
-                                               uc->uc_drv->name, of_offset,
-                                               &dev->req_seq);
+                       if (uc->uc_drv->name && ofnode_valid(node)) {
+                               dev_read_alias_seq(dev, &dev->req_seq);
                        }
                }
        }
@@ -162,7 +161,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
        }
 
        if (parent)
-               dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
+               pr_debug("Bound device %s to %s\n", dev->name, parent->name);
        if (devp)
                *devp = dev;
 
@@ -215,19 +214,19 @@ fail_alloc1:
 
 int device_bind_with_driver_data(struct udevice *parent,
                                 const struct driver *drv, const char *name,
-                                ulong driver_data, int of_offset,
+                                ulong driver_data, ofnode node,
                                 struct udevice **devp)
 {
-       return device_bind_common(parent, drv, name, NULL, driver_data,
-                                 of_offset, 0, devp);
+       return device_bind_common(parent, drv, name, NULL, driver_data, node,
+                                 0, devp);
 }
 
 int device_bind(struct udevice *parent, const struct driver *drv,
                const char *name, void *platdata, int of_offset,
                struct udevice **devp)
 {
-       return device_bind_common(parent, drv, name, platdata, 0, of_offset, 0,
-                                 devp);
+       return device_bind_common(parent, drv, name, platdata, 0,
+                                 offset_to_ofnode(of_offset), 0, devp);
 }
 
 int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
@@ -246,7 +245,8 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
        platdata_size = info->platdata_size;
 #endif
        return device_bind_common(parent, drv, info->name,
-                       (void *)info->platdata, 0, -1, platdata_size, devp);
+                       (void *)info->platdata, 0, ofnode_null(), platdata_size,
+                       devp);
 }
 
 static void *alloc_priv(int size, uint flags)
@@ -254,6 +254,7 @@ static void *alloc_priv(int size, uint flags)
        void *priv;
 
        if (flags & DM_FLAG_ALLOC_PRIV_DMA) {
+               size = ROUND(size, ARCH_DMA_MINALIGN);
                priv = memalign(ARCH_DMA_MINALIGN, size);
                if (priv) {
                        memset(priv, '\0', size);
@@ -383,7 +384,7 @@ int device_probe(struct udevice *dev)
                        goto fail;
        }
 
-       if (drv->ofdata_to_platdata && dev_of_offset(dev) >= 0) {
+       if (drv->ofdata_to_platdata && dev_has_of_node(dev)) {
                ret = drv->ofdata_to_platdata(dev);
                if (ret)
                        goto fail;
@@ -699,7 +700,7 @@ int device_set_name(struct udevice *dev, const char *name)
        return 0;
 }
 
-bool of_device_is_compatible(struct udevice *dev, const char *compat)
+bool device_is_compatible(struct udevice *dev, const char *compat)
 {
        const void *fdt = gd->fdt_blob;