[PATCH 18/30] dm: core: Create a struct for device runtime info
Simon Glass
sjg at chromium.org
Thu Dec 31 05:09:48 CET 2020
At present when driver model needs to change a device it simply updates
the struct udevice structure. But with of-platdata-inst most of the fields
are not modified at runtime. In fact, typically only the flags need to
change.
For systems running SPL from read-only memory it is convenient to separate
out the runtime information, so that the devices don't need to be copied
before being used.
Create a new udevice_rt table, similar to the existing driver_rt. For now
it just holds the flags, although they are not used in this patch.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
drivers/core/root.c | 12 ++++++++++++
include/asm-generic/global_data.h | 12 ++++++++++++
include/dm/device.h | 17 ++++++++++++++++-
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index bb797f12203..6966e9a7ff1 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -132,6 +132,18 @@ static int dm_setup_inst(void)
{
DM_ROOT_NON_CONST = DM_DEVICE_GET(root);
+ if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
+ struct udevice_rt *urt;
+ int n_ents;
+
+ /* Allocate the udevice_rt table */
+ n_ents = ll_entry_count(struct udevice, udevice);
+ urt = calloc(n_ents, sizeof(struct udevice_rt));
+ if (!urt)
+ return log_msg_ret("urt", -ENOMEM);
+ gd_set_dm_udevice_rt(urt);
+ }
+
return 0;
}
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index b63575919f0..67161f624ec 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -205,6 +205,10 @@ struct global_data {
/** Dynamic info about the driver */
struct driver_rt *dm_driver_rt;
# endif
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+ /** @dm_udevice_rt: Dynamic info about the udevice */
+ struct udevice_rt *dm_udevice_rt;
+# endif
#endif
#ifdef CONFIG_TIMER
/**
@@ -465,6 +469,14 @@ struct global_data {
#define gd_dm_driver_rt() NULL
#endif
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+#define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
+#define gd_dm_udevice_rt() gd->dm_udevice_rt
+#else
+#define gd_set_dm_udevice_rt(dyn)
+#define gd_dm_udevice_rt() NULL
+#endif
+
#ifdef CONFIG_GENERATE_ACPI_TABLE
#define gd_acpi_ctx() gd->acpi_ctx
#else
diff --git a/include/dm/device.h b/include/dm/device.h
index 00d25c16862..ba62b5f0365 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -166,7 +166,7 @@ struct udevice {
struct list_head sibling_node;
u32 flags_;
int seq_;
-#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+#if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
ofnode node_;
#endif
#ifdef CONFIG_DEVRES
@@ -174,6 +174,21 @@ struct udevice {
#endif
};
+/**
+ * udevice_rt - runtime information set up by U-Boot
+ *
+ * This is only used with OF_PLATDATA_RT
+ *
+ * There is one of these for every udevice in the linker list, indexed by
+ * the udevice_info idx value.
+ *
+ * @flags_: Flags for this device DM_FLAG_... (do not access outside driver
+ * model)
+ */
+struct udevice_rt {
+ u32 flags_;
+};
+
/* Maximum sequence number supported */
#define DM_MAX_SEQ 999
--
2.29.2.729.g45daf8777d-goog
More information about the U-Boot
mailing list