Skip to content

Commit 57d7577

Browse files
committed
[nrf fromlist] soc: nordic: Add gppi initialization
New GPPI requires instance to be initialized during system boot up. GPPI is initialized with resource that can be allocated. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 86c4309 commit 57d7577

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

soc/nordic/nrf52/soc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,23 @@
1919
#include <hal/nrf_power.h>
2020
#include <lib/nrfx_coredep.h>
2121
#include <zephyr/logging/log.h>
22+
#include <helpers/nrfx_gppi.h>
2223

2324
#include <cmsis_core.h>
2425

2526
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
2627
LOG_MODULE_REGISTER(soc);
2728

29+
void gppi_init(void)
30+
{
31+
static nrfx_gppi_t gppi_instance;
32+
33+
gppi_instance.ch_mask = BIT_MASK(PPI_CH_NUM) & ~NRFX_PPI_CHANNELS_USED;
34+
gppi_instance.group_mask = BIT_MASK(PPI_GROUP_NUM) & ~NRFX_PPI_GROUPS_USED;
35+
36+
nrfx_gppi_init(&gppi_instance);
37+
}
38+
2839
static int nordicsemi_nrf52_init(void)
2940
{
3041
#ifdef CONFIG_NRF_ENABLE_ICACHE
@@ -41,6 +52,10 @@ static int nordicsemi_nrf52_init(void)
4152
nrf_power_dcdcen_vddh_set(NRF_POWER, true);
4253
#endif
4354

55+
if (IS_ENABLED(CONFIG_NRFX_GPPI) && !IS_ENABLED(CONFIG_NRFX_GPPI_V1)) {
56+
gppi_init();
57+
}
58+
4459
return 0;
4560
}
4661

soc/nordic/nrf53/soc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,17 @@ static int rtc_pretick_init(void)
477477
}
478478
#endif /* CONFIG_SOC_NRF53_RTC_PRETICK */
479479

480+
BUILD_ASSERT(DPPIC_CH_NUM == 32);
481+
void gppi_init(void)
482+
{
483+
static nrfx_gppi_t gppi_instance;
484+
485+
gppi_instance.ch_mask = UINT32_MAX & ~NRFX_DPPI_CHANNELS_USED;
486+
gppi_instance.group_mask = BIT_MASK(DPPIC_GROUP_NUM) & ~NRFX_DPPI_GROUPS_USED;
487+
488+
nrfx_gppi_init(&gppi_instance);
489+
}
490+
480491
void soc_early_init_hook(void)
481492
{
482493
#if defined(CONFIG_SOC_NRF5340_CPUAPP) && defined(CONFIG_NRF_ENABLE_CACHE)
@@ -557,6 +568,10 @@ void soc_early_init_hook(void)
557568
__ASSERT_NO_MSG(err == 0);
558569
(void)err;
559570
#endif
571+
572+
if (IS_ENABLED(CONFIG_NRFX_GPPI) && !IS_ENABLED(CONFIG_NRFX_GPPI_V1)) {
573+
gppi_init();
574+
}
560575
}
561576

562577
void soc_late_init_hook(void)

soc/nordic/nrf54l/soc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
3737
#define LFXO_NODE DT_NODELABEL(lfxo)
3838
#define HFXO_NODE DT_NODELABEL(hfxo)
3939

40-
static nrfx_gppi_t gppi_instance;
41-
4240
static inline void power_and_clock_configuration(void)
4341
{
4442
/* NRF_REGULATORS and NRF_OSCILLATORS are configured to be secure
@@ -154,6 +152,8 @@ static inline void power_and_clock_configuration(void)
154152
#if defined(CONFIG_NRFX_GPPI) && !defined(CONFIG_NRFX_GPPI_V1)
155153
void gppi_init(void)
156154
{
155+
static nrfx_gppi_t gppi_instance;
156+
157157
gppi_instance.routes = nrfx_gppi_routes_get();
158158
gppi_instance.route_map = nrfx_gppi_route_map_get();
159159
gppi_instance.nodes = nrfx_gppi_nodes_get();

soc/nordic/nrf91/soc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,34 @@
1616
#include <zephyr/init.h>
1717
#include <lib/nrfx_coredep.h>
1818
#include <zephyr/logging/log.h>
19+
#include <helpers/nrfx_gppi.h>
1920

2021
#include <cmsis_core.h>
2122

2223
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
2324
LOG_MODULE_REGISTER(soc);
2425

26+
void gppi_init(void)
27+
{
28+
static nrfx_gppi_t gppi_instance;
29+
30+
gppi_instance.ch_mask = BIT_MASK(DPPIC_CH_NUM) & ~NRFX_DPPI_CHANNELS_USED;
31+
gppi_instance.group_mask = BIT_MASK(DPPIC_GROUP_NUM) & ~NRFX_DPPI_GROUPS_USED;
32+
33+
nrfx_gppi_init(&gppi_instance);
34+
}
35+
2536
static int nordicsemi_nrf91_init(void)
2637
{
2738
#ifdef CONFIG_NRF_ENABLE_ICACHE
2839
/* Enable the instruction cache */
2940
NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Msk;
3041
#endif
3142

43+
if (IS_ENABLED(CONFIG_NRFX_GPPI) && !IS_ENABLED(CONFIG_NRFX_GPPI_V1)) {
44+
gppi_init();
45+
}
46+
3247
return 0;
3348
}
3449

0 commit comments

Comments
 (0)