summaryrefslogtreecommitdiff
path: root/drivers/cpu
diff options
context:
space:
mode:
authorOvidiu Panait <ovpanait@gmail.com>2022-05-31 21:14:23 +0300
committerMichal Simek <michal.simek@amd.com>2022-06-24 14:16:00 +0200
commitb391b915bb3441a01b18d9b144425b577ea6b2c2 (patch)
treeb6754b9f6c1246e4dc0694ffe753ae2e89a76239 /drivers/cpu
parent15c924a7437b9763b1b84aa693a842c49184586d (diff)
downloadu-boot-b391b915bb3441a01b18d9b144425b577ea6b2c2.tar.gz
u-boot-b391b915bb3441a01b18d9b144425b577ea6b2c2.tar.bz2
u-boot-b391b915bb3441a01b18d9b144425b577ea6b2c2.zip
cpu-uclass: relocate ops pointers for CONFIG_NEEDS_MANUAL_RELOC
Relocate cpu_ops pointers when CONFIG_NEEDS_MANUAL_RELOC is enabled. The (gd->flags & GD_FLG_RELOC) check was added to make sure the reloc_done logic works for drivers that use DM_FLAG_PRE_RELOC. Signed-off-by: Ovidiu Panait <ovpanait@gmail.com> Link: https://lore.kernel.org/r/20220531181435.3473549-2-ovpanait@gmail.com Signed-off-by: Michal Simek <michal.simek@amd.com>
Diffstat (limited to 'drivers/cpu')
-rw-r--r--drivers/cpu/cpu-uclass.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index a5cda6a62c..71e5900d70 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -14,6 +14,9 @@
#include <dm/lists.h>
#include <dm/root.h>
#include <linux/err.h>
+#include <relocate.h>
+
+DECLARE_GLOBAL_DATA_PTR;
int cpu_probe_all(void)
{
@@ -136,9 +139,36 @@ static int uclass_cpu_init(struct uclass *uc)
return ret;
}
+static int uclass_cpu_post_bind(struct udevice *dev)
+{
+ if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) &&
+ (gd->flags & GD_FLG_RELOC)) {
+ struct cpu_ops *ops = cpu_get_ops(dev);
+ static int reloc_done;
+
+ if (!reloc_done) {
+ if (ops->get_desc)
+ MANUAL_RELOC(ops->get_desc);
+ if (ops->get_info)
+ MANUAL_RELOC(ops->get_info);
+ if (ops->get_count)
+ MANUAL_RELOC(ops->get_count);
+ if (ops->get_vendor)
+ MANUAL_RELOC(ops->get_vendor);
+ if (ops->is_current)
+ MANUAL_RELOC(ops->is_current);
+
+ reloc_done++;
+ }
+ }
+
+ return 0;
+}
+
UCLASS_DRIVER(cpu) = {
.id = UCLASS_CPU,
.name = "cpu",
.flags = DM_UC_FLAG_SEQ_ALIAS,
.init = uclass_cpu_init,
+ .post_bind = uclass_cpu_post_bind,
};