summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-09-30 18:16:51 -0400
committerTom Rini <trini@konsulko.com>2018-09-30 18:16:51 -0400
commitd24c1d0f4da3b081a4fedf7ae2a08790871f08d0 (patch)
tree30051c24000bbb640b6296c8a71a8e05f0cc06e4 /drivers
parent2c1e16b9d2e3a6138acf4ffd9866e47ddbe6d453 (diff)
parent31b8217e83a63d1c8c70edcdcdf5aff3b1791640 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/board/Kconfig22
-rw-r--r--drivers/board/Makefile7
-rw-r--r--drivers/board/board-uclass.c60
-rw-r--r--drivers/board/gazerbeam.c262
-rw-r--r--drivers/board/gazerbeam.h18
-rw-r--r--drivers/board/sandbox.c107
-rw-r--r--drivers/board/sandbox.h12
-rw-r--r--drivers/core/device.c78
-rw-r--r--drivers/core/ofnode.c70
-rw-r--r--drivers/firmware/Kconfig2
-rw-r--r--drivers/firmware/Makefile1
-rw-r--r--drivers/firmware/firmware-sandbox.c20
-rw-r--r--drivers/firmware/firmware-uclass.c2
15 files changed, 662 insertions, 2 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9ac90c461f..11b88a1e1a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -24,6 +24,8 @@ source "drivers/ddr/Kconfig"
source "drivers/demo/Kconfig"
+source "drivers/board/Kconfig"
+
source "drivers/ddr/fsl/Kconfig"
source "drivers/dfu/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 1d5905fe73..091b5e8119 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -71,6 +71,7 @@ obj-y += ata/
obj-$(CONFIG_DM_DEMO) += demo/
obj-$(CONFIG_BIOSEMU) += bios_emulator/
obj-y += block/
+obj-y += board/
obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
obj-$(CONFIG_CPU) += cpu/
obj-y += crypto/
diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig
new file mode 100644
index 0000000000..2a3fc9c049
--- /dev/null
+++ b/drivers/board/Kconfig
@@ -0,0 +1,22 @@
+menuconfig BOARD
+ bool "Device Information"
+ help
+ Support methods to query hardware configurations from internal
+ mechanisms (e.g. reading GPIO values, determining the presence of
+ devices on busses, etc.). This enables the usage of U-Boot with
+ modular board architectures.
+
+if BOARD
+
+
+config BOARD_GAZERBEAM
+ bool "Enable board driver for the Gazerbeam board"
+ help
+ Support querying device information for the gdsys Gazerbeam board.
+
+config BOARD_SANDBOX
+ bool "Enable board driver for the Sandbox board"
+ help
+ Support querying device information for the Sandbox boards.
+
+endif
diff --git a/drivers/board/Makefile b/drivers/board/Makefile
new file mode 100644
index 0000000000..22243380af
--- /dev/null
+++ b/drivers/board/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2017
+# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+obj-$(CONFIG_BOARD) += board-uclass.o
+obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o
+obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o
diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
new file mode 100644
index 0000000000..a516ba4962
--- /dev/null
+++ b/drivers/board/board-uclass.c
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <board.h>
+
+int board_get(struct udevice **devp)
+{
+ return uclass_first_device_err(UCLASS_BOARD, devp);
+}
+
+int board_detect(struct udevice *dev)
+{
+ struct board_ops *ops = board_get_ops(dev);
+
+ if (!ops->detect)
+ return -ENOSYS;
+
+ return ops->detect(dev);
+}
+
+int board_get_bool(struct udevice *dev, int id, bool *val)
+{
+ struct board_ops *ops = board_get_ops(dev);
+
+ if (!ops->get_bool)
+ return -ENOSYS;
+
+ return ops->get_bool(dev, id, val);
+}
+
+int board_get_int(struct udevice *dev, int id, int *val)
+{
+ struct board_ops *ops = board_get_ops(dev);
+
+ if (!ops->get_int)
+ return -ENOSYS;
+
+ return ops->get_int(dev, id, val);
+}
+
+int board_get_str(struct udevice *dev, int id, size_t size, char *val)
+{
+ struct board_ops *ops = board_get_ops(dev);
+
+ if (!ops->get_str)
+ return -ENOSYS;
+
+ return ops->get_str(dev, id, size, val);
+}
+
+UCLASS_DRIVER(board) = {
+ .id = UCLASS_BOARD,
+ .name = "board",
+ .post_bind = dm_scan_fdt_dev,
+};
diff --git a/drivers/board/gazerbeam.c b/drivers/board/gazerbeam.c
new file mode 100644
index 0000000000..481cce8e80
--- /dev/null
+++ b/drivers/board/gazerbeam.c
@@ -0,0 +1,262 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <board.h>
+#include <i2c.h>
+#include <asm/gpio.h>
+
+#include "gazerbeam.h"
+
+/* Sequence number of I2C bus that holds the GPIO expanders */
+static const int I2C_BUS_SEQ_NO = 1;
+
+/* I2C address of SC/MC2 expander */
+static const int MC2_EXPANDER_ADDR = 0x20;
+/* I2C address of MC4 expander */
+static const int MC4_EXPANDER_ADDR = 0x22;
+
+/* Number of the GPIO to read the SC data from */
+static const int SC_GPIO_NO;
+/* Number of the GPIO to read the CON data from */
+static const int CON_GPIO_NO = 1;
+
+/**
+ * struct board_gazerbeam_priv - Private data structure for the gazerbeam board
+ * driver.
+ * @reset_gpios: GPIOs for the board's reset GPIOs.
+ * @var_gpios: GPIOs for the board's hardware variant GPIOs
+ * @ver_gpios: GPIOs for the board's hardware version GPIOs
+ * @variant: Container for the board's hardware variant (CON/CPU)
+ * @multichannel: Container for the board's multichannel variant (MC4/MC2/SC)
+ * @hwversion: Container for the board's hardware version
+ */
+struct board_gazerbeam_priv {
+ struct gpio_desc reset_gpios[2];
+ struct gpio_desc var_gpios[2];
+ struct gpio_desc ver_gpios[4];
+ int variant;
+ int multichannel;
+ int hwversion;
+};
+
+/**
+ * _read_board_variant_data() - Read variant information from the hardware.
+ * @dev: The board device for which to determine the multichannel and device
+ * type information.
+ *
+ * The data read from the board's hardware (mostly hard-wired GPIOs) is stored
+ * in the private data structure of the driver to be used by other driver
+ * methods.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+static int _read_board_variant_data(struct udevice *dev)
+{
+ struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+ struct udevice *i2c_bus;
+ struct udevice *dummy;
+ char *listname;
+ int mc4, mc2, sc, con;
+ int gpio_num;
+ int res;
+
+ res = uclass_get_device_by_seq(UCLASS_I2C, I2C_BUS_SEQ_NO, &i2c_bus);
+ if (res) {
+ debug("%s: Could not get I2C bus %d (err = %d)\n",
+ dev->name, I2C_BUS_SEQ_NO, res);
+ return res;
+ }
+
+ if (!i2c_bus) {
+ debug("%s: Could not get I2C bus %d\n",
+ dev->name, I2C_BUS_SEQ_NO);
+ return -EIO;
+ }
+
+ mc2 = !dm_i2c_probe(i2c_bus, MC2_EXPANDER_ADDR, 0, &dummy);
+ mc4 = !dm_i2c_probe(i2c_bus, MC4_EXPANDER_ADDR, 0, &dummy);
+
+ if (mc2 && mc4) {
+ debug("%s: Board hardware configuration inconsistent.\n",
+ dev->name);
+ return -EINVAL;
+ }
+
+ listname = mc2 ? "var-gpios-mc2" : "var-gpios-mc4";
+
+ gpio_num = gpio_request_list_by_name(dev, listname, priv->var_gpios,
+ ARRAY_SIZE(priv->var_gpios),
+ GPIOD_IS_IN);
+ if (gpio_num < 0) {
+ debug("%s: Requesting gpio list %s failed (err = %d).\n",
+ dev->name, listname, gpio_num);
+ return gpio_num;
+ }
+
+ sc = dm_gpio_get_value(&priv->var_gpios[SC_GPIO_NO]);
+ if (sc < 0) {
+ debug("%s: Error while reading 'sc' GPIO (err = %d)",
+ dev->name, sc);
+ return sc;
+ }
+
+ con = dm_gpio_get_value(&priv->var_gpios[CON_GPIO_NO]);
+ if (con < 0) {
+ debug("%s: Error while reading 'con' GPIO (err = %d)",
+ dev->name, con);
+ return con;
+ }
+
+ if ((sc && mc2) || (sc && mc4) || (!sc && !mc2 && !mc4)) {
+ debug("%s: Board hardware configuration inconsistent.\n",
+ dev->name);
+ return -EINVAL;
+ }
+
+ priv->variant = con ? VAR_CON : VAR_CPU;
+
+ priv->multichannel = mc4 ? 4 : (mc2 ? 2 : (sc ? 1 : 0));
+
+ return 0;
+}
+
+/**
+ * _read_hwversion() - Read the hardware version from the board.
+ * @dev: The board device for which to read the hardware version.
+ *
+ * The hardware version read from the board (from hard-wired GPIOs) is stored
+ * in the private data structure of the driver to be used by other driver
+ * methods.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+static int _read_hwversion(struct udevice *dev)
+{
+ struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+ int res;
+
+ res = gpio_request_list_by_name(dev, "ver-gpios", priv->ver_gpios,
+ ARRAY_SIZE(priv->ver_gpios),
+ GPIOD_IS_IN);
+ if (res < 0) {
+ debug("%s: Error getting GPIO list 'ver-gpios' (err = %d)\n",
+ dev->name, res);
+ return -ENODEV;
+ }
+
+ res = dm_gpio_get_values_as_int(priv->ver_gpios,
+ ARRAY_SIZE(priv->ver_gpios));
+ if (res < 0) {
+ debug("%s: Error reading HW version from expander (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ priv->hwversion = res;
+
+ res = gpio_free_list(dev, priv->ver_gpios, ARRAY_SIZE(priv->ver_gpios));
+ if (res < 0) {
+ debug("%s: Error freeing HW version GPIO list (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ return 0;
+}
+
+static int board_gazerbeam_detect(struct udevice *dev)
+{
+ int res;
+
+ res = _read_board_variant_data(dev);
+ if (res) {
+ debug("%s: Error reading multichannel variant (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ res = _read_hwversion(dev);
+ if (res) {
+ debug("%s: Error reading hardware version (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ return 0;
+}
+
+static int board_gazerbeam_get_int(struct udevice *dev, int id, int *val)
+{
+ struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case BOARD_MULTICHANNEL:
+ *val = priv->multichannel;
+ break;
+ case BOARD_VARIANT:
+ *val = priv->variant;
+ break;
+ case BOARD_HWVERSION:
+ *val = priv->hwversion;
+ break;
+ default:
+ debug("%s: Integer value %d unknown\n", dev->name, id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct udevice_id board_gazerbeam_ids[] = {
+ { .compatible = "gdsys,board_gazerbeam" },
+ { /* sentinel */ }
+};
+
+static const struct board_ops board_gazerbeam_ops = {
+ .detect = board_gazerbeam_detect,
+ .get_int = board_gazerbeam_get_int,
+};
+
+static int board_gazerbeam_probe(struct udevice *dev)
+{
+ struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+ int gpio_num, i;
+
+ gpio_num = gpio_request_list_by_name(dev, "reset-gpios",
+ priv->reset_gpios,
+ ARRAY_SIZE(priv->reset_gpios),
+ GPIOD_IS_OUT);
+
+ if (gpio_num < 0) {
+ debug("%s: Error getting GPIO list 'reset-gpios' (err = %d)\n",
+ dev->name, gpio_num);
+ return gpio_num;
+ }
+
+ /* Set startup-finished GPIOs */
+ for (i = 0; i < ARRAY_SIZE(priv->reset_gpios); i++) {
+ int res = dm_gpio_set_value(&priv->reset_gpios[i], 0);
+
+ if (res) {
+ debug("%s: Error while setting GPIO %d (err = %d)\n",
+ dev->name, i, res);
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+U_BOOT_DRIVER(board_gazerbeam) = {
+ .name = "board_gazerbeam",
+ .id = UCLASS_BOARD,
+ .of_match = board_gazerbeam_ids,
+ .ops = &board_gazerbeam_ops,
+ .priv_auto_alloc_size = sizeof(struct board_gazerbeam_priv),
+ .probe = board_gazerbeam_probe,
+};
diff --git a/drivers/board/gazerbeam.h b/drivers/board/gazerbeam.h
new file mode 100644
index 0000000000..0ca003a373
--- /dev/null
+++ b/drivers/board/gazerbeam.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+enum {
+ BOARD_MULTICHANNEL,
+ BOARD_VARIANT,
+ BOARD_HWVERSION,
+};
+
+enum {
+ VAR_CON,
+ VAR_CPU,
+};
diff --git a/drivers/board/sandbox.c b/drivers/board/sandbox.c
new file mode 100644
index 0000000000..50621e47a4
--- /dev/null
+++ b/drivers/board/sandbox.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <board.h>
+
+#include "sandbox.h"
+
+struct board_sandbox_priv {
+ bool called_detect;
+ int test_i1;
+ int test_i2;
+};
+
+char vacation_spots[][64] = {"R'lyeh", "Dreamlands", "Plateau of Leng",
+ "Carcosa", "Yuggoth", "The Nameless City"};
+
+int board_sandbox_detect(struct udevice *dev)
+{
+ struct board_sandbox_priv *priv = dev_get_priv(dev);
+
+ priv->called_detect = true;
+ priv->test_i2 = 100;
+
+ return 0;
+}
+
+int board_sandbox_get_bool(struct udevice *dev, int id, bool *val)
+{
+ struct board_sandbox_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case BOOL_CALLED_DETECT:
+ /* Checks if the dectect method has been called */
+ *val = priv->called_detect;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+int board_sandbox_get_int(struct udevice *dev, int id, int *val)
+{
+ struct board_sandbox_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case INT_TEST1:
+ *val = priv->test_i1;
+ /* Increments with every call */
+ priv->test_i1++;
+ return 0;
+ case INT_TEST2:
+ *val = priv->test_i2;
+ /* Decrements with every call */
+ priv->test_i2--;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+int board_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
+{
+ struct board_sandbox_priv *priv = dev_get_priv(dev);
+ int i1 = priv->test_i1;
+ int i2 = priv->test_i2;
+ int index = (i1 * i2) % ARRAY_SIZE(vacation_spots);
+
+ switch (id) {
+ case STR_VACATIONSPOT:
+ /* Picks a vacation spot depending on i1 and i2 */
+ snprintf(val, size, vacation_spots[index]);
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+static const struct udevice_id board_sandbox_ids[] = {
+ { .compatible = "sandbox,board_sandbox" },
+ { /* sentinel */ }
+};
+
+static const struct board_ops board_sandbox_ops = {
+ .detect = board_sandbox_detect,
+ .get_bool = board_sandbox_get_bool,
+ .get_int = board_sandbox_get_int,
+ .get_str = board_sandbox_get_str,
+};
+
+int board_sandbox_probe(struct udevice *dev)
+{
+ return 0;
+}
+
+U_BOOT_DRIVER(board_sandbox) = {
+ .name = "board_sandbox",
+ .id = UCLASS_BOARD,
+ .of_match = board_sandbox_ids,
+ .ops = &board_sandbox_ops,
+ .priv_auto_alloc_size = sizeof(struct board_sandbox_priv),
+ .probe = board_sandbox_probe,
+};
diff --git a/drivers/board/sandbox.h b/drivers/board/sandbox.h
new file mode 100644
index 0000000000..2cff494f56
--- /dev/null
+++ b/drivers/board/sandbox.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+enum {
+ BOOL_CALLED_DETECT,
+ INT_TEST1,
+ INT_TEST2,
+ STR_VACATIONSPOT,
+};
diff --git a/drivers/core/device.c b/drivers/core/device.c
index fd59fe1e0f..feed43c8c3 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -516,6 +516,33 @@ static int device_get_device_tail(struct udevice *dev, int ret,
return 0;
}
+/**
+ * device_find_by_ofnode() - Return device associated with given ofnode
+ *
+ * The returned device is *not* activated.
+ *
+ * @node: The ofnode for which a associated device should be looked up
+ * @devp: Pointer to structure to hold the found device
+ * Return: 0 if OK, -ve on error
+ */
+static int device_find_by_ofnode(ofnode node, struct udevice **devp)
+{
+ struct uclass *uc;
+ struct udevice *dev;
+ int ret;
+
+ list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+ ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node,
+ &dev);
+ if (!ret || dev) {
+ *devp = dev;
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+}
+
int device_get_child(struct udevice *parent, int index, struct udevice **devp)
{
struct udevice *dev;
@@ -739,3 +766,54 @@ bool of_machine_is_compatible(const char *compat)
return !fdt_node_check_compatible(fdt, 0, compat);
}
+
+int dev_disable_by_path(const char *path)
+{
+ struct uclass *uc;
+ ofnode node = ofnode_path(path);
+ struct udevice *dev;
+ int ret = 1;
+
+ if (!of_live_active())
+ return -ENOSYS;
+
+ list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+ ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node, &dev);
+ if (!ret)
+ break;
+ }
+
+ if (ret)
+ return ret;
+
+ ret = device_remove(dev, DM_REMOVE_NORMAL);
+ if (ret)
+ return ret;
+
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+
+ return ofnode_set_enabled(node, false);
+}
+
+int dev_enable_by_path(const char *path)
+{
+ ofnode node = ofnode_path(path);
+ ofnode pnode = ofnode_get_parent(node);
+ struct udevice *parent;
+ int ret = 1;
+
+ if (!of_live_active())
+ return -ENOSYS;
+
+ ret = device_find_by_ofnode(pnode, &parent);
+ if (ret)
+ return ret;
+
+ ret = ofnode_set_enabled(node, true);
+ if (ret)
+ return ret;
+
+ return lists_bind_fdt(parent, node, NULL);
+}
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index a7e1927723..1e354803b0 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -791,3 +791,73 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
propname, propval, proplen));
}
}
+
+int ofnode_write_prop(ofnode node, const char *propname, int len,
+ const void *value)
+{
+ const struct device_node *np = ofnode_to_np(node);
+ struct property *pp;
+ struct property *pp_last = NULL;
+ struct property *new;
+
+ if (!of_live_active())
+ return -ENOSYS;
+
+ if (!np)
+ return -EINVAL;
+
+ for (pp = np->properties; pp; pp = pp->next) {
+ if (strcmp(pp->name, propname) == 0) {
+ /* Property exists -> change value */
+ pp->value = (void *)value;
+ pp->length = len;
+ return 0;
+ }
+ pp_last = pp;
+ }
+
+ if (!pp_last)
+ return -ENOENT;
+
+ /* Property does not exist -> append new property */
+ new = malloc(sizeof(struct property));
+ if (!new)
+ return -ENOMEM;
+
+ new->name = strdup(propname);
+ if (!new->name)
+ return -ENOMEM;
+
+ new->value = (void *)value;
+ new->length = len;
+ new->next = NULL;
+
+ pp_last->next = new;
+
+ return 0;
+}
+
+int ofnode_write_string(ofnode node, const char *propname, const char *value)
+{
+ if (!of_live_active())
+ return -ENOSYS;
+
+ assert(ofnode_valid(node));
+
+ debug("%s: %s = %s", __func__, propname, value);
+
+ return ofnode_write_prop(node, propname, strlen(value) + 1, value);
+}
+
+int ofnode_set_enabled(ofnode node, bool value)
+{
+ if (!of_live_active())
+ return -ENOSYS;
+
+ assert(ofnode_valid(node));
+
+ if (value)
+ return ofnode_write_string(node, "status", "okay");
+ else
+ return ofnode_write_string(node, "status", "disable");
+}
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index cb73b70f5b..feaea8130f 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -1,5 +1,5 @@
config FIRMWARE
- bool
+ bool "Enable Firmware driver support"
config ARM_PSCI_FW
bool
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 1cdda14977..6cb83582b9 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -1,3 +1,4 @@
obj-$(CONFIG_FIRMWARE) += firmware-uclass.o
obj-$(CONFIG_ARM_PSCI_FW) += psci.o
obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
+obj-$(CONFIG_SANDBOX) += firmware-sandbox.o
diff --git a/drivers/firmware/firmware-sandbox.c b/drivers/firmware/firmware-sandbox.c
new file mode 100644
index 0000000000..d970d75f78
--- /dev/null
+++ b/drivers/firmware/firmware-sandbox.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * sandbox firmware driver
+ *
+ * Copyright (C) 2018 Xilinx, Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+
+static const struct udevice_id generic_sandbox_firmware_ids[] = {
+ { .compatible = "sandbox,firmware" },
+ { }
+};
+
+U_BOOT_DRIVER(sandbox_firmware) = {
+ .name = "sandbox_firmware",
+ .id = UCLASS_FIRMWARE,
+ .of_match = generic_sandbox_firmware_ids,
+};
diff --git a/drivers/firmware/firmware-uclass.c b/drivers/firmware/firmware-uclass.c
index 3d33b6deba..7fcd7fb904 100644
--- a/drivers/firmware/firmware-uclass.c
+++ b/drivers/firmware/firmware-uclass.c
@@ -7,7 +7,7 @@
UCLASS_DRIVER(firmware) = {
.id = UCLASS_FIRMWARE,
.name = "firmware",
-#if CONFIG_IS_ENABLED(OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
.post_bind = dm_scan_fdt_dev,
#endif
};