@@ -25,21 +25,52 @@ extern "C" {
2525/** Type for nRF pin. */
2626typedef uint32_t pinctrl_soc_pin_t ;
2727
28+ /**
29+ * @brief Utility macro to check if a function requires clockpin enable.
30+ *
31+ * @param node_id Node identifier.
32+ * @param prop Property name.
33+ * @param idx Property entry index.
34+ * @param p_node_id Parent node identifier.
35+ */
36+ #define Z_CHECK_CLOCKPIN_ENABLE (node_id , prop , idx , fun ) \
37+ DT_PROP_BY_IDX(node_id, prop, idx) == fun ? BIT(NRF_CLOCKPIN_ENABLE_POS) :
38+
39+ /**
40+ * @brief Utility macro compute the clockpin enable bit.
41+ *
42+ * @note DT_FOREACH_PROP_ELEM_SEP_VARGS() is used instead of
43+ * DT_FOREACH_PROP_ELEM_VARGS() because the latter is already resolved in the
44+ * same run.
45+ *
46+ * @param node_id Node identifier.
47+ * @param prop Property name.
48+ * @param idx Property entry index.
49+ * @param p_node_id Parent node identifier.
50+ */
51+ #define Z_GET_CLOCKPIN_ENABLE (node_id , prop , idx , p_node_id ) \
52+ COND_CODE_1(DT_NODE_HAS_PROP(p_node_id, nordic_clockpin_enable), \
53+ ((DT_FOREACH_PROP_ELEM_SEP_VARGS( \
54+ p_node_id, nordic_clockpin_enable, Z_CHECK_CLOCKPIN_ENABLE, \
55+ (), NRF_GET_FUN(DT_PROP_BY_IDX(node_id, prop, idx))) \
56+ 0)), (0))
57+
2858/**
2959 * @brief Utility macro to initialize each pin.
3060 *
3161 * @param node_id Node identifier.
3262 * @param prop Property name.
3363 * @param idx Property entry index.
64+ * @param p_node_id Parent node identifier.
3465 */
35- #define Z_PINCTRL_STATE_PIN_INIT (node_id , prop , idx ) \
66+ #define Z_PINCTRL_STATE_PIN_INIT (node_id , prop , idx , p_node_id ) \
3667 (DT_PROP_BY_IDX(node_id, prop, idx) | \
3768 ((NRF_PULL_DOWN * DT_PROP(node_id, bias_pull_down)) << NRF_PULL_POS) |\
3869 ((NRF_PULL_UP * DT_PROP(node_id, bias_pull_up)) << NRF_PULL_POS) | \
3970 (DT_PROP(node_id, nordic_drive_mode) << NRF_DRIVE_POS) | \
4071 ((NRF_LP_ENABLE * DT_PROP(node_id, low_power_enable)) << NRF_LP_POS) |\
4172 (DT_PROP(node_id, nordic_invert) << NRF_INVERT_POS) | \
42- (DT_PROP( node_id, nordic_clock_enable) << NRF_CLOCK_ENABLE_POS) \
73+ Z_GET_CLOCKPIN_ENABLE( node_id, prop, idx, p_node_id) \
4374 ),
4475
4576/**
@@ -50,8 +81,8 @@ typedef uint32_t pinctrl_soc_pin_t;
5081 */
5182#define Z_PINCTRL_STATE_PINS_INIT (node_id , prop ) \
5283 {DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), \
53- DT_FOREACH_PROP_ELEM , psels, \
54- Z_PINCTRL_STATE_PIN_INIT)}
84+ DT_FOREACH_PROP_ELEM_VARGS , psels, \
85+ Z_PINCTRL_STATE_PIN_INIT, node_id )}
5586
5687/**
5788 * @brief Utility macro to obtain pin function.
@@ -61,11 +92,12 @@ typedef uint32_t pinctrl_soc_pin_t;
6192#define NRF_GET_FUN (pincfg ) (((pincfg) >> NRF_FUN_POS) & NRF_FUN_MSK)
6293
6394/**
64- * @brief Utility macro to obtain pin clock enable flag.
95+ * @brief Utility macro to obtain pin clockpin enable flag.
6596 *
6697 * @param pincfg Pin configuration bit field.
6798 */
68- #define NRF_GET_CLOCK_ENABLE (pincfg ) (((pincfg) >> NRF_CLOCK_ENABLE_POS) & NRF_CLOCK_ENABLE_MSK)
99+ #define NRF_GET_CLOCKPIN_ENABLE (pincfg ) \
100+ (((pincfg) >> NRF_CLOCKPIN_ENABLE_POS) & NRF_CLOCKPIN_ENABLE_MSK)
69101
70102/**
71103 * @brief Utility macro to obtain pin inversion flag.
0 commit comments