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  *      SCMI power capping and monitoring protocol completer support.
9  */
10 
11 #ifndef INTERNAL_SCMI_POWER_CAPPING_H
12 #define INTERNAL_SCMI_POWER_CAPPING_H
13 
14 #include "mod_power_allocator.h"
15 #include "mod_power_coordinator.h"
16 #include "mod_power_meter.h"
17 #include "mod_scmi_power_capping.h"
18 
19 #include <fwk_event.h>
20 #include <fwk_id.h>
21 
22 #include <stdint.h>
23 
24 /*!
25  * \addtogroup GroupModules Modules
26  * \{
27  */
28 
29 /*!
30  * \defgroup GroupSCMI_POWER_CAPPING SCMI power capping and monitoring Protocol
31  * \{
32  */
33 
34 /*
35  * SCMI power cap event IDs
36  */
37 enum scmi_power_capping_event_idx {
38 #ifdef BUILD_HAS_SCMI_NOTIFICATIONS
39     SCMI_POWER_CAPPING_EVENT_IDX_CAP_PAI_NOTIFY_PROCESS,
40     SCMI_POWER_CAPPING_EVENT_IDX_MEASUREMENT_NOTIFY_PROCESS,
41 #endif
42 #ifdef BUILD_HAS_SCMI_POWER_CAPPING_FAST_CHANNELS_COMMANDS
43     SCMI_POWER_CAPPING_EVENT_IDX_FAST_CHANNELS_PROCESS,
44 #endif
45     SCMI_POWER_CAPPING_EVENT_COUNT,
46 };
47 
48 /*!
49  * \brief Power management related APIs.
50  */
51 struct mod_scmi_power_capping_power_apis {
52     /* Power allocator API */
53     const struct mod_power_allocator_api *power_allocator_api;
54 
55     /* Power coordinator API */
56     const struct mod_power_coordinator_api *power_coordinator_api;
57 
58     /* Power meter API */
59     const struct mod_power_meter_api *power_meter_api;
60 };
61 
62 struct mod_scmi_power_capping_domain_context {
63     /* Power capping domain configuration */
64     const struct mod_scmi_power_capping_domain_config *config;
65 
66     /*!
67      * \brief Power Cap Service ID
68      *
69      * \details Stores the service id corresponding to the agent that requested
70      *      a power cap indicating that the domain is busy.
71      *      It is set to FWK_ID_NONE when the domain is not used by an agent.
72      */
73 
74     fwk_id_t cap_pending_service_id;
75 
76     /*!
77      * \brief Power Cap Notification Service ID
78      *
79      * \details Stores the service id corresponding to the agent that requested
80      *      a Power Cap change. This variable is then used to determine which
81      *      agent that is responsible for the Power Cap change SCMI
82      *      notification.
83      *      It is set to FWK_ID_NONE when no agent is responsible for the Power
84      *      Cap change notification.
85      */
86     fwk_id_t cap_notification_service_id;
87 
88     /*!
89      * \brief PAI Notification Service ID
90      *
91      * \details Stores the service id corresponding to the agent that requested
92      *      a PAI change. This variable is then used to determine which agent
93      *      that is responsible for the PAI change SCMI notification.
94      *      It is set to FWK_ID_NONE when no agent is responsible for the PAI
95      *      change notification.
96      */
97     fwk_id_t pai_notification_service_id;
98 
99     /*!
100      * \brief Power capping configuration support.
101      */
102     bool cap_config_support;
103 
104     /*!
105      * \brief PAI configuration support.
106      */
107     bool pai_config_support;
108 };
109 
110 struct mod_scmi_power_capping_context {
111     /* Table of power capping domain ctxs */
112     struct mod_scmi_power_capping_domain_context
113         *power_capping_domain_ctx_table;
114     /* Power capping domain count */
115     uint32_t domain_count;
116 };
117 
118 /*!
119  * \}
120  */
121 
122 /*!
123  * \}
124  */
125 
126 #endif /* INTERNAL_SCMI_POWER_CAPPING_H */
127