Skip to content

Commit 7285f59

Browse files
anangljfischer-no
authored andcommitted
[nrf fromlist] modules: hal_nordic: Enable support for DPPI on nRF54H20
Include into compilation the nrfx_gppi_dppi_ppib helper and related interconnect layers when DPPIC nodes are enabled in DTS. Provide macro definitions required by those interconnect layers based on information from devicetree (the nrf_grtc_timer is only modified because a macro that it uses became more generic). Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit e46a0a51650dcd2afd3216fdb8a003dd7080cdf9) Upstream PR: zephyrproject-rtos/zephyr#69811
1 parent 1382003 commit 7285f59

File tree

3 files changed

+121
-12
lines changed

3 files changed

+121
-12
lines changed

drivers/timer/nrf_grtc_timer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#if !DT_NODE_HAS_PROP(GRTC_NODE, owned_channels)
2222
#error GRTC owned-channels DT property is not defined
2323
#endif
24-
#define OWNED_CHANNELS_MASK NRFX_CONFIG_GRTC_MASK_DT(owned_channels)
25-
#define CHILD_OWNED_CHANNELS_MASK NRFX_CONFIG_GRTC_MASK_DT(child_owned_channels)
24+
#define OWNED_CHANNELS_MASK NRFX_CONFIG_MASK_DT(GRTC_NODE, owned_channels)
25+
#define CHILD_OWNED_CHANNELS_MASK NRFX_CONFIG_MASK_DT(GRTC_NODE, child_owned_channels)
2626
#if ((OWNED_CHANNELS_MASK | CHILD_OWNED_CHANNELS_MASK) != OWNED_CHANNELS_MASK)
2727
#error GRTC child-owned-channels DT property must be a subset of owned-channels
2828
#endif

modules/hal_nordic/nrfx/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ if(CONFIG_SOC_SERIES_NRF54LX AND CONFIG_NRFX_DPPI)
158158
zephyr_library_sources(${NRFX_DIR}/soc/interconnect/dppic_ppib/nrfx_interconnect_dppic_ppib.c)
159159
endif()
160160

161+
if(CONFIG_SOC_SERIES_NRF54HX AND
162+
(CONFIG_DT_HAS_NORDIC_NRF_DPPIC_LOCAL_ENABLED OR
163+
CONFIG_DT_HAS_NORDIC_NRF_DPPIC_GLOBAL_ENABLED))
164+
zephyr_library_sources(${HELPERS_DIR}/nrfx_gppi_dppi_ppib.c)
165+
zephyr_library_sources(${NRFX_DIR}/soc/interconnect/apb/nrfx_interconnect_apb.c)
166+
zephyr_library_sources(${NRFX_DIR}/soc/interconnect/ipct/nrfx_interconnect_ipct.c)
167+
endif()
168+
161169
# Get the SVD file for the current SoC
162170
macro(mdk_svd_ifdef feature_toggle filename)
163171
if(${feature_toggle})

modules/hal_nordic/nrfx/nrfx_config.h

+111-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define NRFX_CONFIG_H__
99

1010
#include <zephyr/devicetree.h>
11+
#include <zephyr/sys/util_macro.h>
1112

1213
/*
1314
* These are mappings of Kconfig options enabling nrfx drivers and particular
@@ -756,27 +757,127 @@
756757
#define NRF_PERIPH(P) P##_S
757758
#endif
758759

760+
#define NRFX_CONFIG_BIT_DT(node_id, prop, idx) BIT(DT_PROP_BY_IDX(node_id, prop, idx))
761+
#define NRFX_CONFIG_MASK_DT(node_id, prop) \
762+
(COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
763+
(DT_FOREACH_PROP_ELEM_SEP(node_id, prop, NRFX_CONFIG_BIT_DT, (|))), \
764+
(0)))
765+
759766
/* If the GRTC system timer driver is to be used, prepare definitions required
760767
* by the nrfx_grtc driver (NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK and
761768
* NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS) based on information from devicetree.
762769
*/
763770
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc)
764-
#define NRFX_CONFIG_BIT_DT(node_id, prop, idx) \
765-
BIT(DT_PROP_BY_IDX(node_id, prop, idx))
766-
#define NRFX_CONFIG_GRTC_MASK_DT(prop) \
767-
(COND_CODE_1(DT_NODE_HAS_PROP(DT_INST(0, nordic_nrf_grtc), prop), \
768-
(DT_FOREACH_PROP_ELEM_SEP(DT_INST(0, nordic_nrf_grtc), prop, \
769-
NRFX_CONFIG_BIT_DT, (|))), \
770-
(0)))
771-
772771
#define NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK \
773-
(NRFX_CONFIG_GRTC_MASK_DT(owned_channels) & \
774-
~NRFX_CONFIG_GRTC_MASK_DT(child_owned_channels))
772+
(NRFX_CONFIG_MASK_DT(DT_INST(0, nordic_nrf_grtc), owned_channels) & \
773+
~NRFX_CONFIG_MASK_DT(DT_INST(0, nordic_nrf_grtc), child_owned_channels))
775774
#define NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS \
776775
(DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), owned_channels, 0) - \
777776
DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), child_owned_channels, 0))
778777
#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc) */
779778

