1 year ago
#244872
user10008009
U-Boot: ARM: Simple delay function because of an chicken and egg problem
I'm running into an chicken and egg problem when modifying (fixing) some drivers for STMicroelectronics SoC's
The problem, I will implement a timeout, when accessing some
registers. Unfortunately I cannot use the basic mdelay()
or
higher level functions, which use this function, because
on these SoC's there isn't setup and enabled the timer before.
Also the ARMv7-M
SysTick
timer will not be used.
I could write a simple delay loop which counts down at the
frequency from the processor speed. But I think, this is
not a good idea.
Any suggestion, what I can do? I'm still new in U-Boot, so I don't know if there a simple delay function exists.
UPDATE:
The reason why I currently cannot use the SysTick
timer is, that it will be not linked in the current configuration. This is not a big problem. But the current implementation of the SysTick
low-level source defines functions, which will be defined by another timer driver on these SoC series. So when I enable the SysTick
in Kconfig
I will be possible that I get a linker error with multiple definition of those functions.
Example driver with IMHO an fatal issue (missing timeout when polling a register value):
GitHub: U-Boot: driver/clk/clk_stm32h7.c
The driver currently requires a external working clock source
(HSE
). No issues in the circuit are accepted by the current
implementation. Also a fixed (defined) frequency of the external
clock source.
In the probe function stm32_clk_probe()
from the driver there
will be configure_clocks()
called. Here are the issues.
A code snippet from configure_clocks()
:
/* Switch on HSE */
setbits_le32(®s->cr, RCC_CR_HSEON);
while (!(readl(®s->cr) & RCC_CR_HSERDY))
;
RCC_CR_HSERDY
will here never set by hardware, when there is no external clock source or an issue in the circuit. These leads in an endless loop. The loop of dead.
arm
driver
delay
u-boot
0 Answers
Your Answer