LCOV - code coverage report
Current view: top level - subsys/pm - state.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 5 0.0 %
Date: 2022-08-18 11:36:24 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2018 Intel Corporation.
       3                 :            :  * Copyright (c) 2021 Nordic Semiconductor ASA
       4                 :            :  *
       5                 :            :  * SPDX-License-Identifier: Apache-2.0
       6                 :            :  */
       7                 :            : 
       8                 :            : #include <pm/state.h>
       9                 :            : #include <toolchain.h>
      10                 :            : 
      11                 :            : BUILD_ASSERT(DT_NODE_EXISTS(DT_PATH(cpus)),
      12                 :            :              "cpus node not defined in Devicetree");
      13                 :            : 
      14                 :            : /**
      15                 :            :  * Check CPU power state consistency.
      16                 :            :  *
      17                 :            :  * @param i Power state index.
      18                 :            :  * @param node_id CPU node identifier.
      19                 :            :  */
      20                 :            : #define CHECK_POWER_STATE_CONSISTENCY(i, node_id)                              \
      21                 :            :         BUILD_ASSERT(                                                          \
      22                 :            :                 DT_PROP_BY_PHANDLE_IDX_OR(node_id, cpu_power_states, i,        \
      23                 :            :                                           min_residency_us, 0U) >=          \
      24                 :            :                 DT_PROP_BY_PHANDLE_IDX_OR(node_id, cpu_power_states, i,        \
      25                 :            :                                           exit_latency_us, 0U),                \
      26                 :            :                 "Found CPU power state with min_residency < exit_latency")
      27                 :            : 
      28                 :            : /**
      29                 :            :  * @brief Check CPU power states consistency
      30                 :            :  *
      31                 :            :  * All states should have a minimum residency >= than the exit latency.
      32                 :            :  *
      33                 :            :  * @param node_id A CPU node identifier.
      34                 :            :  */
      35                 :            : #define CHECK_POWER_STATES_CONSISTENCY(node_id)                                \
      36                 :            :         LISTIFY(DT_NUM_CPU_POWER_STATES(node_id),                              \
      37                 :            :                 CHECK_POWER_STATE_CONSISTENCY, (;), node_id);                  \
      38                 :            : 
      39                 :            : /* Check that all power states are consistent */
      40                 :            : DT_FOREACH_CHILD(DT_PATH(cpus), CHECK_POWER_STATES_CONSISTENCY)
      41                 :            : 
      42                 :            : #define NUM_CPU_STATES(n) DT_NUM_CPU_POWER_STATES(n),
      43                 :            : 
      44                 :            : #define DEFINE_CPU_STATES(n) \
      45                 :            :         static const struct pm_state_info pmstates_##n[] \
      46                 :            :                 = PM_STATE_INFO_LIST_FROM_DT_CPU(n);
      47                 :            : #define CPU_STATE_REF(n) pmstates_##n,
      48                 :            : 
      49                 :            : DT_FOREACH_CHILD(DT_PATH(cpus), DEFINE_CPU_STATES);
      50                 :            : 
      51                 :            : /** CPU power states information for each CPU */
      52                 :            : static const struct pm_state_info *cpus_states[] = {
      53                 :            :         DT_FOREACH_CHILD(DT_PATH(cpus), CPU_STATE_REF)
      54                 :            : };
      55                 :            : 
      56                 :            : /** Number of states for each CPU */
      57                 :            : static const uint8_t states_per_cpu[] = {
      58                 :            :         DT_FOREACH_CHILD(DT_PATH(cpus), NUM_CPU_STATES)
      59                 :            : };
      60                 :            : 
      61                 :          0 : uint8_t pm_state_cpu_get_all(uint8_t cpu, const struct pm_state_info **states)
      62                 :            : {
      63         [ #  # ]:          0 :         if (cpu >= ARRAY_SIZE(cpus_states)) {
      64                 :          0 :                 return 0;
      65                 :            :         }
      66                 :            : 
      67                 :          0 :         *states = cpus_states[cpu];
      68                 :            : 
      69                 :          0 :         return states_per_cpu[cpu];
      70                 :            : }

Generated by: LCOV version 1.14