feat(st-clock): add function to restore generic timer rate

Add a function to restore the CPU generic timer rate from STGEN content.
After wake-up from LPLV-Stop2, STGEN content is not lost, but generic timer
has been reset.

Signed-off-by: Pascal Paillet <p.paillet@st.com>
Change-Id: I6f91dbd051f76383e9ff1d6bb86225d373dbf33a
This commit is contained in:
Pascal Paillet 2021-07-06 18:08:32 +02:00 committed by Yann Gautier
parent 1e34c3bca2
commit bfe8a12eea
2 changed files with 15 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2023, STMicroelectronics - All Rights Reserved
* Copyright (c) 2017-2024, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -362,6 +362,18 @@ void stm32mp_stgen_config(unsigned long rate)
generic_delay_timer_init();
}
/*******************************************************************************
* This function restores CPU generic timer rate from the STGEN clock rate.
******************************************************************************/
void stm32mp_stgen_restore_rate(void)
{
unsigned long rate;
rate = mmio_read_32(STGEN_BASE + CNTFID_OFF);
write_cntfrq_el0((u_register_t)rate);
}
/*******************************************************************************
* This function returns the STGEN counter value.
******************************************************************************/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2022, STMicroelectronics - All Rights Reserved
* Copyright (c) 2017-2024, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -29,6 +29,7 @@ int fdt_get_clock_id(int node);
unsigned long fdt_get_uart_clock_freq(uintptr_t instance);
void stm32mp_stgen_config(unsigned long rate);
void stm32mp_stgen_restore_rate(void);
void stm32mp_stgen_restore_counter(unsigned long long value,
unsigned long long offset_in_ms);
unsigned long long stm32mp_stgen_get_counter(void);