Skip to content

Commit 01b69e9

Browse files
ycsinnashif
authored andcommitted
soc: andestech: run pma_init_per_core() with soc_per_core_init_hook()
The function `pma_init_per_core()`, as its name suggest, should be run from every core, so call it from `soc_per_core_init_hook()` Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent de347a4 commit 01b69e9

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

soc/andestech/ae350/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
zephyr_include_directories(.)
44

55
zephyr_sources(
6+
soc.c
67
start.S
78
soc_irq.S
89
)

soc/andestech/ae350/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ config SOC_ANDES_V5_PMA
9292
bool "Andes V5 Physical Memory Attribute (PMA)"
9393
select ARCH_HAS_NOCACHE_MEMORY_SUPPORT
9494
select SOC_EARLY_INIT_HOOK
95+
select SOC_PER_CORE_INIT_HOOK
9596
help
9697
This option enables the Andes V5 PMA, in order to support SW to
9798
configure physical memory attribute by PMA CSRs. The address

soc/andestech/ae350/pma.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,6 @@ static void configure_nocache_region(void)
187187
}
188188
#endif /* CONFIG_NOCACHE_MEMORY */
189189

190-
/*
191-
* @brief Init PMA CSRs of each CPU core
192-
*
193-
* In SMP, each CPU has it's own PMA CSR and PMA CSR only affect one CPU.
194-
* We should configure CSRs of all CPUs to make memory attribute
195-
* (e.g. uncacheable) affects all CPUs.
196-
*/
197190
void pma_init_per_core(void)
198191
{
199192
#ifdef CONFIG_NOCACHE_MEMORY
@@ -218,6 +211,4 @@ void soc_early_init_hook(void)
218211
#endif
219212
return;
220213
}
221-
222-
pma_init_per_core();
223214
}

soc/andestech/ae350/pma.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2021 Andes Technology Corporation
3+
* Copyright (c) 2024 Meta Platforms
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/*
9+
* @brief Init PMA CSRs of each CPU core
10+
*
11+
* In SMP, each CPU has it's own PMA CSR and PMA CSR only affect one CPU.
12+
* We should configure CSRs of all CPUs to make memory attribute
13+
* (e.g. uncacheable) affects all CPUs.
14+
*/
15+
void pma_init_per_core(void);

soc/andestech/ae350/soc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Meta Platforms
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "pma.h"
8+
9+
#ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
10+
void soc_per_core_init_hook(void)
11+
{
12+
#ifdef CONFIG_SOC_ANDES_V5_PMA
13+
pma_init_per_core();
14+
#endif /* SOC_ANDES_V5_PMA */
15+
}
16+
#endif /* CONFIG_SOC_PER_CORE_INIT_HOOK */

0 commit comments

Comments
 (0)