RDK Documentation (Open Sourced RDK Components)
plat_power.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt 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  * @defgroup IARM_PLAT_POWER_API Power Manager (HAL Types and Public API)
22  * Described herein are the IARM-Bus HAL types and functions that are part of the Power
23  * Manager application. This manager monitors Power IR key events and reacts to power
24  * state changes based on RDK Power Management Specification. It dispatches
25  * Power Mode Change events to IARM-Bus. All listeners should releases resources when
26  * entering POWER OFF/STANDBY state and re-acquire them when entering POWER ON state.
27  * @ingroup IARMMGR_HAL
28  */
29 
30 /**
31 * @defgroup iarmmgrs
32 * @{
33 * @defgroup hal
34 * @{
35 **/
36 
37 
38 #ifndef _POWERMGR_PLAT_H
39 #define _POWERMGR_PLAT_H
40 #include "pwrMgr.h"
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45 
46 /**
47  * @addtogroup IARM_PLAT_POWER_API
48  * @{
49  */
50 /**
51  * @todo Should a callback function mode and registration API be added here?
52  */
53 
54  /** @addtogroup IARM_BUS_PWRMGR_HAL_API IARM-Bus HAL Power Manager API.
55  * @ingroup IARM_BUS
56  *
57  * Described herein are the IARM-Bus HAL types and functions that are part of the Power
58  * Manager application. This manager monitors Power IR key events and reacts to power
59  * state changes based on Comcast RDK Power Management Specification. It dispatches
60  * Power Mode Change events to IARM-Bus. All listeners should releases resources when
61  * entering POWER OFF/STANDBY state and re-acquire them when entering POWER ON state.
62  *
63  * @{
64  */
65 
66 /**
67  * @todo Should a callback function mode and registration API be added here?
68  */
69 
70 /**
71  * @brief Initialize the underlying Power Management module.
72  *
73  * This function must initialize all aspects of the CPE's Power Management module.
74  *
75  * @return Returns the status of the operation
76  * @retval 0 if successful, appropiate error code otherwise.
77  */
78 int PLAT_INIT(void);
79 
80 /**
81  * @brief This API sets the CPE Power State.
82  *
83  * This function sets the CPE's current power state to the specified state.
84  *
85  * @param[in] newState The power state to which to set the CPE.
86  *
87  * @return Returns the status of the operation.
88  * @retval 0 if successful, appropiate error code otherwise.
89  */
90 int PLAT_API_SetPowerState(IARM_Bus_PWRMgr_PowerState_t newState);
91 
92 /**
93  * @brief This function is used to get the CPE Power State.
94  *
95  * This function returns the current power state of the CPE.
96  *
97  * @param[in] curState The address of a location to hold the current power state of the CPE on return.
98  *
99  * @return Returns the status of the operation.
100  * @retval 0 if successful, appropiate error code otherwise.
101  */
102 int PLAT_API_GetPowerState(IARM_Bus_PWRMgr_PowerState_t *curState);
103 
104 #ifdef ENABLE_THERMAL_PROTECTION
105 
106 /**
107  * @brief Get the current temperature of the core.
108  *
109  * @param[out] state The current state of the core temperature
110  * @param[out] curTemperature Raw temperature value of the core
111  * in degrees Celsius
112  * @param[out] wifiTemperature Raw temperature value of the wifi chip
113  * in degrees Celsius
114  *
115  * @return Returns the status of the operation.
116  * @retval 0 if successful, appropiate error code otherwise.
117 */
118 int PLAT_API_GetTemperature(IARM_Bus_PWRMgr_ThermalState_t *curState, float *curTemperature, float *wifiTemperature);
119 
120 /**
121  * @brief Set temperature thresholds which will determine the state returned from a call to mfrGetTemperature.
122  *
123  * @param[in] tempHigh Temperature threshold at which mfrTEMPERATURE_HIGH
124  * state will be reported.
125  * @param[in] tempCritical Temperature threshold at which mfrTEMPERATURE_CRITICAL
126  * state will be reported.
127  *
128  * @return Returns the status of the operation.
129  * @retval 0 if successful, appropiate error code otherwise.
130  */
131 int PLAT_API_SetTempThresholds(float tempHigh, float tempCritical);
132 
133 /**
134  * @brief Get temperature thresholds which will determine the state returned from a call to mfrGetTemperature.
135  *
136  * @param[out] tempHigh Temperature threshold at which mfrTEMPERATURE_HIGH
137  * state will be reported.
138  * @param[out] tempCritical Temperature threshold at which mfrTEMPERATURE_CRITICAL
139  * state will be reported.
140  *
141  * @return Returns the status of the operation.
142  * @retval 0 if successful, appropiate error code otherwise.
143  */
144 int PLAT_API_GetTempThresholds(float *tempHigh, float *tempCritical);
145 
146 /**
147  * @brief Get clock speeds for this device for the given states
148  *
149  * @param [out] cpu_rate_Normal The clock rate to be used when in the 'normal' state
150  * @param [out] cpu_rate_Scaled The clock rate to be used when in the 'scaled' state
151  * @param [out] cpu_rate_Minimal The clock rate to be used when in the 'minimal' state
152  *
153  * @return 1 if operation is attempted 0 otherwise
154  */
155 int PLAT_API_DetemineClockSpeeds(uint32_t *cpu_rate_Normal, uint32_t *cpu_rate_Scaled, uint32_t *cpu_rate_Minimal);
156 
157 /**
158  * @brief This API sets the clock speed of the CPU.
159  * @param [in] speed One of the predefined parameters to set the clock speed.
160  *
161  * @return Returns the status of the operation
162  * @retval returns 1, if operation is attempted and 0 otherwise
163  */
164 int PLAT_API_SetClockSpeed(uint32_t speed);
165 
166 /**
167  * @brief This API returns the clock speed of the CPU
168  *
169  * @param [out] speed One of the predefined parameters
170  * @return Returns the current clock speed.
171  */
172 int PLAT_API_GetClockSpeed(uint32_t *speed);
173 
174 #endif //ENABLE_THERMAL_PROTECTION
175 
176 /**
177  * @brief This API resets the power state of the device.
178  *
179  * @param[in] newState The state to be set.
180  * The input paramter is not in use.
181  */
182 void PLAT_Reset(IARM_Bus_PWRMgr_PowerState_t newState);
183 
184 /**
185  * @brief This API terminates the power management module.
186  *
187  * This function must terminate the CPE Power Management module. It must reset any data
188  * structures used within Power Management module and release any Power Management
189  * specific handles and resources.
190  */
191 void PLAT_TERM(void);
192 
193 /** @} */ //End of Doxygen Tag
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 #endif
199 
200 /** @} */
201 /** @} */
PLAT_API_GetPowerState
int PLAT_API_GetPowerState(IARM_Bus_PWRMgr_PowerState_t *curState)
This function is used to get the CPE Power State.
PLAT_INIT
int PLAT_INIT(void)
Initialize the underlying Power Management module.
PLAT_API_SetPowerState
int PLAT_API_SetPowerState(IARM_Bus_PWRMgr_PowerState_t newState)
This API sets the CPE Power State.
PLAT_Reset
void PLAT_Reset(IARM_Bus_PWRMgr_PowerState_t newState)
This API resets the power state of the device.
IARM_Bus_PWRMgr_ThermalState_t
enum _IARM_Bus_PWRMgr_ThermalState_t IARM_Bus_PWRMgr_ThermalState_t
Enumerator which represents the possible temeperature states.
PLAT_TERM
void PLAT_TERM(void)
This API terminates the power management module.
pwrMgr.h
IARM-Bus Power Manager Public API.