rockchip: arm64: rk3399: revise timeout-handling for DRAM PHY lock
Revise the loop watching for a timeout on obtaining a DRAM PHY lock to clearly state a timeout in milliseconds and use get_timer (based on the ARMv8 architected timer) to detect a timeout. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a1c29d4b43
commit
fbecb94e4b
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Adapted from coreboot.
|
* Adapted from coreboot.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
@ -19,6 +20,7 @@
|
|||||||
#include <asm/arch/grf_rk3399.h>
|
#include <asm/arch/grf_rk3399.h>
|
||||||
#include <asm/arch/hardware.h>
|
#include <asm/arch/hardware.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
struct chan_info {
|
struct chan_info {
|
||||||
@ -506,6 +508,7 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel,
|
|||||||
u32 tmp, tmp1, tmp2;
|
u32 tmp, tmp1, tmp2;
|
||||||
u32 pwrup_srefresh_exit;
|
u32 pwrup_srefresh_exit;
|
||||||
int ret;
|
int ret;
|
||||||
|
const ulong timeout_ms = 200;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* work around controller bug:
|
* work around controller bug:
|
||||||
@ -588,13 +591,15 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel,
|
|||||||
clrsetbits_le32(&denali_phy[957], 0x3 << 24, 0x2 << 24);
|
clrsetbits_le32(&denali_phy[957], 0x3 << 24, 0x2 << 24);
|
||||||
|
|
||||||
/* Wating for PHY and DRAM init complete */
|
/* Wating for PHY and DRAM init complete */
|
||||||
tmp = 0;
|
tmp = get_timer(0);
|
||||||
while (!(readl(&denali_ctl[203]) & (1 << 3))) {
|
do {
|
||||||
mdelay(10);
|
if (get_timer(tmp) > timeout_ms) {
|
||||||
tmp++;
|
error("DRAM (%s): phy failed to lock within %ld ms\n",
|
||||||
if (tmp > 10)
|
__func__, timeout_ms);
|
||||||
return -ETIME;
|
return -ETIME;
|
||||||
}
|
}
|
||||||
|
} while (!(readl(&denali_ctl[203]) & (1 << 3)));
|
||||||
|
debug("DRAM (%s): phy locked after %ld ms\n", __func__, get_timer(tmp));
|
||||||
|
|
||||||
clrsetbits_le32(&denali_ctl[68], PWRUP_SREFRESH_EXIT,
|
clrsetbits_le32(&denali_ctl[68], PWRUP_SREFRESH_EXIT,
|
||||||
pwrup_srefresh_exit);
|
pwrup_srefresh_exit);
|
||||||
|
Loading…
Reference in New Issue
Block a user