aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorOvidiu Panait <ovpanait@gmail.com>2022-10-12 08:36:55 +0300
committerMichal Simek <michal.simek@amd.com>2022-11-22 15:02:07 +0100
commit8272d4cb897ca15eef2f39afe488f6731312e5c2 (patch)
tree20434530c1b238ee89d4113416fc47b501f24769 /drivers
parent1e766a04c723e003c001c0f1a4f301aef026a75e (diff)
downloadu-boot-8272d4cb897ca15eef2f39afe488f6731312e5c2.zip
u-boot-8272d4cb897ca15eef2f39afe488f6731312e5c2.tar.gz
u-boot-8272d4cb897ca15eef2f39afe488f6731312e5c2.tar.bz2
timer-uclass: relocate ops pointers for CONFIG_NEEDS_MANUAL_RELOC
Relocate timer_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> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20221012053656.1492457-2-ovpanait@gmail.com Signed-off-by: Michal Simek <michal.simek@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/timer/timer-uclass.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index bdc77b3..bb71979 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -18,6 +18,7 @@
#include <init.h>
#include <timer.h>
#include <linux/err.h>
+#include <relocate.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -50,6 +51,19 @@ unsigned long notrace timer_get_rate(struct udevice *dev)
static int timer_pre_probe(struct udevice *dev)
{
+ if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) &&
+ (gd->flags & GD_FLG_RELOC)) {
+ struct timer_ops *ops = timer_get_ops(dev);
+ static int reloc_done;
+
+ if (!reloc_done) {
+ if (ops->get_count)
+ MANUAL_RELOC(ops->get_count);
+
+ reloc_done++;
+ }
+ }
+
if (CONFIG_IS_ENABLED(OF_REAL)) {
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct clk timer_clk;