Power Manager HAL 0.2.0
 
Loading...
Searching...
No Matches
plat_power.h
Go to the documentation of this file.
1/*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2016 RDK Management
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18*/
19
20/**
21 * @addtogroup HPK Hardware Porting Kit
22 * @{
23 * @par The Hardware Porting Kit
24 * HPK is the next evolution of the well-defined Hardware Abstraction Layer
25 * (HAL), but augmented with more comprehensive documentation and test suites
26 * that OEM or SOC vendors can use to self-certify their ports before taking
27 * them to RDKM for validation or to an operator for final integration and
28 * deployment. The Hardware Porting Kit effectively enables an OEM and/or SOC
29 * vendor to self-certify their own Video Accelerator devices, with minimal RDKM
30 * assistance.
31 *
32 */
33
34 /**
35 * @defgroup POWER_MANAGER Power Manager Module
36 * @{
37 */
38
39/**
40 * @defgroup POWER_MANAGER_HAL Power Manager HAL
41 * @{
42 * Described herein are the PWRMGR_HAL HAL types and functions that are part of the Power
43 * Manager HAL. All listeners should releases resources when
44 * entering POWER OFF/STANDBY state and re-acquire them when entering POWER ON state.
45 */
46
47/**
48 * @defgroup IARM_PLAT_POWER_API Power Manager (HAL Types and Public API)
49 * Described herein are the IARM-Bus HAL types and functions that are part of the Power
50 * Manager application. This manager monitors Power IR key events and reacts to power
51 * state changes based on RDK Power Management Specification. It dispatches
52 * Power Mode Change events to IARM-Bus. All listeners should releases resources when
53 * entering POWER OFF/STANDBY state and re-acquire them when entering POWER ON state.
54 */
55
56/**
57 * @defgroup PLAT_POWER_H Plat Power
58 * @{
59 */
60
61/**
62 * @file plat_power.h
63 *
64 * @par Abbreviations
65 * - HAL: Hardware Abstraction Layer
66 * - CPE: Customer Premises Equipment
67 * - CPU: Central Processing Unit
68 *
69 *
70 * @par Implementation Notes
71 * -# None
72 *
73 */
74
75
76#ifndef _POWERMGR_PLAT_H
77#define _POWERMGR_PLAT_H
78#include "pwrMgr.h"
79#ifdef __cplusplus
80extern "C"
81{
82#endif
83
84/**
85 * @brief Initializes the underlying Power Management module
86 *
87 * This function must initialize all aspects of the CPE's Power Management module.
88 *
89 * @return Returns the status of the operation
90 * @retval 0 if successful, appropiate error code otherwise.
91 *
92 */
93int PLAT_INIT(void);
94
95/**
96 * @brief Sets the CPE Power State
97 *
98 * This fumction is just required to hold the value of the current power state status.
99 *
100 * @param[in] newState - The new power state value
101 *
102 * @return Returns the status of the operation.
103 * @retval 0 if successful, appropiate error code otherwise.
104 *
105 * @pre PLAT_INIT() must be called before calling this API
106 *
107 * @warning This API is Not thread safe
108 *
109 * @see PLAT_API_GetPowerState(), IARM_Bus_PWRMgr_PowerState_t (@see section)
110 *
111 */
112int PLAT_API_SetPowerState(IARM_Bus_PWRMgr_PowerState_t newState);
113
114/**
115 * @brief Gets the CPE Power State
116 *
117 * @param[out] curState - The current power state of the CPE
118 *
119 * @return Returns the status of the operation.
120 * @retval 0 if successful, appropiate error code otherwise.
121 *
122 * @pre PLAT_INIT() must be called before calling this API
123 *
124 * @warning This API is Not thread safe
125 *
126 * @see PLAT_API_SetPowerState(), IARM_Bus_PWRMgr_PowerState_t()
127 *
128 */
129int PLAT_API_GetPowerState(IARM_Bus_PWRMgr_PowerState_t *curState);
130
131#ifdef ENABLE_THERMAL_PROTECTION
132
133/**
134 * @brief Get the current temperature of the core.
135 *
136 * @param[out] curState - The current state of the core temperature
137 * @param[out] curTemperature - Raw temperature value of the core
138 * in degrees Celsius
139 * @param[out] wifiTemperature - Raw temperature value of the wifi chip
140 * in degrees Celsius
141 * @pre PLAT_INIT() must be called before calling this API
142 *
143 * @see for IARM_Bus_PWRMgr_ThermalState_t()
144 *
145 * @return Returns the status of the operation.
146 * @retval 0 if successful, appropiate error code otherwise.
147 *
148 */
149int PLAT_API_GetTemperature(IARM_Bus_PWRMgr_ThermalState_t *curState, float *curTemperature, float *wifiTemperature);
150
151/**
152 * @brief Set temperature thresholds which will determine the state returned from a call to mfrGetTemperature.
153 *
154 * @param[in] tempHigh Temperature threshold at which mfrTEMPERATURE_HIGH
155 * state will be reported.
156 * @param[in] tempCritical Temperature threshold at which mfrTEMPERATURE_CRITICAL
157 * state will be reported.
158 *
159 * @pre PLAT_INIT() must be called before calling this API
160 *
161 * @return Returns the status of the operation.
162 * @retval 0 if successful, appropiate error code otherwise.
163 *
164 */
165int PLAT_API_SetTempThresholds(float tempHigh, float tempCritical);
166
167/**
168 * @brief Get temperature thresholds which will determine the state returned from a call to mfrGetTemperature.
169 *
170 * @param[out] tempHigh Temperature threshold at which mfrTEMPERATURE_HIGH
171 * state will be reported.
172 * @param[out] tempCritical Temperature threshold at which mfrTEMPERATURE_CRITICAL
173 * state will be reported.
174 *
175 * @pre PLAT_INIT() must be called before calling this API
176 * @return Returns the status of the operation.
177 * @retval 0 if successful, appropiate error code otherwise.
178 *
179 */
180int PLAT_API_GetTempThresholds(float *tempHigh, float *tempCritical);
181
182/**
183 * @brief Get clock speeds for this device for the given states
184 *
185 * @param [out] cpu_rate_Normal The clock rate to be used when in the 'normal' state
186 * @param [out] cpu_rate_Scaled The clock rate to be used when in the 'scaled' state
187 * @param [out] cpu_rate_Minimal The clock rate to be used when in the 'minimal' state
188 *
189 * @pre PLAT_INIT() must be called before calling this API
190 * @return 1 if operation is attempted 0 otherwise
191 *
192 */
193int PLAT_API_DetemineClockSpeeds(uint32_t *cpu_rate_Normal, uint32_t *cpu_rate_Scaled, uint32_t *cpu_rate_Minimal);
194
195/**
196 * @brief This API sets the clock speed of the CPU.
197 *
198 * @param [in] speed One of the predefined parameters to set the clock speed.
199 *
200 * @pre PLAT_INIT() must be called before calling this API
201 * @return Returns the status of the operation
202 * @retval returns 1, if operation is attempted and 0
203 *
204 */
205int PLAT_API_SetClockSpeed(uint32_t speed);
206
207/**
208 * @brief This API returns the clock speed of the CPU
209 *
210 * @param [out] speed One of the predefined parameters
211 *
212 * @pre PLAT_INIT() must be called before calling this API
213 * @return Returns the current clock speed.
214 *
215 */
216int PLAT_API_GetClockSpeed(uint32_t *speed);
217
218#endif //ENABLE_THERMAL_PROTECTION
219
220
221/**
222 * @brief Enables or disables the Wakeup source type
223 *
224 * @param [in] srcType - Wake up source type
225 * @param [in] enable - Enable or disable Wake up source
226 * True for enabled, false for disabled
227 *
228 * @return Returns the status of the API execution
229 * @retval 0 for success, 1 for unsupported source type, negative value for error cases.
230 * @pre PLAT_INIT() must be called before calling this API
231 *
232 * @warning This API is Not thread safe
233 *
234 * @see PLAT_API_GetWakeupSrc(), WakeupSrcType_t
235 */
236int32_t PLAT_API_SetWakeupSrc(WakeupSrcType_t srcType, bool enable);
237
238/**
239 * @brief Checks if the wake up source is enabled or disabled for the device
240 *
241 * @param [in] srcType - Wake up source type
242 * @param [out] enable - Variable to store if wake up source type is enabled or disabled
243 * True for enabled, false for disabled
244 *
245 * @return Returns the status of the API execution
246 * @retval 0 for success, 1 for unsupported source type, negative value for error cases.
247 *
248 * @pre PLAT_INIT() must be called before calling this API
249 *
250 * @warning This API is Not thread safe
251 *
252 * @see WakeupSrcType_t, PLAT_API_SetWakeupSrc()
253 */
254int32_t PLAT_API_GetWakeupSrc(WakeupSrcType_t srcType, bool *enable);
255
256/**
257 * @brief Resets the power state of the device
258 *
259 * @note PLAT_Reset() will be deprecated.
260 *
261 * @param[in] newState - The state to be set
262 *
263 * @pre PLAT_INIT() must be called before calling this API
264 *
265 * @warning This API is Not thread safe
266 *
267 * @see IARM_Bus_PWRMgr_PowerState_t
268 *
269 */
270void PLAT_Reset(IARM_Bus_PWRMgr_PowerState_t newState);
271
272/**
273 * @brief Terminates the CPE Power Management module
274 *
275 * All data structures used within Power Management module must be reset and release any
276 * Power Management specific handles and resources.
277 *
278 * @pre PLAT_INIT() must be called before calling this API
279 *
280 */
281void PLAT_TERM(void);
282
283
284#ifdef __cplusplus
285}
286#endif
287#endif //End of _POWERMGR_PLAT_H
288
289/** @} */ // End of PLAT_POWER_H
290/** @} */ // End of POWER_MANAGER_HAL
291/** @} */ // End of POWER_MANAGER
292/** @} */ // End of HPK
void PLAT_TERM(void)
Terminates the CPE Power Management module.
int32_t PLAT_API_SetWakeupSrc(WakeupSrcType_t srcType, bool enable)
Enables or disables the Wakeup source type.
void PLAT_Reset(IARM_Bus_PWRMgr_PowerState_t newState)
Resets the power state of the device.
int PLAT_API_SetPowerState(IARM_Bus_PWRMgr_PowerState_t newState)
Sets the CPE Power State.
int32_t PLAT_API_GetWakeupSrc(WakeupSrcType_t srcType, bool *enable)
Checks if the wake up source is enabled or disabled for the device.
int PLAT_API_GetPowerState(IARM_Bus_PWRMgr_PowerState_t *curState)
Gets the CPE Power State.
int PLAT_INIT(void)
Initializes the underlying Power Management module.