Merge tag 'u-boot-imx-20191209' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[oweals/u-boot.git] / drivers / core / simple-bus.c
index 5c955da3346b2c1ff665060100b2f875a87cbe50..7fc23ef82d8822a04f5c2070c2a96f9b387d1f3d 100644 (file)
@@ -1,14 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2014 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 struct simple_bus_plat {
        u32 base;
        u32 size;
@@ -27,11 +24,13 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr)
 
 static int simple_bus_post_bind(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       return 0;
+#else
        u32 cell[3];
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "ranges",
-                                  cell, ARRAY_SIZE(cell));
+       ret = dev_read_u32_array(dev, "ranges", cell, ARRAY_SIZE(cell));
        if (!ret) {
                struct simple_bus_plat *plat = dev_get_uclass_platdata(dev);
 
@@ -41,6 +40,7 @@ static int simple_bus_post_bind(struct udevice *dev)
        }
 
        return dm_scan_fdt_dev(dev);
+#endif
 }
 
 UCLASS_DRIVER(simple_bus) = {
@@ -60,4 +60,5 @@ U_BOOT_DRIVER(simple_bus_drv) = {
        .name   = "generic_simple_bus",
        .id     = UCLASS_SIMPLE_BUS,
        .of_match = generic_simple_bus_ids,
+       .flags  = DM_FLAG_PRE_RELOC,
 };