mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-26 04:53:42 +00:00
d7a184d4a7
When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be bound before relocation. However due to a bug in the DM core, the flag only takes effect when devices are statically declared via U_BOOT_DEVICE(). This bug has been fixed recently by commit "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()", but with the fix, it has a side effect that all existing drivers that declared DM_FLAG_PRE_RELOC flag will be bound before relocation now. This may expose potential boot failure on some boards due to insufficient memory during the pre-relocation stage. To mitigate this potential impact, the following changes are implemented: - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver only supports configuration from device tree (OF_CONTROL) - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device is statically declared via U_BOOT_DEVICE() - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for drivers that support both statically declared devices and configuration from device tree Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
77 lines
1.7 KiB
C
77 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
|
* Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <fdtdec.h>
|
|
#include <timer.h>
|
|
|
|
#include <asm/io.h>
|
|
#include <asm/arch-armv7/globaltimer.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
struct sti_timer_priv {
|
|
struct globaltimer *global_timer;
|
|
};
|
|
|
|
static int sti_timer_get_count(struct udevice *dev, u64 *count)
|
|
{
|
|
struct sti_timer_priv *priv = dev_get_priv(dev);
|
|
struct globaltimer *global_timer = priv->global_timer;
|
|
u32 low, high;
|
|
u64 timer;
|
|
u32 old = readl(&global_timer->cnt_h);
|
|
|
|
while (1) {
|
|
low = readl(&global_timer->cnt_l);
|
|
high = readl(&global_timer->cnt_h);
|
|
if (old == high)
|
|
break;
|
|
else
|
|
old = high;
|
|
}
|
|
timer = high;
|
|
*count = (u64)((timer << 32) | low);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sti_timer_probe(struct udevice *dev)
|
|
{
|
|
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
|
struct sti_timer_priv *priv = dev_get_priv(dev);
|
|
fdt_addr_t addr;
|
|
|
|
uc_priv->clock_rate = CONFIG_SYS_HZ_CLOCK;
|
|
|
|
/* get arm global timer base address */
|
|
addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
|
|
priv->global_timer = (struct globaltimer *)addr;
|
|
|
|
/* init timer */
|
|
writel(0x01, &priv->global_timer->ctl);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct timer_ops sti_timer_ops = {
|
|
.get_count = sti_timer_get_count,
|
|
};
|
|
|
|
static const struct udevice_id sti_timer_ids[] = {
|
|
{ .compatible = "arm,cortex-a9-global-timer" },
|
|
{}
|
|
};
|
|
|
|
U_BOOT_DRIVER(sti_timer) = {
|
|
.name = "sti_timer",
|
|
.id = UCLASS_TIMER,
|
|
.of_match = sti_timer_ids,
|
|
.priv_auto_alloc_size = sizeof(struct sti_timer_priv),
|
|
.probe = sti_timer_probe,
|
|
.ops = &sti_timer_ops,
|
|
};
|