|
8 | 8 | #define NRFX_CONFIG_H__
|
9 | 9 |
|
10 | 10 | #include <zephyr/devicetree.h>
|
| 11 | +#include <zephyr/sys/util_macro.h> |
11 | 12 |
|
12 | 13 | /*
|
13 | 14 | * These are mappings of Kconfig options enabling nrfx drivers and particular
|
|
756 | 757 | #define NRF_PERIPH(P) P##_S
|
757 | 758 | #endif
|
758 | 759 |
|
| 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 | + |
759 | 766 | /* If the GRTC system timer driver is to be used, prepare definitions required
|
760 | 767 | * by the nrfx_grtc driver (NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK and
|
761 | 768 | * NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS) based on information from devicetree.
|
762 | 769 | */
|
763 | 770 | #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 |
| - |
772 | 771 | #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)) |
775 | 774 | #define NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS \
|
776 | 775 | (DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), owned_channels, 0) - \
|
777 | 776 | DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), child_owned_channels, 0))
|
778 | 777 | #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc) */
|
779 | 778 |
|
| 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 | + |
780 | 881 | #include <nrfx_config_common.h>
|
781 | 882 | #if defined(NRF51)
|
782 | 883 | #include <nrfx_config_nrf51.h>
|
|
0 commit comments