Skip to content

Commit 18e4ee2

Browse files
nordic-krchkartben
authored andcommitted
soc: nordic: nrf53: Forward gpio pins to network core just before reset
Instead of forwarding pins to the network core during the initialization, do it just before reseting the network core. With this approach pins can be used by the application core as long as network core is not started. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 7254a61 commit 18e4ee2

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

soc/nordic/nrf53/nrf53_cpunet_mgmt.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,41 @@
1515
#include <zephyr/sys/__assert.h>
1616
#include <zephyr/sys/notify.h>
1717
#include <zephyr/sys/onoff.h>
18+
#include <soc_secure.h>
1819

1920
#include <hal/nrf_reset.h>
2021
#include <hal/nrf_spu.h>
2122

2223
static struct onoff_manager cpunet_mgr;
2324

25+
#ifdef CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340
26+
27+
#define GPIOS_PSEL_BY_IDX(node_id, prop, idx) \
28+
NRF_DT_GPIOS_TO_PSEL_BY_IDX(node_id, prop, idx),
29+
#define ALL_GPIOS_IN_NODE(node_id) \
30+
DT_FOREACH_PROP_ELEM(node_id, gpios, GPIOS_PSEL_BY_IDX)
31+
#define ALL_GPIOS_IN_FORWARDER(node_id) \
32+
DT_FOREACH_CHILD(node_id, ALL_GPIOS_IN_NODE)
33+
34+
static void assign_pins(nrf_gpio_pin_sel_t sel)
35+
{
36+
static const uint8_t forwarded_psels[] = {
37+
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpio_forwarder, ALL_GPIOS_IN_FORWARDER)
38+
};
39+
40+
for (int i = 0; i < ARRAY_SIZE(forwarded_psels); i++) {
41+
soc_secure_gpio_pin_mcu_select(forwarded_psels[i], sel);
42+
}
43+
}
44+
#endif /* CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340 */
45+
2446
static void onoff_start(struct onoff_manager *mgr, onoff_notify_fn notify)
2547
{
48+
#ifdef CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340
49+
/* Forward assigned pins to the network core. */
50+
assign_pins(NRF_GPIO_PIN_SEL_NETWORK);
51+
#endif
52+
2653
nrf_reset_network_force_off(NRF_RESET, false);
2754

2855
notify(mgr, 0);
@@ -32,6 +59,11 @@ static void onoff_stop(struct onoff_manager *mgr, onoff_notify_fn notify)
3259
{
3360
nrf_reset_network_force_off(NRF_RESET, true);
3461

62+
#ifdef CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340
63+
/* Assign pins back to app core. */
64+
assign_pins(NRF_GPIO_PIN_SEL_APP);
65+
#endif
66+
3567
notify(mgr, 0);
3668
}
3769

soc/nordic/nrf53/soc.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@
4747
#define RTC1_PRETICK_SELECTED_CC_MASK BIT_MASK(CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT + 1U)
4848
#define RTC0_PRETICK_SELECTED_CC_MASK BIT_MASK(NRF_RTC_CC_COUNT_MAX)
4949

50-
#if defined(CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340)
51-
#define GPIOS_PSEL_BY_IDX(node_id, prop, idx) \
52-
NRF_DT_GPIOS_TO_PSEL_BY_IDX(node_id, prop, idx),
53-
#define ALL_GPIOS_IN_NODE(node_id) \
54-
DT_FOREACH_PROP_ELEM(node_id, gpios, GPIOS_PSEL_BY_IDX)
55-
#define ALL_GPIOS_IN_FORWARDER(node_id) \
56-
DT_FOREACH_CHILD(node_id, ALL_GPIOS_IN_NODE)
57-
#endif
58-
5950
#ifdef CONFIG_SOC_NRF5340_CPUAPP
6051
#define LFXO_NODE DT_NODELABEL(lfxo)
6152
#define HFXO_NODE DT_NODELABEL(hfxo)
@@ -562,17 +553,6 @@ static int nordicsemi_nrf53_init(void)
562553
nrf_regulators_vreg_enable_set(NRF_REGULATORS, NRF_REGULATORS_VREG_HIGH, true);
563554
#endif
564555

565-
#if defined(CONFIG_SOC_NRF_GPIO_FORWARDER_FOR_NRF5340)
566-
static const uint8_t forwarded_psels[] = {
567-
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpio_forwarder, ALL_GPIOS_IN_FORWARDER)
568-
};
569-
570-
for (int i = 0; i < ARRAY_SIZE(forwarded_psels); i++) {
571-
soc_secure_gpio_pin_mcu_select(forwarded_psels[i], NRF_GPIO_PIN_SEL_NETWORK);
572-
}
573-
574-
#endif
575-
576556
return 0;
577557
}
578558

0 commit comments

Comments
 (0)