drivers: clk: stm32h7: Endless loop of dead in driver probe function

Patrick DELAUNAY patrick.delaunay at foss.st.com
Tue Mar 8 10:00:36 CET 2022


Hi,

On 3/2/22 18:00, Johannes (krjdev) Krottmayer wrote:
> Hi,
>
> Some IMHO fatal issues in the the clock driver for the
> STM32H7 series driver.
>
> Affected driver:
> drivers/clk/clk_stm32h7.c
>
> Affected configs (boards):
> configs/stm32h750-art-pi_defconfig
> configs/stm32h743-disco_defconfig
> configs/stm32h743-eval_defconfig
>
> Description:
> 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.
>
> As code snippet from configure_clocks():
>
> /* Switch on HSE */
> setbits_le32(&regs->cr, RCC_CR_HSEON);
> while (!(readl(&regs->cr) & RCC_CR_HSERDY))
> 	;
>
> RCC_CR_HSERDY will here never set, when there is no external
> clock source or an issue in the circuit. -> Endless loop of dead.


Yes, the current clock driver for STM32 MCU is not perfect,

as the all U-Boot and the Linux support on STM32 MCU.


For information, in the other driver based on a other version of RCC for 
STM32 MPU

STM32MP1 = clk_stm32mp1.c, it is correctly managed in

stm32mp1_osc_wait(1, rcc, RCC_OCRDYR, RCC_OCRDYR_HSERDY);

by using readl_poll_timeout() function.


> My possible fixes:
> At a timeout when reading the register and if the timeout is
> elapsed, print an error message and return with ETIMEDOUT, so
> the dm manger can call the hang() function.

I agree, it is a correct management: at least indicate this hardware issue

even if the rdy bit can't be stay at 0 in normal use case when HSE is

present.


=> replace all while() in the RCC clock driver with readl_poll_timeout


but to call readl_poll_timeout(), the arch timer need to ready

(timer_init() already called) when RCC clokc driver probe is executed.


An issue the I encounters on STM32MP need to be checked in MCU driver:

the timer can't dependant of RCC probe when polling function is used.


This issue was solved in STM32MP by using the generic armv7 timer

(only dependant of Cortex core) and call the initialization in

arch/arm/mach-stm32mp/cpu.c:

int arch_cpu_init(void)
{
....

     /* early armv7 timer init: needed for polling */
     timer_init();

     return 0;
}


The timer management on MCU need to be check before any patch.


Can you propose something ?


>
> Johannes K.


Patrick



More information about the U-Boot mailing list