@@ -192,6 +192,20 @@ struct pm_state_info {
192192 COND_CODE_1(DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i), okay), \
193193 (PM_STATE_INFO_DT_INIT(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)),), ())
194194
195+ /**
196+ * @brief Helper macro to initialize an entry of a struct pm_state_info array
197+ * when using UTIL_LISTIFY in PM_STATE_INFO_LIST_FROM_DT_REINIT.
198+ *
199+ * @note Only enabled states are initialized.
200+ *
201+ * @param i UTIL_LISTIFY entry index.
202+ * @param node_id A node identifier with compatible zephyr,power-state
203+ */
204+ #define Z_PM_STATE_INFO_FROM_DT_REINIT (i , node_id ) \
205+ COND_CODE_1(DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, reinit_power_states, i), okay), \
206+ (PM_STATE_INFO_DT_INIT(DT_PHANDLE_BY_IDX(node_id, reinit_power_states, i)),), \
207+ ())
208+
195209/**
196210 * @brief Helper macro to initialize an entry of a struct pm_state array when
197211 * using UTIL_LISTIFY in PM_STATE_LIST_FROM_DT_CPU.
@@ -303,6 +317,60 @@ struct pm_state_info {
303317 Z_PM_STATE_INFO_FROM_DT_CPU, (), node_id) \
304318 }
305319
320+ /**
321+ * @brief Initialize an array of struct pm_state_info with information from all
322+ * the states present and enabled in the given device node identifier.
323+ *
324+ * Example devicetree fragment:
325+ *
326+ * @code{.dts}
327+ soc {
328+ * ...
329+ * cpu0: cpu@0 {
330+ * device_type = "cpu";
331+ * ...
332+ * cpu-power-states = <&state0 &state1>;
333+ * };
334+
335+ * i2c1: i2c@50000000 {
336+ * ...
337+ * reinit-power-states = <&state1>;
338+ * };
339+ *
340+ * power-states {
341+ * state0: state0 {
342+ * compatible = "zephyr,power-state";
343+ * power-state-name = "suspend-to-idle";
344+ * min-residency-us = <10000>;
345+ * exit-latency-us = <100>;
346+ * };
347+ *
348+ * state1: state1 {
349+ * compatible = "zephyr,power-state";
350+ * power-state-name = "suspend-to-ram";
351+ * min-residency-us = <50000>;
352+ * exit-latency-us = <500>;
353+ * };
354+ * };
355+ * };
356+
357+ * @endcode
358+ *
359+ * Example usage:
360+ *
361+ * @code{.c}
362+ * const struct pm_state_info states[] =
363+ * PM_STATE_INFO_LIST_FROM_DT_REINIT(DT_NODELABEL(i2c1));
364+ * @endcode
365+ *
366+ * @param node_id A device node identifier.
367+ */
368+ #define PM_STATE_INFO_LIST_FROM_DT_REINIT (node_id ) \
369+ { \
370+ LISTIFY(DT_PROP_LEN_OR(node_id, reinit_power_states, 0), \
371+ Z_PM_STATE_INFO_FROM_DT_REINIT, (), node_id) \
372+ }
373+
306374/**
307375 * @brief Initialize an array of struct pm_state with information from all the
308376 * states present and enabled in the given CPU node identifier.
0 commit comments