1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/*
* Copyright © 2019-2022 The Crust Firmware Authors.
* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
*/
#ifndef CSS_PRIVATE_H
#define CSS_PRIVATE_H
#include <stdbool.h>
#include <stdint.h>
#include <platform/css.h>
struct power_state {
uint8_t core[MAX_CLUSTERS][MAX_CORES_PER_CLUSTER];
uint8_t cluster[MAX_CLUSTERS];
uint8_t css;
};
extern struct power_state power_state;
/**
* Get the number of cores present in a cluster.
*
* The number returned cannot be greater than 8.
*
* @param cluster The index of the cluster.
*/
uint32_t css_get_core_count(uint32_t cluster) ATTRIBUTE(const);
/**
* Get the pending IRQ status for each core in the CSS.
*
* Cores with pending IRQs will be woken up.
*
* @return Each set bit means some IRQ is pending for that core.
*/
uint32_t css_get_irq_status(void);
/**
* Suspend the compute subsystem (CSS).
*
* This function assumes that the previous CSS power state was "on".
*
* @param new_state The new coordinated power state for the CSS.
*/
void css_suspend_css(uint32_t new_state);
/**
* Prepare the compute subsystem (CSS) to resume execution.
*
* @param old_state The previous coordinated power state for the CSS.
*/
void css_resume_css(uint32_t old_state);
/**
* Suspend a cluster.
*
* This function assumes that the previous cluster power state was "on".
*
* @param cluster The index of the cluster.
* @param new_state The new coordinated power state for this cluster.
*/
void css_suspend_cluster(uint32_t cluster, uint32_t new_state);
/**
* Prepare a cluster to resume execution.
*
* @param cluster The index of the cluster.
* @param old_state The previous coordinated power state for this cluster.
*/
void css_resume_cluster(uint32_t cluster, uint32_t old_state);
/**
* Suspend a core.
*
* This function assumes that the previous core power state was "on".
*
* @param cluster The index of the cluster.
* @param core The index of the core within the cluster.
* @param new_state The new coordinated power state for this core.
*/
void css_suspend_core(uint32_t cluster, uint32_t core, uint32_t new_state);
/**
* Begin or resume execution on a core.
*
* @param cluster The index of the cluster.
* @param core The index of the core within the cluster.
* @param old_state The previous coordinated power state for this core.
*/
void css_resume_core(uint32_t cluster, uint32_t core, uint32_t old_state);
/**
* Enable or disable power to a core or cluster power domain.
*
* When enabling a power switch, the power domain will be turned on gradually
* to minimize inrush current and voltage drops.
*
* The mapping of cores/clusters to register addresses is platform-dependent.
*
* @param addr The address of the register controlling the power switch.
* @param enable Whether to enable or disable the power switch.
*/
void css_set_power_switch(uintptr_t addr, bool enable);
#endif /* CSS_PRIVATE_H */
|