1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *     Power allocator module header.
9  */
10 
11 #ifndef MOD_POWER_ALLOCATOR_H
12 #define MOD_POWER_ALLOCATOR_H
13 
14 #include <fwk_id.h>
15 
16 /*!
17  * \addtogroup GroupModules Modules
18  * \{
19  */
20 
21 /*!
22  * \defgroup GroupPowerAllocator Power Allocator
23  *
24  * \details Responsible for power allocation and management in SCP
25  *
26  * \{
27  */
28 
29 /*!
30  * \brief Power Allocator interface.
31  */
32 struct mod_power_allocator_api {
33     /*!
34      * \brief Get the power cap imposed on a power capping domain.
35      *
36      * \param domain_id Power capping domain id.
37      * \param[out] cap Power cap imposed on the domain specified by the
38      *      domain id.
39      *
40      * \retval ::FWK_SUCCESS The cap is returned successfully.
41      */
42     int (*get_cap)(fwk_id_t domain_id, uint32_t *cap);
43 
44     /*!
45      * \brief Set a power cap for a power capping domain.
46      *
47      * \param domain_id Power capping domain id.
48      * \param cap The required power cap to be set for a domain specified by the
49      *      domain id. Setting this value to zero means disabling power capping.
50      *
51      * \retval ::FWK_SUCCESS The cap is set successfully.
52      * \retval ::FWK_PENDING The cap hasn't been set yet. The power allocator
53      *      is processing the cap set request. Once the power allocator sets a
54      *      new power cap, it will notify the registered modules about it.
55      */
56     int (*set_cap)(fwk_id_t domain_id, uint32_t cap);
57 };
58 
59 /*!
60  * \brief API indices.
61  */
62 enum mod_power_allocator_api_idx {
63     /*! Cap set and get API. */
64     MOD_POWER_ALLOCATOR_API_IDX_CAP,
65 
66     /*! Number of defined APIs. */
67     MOD_POWER_ALLOCATOR_API_IDX_COUNT,
68 };
69 
70 /*!
71  * \brief Power allocator notification indices.
72  */
73 enum mod_power_allocator_notification_idx {
74     /*! Power cap changed notification. */
75     MOD_POWER_ALLOCATOR_NOTIFICATION_IDX_CAP_CHANGED,
76 
77     /*! Number of defined notifications. */
78     MOD_POWER_ALLOCATOR_NOTIFICATION_IDX_COUNT,
79 };
80 
81 /*!
82  * \}
83  */
84 
85 /*!
86  * \}
87  */
88 #endif /* MOD_POWER_ALLOCATOR_H */
89