|
| 1 | +/*----------------------------------------------------------------------------- |
| 2 | + Copyright (c) 2021, 2022 QUALCOMM Technologies, Incorporated. |
| 3 | + All Rights Reserved. |
| 4 | + QUALCOMM Proprietary. |
| 5 | +-----------------------------------------------------------------------------*/ |
| 6 | + |
| 7 | +#ifndef HAP_DCVS_H_ |
| 8 | +#define HAP_DCVS_H_ |
| 9 | + |
| 10 | +/** |
| 11 | + * @file HAP_dcvs.h |
| 12 | + * @brief Header file for DCVS APIs. |
| 13 | + */ |
| 14 | + |
| 15 | +#include "AEEStdErr.h" |
| 16 | +#include "HAP_power.h" |
| 17 | + |
| 18 | +#ifdef __cplusplus |
| 19 | +extern "C" { |
| 20 | +#endif |
| 21 | + |
| 22 | +/** |
| 23 | + * Perf modes to specify core/bus clock frequency level within |
| 24 | + * target voltage corner for HAP DCVS V3 interface. |
| 25 | + */ |
| 26 | +typedef enum { |
| 27 | + HAP_DCVS_CLK_PERF_HIGH, /**< To select max frequency at target voltage corner. */ |
| 28 | + HAP_DCVS_CLK_PERF_LOW, /**< To select min frequency at target voltage corner. */ |
| 29 | +} HAP_dcvs_clk_perf_mode_t; |
| 30 | + |
| 31 | +/** |
| 32 | + * @cond DEV |
| 33 | + */ |
| 34 | +int __attribute__((weak)) sysmon_set_dcvs_v3_duty_cycle( |
| 35 | + void* context, |
| 36 | + uint32 max_active_time, |
| 37 | + uint32 periodicity); |
| 38 | + |
| 39 | +int __attribute__((weak)) sysmon_set_dcvs_v3_duty_cycle_params( |
| 40 | + HAP_power_request_t* request, |
| 41 | + uint32 max_active_time, |
| 42 | + uint32 periodicity); |
| 43 | + |
| 44 | +int __attribute__((weak)) sysmon_set_dcvs_v3_core_perf_mode( |
| 45 | + HAP_power_request_t* request, |
| 46 | + HAP_dcvs_clk_perf_mode_t perf_mode); |
| 47 | + |
| 48 | +int __attribute__((weak)) sysmon_set_dcvs_v3_bus_perf_mode( |
| 49 | + HAP_power_request_t* request, |
| 50 | + HAP_dcvs_clk_perf_mode_t perf_mode); |
| 51 | + |
| 52 | +int __attribute__((weak)) sysmon_set_dcvs_v3_protected_bus_corners( |
| 53 | + HAP_power_request_t* request, |
| 54 | + unsigned char enable_protected_corners); |
| 55 | + |
| 56 | +int __attribute__((weak)) sysmon_set_ddr_perf_mode( |
| 57 | + HAP_power_request_t *request, |
| 58 | + unsigned int perf_mode); |
| 59 | +/** |
| 60 | + * @endcond |
| 61 | + */ |
| 62 | + |
| 63 | +/** |
| 64 | + * @defgroup helperapi Helper APIs for DCVS Duty Cycle |
| 65 | + * @{ |
| 66 | + */ |
| 67 | + |
| 68 | +/** |
| 69 | + * Method to enable DCVS Duty Cycle. |
| 70 | + * |
| 71 | + * Calls HAP_power_set API with the provided context and selects |
| 72 | + * DCVS duty cycle mode via HAP_power_set_DCVS_v3 request type. |
| 73 | + * |
| 74 | + * @param[in] context User context - power client identifier to be used in |
| 75 | + * HAP_power_set call. |
| 76 | + * |
| 77 | + * @param[in] max_active_time Max active time allowed per frame in ms |
| 78 | + * (optional, can pass 0 if don’t want to specify). |
| 79 | + * DCVS selects appropriate operating levels to |
| 80 | + * keep the activity time within the provided |
| 81 | + * maximum allowed time. |
| 82 | + * |
| 83 | + * @param[in] periodicity Frame time in ms (optional, can pass 0 if |
| 84 | + * don’t want to specify periodicity). For example, |
| 85 | + * periodicity = 100 (milli-seconds) for a |
| 86 | + * 10 FPS activity. DCVS uses this as a hint while |
| 87 | + * predicting activity. |
| 88 | + * |
| 89 | + * @return |
| 90 | + * 0 upon success. \n |
| 91 | + * Nonzero upon failure. \n |
| 92 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 93 | + */ |
| 94 | +static inline int HAP_set_dcvs_v3_duty_cycle( |
| 95 | + void* context, |
| 96 | + uint32 max_active_time, |
| 97 | + uint32 periodicity) |
| 98 | +{ |
| 99 | + if (sysmon_set_dcvs_v3_duty_cycle) |
| 100 | + return sysmon_set_dcvs_v3_duty_cycle( |
| 101 | + context, |
| 102 | + max_active_time, |
| 103 | + periodicity); |
| 104 | + |
| 105 | + return AEE_EVERSIONNOTSUPPORT; |
| 106 | +} |
| 107 | + |
| 108 | +/** |
| 109 | + * Method to set duty cycle threshold params (periodicity and activity time hints) |
| 110 | + * in the request structure intended for HAP_power_set for request type set to |
| 111 | + * HAP_power_set_DCVS_v3. |
| 112 | + * |
| 113 | + * Sets the max_active_time and periodicity fields under dcvs_v3 payload of given |
| 114 | + * request structure. |
| 115 | + * |
| 116 | + * Note: Request type should be set to HAP_power_set_DCVS_v3. |
| 117 | + * |
| 118 | + * @param[in] request Pointer to request structure. |
| 119 | + * |
| 120 | + * @param[in] max_active_time Max active time allowed per frame in ms. |
| 121 | + * DCVS selects appropriate operating levels to |
| 122 | + * keep the activity time within the provided |
| 123 | + * maximum allowed time. |
| 124 | + * |
| 125 | + * @param[in] periodicity Frame time in ms (optional, can pass 0 if |
| 126 | + * don’t want to specify periodicity). For example, |
| 127 | + * periodicity = 100 (milli-seconds) for a |
| 128 | + * 10 FPS activity. DCVS uses this as a hint while |
| 129 | + * predicting activity. |
| 130 | + * |
| 131 | + * @return |
| 132 | + * 0 upon success. \n |
| 133 | + * Nonzero upon failure. \n |
| 134 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 135 | + */ |
| 136 | +static inline int HAP_set_dcvs_v3_duty_cycle_params( |
| 137 | + HAP_power_request_t* request, |
| 138 | + uint32 max_active_time, |
| 139 | + uint32 periodicity) |
| 140 | +{ |
| 141 | + if (sysmon_set_dcvs_v3_duty_cycle_params) |
| 142 | + { |
| 143 | + return sysmon_set_dcvs_v3_duty_cycle_params( |
| 144 | + request, |
| 145 | + max_active_time, |
| 146 | + periodicity); |
| 147 | + } |
| 148 | + |
| 149 | + return AEE_EVERSIONNOTSUPPORT; |
| 150 | +} |
| 151 | + |
| 152 | +/** |
| 153 | + * @} |
| 154 | + */ |
| 155 | + |
| 156 | +/** |
| 157 | + * @defgroup enable_protected_corner_api Helper API for protected bus corners |
| 158 | + * |
| 159 | + * @{ |
| 160 | + */ |
| 161 | +/** |
| 162 | + * On chipsets supporting bus corners above HAP_DCVS_VCORNER_TURBO_PLUS, to optimize residency at these corners, |
| 163 | + * target corner requests for bus are capped to HAP_DCVS_VCORNER_TURBO_PLUS by default. |
| 164 | + * Any request beyond HAP_DCVS_VCORNER_TURBO_PLUS (including HAP_DCVS_VCORNER_MAX) will be wrapped to HAP_DCVS_VCORNER_TURBO_PLUS. |
| 165 | + * |
| 166 | + * This API enables clients of HAP_power_set to override this protection when voting explicitly for bus corners |
| 167 | + * above HAP_DCVS_VCORNER_TURBO_PLUS in necessary use cases. |
| 168 | + * |
| 169 | + * Note: |
| 170 | + * API is supported starting with V79 QDSP6 architecture, AEE_EVERSIONNOTSUPPORT error (can be safely ignored) is returned by the API when not supported. |
| 171 | + * |
| 172 | + * Request type should be set to HAP_power_set_DCVS_v3. |
| 173 | + * |
| 174 | + * @param[in] request Pointer to HAP_power_request_t structure with request type set to HAP_power_set_DCVS_v3. |
| 175 | + * @param[in] enable_protected_corners 1 - to consider bus corner requests above HAP_DCVS_VCORNER_TURBO_PLUS |
| 176 | + * 0 (default) - to cap bus corner requests to HAP_DCVS_VCORNER_TURBO_PLUS |
| 177 | + * @return |
| 178 | + * 0 upon success. \n |
| 179 | + * Nonzero upon failure. \n |
| 180 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 181 | + */ |
| 182 | + |
| 183 | +static inline int HAP_set_dcvs_v3_protected_bus_corners( |
| 184 | + HAP_power_request_t* request, |
| 185 | + unsigned char enable_protected_corners) |
| 186 | +{ |
| 187 | + if (sysmon_set_dcvs_v3_protected_bus_corners) |
| 188 | + { |
| 189 | + return sysmon_set_dcvs_v3_protected_bus_corners(request, |
| 190 | + enable_protected_corners); |
| 191 | + } |
| 192 | + |
| 193 | + return AEE_EVERSIONNOTSUPPORT; |
| 194 | +} |
| 195 | + |
| 196 | +/** |
| 197 | + * @} |
| 198 | + */ |
| 199 | +/** |
| 200 | + * @defgroup enable_ddr_perf_mode_api Helper API to enable DDR perf mode |
| 201 | + * |
| 202 | + * @{ |
| 203 | + */ |
| 204 | +/** |
| 205 | + * This API enables clients of HAP_power_set to vote for DDR performance mode. |
| 206 | + * |
| 207 | + * Note: |
| 208 | + * API is supported starting with V79 QDSP6 architecture, AEE_EVERSIONNOTSUPPORT error (can be safely ignored) is returned by the API when not supported. |
| 209 | + * |
| 210 | + * Note: Request type should be set to HAP_power_set_DCVS_v3. |
| 211 | + * |
| 212 | + * @param[in] request Pointer to HAP_power_request_t structure with request type set to HAP_power_set_DCVS_v3 |
| 213 | + * |
| 214 | + * @param[in] perf_mode 1 - to enable DDR performance mode |
| 215 | + * 0 - to disable the DDR performance mode |
| 216 | + * |
| 217 | + * @return |
| 218 | + * 0 upon success. \n |
| 219 | + * Nonzero upon failure. \n |
| 220 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 221 | + */ |
| 222 | +static inline int HAP_set_ddr_perf_mode( |
| 223 | + HAP_power_request_t *request, |
| 224 | + unsigned int perf_mode) |
| 225 | +{ |
| 226 | + if (sysmon_set_ddr_perf_mode) |
| 227 | + { |
| 228 | + return sysmon_set_ddr_perf_mode(request, perf_mode); |
| 229 | + } |
| 230 | + |
| 231 | + return AEE_EVERSIONNOTSUPPORT; |
| 232 | +} |
| 233 | + |
| 234 | +/** |
| 235 | + * @} |
| 236 | + */ |
| 237 | + |
| 238 | +/** |
| 239 | + * @defgroup clk_perfmode_api APIs to specify core/bus clock frequency level within target voltage corner |
| 240 | + * |
| 241 | + * @{ |
| 242 | + */ |
| 243 | + |
| 244 | +/** |
| 245 | + * Method to specify core clock frequency level corresponding to the |
| 246 | + * target corner request in the request structure intended for |
| 247 | + * HAP_power_set for request type set to HAP_power_set_DCVS_v3. |
| 248 | + * |
| 249 | + * By default, the highest core clock frequency available at the requested |
| 250 | + * target_corner is selected. Using this API, user can select either the |
| 251 | + * highest (HAP_DCVS_CLK_PERF_HIGH) or the lowest (HAP_DCVS_CLK_PERF_LOW) |
| 252 | + * core clock frequency at any given target_corner. If there is only one |
| 253 | + * core clock frequency available at the requested target_corner, both the |
| 254 | + * high and low settings will select the same. |
| 255 | + * |
| 256 | + * Note: Request type should be set to HAP_power_set_DCVS_v3. |
| 257 | + * |
| 258 | + * Supported on latest chipsets(released after Palima). |
| 259 | + * |
| 260 | + * @param[in] request Pointer to request structure. |
| 261 | + * |
| 262 | + * @param[in] perf_mode Perf mode to specify core clock frequency level |
| 263 | + * within target voltage corner. |
| 264 | + * |
| 265 | + * @return |
| 266 | + * 0 upon success. \n |
| 267 | + * Nonzero upon failure. \n |
| 268 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 269 | + */ |
| 270 | +static inline int HAP_set_dcvs_v3_core_perf_mode( |
| 271 | + HAP_power_request_t* request, |
| 272 | + HAP_dcvs_clk_perf_mode_t perf_mode) |
| 273 | +{ |
| 274 | + if (sysmon_set_dcvs_v3_core_perf_mode) |
| 275 | + { |
| 276 | + return sysmon_set_dcvs_v3_core_perf_mode( |
| 277 | + request, |
| 278 | + perf_mode); |
| 279 | + } |
| 280 | + |
| 281 | + return AEE_EVERSIONNOTSUPPORT; |
| 282 | +} |
| 283 | + |
| 284 | +/** |
| 285 | + * Method to specify bus clock frequency level corresponding to the |
| 286 | + * target corner request in the request structure intended for |
| 287 | + * HAP_power_set for request type set to HAP_power_set_DCVS_v3. |
| 288 | + * |
| 289 | + * By default, the highest bus clock frequency available at the requested |
| 290 | + * target_corner is selected. Using this API, user can select either the |
| 291 | + * highest (HAP_DCVS_CLK_PERF_HIGH) or the lowest (HAP_DCVS_CLK_PERF_LOW) |
| 292 | + * bus clock frequency at any given target_corner. If there is only one |
| 293 | + * bus clock frequency available at the requested target_corner, both the |
| 294 | + * high and low settings will select the same. |
| 295 | + * |
| 296 | + * Note: Request type should be set to HAP_power_set_DCVS_v3. |
| 297 | + * |
| 298 | + * Supported on latest chipsets(released after Palima). |
| 299 | + * |
| 300 | + * @param[in] request Pointer to request structure. |
| 301 | + * |
| 302 | + * @param[in] perf_mode Perf mode to specify bus clock frequency level |
| 303 | + * within target voltage corner. |
| 304 | + * |
| 305 | + * @return |
| 306 | + * 0 upon success. \n |
| 307 | + * Nonzero upon failure. \n |
| 308 | + * AEE_EVERSIONNOTSUPPORT if unsupported. |
| 309 | + */ |
| 310 | +static inline int HAP_set_dcvs_v3_bus_perf_mode( |
| 311 | + HAP_power_request_t* request, |
| 312 | + HAP_dcvs_clk_perf_mode_t perf_mode) |
| 313 | +{ |
| 314 | + if (sysmon_set_dcvs_v3_bus_perf_mode) |
| 315 | + { |
| 316 | + return sysmon_set_dcvs_v3_bus_perf_mode( |
| 317 | + request, |
| 318 | + perf_mode); |
| 319 | + } |
| 320 | + |
| 321 | + return AEE_EVERSIONNOTSUPPORT; |
| 322 | +} |
| 323 | + |
| 324 | +/** |
| 325 | + * @} |
| 326 | + */ |
| 327 | + |
| 328 | +#ifdef __cplusplus |
| 329 | +} |
| 330 | +#endif |
| 331 | + |
| 332 | +#endif //HAP_DCVS_H_ |
0 commit comments