• Soby Mathew's avatar
    PSCI: Add framework to handle composite power states · 8ee24980
    Soby Mathew authored
    The state-id field in the power-state parameter of a CPU_SUSPEND call can be
    used to describe composite power states specific to a platform. The current PSCI
    implementation does not interpret the state-id field. It relies on the target
    power level and the state type fields in the power-state parameter to perform
    state coordination and power management operations. The framework introduced
    in this patch allows the PSCI implementation to intepret generic global states
    like RUN, RETENTION or OFF from the State-ID to make global state coordination
    decisions and reduce the complexity of platform ports. It adds support to
    involve the platform in state coordination which facilitates the use of
    composite power states and improves the support for entering standby states
    at multiple power domains.
    
    The patch also includes support for extended state-id format for the power
    state parameter as specified by PSCIv1.0.
    
    The PSCI implementation now defines a generic representation of the power-state
    parameter. It depends on the platform port to convert the power-state parameter
    (possibly encoding a composite power state) passed in a CPU_SUSPEND call to this
    representation via the `validate_power_state()` plat_psci_ops handler. It is an
    array where each index corresponds to a power level. Each entry contains the
    local power state the power domain at that power level could enter.
    
    The meaning of the local power state values is platform defined, and may vary
    between levels in a single platform. The PSCI implementation constrains the
    values only so that it can classify the state as RUN, RETENTION or OFF as
    required by the specification:
       * zero means RUN
       * all OFF state values at all levels must be higher than all RETENTION
         state values at all levels
       * the platform provides PLAT_MAX_RET_STATE and PLAT_MAX_OFF_STATE values
         to the framework
    
    The platform also must define the macros PLAT_MAX_RET_STATE and
    PLAT_MAX_OFF_STATE which lets the PSCI implementation find out which power
    domains have been requested to enter a retention or power down state. The PSCI
    implementation does not interpret the local power states defined by the
    platform. The only constraint is that the PLAT_MAX_RET_STATE <
    PLAT_MAX_OFF_STATE.
    
    For a power domain tree, the generic implementation maintains an array of local
    power states. These are the states requested for each power domain by all the
    cores contained within the domain. During a request to place multiple power
    domains in a low power state, the platform is passed an array of requested
    power-states for each power domain through the plat_get_target_pwr_state()
    API. It coordinates amongst these states to determine a target local power
    state for the power domain. A default weak implementation of this API is
    provided in the platform layer which returns the minimum of the requested
    power-states back to the PSCI state coordination.
    
    Finally, the plat_psci_ops power management handlers are passed the target
    local power states for each affected power domain using the generic
    representation described above. The platform executes operations specific to
    these target states.
    
    The platform power management handler for placing a power domain in a standby
    state (plat_pm_ops_t.pwr_domain_standby()) is now only used as a fast path for
    placing a core power domain into a standby or retention state should now be
    used to only place the core power domain in a standby or retention state.
    
    The extended state-id power state format can be enabled by setting the
    build flag PSCI_EXTENDED_STATE_ID=1 and it is disabled by default.
    
    Change-Id: I9d4123d97e179529802c1f589baaa4101759d80c
    8ee24980
psci_suspend.c 9.57 KB