summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dm/platdata.h8
-rw-r--r--tools/dtoc/dtb_platdata.py3
-rwxr-xr-xtools/dtoc/test_dtoc.py3
3 files changed, 14 insertions, 0 deletions
diff --git a/include/dm/platdata.h b/include/dm/platdata.h
index f800a866dd..216efa8ef7 100644
--- a/include/dm/platdata.h
+++ b/include/dm/platdata.h
@@ -55,9 +55,17 @@ struct driver_rt {
* NOTE: Avoid using these except in extreme circumstances, where device tree
* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is
* available). U-Boot's driver model uses device tree for configuration.
+ *
+ * When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the
+ * dt-platdata.c file created by dtoc
*/
+#if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLATDATA_C)
+#define U_BOOT_DEVICE(__name) _Static_assert(false, \
+ "Cannot use U_BOOT_DEVICE with of-platdata. Please use devicetree instead")
+#else
#define U_BOOT_DEVICE(__name) \
ll_entry_declare(struct driver_info, __name, driver_info)
+#endif
/* Declare a list of devices. The argument is a driver_info[] array */
#define U_BOOT_DEVICES(__name) \
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 2be11fff6c..9b27aecc14 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -673,6 +673,9 @@ class DtbPlatdata(object):
information.
"""
self.out_header()
+ self.out('/* Allow use of U_BOOT_DEVICE() in this file */\n')
+ self.out('#define DT_PLATDATA_C\n')
+ self.out('\n')
self.out('#include <common.h>\n')
self.out('#include <dm.h>\n')
self.out('#include <dt-structs.h>\n')
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 8e16dc0f0f..a5836e04b7 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -44,6 +44,9 @@ C_HEADER = '''/*
* This file was generated by dtoc from a .dtb (device tree binary) file.
*/
+/* Allow use of U_BOOT_DEVICE() in this file */
+#define DT_PLATDATA_C
+
#include <common.h>
#include <dm.h>
#include <dt-structs.h>