Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf53 sync_rtc refactor and fix for simulated nrf5340 #64135

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 1 addition & 73 deletions soc/arm/nordic_nrf/nrf53/Kconfig.soc
Original file line number Diff line number Diff line change
Expand Up @@ -188,78 +188,6 @@ config BUILD_WITH_TFM
# TF-M nRF53 platform enables the cache unconditionally.
select NRF_ENABLE_CACHE if SOC_NRF5340_CPUAPP

config NRF53_SYNC_RTC
bool "RTC clock synchronization"
default y if LOG && !LOG_MODE_MINIMAL
depends on NRF_RTC_TIMER
select NRFX_DPPI
select MBOX if !IPM

if NRF53_SYNC_RTC

module = SYNC_RTC
module-str = Synchronized RTC
source "subsys/logging/Kconfig.template.log_config"

config NRF53_SYNC_RTC_INIT_PRIORITY
int "nRF53 Synchronized RTC init priority"
default APPLICATION_INIT_PRIORITY
help
nRF53 Synchronized RTC initialization priority.

config NRF_RTC_TIMER_USER_CHAN_COUNT
default 2 if NRF_802154_RADIO_DRIVER && SOC_NRF5340_CPUNET
default 3 if NRF_802154_RADIO_DRIVER
default 1
rsource "Kconfig.sync_rtc"

config NRF53_SYNC_RTC_LOG_TIMESTAMP
bool "Use Synchronized RTC for logging timestamp"
default y

config NRF53_SYNC_RTC_IPM_OUT
int "IPM channel from APP to NET"
range 0 15
default 7 if SOC_NRF5340_CPUAPP
default 8

config NRF53_SYNC_RTC_IPM_IN
int "IPM channel from APP to NET"
range 0 15
default 8 if SOC_NRF5340_CPUAPP
default 7

ipm_num = 0
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 1
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 2
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 3
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 4
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 5
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 6
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 7
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 8
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 9
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 10
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 11
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 12
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 13
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 14
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 15
rsource "Kconfig.sync_rtc_ipm"

endif # NRF53_SYNC_RTC
endif # SOC_SERIES_NRF53X
77 changes: 77 additions & 0 deletions soc/arm/nordic_nrf/nrf53/Kconfig.sync_rtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config NRF53_SYNC_RTC
bool "RTC clock synchronization"
default y if LOG && !LOG_MODE_MINIMAL
depends on NRF_RTC_TIMER
select NRFX_DPPI
select MBOX if !IPM

if NRF53_SYNC_RTC

module = SYNC_RTC
module-str = Synchronized RTC
source "subsys/logging/Kconfig.template.log_config"

config NRF53_SYNC_RTC_INIT_PRIORITY
int "nRF53 Synchronized RTC init priority"
default APPLICATION_INIT_PRIORITY
help
nRF53 Synchronized RTC initialization priority.

config NRF_RTC_TIMER_USER_CHAN_COUNT
default 2 if NRF_802154_RADIO_DRIVER && SOC_COMPATIBLE_NRF5340_CPUNET
default 3 if NRF_802154_RADIO_DRIVER
default 1

config NRF53_SYNC_RTC_LOG_TIMESTAMP
bool "Use Synchronized RTC for logging timestamp"
default y

config NRF53_SYNC_RTC_IPM_OUT
int "IPM channel from APP to NET"
range 0 15
default 7 if SOC_COMPATIBLE_NRF5340_CPUAPP
default 8

config NRF53_SYNC_RTC_IPM_IN
int "IPM channel from APP to NET"
range 0 15
default 8 if SOC_COMPATIBLE_NRF5340_CPUAPP
default 7

ipm_num = 0
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 1
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 2
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 3
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 4
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 5
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 6
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 7
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 8
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 9
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 10
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 11
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 12
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 13
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 14
rsource "Kconfig.sync_rtc_ipm"
ipm_num = 15
rsource "Kconfig.sync_rtc_ipm"

endif # NRF53_SYNC_RTC
8 changes: 4 additions & 4 deletions soc/arm/nordic_nrf/nrf53/sync_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void free_resources(union rtc_sync_channels channels)

int z_nrf_rtc_timer_nrf53net_offset_get(void)
{
if (!IS_ENABLED(CONFIG_SOC_NRF5340_CPUNET)) {
if (!IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET)) {
return -ENOSYS;
}

Expand All @@ -135,7 +135,7 @@ static void rtc_cb(int32_t id, uint64_t cc_value, void *user_data)

channels.raw = (uint32_t)user_data;
ppi_rtc_to_ipc(channels, false);
if (IS_ENABLED(CONFIG_SOC_NRF5340_CPUAPP)) {
if (IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF5340_CPUAPP)) {
/* APP: Synchronized completed */
free_resources(channels);
} else {
Expand Down Expand Up @@ -165,7 +165,7 @@ static void remote_callback(void *user_data)
/* Clear previous task,event */
ppi_ipc_to_rtc(channels, false);

if (IS_ENABLED(CONFIG_SOC_NRF5340_CPUAPP)) {
if (IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF5340_CPUAPP)) {
/* Setup new connection from RTC to IPC and set RTC to a new
* interval that contains captured offset.
*/
Expand Down Expand Up @@ -258,7 +258,7 @@ static int sync_rtc_setup(void)

nrfx_gppi_channels_enable(BIT(channels.ch.ppi));

if (IS_ENABLED(CONFIG_SOC_NRF5340_CPUAPP)) {
if (IS_ENABLED(CONFIG_SOC_COMPATIBLE_NRF5340_CPUAPP)) {
ppi_ipc_to_rtc(channels, true);
} else {
ppi_rtc_to_ipc(channels, true);
Expand Down
Loading