779+
/* If global of local DPPIC peripherals are used, provide the following macro
780+
* definitions required by the interconnect/apb layer:
781+
* - NRFX_DPPI_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num)
782+
* - NRFX_DPPI_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num)
783+
* - NRFX_DPPI_PUB_OR_SUB_MASK(inst_num)
784+
* - NRFX_DPPI_CHANNELS_SINGLE_VAR_NAME_BY_INST_NUM(inst_num)
785+
* - NRFX_INTERCONNECT_APB_GLOBAL_DPPI_DEFINE
786+
* - NRFX_INTERCONNECT_APB_LOCAL_DPPI_DEFINE
787+
* based on information from devicetree.
788+
*/
789+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_dppic_global) || \
790+
DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_dppic_local)
791+
#ifndef NRFX_DPPI_ENABLED
792+
#define NRFX_DPPI_ENABLED 1
793+
#endif
794+
/* Source (publish) channels masks generation. */
795+
#define NRFX_DPPI_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \
796+
NRFX_CONFIG_MASK_DT(DT_NODELABEL(_CONCAT(dppic, inst_num)), source_channels)
797+
798+
/* Sink (subscribe) channels masks generation. */
799+
#define NRFX_DPPI_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \
800+
NRFX_CONFIG_MASK_DT(DT_NODELABEL(_CONCAT(dppic, inst_num)), sink_channels)
801+
802+
#define NRFX_DPPI_PUB_OR_SUB_MASK(inst_num) \
803+
UTIL_OR(DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), source_channels), \
804+
DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), sink_channels))
805+
806+
/* Variables names generation. */
807+
#define NRFX_CONFIG_DPPI_CHANNELS_ENTRY_NAME(node_id) _CONCAT(_CONCAT(m_, node_id), _channels)
808+
#define NRFX_DPPI_CHANNELS_SINGLE_VAR_NAME_BY_INST_NUM(inst_num) \
809+
NRFX_CONFIG_DPPI_CHANNELS_ENTRY_NAME(DT_NODELABEL(_CONCAT(dppic, inst_num)))
810+
811+
/* Variables entries generation. */
812+
#define NRFX_CONFIG_DPPI_CHANNELS_ENTRY(node_id) \
813+
static nrfx_atomic_t NRFX_CONFIG_DPPI_CHANNELS_ENTRY_NAME(node_id) \
814+
__attribute__((used)) = \
815+
NRFX_CONFIG_MASK_DT(node_id, source_channels) | \
816+
NRFX_CONFIG_MASK_DT(node_id, sink_channels);
817+
#define NRFX_INTERCONNECT_APB_GLOBAL_DPPI_DEFINE \
818+
DT_FOREACH_STATUS_OKAY(nordic_nrf_dppic_global, NRFX_CONFIG_DPPI_CHANNELS_ENTRY)
819+
#define NRFX_INTERCONNECT_APB_LOCAL_DPPI_DEFINE \
820+
DT_FOREACH_STATUS_OKAY(nordic_nrf_dppic_local, NRFX_CONFIG_DPPI_CHANNELS_ENTRY)
821+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_dppic_global) || ... */
822+
823+
/* If local or global DPPIC peripherals are used, provide the following macro
824+
* definitions required by the interconnect/ipct layer:
825+
* - NRFX_IPCTx_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num)
826+
* - NRFX_IPCTx_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num)
827+
* - NRFX_IPCT_PUB_OR_SUB_MASK(inst_num)
828+
* - NRFX_IPCTx_CHANNELS_SINGLE_VAR_NAME_BY_INST_NUM(inst_num)
829+
* - NRFX_INTERCONNECT_IPCT_GLOBAL_DEFINE
830+
* - NRFX_INTERCONNECT_IPCT_LOCAL_DEFINE
831+
* based on information from devicetree.
832+
*/
833+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_ipct_global) || \
834+
DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_ipct_local)
835+
/* Channels masks generation. */
836+
#define NRFX_CONFIG_IPCT_MASK_DT(node_id) \
837+
COND_CODE_1(DT_NODE_HAS_PROP(node_id, owned_channels), \
838+
(NRFX_CONFIG_MASK_DT(node_id, owned_channels)), \
839+
(COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, nordic_nrf_ipct_local), \
840+
(BIT_MASK(DT_PROP(node_id, channels))), (0))))
841+
842+
#if defined(NRF_APPLICATION)
843+
#define NRFX_CONFIG_IPCT_LOCAL_NODE DT_NODELABEL(cpuapp_ipct)
844+
#elif defined(NRF_RADIOCORE)
845+
#define NRFX_CONFIG_IPCT_LOCAL_NODE DT_NODELABEL(cpurad_ipct)
846+
#endif
847+
#define NRFX_CONFIG_IPCT_NODE_BY_INST_NUM(inst_num) \
848+
COND_CODE_1(IS_EMPTY(inst_num), \
849+
(NRFX_CONFIG_IPCT_LOCAL_NODE), \
850+
(DT_NODELABEL(_CONCAT(ipct, inst_num))))
851+
852+
#define NRFX_IPCTx_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \
853+
NRFX_CONFIG_IPCT_MASK_DT(NRFX_CONFIG_IPCT_NODE_BY_INST_NUM(inst_num))
854+
855+
#define NRFX_IPCTx_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \
856+
NRFX_CONFIG_IPCT_MASK_DT(NRFX_CONFIG_IPCT_NODE_BY_INST_NUM(inst_num))
857+
858+
#define NRFX_IPCT_PUB_OR_SUB_MASK(inst_num) \
859+
COND_CODE_1(IS_EMPTY(inst_num), \
860+
(DT_NODE_HAS_STATUS(NRFX_CONFIG_IPCT_LOCAL_NODE, okay)), \
861+
(DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(ipct, inst_num)), owned_channels)))
862+
863+
/* Variables names generation. */
864+
#define NRFX_CONFIG_IPCT_CHANNELS_ENTRY_NAME(node_id) _CONCAT(_CONCAT(m_, node_id), _channels)
865+
#define NRFX_IPCTx_CHANNELS_SINGLE_VAR_NAME_BY_INST_NUM(inst_num) \
866+
COND_CODE_1(IS_EMPTY(inst_num), \
867+
(NRFX_CONFIG_IPCT_CHANNELS_ENTRY_NAME(NRFX_CONFIG_IPCT_LOCAL_NODE)), \
868+
(NRFX_CONFIG_IPCT_CHANNELS_ENTRY_NAME(DT_NODELABEL(_CONCAT(ipct, inst_num)))))
869+
870+
/* Variables entries generation. */
871+
#define NRFX_CONFIG_IPCT_CHANNELS_ENTRY(node_id) \
872+
static nrfx_atomic_t NRFX_CONFIG_IPCT_CHANNELS_ENTRY_NAME(node_id) \
873+
__attribute__((used)) = \
874+
NRFX_CONFIG_IPCT_MASK_DT(node_id);
875+
#define NRFX_INTERCONNECT_IPCT_LOCAL_DEFINE \
876+
DT_FOREACH_STATUS_OKAY(nordic_nrf_ipct_local, NRFX_CONFIG_IPCT_CHANNELS_ENTRY)
877+
#define NRFX_INTERCONNECT_IPCT_GLOBAL_DEFINE \
878+
DT_FOREACH_STATUS_OKAY(nordic_nrf_ipct_global, NRFX_CONFIG_IPCT_CHANNELS_ENTRY)
879+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_ipct_global) || ... */
880+
780881
#include <nrfx_config_common.h>
781882
#if defined(NRF51)
782883
#include <nrfx_config_nrf51.h>

0 commit comments

Comments
 (0)