Skip to content

Commit

Permalink
hw/drivers/nrf53_ipc: Split IPC initalization
Browse files Browse the repository at this point in the history
This splits IPC initialization into two phases: IPC setup and
networking core startup. This allows to do any custom IPC setup
before actually starting networking core. By default netcore is
enabled right after setup so not functional changes.
  • Loading branch information
sjanc committed Nov 13, 2023
1 parent 1359252 commit 063ad03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions hw/drivers/ipc_nrf5340/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ pkg.deps:

pkg.init:
ipc_nrf5340_init: 'MYNEWT_VAL(IPC_NRF5340_SYSINIT_STAGE)'
ipc_nrf5340_netcore_init: 'MYNEWT_VAL(IPC_NRF5340_NETCORE_SYSINIT_STAGE)'
18 changes: 13 additions & 5 deletions hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ ipc_nrf5340_init(void)
NRF_GPIO_Type *nrf_gpio;
#endif

/* Make sure network core if off when we set up IPC */
NRF_RESET->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Hold;

memset(ipc_shared, 0, sizeof(ipc_shared));
memset(shms, 0, sizeof(shms));

#if MYNEWT_VAL(NRF5340_EMBED_NET_CORE)
/*
Expand All @@ -286,10 +290,6 @@ ipc_nrf5340_init(void)
}
#endif

/* Make sure network core if off when we set up IPC */
NRF_RESET->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Hold;
memset(shms, 0, sizeof(shms));

for (i = 0; i < IPC_MAX_CHANS; ++i) {
shms[i].buf = shms_bufs[i];
shms[i].buf_size = IPC_BUF_SIZE;
Expand Down Expand Up @@ -325,7 +325,11 @@ ipc_nrf5340_init(void)
/* this allows netcore to access appcore RAM */
NRF_SPU_S->EXTDOMAIN[0].PERM = SPU_EXTDOMAIN_PERM_SECATTR_Secure << SPU_EXTDOMAIN_PERM_SECATTR_Pos;
}
}

void
ipc_nrf5340_netcore_init(void)
{
/* Start Network Core */
/* Workaround for Errata 161: "RESET: Core is not fully reset after Force-OFF" */
*(volatile uint32_t *) ((uint32_t)NRF_RESET + 0x618ul) = 1ul;
Expand Down Expand Up @@ -358,10 +362,14 @@ ipc_nrf5340_init(void)

ipc_nrf5340_init_nrf_ipc();
NRF_IPC->SEND_CNF[NET_CRASH_CHANNEL] = (0x01UL << NET_CRASH_CHANNEL);
}

void
ipc_nrf5340_netcore_init(void)
{
/*
* If ipc_state is already APP_AND_NET_RUNNING it means that net core
* restarted without app core involvment, notify app core about such
* restarted without app core involvement, notify app core about such
* case.
*/
if (ipc_shared->ipc_state == APP_AND_NET_RUNNING) {
Expand Down
8 changes: 8 additions & 0 deletions hw/drivers/ipc_nrf5340/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ syscfg.defs:
Sysinit stage for nRF53 IPC
value: 10

IPC_NRF5340_NETCORE_SYSINIT_STAGE:
description: >
Sysinit stage for nRF53 IPC networking core start. On application
core this enables networking core and wait for it to notify that IPC
is ready. On networking core this notifies application core that IPC
is ready.
value: 11

IPC_NRF5340_NET_GPIO:
description: >
List of comma separated GPIO that should be configured for Network
Expand Down

0 comments on commit 063ad03

Please sign in to comment.