aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 17:25:37 +1300
committerSimon Glass <sjg@chromium.org>2021-03-22 19:23:28 +1300
commitae6ba148dd912529cf1ff06cb3b6f6aac17ff6fb (patch)
treea8f3d96fc5651eee70e78a691922d983c074009a
parent79448d30957b30c298f2617c0584d08ede4c9fa1 (diff)
downloadu-boot-ae6ba148dd912529cf1ff06cb3b6f6aac17ff6fb.zip
u-boot-ae6ba148dd912529cf1ff06cb3b6f6aac17ff6fb.tar.gz
u-boot-ae6ba148dd912529cf1ff06cb3b6f6aac17ff6fb.tar.bz2
dm: core: Move flags to device-runtime info
When of-platdata-inst is active, use the flags in the new udevice_rt table, dropping them from the main struct udevice. This ensures that the latter is not updated at runtime. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/core/device.c33
-rw-r--r--include/dm/device.h8
2 files changed, 41 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 1990b6f..06d2467 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -1136,3 +1136,36 @@ int dev_enable_by_path(const char *path)
return lists_bind_fdt(parent, node, NULL, false);
}
#endif
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+static struct udevice_rt *dev_get_rt(const struct udevice *dev)
+{
+ struct udevice *base = ll_entry_start(struct udevice, udevice);
+ int idx = dev - base;
+
+ struct udevice_rt *urt = gd_dm_udevice_rt() + idx;
+
+ return urt;
+}
+
+u32 dev_get_flags(const struct udevice *dev)
+{
+ const struct udevice_rt *urt = dev_get_rt(dev);
+
+ return urt->flags_;
+}
+
+void dev_or_flags(const struct udevice *dev, u32 or)
+{
+ struct udevice_rt *urt = dev_get_rt(dev);
+
+ urt->flags_ |= or;
+}
+
+void dev_bic_flags(const struct udevice *dev, u32 bic)
+{
+ struct udevice_rt *urt = dev_get_rt(dev);
+
+ urt->flags_ &= ~bic;
+}
+#endif /* OF_PLATDATA_RT */
diff --git a/include/dm/device.h b/include/dm/device.h
index 8e16f2e..0a9718a 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -177,7 +177,9 @@ struct udevice {
struct list_head uclass_node;
struct list_head child_head;
struct list_head sibling_node;
+#if !CONFIG_IS_ENABLED(OF_PLATDATA_RT)
u32 flags_;
+#endif
int seq_;
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
ofnode node_;
@@ -211,6 +213,11 @@ struct udevice_rt {
/* Returns the operations for a device */
#define device_get_ops(dev) (dev->driver->ops)
+#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
+u32 dev_get_flags(const struct udevice *dev);
+void dev_or_flags(const struct udevice *dev, u32 or);
+void dev_bic_flags(const struct udevice *dev, u32 bic);
+#else
static inline u32 dev_get_flags(const struct udevice *dev)
{
return dev->flags_;
@@ -225,6 +232,7 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
{
dev->flags_ &= ~bic;
}
+#endif /* OF_PLATDATA_RT */
/**
* dev_ofnode() - get the DT node reference associated with a udevice