summaryrefslogtreecommitdiff
path: root/arch/arm/mach-stm32mp/psci.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-03-26 13:18:22 -0400
committerTom Rini <trini@konsulko.com>2020-03-26 13:18:22 -0400
commit779e6dc6a429ac28dfd4f07ab0c3648a31399d4a (patch)
tree2dfc6d6953793e85d78b4ca79bec6b1a5fbca421 /arch/arm/mach-stm32mp/psci.c
parent2738f0edea7d19960d692284d1f378b1a2b4c4a5 (diff)
parent5b5699cdc97122e08e7fd0886a9e4474ca3ccb35 (diff)
Merge tag 'u-boot-stm32-20200324' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm into next
- stm32mp: fix command stboard - stm32mp: update kernel device tree according the part number - stm32mp: add 800 MHz profile support = stm32mp15xd and stm32mp15xf - stm32mp: set cp15 frequency in psci cpu on - stm32mp: DT alignment with Linux 5.6-rc1 - stm32mp: clk: add SPI5 support and correct CKSELR masks - stm32mp: ram: fixes on LPDDR2/LPDDR3 support and on tuning - stm32: i2c: allows for any bus frequency - sti: timer: livetree and clk API conversion
Diffstat (limited to 'arch/arm/mach-stm32mp/psci.c')
-rw-r--r--arch/arm/mach-stm32mp/psci.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/arm/mach-stm32mp/psci.c b/arch/arm/mach-stm32mp/psci.c
index 1d91b2d324a..3fb038d3e77 100644
--- a/arch/arm/mach-stm32mp/psci.c
+++ b/arch/arm/mach-stm32mp/psci.c
@@ -30,6 +30,22 @@ u8 psci_state[STM32MP1_PSCI_NR_CPUS] __secure_data = {
PSCI_AFFINITY_LEVEL_ON,
PSCI_AFFINITY_LEVEL_OFF};
+static u32 __secure_data cntfrq;
+
+static u32 __secure cp15_read_cntfrq(void)
+{
+ u32 frq;
+
+ asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
+
+ return frq;
+}
+
+static void __secure cp15_write_cntfrq(u32 frq)
+{
+ asm volatile ("mcr p15, 0, %0, c14, c0, 0" : : "r" (frq));
+}
+
static inline void psci_set_state(int cpu, u8 state)
{
psci_state[cpu] = state;
@@ -63,6 +79,9 @@ void __secure psci_arch_cpu_entry(void)
psci_set_state(cpu, PSCI_AFFINITY_LEVEL_ON);
+ /* write the saved cntfrq */
+ cp15_write_cntfrq(cntfrq);
+
/* reset magic in TAMP register */
writel(0xFFFFFFFF, TAMP_BACKUP_MAGIC_NUMBER);
}
@@ -130,6 +149,9 @@ s32 __secure psci_cpu_on(u32 function_id, u32 target_cpu, u32 pc,
if (psci_state[cpu] == PSCI_AFFINITY_LEVEL_ON)
return ARM_PSCI_RET_ALREADY_ON;
+ /* read and save cntfrq of current cpu to write on target cpu */
+ cntfrq = cp15_read_cntfrq();
+
/* reset magic in TAMP register */
if (readl(TAMP_BACKUP_MAGIC_NUMBER))
writel(0xFFFFFFFF, TAMP_BACKUP_MAGIC_NUMBER);