OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #ifndef INCLUDED_nvrm_power_H |
| 34 #define INCLUDED_nvrm_power_H |
| 35 |
| 36 |
| 37 #if defined(__cplusplus) |
| 38 extern "C" |
| 39 { |
| 40 #endif |
| 41 |
| 42 #include "nvrm_module.h" |
| 43 #include "nvrm_init.h" |
| 44 |
| 45 #include "nvos.h" |
| 46 |
| 47 /** |
| 48 * Frequency data type, expressed in KHz. |
| 49 */ |
| 50 |
| 51 typedef NvU32 NvRmFreqKHz; |
| 52 |
| 53 /** |
| 54 * Special value for an unspecified or default frequency. |
| 55 */ |
| 56 static const NvRmFreqKHz NvRmFreqUnspecified = 0xFFFFFFFF; |
| 57 |
| 58 /** |
| 59 * Special value for the maximum possible frequency. |
| 60 */ |
| 61 static const NvRmFreqKHz NvRmFreqMaximum = 0xFFFFFFFD; |
| 62 |
| 63 /** |
| 64 * Voltage data type, expressed in millivolts. |
| 65 */ |
| 66 |
| 67 typedef NvU32 NvRmMilliVolts; |
| 68 |
| 69 /** |
| 70 * Special value for an unspecified or default voltage. |
| 71 */ |
| 72 static const NvRmMilliVolts NvRmVoltsUnspecified = 0xFFFFFFFF; |
| 73 |
| 74 /** |
| 75 * Special value for the maximum possible voltage. |
| 76 */ |
| 77 static const NvRmMilliVolts NvRmVoltsMaximum = 0xFFFFFFFD; |
| 78 |
| 79 /** |
| 80 * Special value for voltage / power disable. |
| 81 */ |
| 82 static const NvRmMilliVolts NvRmVoltsCycled = 0xFFFFFFFC; |
| 83 |
| 84 /** |
| 85 * Special value for voltage / power disable. |
| 86 */ |
| 87 static const NvRmMilliVolts NvRmVoltsOff = 0; |
| 88 |
| 89 /** |
| 90 * Defines possible power management events |
| 91 */ |
| 92 |
| 93 typedef enum |
| 94 { |
| 95 |
| 96 /// Specifies no outstanding events |
| 97 NvRmPowerEvent_NoEvent = 1, |
| 98 |
| 99 /// Specifies wake from LP0 |
| 100 NvRmPowerEvent_WakeLP0, |
| 101 |
| 102 /// Specifies wake from LP1 |
| 103 NvRmPowerEvent_WakeLP1, |
| 104 NvRmPowerEvent_Num, |
| 105 NvRmPowerEvent_Force32 = 0x7FFFFFFF |
| 106 } NvRmPowerEvent; |
| 107 |
| 108 /** |
| 109 * Defines combined RM clients power state |
| 110 */ |
| 111 |
| 112 typedef enum |
| 113 { |
| 114 |
| 115 /// Specifies boot state ("RM is not open, yet") |
| 116 NvRmPowerState_Boot = 1, |
| 117 |
| 118 /// Specifies active state ("not ready-to-suspend") |
| 119 /// This state is entered if any client enables power to any module, other |
| 120 /// than NvRmPrivModuleID_System, via NvRmPowerVoltageControl() API |
| 121 NvRmPowerState_Active, |
| 122 |
| 123 /// Specifies h/w autonomous state ("ready-to-core-power-on-suspend") |
| 124 /// This state is entered if all RM clients enable power only for |
| 125 /// NvRmPrivModuleID_System, via NvRmPowerVoltageControl() API |
| 126 NvRmPowerState_AutoHw, |
| 127 |
| 128 /// Specifies idle state ("ready-to-core-power-off-suspend") |
| 129 /// This state is entered if none of the RM clients enables power |
| 130 /// to any module. |
| 131 NvRmPowerState_Idle, |
| 132 |
| 133 /// Specifies LP0 state ("main power-off suspend") |
| 134 NvRmPowerState_LP0, |
| 135 |
| 136 /// Specifies LP1 state ("main power-on suspend") |
| 137 NvRmPowerState_LP1, |
| 138 |
| 139 /// Specifies Skipped LP0 state (set when LP0 entry error is |
| 140 /// detected, SoC resumes operations without entering LP0 state) |
| 141 NvRmPowerState_SkippedLP0, |
| 142 NvRmPowerState_Num, |
| 143 NvRmPowerState_Force32 = 0x7FFFFFFF |
| 144 } NvRmPowerState; |
| 145 |
| 146 /** Defines the clock configuration flags which are applicable for some modules. |
| 147 * Multiple flags can be OR'ed and passed to the NvRmPowerModuleClockConfig API. |
| 148 */ |
| 149 |
| 150 typedef enum |
| 151 { |
| 152 |
| 153 /// Use external clock for the pads of the module. |
| 154 NvRmClockConfig_ExternalClockForPads = 0x1, |
| 155 |
| 156 /// Use internal clock for the pads of the module |
| 157 NvRmClockConfig_InternalClockForPads = 0x2, |
| 158 |
| 159 /// Use external clock for the core of the module, or |
| 160 /// module is in slave mode |
| 161 NvRmClockConfig_ExternalClockForCore = 0x4, |
| 162 |
| 163 /// Use Internal clock for the core of the module, or |
| 164 /// module is in master mode. |
| 165 NvRmClockConfig_InternalClockForCore = 0x8, |
| 166 |
| 167 /// Use inverted clock for the module. i.e the polarity of the clock used is |
| 168 /// inverted with respect to the source clock. |
| 169 NvRmClockConfig_InvertedClock = 0x10, |
| 170 |
| 171 /// Configure target module sub-clock |
| 172 /// - Target Display: configure Display and TVDAC |
| 173 /// - Target TVO: configure CVE and TVDAC only |
| 174 /// - Target VI: configure VI_SENSOR only |
| 175 /// - Target SPDIF: configure SPDIFIN only |
| 176 NvRmClockConfig_SubConfig = 0x20, |
| 177 |
| 178 /// Use MIPI PLL as Display clock source |
| 179 NvRmClockConfig_MipiSync = 0x40, |
| 180 |
| 181 /// Adjust Audio PLL to match requested I2S or SPDIF frequency |
| 182 NvRmClockConfig_AudioAdjust = 0x80, |
| 183 |
| 184 /// Disable TVDAC along with Display configuration |
| 185 NvRmClockConfig_DisableTvDAC = 0x100, |
| 186 |
| 187 /// Do not fail clock configuration request with specific target frequency |
| 188 /// above Hw limit - just configure clock at Hw limit. (Note that caller |
| 189 /// can request NvRmFreqMaximum to configure clock at Hw limit, regardless |
| 190 /// of this flag presence). |
| 191 NvRmClockConfig_QuietOverClock = 0x200, |
| 192 NvRmClockConfigFlags_Num, |
| 193 NvRmClockConfigFlags_Force32 = 0x7FFFFFFF |
| 194 } NvRmClockConfigFlags; |
| 195 |
| 196 /** |
| 197 * Defines SOC-wide clocks controlled by Dynamic Frequency Scaling (DFS) |
| 198 * that can be targeted by Starvation and Busy hints |
| 199 */ |
| 200 |
| 201 typedef enum |
| 202 { |
| 203 |
| 204 /// Specifies CPU clock |
| 205 NvRmDfsClockId_Cpu = 1, |
| 206 |
| 207 /// Specifies AVP clock |
| 208 NvRmDfsClockId_Avp, |
| 209 |
| 210 /// Specifies System bus clock |
| 211 NvRmDfsClockId_System, |
| 212 |
| 213 /// Specifies AHB bus clock |
| 214 NvRmDfsClockId_Ahb, |
| 215 |
| 216 /// Specifies APB bus clock |
| 217 NvRmDfsClockId_Apb, |
| 218 |
| 219 /// Specifies video pipe clock |
| 220 NvRmDfsClockId_Vpipe, |
| 221 |
| 222 /// Specifies external memory controller clock |
| 223 NvRmDfsClockId_Emc, |
| 224 NvRmDfsClockId_Num, |
| 225 NvRmDfsClockId_Force32 = 0x7FFFFFFF |
| 226 } NvRmDfsClockId; |
| 227 |
| 228 /** |
| 229 * Defines DFS manager run states |
| 230 */ |
| 231 |
| 232 typedef enum |
| 233 { |
| 234 |
| 235 /// DFS is in invalid, not initialized state |
| 236 NvRmDfsRunState_Invalid = 0, |
| 237 |
| 238 /// DFS is disabled / not supported (terminal state) |
| 239 NvRmDfsRunState_Disabled = 1, |
| 240 |
| 241 /// DFS is stopped - no automatic clock control. Starvation and Busy hints |
| 242 /// are recorded but have no affect. |
| 243 NvRmDfsRunState_Stopped, |
| 244 |
| 245 /// DFS is running in closed loop - full automatic control of SoC-wide |
| 246 /// clocks based on clock activity measuremnets. Starvation and Busy hints |
| 247 /// are functional as well. |
| 248 NvRmDfsRunState_ClosedLoop, |
| 249 |
| 250 /// DFS is running in closed loop with profiling (can not be set on non |
| 251 /// profiling build). |
| 252 NvRmDfsRunState_ProfiledLoop, |
| 253 NvRmDfsRunState_Num, |
| 254 NvRmDfsRunState_Force32 = 0x7FFFFFFF |
| 255 } NvRmDfsRunState; |
| 256 |
| 257 /** |
| 258 * Defines DFS profile targets |
| 259 */ |
| 260 |
| 261 typedef enum |
| 262 { |
| 263 |
| 264 /// DFS algorithm within ISR |
| 265 NvRmDfsProfileId_Algorithm = 1, |
| 266 |
| 267 /// DFS Interrupt service - includes algorithm plus OS locking and |
| 268 /// signaling calls; hence, includes blocking time (if any) as well |
| 269 NvRmDfsProfileId_Isr, |
| 270 |
| 271 /// DFS clock control time - includes PLL stabilazation time, OS locking |
| 272 /// and signalling calls; hence, includes blocking time (if any) as well |
| 273 NvRmDfsProfileId_Control, |
| 274 NvRmDfsProfileId_Num, |
| 275 NvRmDfsProfileId_Force32 = 0x7FFFFFFF |
| 276 } NvRmDfsProfileId; |
| 277 |
| 278 /** |
| 279 * Defines voltage rails that are controlled in conjunction with dynamic |
| 280 * frequency scaling. |
| 281 */ |
| 282 |
| 283 typedef enum |
| 284 { |
| 285 |
| 286 /// SoC core rail |
| 287 NvRmDfsVoltageRailId_Core = 1, |
| 288 |
| 289 /// Dedicated CPU rail |
| 290 NvRmDfsVoltageRailId_Cpu, |
| 291 NvRmDfsVoltageRailId_Num, |
| 292 NvRmDfsVoltageRailId_Force32 = 0x7FFFFFFF |
| 293 } NvRmDfsVoltageRailId; |
| 294 |
| 295 /** |
| 296 * Defines busy hint API synchronization modes. |
| 297 */ |
| 298 |
| 299 typedef enum |
| 300 { |
| 301 |
| 302 /// Asynchronous mode (non-blocking API) |
| 303 NvRmDfsBusyHintSyncMode_Async = 1, |
| 304 |
| 305 /// Synchronous mode (blocking API) |
| 306 NvRmDfsBusyHintSyncMode_Sync, |
| 307 NvRmDfsBusyHintSyncMode_Num, |
| 308 NvRmDfsBusyHintSyncMode_Force32 = 0x7FFFFFFF |
| 309 } NvRmDfsBusyHintSyncMode; |
| 310 |
| 311 /** |
| 312 * Holds information on DFS clock domain utilization |
| 313 */ |
| 314 |
| 315 typedef struct NvRmDfsClockUsageRec |
| 316 { |
| 317 |
| 318 /// Minimum clock domain frequency |
| 319 NvRmFreqKHz MinKHz; |
| 320 |
| 321 /// Maximum clock domain frequency |
| 322 NvRmFreqKHz MaxKHz; |
| 323 |
| 324 /// Low corner frequency - current low boundary for DFS control algorithm. |
| 325 /// Can be dynamically adjusted via APIs: NvRmDfsSetLowCorner() for all DFS |
| 326 /// domains, NvRmDfsSetCpuEnvelope() for CPU, and NvRmDfsSetEmcEnvelope() |
| 327 /// for EMC. When all DFS domains hit low corner, DFS stops waking up CPU |
| 328 /// from low power state. |
| 329 NvRmFreqKHz LowCornerKHz; |
| 330 |
| 331 /// High corner frequency - current high boundary for DFS control algorithm. |
| 332 /// Can be dynamically adjusted via APIs: NvRmDfsSetCpuEnvelope() for Cpu, |
| 333 /// NvRmDfsSetEmcEnvelope() for Emc, and NvRmDfsSetAvHighCorner() for other |
| 334 // DFS domains. |
| 335 NvRmFreqKHz HighCornerKHz; |
| 336 |
| 337 /// Current clock domain frequency |
| 338 NvRmFreqKHz CurrentKHz; |
| 339 |
| 340 /// Average frequency of domain *activity* (not average frequency). For |
| 341 /// domains that do not have activity monitors reported as unspecified. |
| 342 NvRmFreqKHz AverageKHz; |
| 343 } NvRmDfsClockUsage; |
| 344 |
| 345 /** |
| 346 * Holds information on DFS busy hint |
| 347 */ |
| 348 |
| 349 typedef struct NvRmDfsBusyHintRec |
| 350 { |
| 351 |
| 352 /// Target clock domain ID |
| 353 NvRmDfsClockId ClockId; |
| 354 |
| 355 /// Requested boost duration in milliseconds |
| 356 NvU32 BoostDurationMs; |
| 357 |
| 358 /// Requested clock frequency level in kHz |
| 359 NvRmFreqKHz BoostKHz; |
| 360 |
| 361 /// Busy pulse mode indicator - if true, busy boost is completely removed |
| 362 /// after busy time has expired; if false, DFS will gradually lower domain |
| 363 /// frequency after busy boost. |
| 364 NvBool BusyAttribute; |
| 365 } NvRmDfsBusyHint; |
| 366 |
| 367 /** |
| 368 * Holds information on DFS starvation hint |
| 369 */ |
| 370 |
| 371 typedef struct NvRmDfsStarvationHintRec |
| 372 { |
| 373 |
| 374 /// Target clock domain ID |
| 375 NvRmDfsClockId ClockId; |
| 376 |
| 377 /// The starvation indicator for the target domain |
| 378 NvBool Starving; |
| 379 } NvRmDfsStarvationHint; |
| 380 |
| 381 /** |
| 382 * The NVRM_POWER_CLIENT_TAG macro is used to convert ASCII 4-character codes |
| 383 * into the 32-bit tag that can be used to identify power manager clients for |
| 384 * logging purposes. |
| 385 */ |
| 386 #define NVRM_POWER_CLIENT_TAG(a,b,c,d) \ |
| 387 ((NvU32) ((((a)&0xffUL)<<24UL) | \ |
| 388 (((b)&0xffUL)<<16UL) | \ |
| 389 (((c)&0xffUL)<< 8UL) | \ |
| 390 (((d)&0xffUL)))) |
| 391 |
| 392 /** |
| 393 * Registers RM power client. |
| 394 * |
| 395 * @param hRmDeviceHandle The RM device handle. |
| 396 * @param hEventSemaphore The client semaphore for power management event |
| 397 * signaling. If null, no events will be signaled to the particular client. |
| 398 * @param pClientId A pointer to the storage that on entry contains client |
| 399 * tag (optional), and on exit returns client ID, assigned by power manager. |
| 400 * |
| 401 * @retval NvSuccess if registration was successful. |
| 402 * @retval NvError_InsufficientMemory if failed to allocate memory for client |
| 403 * registration. |
| 404 */ |
| 405 |
| 406 NvError NvRmPowerRegister( |
| 407 NvRmDeviceHandle hRmDeviceHandle, |
| 408 NvOsSemaphoreHandle hEventSemaphore, |
| 409 NvU32 * pClientId ); |
| 410 |
| 411 /** |
| 412 * Unregisters RM power client. Power and clock for the modules enabled by this |
| 413 * client are disabled and any starvation or busy requests are cancelled during |
| 414 * the unregistration. |
| 415 * |
| 416 * @param hRmDeviceHandle The RM device handle. |
| 417 * @param ClientId The client ID obtained during registration. |
| 418 */ |
| 419 |
| 420 void NvRmPowerUnRegister( |
| 421 NvRmDeviceHandle hRmDeviceHandle, |
| 422 NvU32 ClientId ); |
| 423 |
| 424 /** |
| 425 * Gets last detected and not yet retrieved power management event. |
| 426 * Returns no outstanding event if no events has been detected since the |
| 427 * client registration or the last call to this function. |
| 428 * |
| 429 * @param hRmDeviceHandle The RM device handle. |
| 430 * @param ClientId The client ID obtained during registration. |
| 431 * @param pEvent Output storage pointer for power event identifier. |
| 432 * |
| 433 * @retval NvSuccess if event identifier was retrieved successfully. |
| 434 * @retval NvError_BadValue if specified client ID is not registered. |
| 435 */ |
| 436 |
| 437 NvError NvRmPowerGetEvent( |
| 438 NvRmDeviceHandle hRmDeviceHandle, |
| 439 NvU32 ClientId, |
| 440 NvRmPowerEvent * pEvent ); |
| 441 |
| 442 /** |
| 443 * Notifies RM about power management event. Provides an interface for |
| 444 * OS power manager to report system power events to RM. |
| 445 * |
| 446 * @param hRmDeviceHandle The RM device handle. |
| 447 * @param Event The event RM power manager is to be aware of. |
| 448 */ |
| 449 |
| 450 void NvRmPowerEventNotify( |
| 451 NvRmDeviceHandle hRmDeviceHandle, |
| 452 NvRmPowerEvent Event ); |
| 453 |
| 454 /** |
| 455 * Gets combined RM clients power state. |
| 456 * |
| 457 * @param hRmDeviceHandle The RM device handle. |
| 458 * @param pState Output storage pointer for combined RM clients power state. |
| 459 * |
| 460 * @retval NvSuccess if power state was retrieved successfully. |
| 461 */ |
| 462 |
| 463 NvError NvRmPowerGetState( |
| 464 NvRmDeviceHandle hRmDeviceHandle, |
| 465 NvRmPowerState * pState ); |
| 466 |
| 467 /** |
| 468 * Gets SoC primary oscillator/input frequency. |
| 469 * |
| 470 * @param hRmDeviceHandle The RM device handle. |
| 471 * |
| 472 * @retval Primary frequency in KHz. |
| 473 */ |
| 474 |
| 475 NvRmFreqKHz NvRmPowerGetPrimaryFrequency( |
| 476 NvRmDeviceHandle hRmDeviceHandle ); |
| 477 |
| 478 /** |
| 479 * Gets maximum frequency limit for the module clock. |
| 480 * |
| 481 * @param hRmDeviceHandle The RM device handle. |
| 482 * @param ModuleId The combined module ID and instance of the target module. |
| 483 * |
| 484 * @retval Module clock maximum frequency in KHz. |
| 485 */ |
| 486 |
| 487 NvRmFreqKHz NvRmPowerModuleGetMaxFrequency( |
| 488 NvRmDeviceHandle hRmDeviceHandle, |
| 489 NvRmModuleID ModuleId ); |
| 490 |
| 491 /** |
| 492 * This API is used to set the clock configuration of the module clock. |
| 493 * This API can also be used to query the existing configuration. |
| 494 * |
| 495 * Usage example: |
| 496 * |
| 497 * NvError Error; |
| 498 * NvRmFreqKHz MyFreqKHz = 0; |
| 499 * ModuleId = NVRM_MODULE_ID(NvRmModuleID_Uart, 0); |
| 500 * |
| 501 * // Get current frequency settings |
| 502 * Error = NvRmPowerModuleClockConfig(RmHandle, ModuleId, ClientId, |
| 503 * 0, 0, NULL, 0, &MyFreqKHz, 0); |
| 504 * |
| 505 * // Set target frequency within HW defined limits |
| 506 * MyFreqKHz = TARGET_FREQ; |
| 507 * Error = NvRmPowerModuleClockConfig(RmHandle, ModuleId, ClientId, |
| 508 * NvRmFreqUnspecified, NvRmFreqUnspecified, |
| 509 * &MyFreqKHz, 1, &MyFreqKHz); |
| 510 * |
| 511 * @param hRmDeviceHandle The RM device handle. |
| 512 * @param ModuleId The combined module ID and instance of the target module. |
| 513 * @param ClientId The client ID obtained during registration. |
| 514 * @param MinFreq Requested minimum frequency for hardware module operation. |
| 515 * If the value is NvRmFreqUnspecified, RM uses the the min freq that this |
| 516 * module can operate. |
| 517 * If the value specified is more than the Hw minimum, passed value is used
. |
| 518 * If the value specified is less than the Hw minimum, it will be clipped t
o |
| 519 * the HW minimum value. |
| 520 * @param MaxFreq Requested maximum frequency for hardware module operation. |
| 521 * If the value is NvRmFreqUnspecified, RM uses the the max freq that this |
| 522 * module can run. |
| 523 * If the value specified is less than the Hw maximum, that value is used. |
| 524 * If the value specified is more than the Hw limit, it will be clipped to |
| 525 * the HW maximum. |
| 526 * @param PrefFreqList Pointer to a list of preferred frequencies, sorted in the |
| 527 * decresing order of priority. Use NvRmFreqMaximum to request Hw maximum. |
| 528 * @param PrefFreqListCount Number of entries in the PrefFreqList array. |
| 529 * @param CurrentFreq Returns the current clock frequency of that module. NULL |
| 530 * is a valid value for this parameter. |
| 531 * @param flags Module specific flags. Thse flags are valid only for some |
| 532 * modules. See @NvRmClockConfigFlags |
| 533 * |
| 534 * @retval NvSuccess if clock control request completed successfully. |
| 535 * @retval NvError_ModuleNotPresent if the module ID or instance is invalid. |
| 536 * @retval NvError_NotSupported if failed to configure requested frequency (e.g.
, |
| 537 * output frequency for possible divider settings is outside specified range). |
| 538 */ |
| 539 |
| 540 NvError NvRmPowerModuleClockConfig( |
| 541 NvRmDeviceHandle hRmDeviceHandle, |
| 542 NvRmModuleID ModuleId, |
| 543 NvU32 ClientId, |
| 544 NvRmFreqKHz MinFreq, |
| 545 NvRmFreqKHz MaxFreq, |
| 546 const NvRmFreqKHz * PrefFreqList, |
| 547 NvU32 PrefFreqListCount, |
| 548 NvRmFreqKHz * CurrentFreq, |
| 549 NvU32 flags ); |
| 550 |
| 551 /** |
| 552 * This API is used to enable and disable the module clock. |
| 553 * |
| 554 * @param hRmDeviceHandle The RM device handle. |
| 555 * @param ModuleId The combined module ID and instance of the target module. |
| 556 * @param ClientId The client ID obtained during registration. |
| 557 * @param Enable Enables/diables the module clock. |
| 558 * |
| 559 * @retval NvSuccess if the module is enabled. |
| 560 * @retval NvError_ModuleNotPresent if the module ID or instance is invalid. |
| 561 */ |
| 562 |
| 563 NvError NvRmPowerModuleClockControl( |
| 564 NvRmDeviceHandle hRmDeviceHandle, |
| 565 NvRmModuleID ModuleId, |
| 566 NvU32 ClientId, |
| 567 NvBool Enable ); |
| 568 |
| 569 /** |
| 570 * Request the voltage range for a hardware module. As power planes are shared |
| 571 * between different modules, in the majority of cases the RM will choose the |
| 572 * appropriate voltage, and module owners only need to enable or disable power |
| 573 * for a module. Enable request is always completed (i.e., voltage is applied |
| 574 * to the module) before this function returns. Disable request just means that |
| 575 * the client is ready for module power down. Actually the power may be removed |
| 576 * within the call or any time later, depending on other client needs and power |
| 577 * plane dependencies with other modules. |
| 578 * |
| 579 * Assert encountered in debug mode if the module ID or instance is invalid. |
| 580 * |
| 581 * Usage example: |
| 582 * |
| 583 * NvError Error; |
| 584 * ModuleId = NVRM_MODULE_ID(NvRmModuleID_Uart, 0); |
| 585 * |
| 586 * // Enable module power |
| 587 * Error = NvRmPowerVoltageControl(RmHandle, ModuleId, ClientId, |
| 588 * NvRmVoltsUnspecified, NvRmVoltsUnspecified, |
| 589 * NULL, 0, NULL); |
| 590 * |
| 591 * // Disable module power |
| 592 * Error = NvRmPowerVoltageControl(RmHandle, ModuleId, ClientId, |
| 593 * NvRmVoltsOff, NvRmVoltsOff, |
| 594 * NULL, 0, NULL); |
| 595 * |
| 596 * @param hRmDeviceHandle The RM device handle |
| 597 * @param ModuleId The combined module ID and instance of the target module |
| 598 * @param ClientId The client ID obtained during registration |
| 599 * @param MinVolts Requested minimum voltage for hardware module operation |
| 600 * @param MaxVolts Requested maximum voltage for hardware module operation |
| 601 * Set to NvRmVoltsUnspecified when enabling power for a module, or to |
| 602 * NvRmVoltsOff when disabling. |
| 603 * @param PrefVoltageList Pointer to a list of preferred voltages, ordered from |
| 604 * lowest to highest, and terminated with a voltage of NvRmVoltsUnspecified. |
| 605 * This parameter is optional - ignored if null. |
| 606 * @param PrefVoltageListCount Number of entries in the PrefVoltageList array. |
| 607 * @param CurrentVolts Output storage pointer for resulting module voltage. |
| 608 * NvRmVoltsUnspecified is returned if module power is On and was not cycled, |
| 609 * since the last voltage request with the same ClientId and ModuleId; |
| 610 * NvRmVoltsCycled is returned if module power is On but was powered down, |
| 611 * since the last voltage request with the same ClientId and ModuleId; |
| 612 * NvRmVoltsOff is returned if module power is Off. |
| 613 * This parameter is optional - ignored if null. |
| 614 * |
| 615 * @retval NvSuccess if voltage control request completed successfully. |
| 616 * @retval NvError_BadValue if specified client ID is not registered. |
| 617 * @retval NvError_InsufficientMemory if failed to allocate memory for |
| 618 * voltage request. |
| 619 */ |
| 620 |
| 621 NvError NvRmPowerVoltageControl( |
| 622 NvRmDeviceHandle hRmDeviceHandle, |
| 623 NvRmModuleID ModuleId, |
| 624 NvU32 ClientId, |
| 625 NvRmMilliVolts MinVolts, |
| 626 NvRmMilliVolts MaxVolts, |
| 627 const NvRmMilliVolts * PrefVoltageList, |
| 628 NvU32 PrefVoltageListCount, |
| 629 NvRmMilliVolts * CurrentVolts ); |
| 630 |
| 631 /** |
| 632 * Lists modules registered by power clients for voltage control. |
| 633 * |
| 634 * @param pListSize Pointer to the list size. On entry specifies list size |
| 635 * allocated by the caller, on exit - actual number of Ids returned. If |
| 636 * entry size is 0, maximum list size is returned. |
| 637 * @param pIdList Pointer to the list of combined module Id/Instance values |
| 638 * to be filled in by this function. Ignored if input list size is 0. |
| 639 * @param pActiveList Pointer to the list of modules Active attributes |
| 640 * to be filled in by this function. Ignored if input list size is 0. |
| 641 */ |
| 642 |
| 643 void NvRmListPowerAwareModules( |
| 644 NvRmDeviceHandle hRmDeviceHandle, |
| 645 NvU32 * pListSize, |
| 646 NvRmModuleID * pIdList, |
| 647 NvBool * pActiveList ); |
| 648 |
| 649 /** |
| 650 * Requests immediate frequency boost for SOC-wide clocks. In general, the RM |
| 651 * DFS manages SOC-wide clocks by measuring the average use of clock cycles, |
| 652 * and adjusting clock rates to minimize wasted clocks. It is preferable and |
| 653 * expected that modules consume clock cycles at a more-or-less constant rate. |
| 654 * Under some circumstances this will not be the case. For example, many cycles |
| 655 * may be consumed to prime a new media processing activity. If power client |
| 656 * anticipates such circumstances, it may sparingly use this API to alert the RM |
| 657 * that a temporary spike in clock usage is about to occur. |
| 658 * |
| 659 * Usage example: |
| 660 * |
| 661 * // Busy hint for CPU clock |
| 662 * NvError Error; |
| 663 * Error = NvRmPowerBusyHint(RmHandle, NvRmDfsClockId_Cpu, ClientId, |
| 664 * BoostDurationMs, BoostFreqKHz); |
| 665 * |
| 666 * Clients should not call this API in an attempt to micro-manage a particular |
| 667 * clock frequency as that is the responsibility of the RM. |
| 668 * |
| 669 * @param hRmDeviceHandle The RM device handle. |
| 670 * @param ClockId The DFS ID of the clock targeted by this hint. |
| 671 * @param ClientId The client ID obtained during registration. |
| 672 * @param BoostDurationMs The estimate of the boost duration in milliseconds. |
| 673 * Use NV_WAIT_INFINITE to specify busy until canceled. Use 0 to request |
| 674 * instantaneous spike in frequency and let DFS to scale down. |
| 675 * @param BoostKHz The requirements for the boosted clock frequency in kHz. |
| 676 * Use NvRmFreqMaximum to request maximum domain frequency. Use 0 to cancel |
| 677 * all busy hints reported by the specified client for the specified domain. |
| 678 * |
| 679 * @retval NvSuccess if busy request completed successfully. |
| 680 * @retval NvError_BadValue if specified client ID is not registered. |
| 681 * @retval NvError_InsufficientMemory if failed to allocate memory for |
| 682 * busy hint. |
| 683 */ |
| 684 |
| 685 NvError NvRmPowerBusyHint( |
| 686 NvRmDeviceHandle hRmDeviceHandle, |
| 687 NvRmDfsClockId ClockId, |
| 688 NvU32 ClientId, |
| 689 NvU32 BoostDurationMs, |
| 690 NvRmFreqKHz BoostKHz ); |
| 691 |
| 692 /** |
| 693 * Requests immediate frequency boost for multiple SOC-wide clock domains. |
| 694 * @sa NvRmPowerBusyHint() for detailed explanation of busy hint effects. |
| 695 * |
| 696 * @param hRmDeviceHandle The RM device handle. |
| 697 * @param ClientId The client ID obtained during registration. |
| 698 * @param pMultiHint Pointer to a list of busy hint records for |
| 699 * targeted clocks. |
| 700 * @param NumHints Number of entries in pMultiHint array. |
| 701 * @param Mode Synchronization mode. In asynchronous mode this API returns to |
| 702 * the caller after request is signaled to power manager (non-blocking call). |
| 703 * In synchronous mode the API returns after busy hints are processed by power |
| 704 * manager (blocking call). |
| 705 * |
| 706 * @note It is recommended to use synchronous mode only when low frequency |
| 707 * may result in functional failure. Otherwise, use asynchronous mode or |
| 708 * NvRmPowerBusyHint API, which is always executed as non-blocking request. |
| 709 * Synchronous mode must not be used by PMU transport. |
| 710 * |
| 711 * |
| 712 * @retval NvSuccess if busy hint request completed successfully. |
| 713 * @retval NvError_BadValue if specified client ID is not registered. |
| 714 * @retval NvError_InsufficientMemory if failed to allocate memory for |
| 715 * busy hints. |
| 716 */ |
| 717 |
| 718 NvError NvRmPowerBusyHintMulti( |
| 719 NvRmDeviceHandle hRmDeviceHandle, |
| 720 NvU32 ClientId, |
| 721 const NvRmDfsBusyHint * pMultiHint, |
| 722 NvU32 NumHints, |
| 723 NvRmDfsBusyHintSyncMode Mode ); |
| 724 |
| 725 /** |
| 726 * Request frequency increase for SOC-wide clock to avoid real-time starvation |
| 727 * conditions. Allows modules to contribute to the detection and avoidance of |
| 728 * clock starvation for DFS controlled clocks. |
| 729 * |
| 730 * This API should be called to indicate starvation threat and also to cancel |
| 731 * request when a starvation condition has eased. |
| 732 * |
| 733 * @note Although the RM DFS does its best to manage clocks without starving |
| 734 * the system for clock cycles, bursty clock usage can occasionally cause |
| 735 * short-term clock starvation. One solution is to leave a large enough clock |
| 736 * rate guard band such that any possible burst in clock usage will be absorbed. |
| 737 * This approach tends to waste clock cycles, and worsen power management. |
| 738 * |
| 739 * By allowing power clients to participate in the avoidance of system clock |
| 740 * starvation situations, detection responsibility can be moved closer to the |
| 741 * hardware buffers and processors where starvation occurs, while leaving the |
| 742 * overall dynamic clocking policy to the RM. A typical client would be a module |
| 743 * that manages media processing and is able to determine when it is falling |
| 744 * behind by watching buffer levels or some other module-specific indicator. In |
| 745 * response to the starvation request the RM increases gradually the respective |
| 746 * clock frequency until the request vis cancelled by the client. |
| 747 * |
| 748 * Usage example: |
| 749 * |
| 750 * NvError Error; |
| 751 * |
| 752 * // Request CPU clock frequency increase to avoid starvation |
| 753 * Error = NvRmPowerStarvationHint( |
| 754 * RmHandle, NvRmDfsClockId_Cpu, ClientId, NV_TRUE); |
| 755 * |
| 756 * // Cancel starvation request for CPU clock frequency |
| 757 * Error = NvRmPowerStarvationHint( |
| 758 * RmHandle, NvRmDfsClockId_Cpu, ClientId, NV_FALSE); |
| 759 * |
| 760 * @param hRmDeviceHandle The RM device handle. |
| 761 * @param ClockId The DFS ID of the clock targeted by this hint. |
| 762 * @param ClientId The client ID obtained during registration. |
| 763 * @param Starving The starvation indicator for the target module. If true, |
| 764 * the client is requesting target frequency increase to avoid starvation |
| 765 * If false, the indication is that the imminent starvation is no longer a |
| 766 * concern for this particular client. |
| 767 * |
| 768 * @retval NvSuccess if starvation request completed successfully. |
| 769 * @retval NvError_BadValue if specified client ID is not registered. |
| 770 * @retval NvError_InsufficientMemory if failed to allocate memory for |
| 771 * starvation hint. |
| 772 */ |
| 773 |
| 774 NvError NvRmPowerStarvationHint( |
| 775 NvRmDeviceHandle hRmDeviceHandle, |
| 776 NvRmDfsClockId ClockId, |
| 777 NvU32 ClientId, |
| 778 NvBool Starving ); |
| 779 |
| 780 /** |
| 781 * Request frequency increase for multiple SOC-wide clock domains to avoid |
| 782 * real-time starvation conditions. |
| 783 * @sa NvRmPowerStarvationHint() for detailed explanation of starvation hint |
| 784 * effects. |
| 785 * |
| 786 * @param hRmDeviceHandle The RM device handle. |
| 787 * @param ClientId The client ID obtained during registration. |
| 788 * @param pMultiHint Pointer to a list of starvation hint records for |
| 789 * targeted clocks. |
| 790 * @param NumHints Number of entries in pMultiHint array. |
| 791 * |
| 792 * @retval NvSuccess if starvation hint request completed successfully. |
| 793 * @retval NvError_BadValue if specified client ID is not registered. |
| 794 * @retval NvError_InsufficientMemory if failed to allocate memory for |
| 795 * starvation hints. |
| 796 */ |
| 797 |
| 798 NvError NvRmPowerStarvationHintMulti( |
| 799 NvRmDeviceHandle hRmDeviceHandle, |
| 800 NvU32 ClientId, |
| 801 const NvRmDfsStarvationHint * pMultiHint, |
| 802 NvU32 NumHints ); |
| 803 |
| 804 /** |
| 805 * Notifies the RM about DDK module activity. |
| 806 * |
| 807 * @note This function lets DDK modules notify the RM about interesting system |
| 808 * activities. Not all modules will need to make this indication, typically only |
| 809 * modules involved in user input or output activities. However, with current |
| 810 * SOC power management architecture such activities will be detected by the OS |
| 811 * adaptation layer, not RM. This API is not removed, just in case, we will find |
| 812 * out that RM still need to participate in user activity detection. In general, |
| 813 * modules should call this interface sparingly, no more than once every few |
| 814 * seconds. |
| 815 * |
| 816 * In current power management architecture user activity is handled by OS |
| 817 * (nor RM) power manager, and activity API is not used at all. |
| 818 * |
| 819 * Assert encountered in debug mode if the module ID or instance is invalid. |
| 820 * |
| 821 * TODO: Remove this API? |
| 822 * |
| 823 * @param hRmDeviceHandle The RM device handle. |
| 824 * @param ModuleId The combined module ID and instance of the target module. |
| 825 * @param ClientId The client ID obtained during registration. |
| 826 * @param ActivityDurationMs The duration of the module activity. |
| 827 * |
| 828 * For cases when activity is a series of discontinuous events (keypresses, for |
| 829 * example), this parameter should simply be set to 1. |
| 830 * |
| 831 * For lengthy, continuous activities, this parameter is set to the estimated |
| 832 * length of the activity in milliseconds. This can reduce the number of calls |
| 833 * made to this API. |
| 834 * |
| 835 * A value of 0 in this parameter indicates that the module is not active and |
| 836 * can be used to signal the end of a previously estimated continuous activity. |
| 837 * |
| 838 * @retval NvSuccess if clock control request completed successfully. |
| 839 */ |
| 840 |
| 841 NvError NvRmPowerActivityHint( |
| 842 NvRmDeviceHandle hRmDeviceHandle, |
| 843 NvRmModuleID ModuleId, |
| 844 NvU32 ClientId, |
| 845 NvU32 ActivityDurationMs ); |
| 846 |
| 847 /** |
| 848 * Gets DFS run sate. |
| 849 * |
| 850 * @param hRmDeviceHandle The RM device handle. |
| 851 * |
| 852 * @return Current DFS run state. |
| 853 */ |
| 854 |
| 855 NvRmDfsRunState NvRmDfsGetState( |
| 856 NvRmDeviceHandle hRmDeviceHandle ); |
| 857 |
| 858 /** |
| 859 * Gets information on DFS controlled clock utilization. If DFS is stopped |
| 860 * or disabled the average frequency is always equal to current frequency. |
| 861 * |
| 862 * @param hRmDeviceHandle The RM device handle. |
| 863 * @param ClockId The DFS ID of the clock targeted by this request. |
| 864 * @param pClockInfo Output storage pointer for clock utilization information. |
| 865 * |
| 866 * @return NvSuccess if clock usage information is returned successfully. |
| 867 */ |
| 868 |
| 869 NvError NvRmDfsGetClockUtilization( |
| 870 NvRmDeviceHandle hRmDeviceHandle, |
| 871 NvRmDfsClockId ClockId, |
| 872 NvRmDfsClockUsage * pClockUsage ); |
| 873 |
| 874 /** |
| 875 * Sets DFS run state. Allows to stop or re-start DFS as well as switch |
| 876 * between open and closed loop operations. |
| 877 * |
| 878 * On transition to the DFS stopped state, the DFS clocks are just kept at |
| 879 * current frequencies. On transition to DFS run states, DFS sampling data |
| 880 * is re-initialized only if originally DFS was stopped. Transition between |
| 881 * running states has no additional effects, besides operation mode changes. |
| 882 * |
| 883 * @param hRmDeviceHandle The RM device handle. |
| 884 * @param NewDfsRunState The DFS run state to be set. |
| 885 * |
| 886 * @retval NvSuccess if DFS state was set successfully. |
| 887 * @retval NvError_NotSupported if DFS was disabled initially, in attempt |
| 888 * to disable initially enabled DFS, or in attempt to run profiled loop |
| 889 * on non profiling build. |
| 890 */ |
| 891 |
| 892 NvError NvRmDfsSetState( |
| 893 NvRmDeviceHandle hRmDeviceHandle, |
| 894 NvRmDfsRunState NewDfsRunState ); |
| 895 |
| 896 /** |
| 897 * Sets DFS low corner frequencies - low boundaries for DFS clocks when DFS. |
| 898 * is running. If all DFS domains hit low corner, DFS will no longer wake |
| 899 * CPU from low power state. |
| 900 * |
| 901 * @note When CPU envelope is set via NvRmDfsSetCpuEnvelope() API the CPU |
| 902 * low corner boundary can not be changed by this function. |
| 903 * @note When EMC envelope is set via NvRmDfsSetEmcEnvelope() API the EMC |
| 904 * low corner boundary can not be changed by this function. |
| 905 * |
| 906 * Usage example: |
| 907 * |
| 908 * NvError Error; |
| 909 * NvRmFreqKHz LowCorner[NvRmDfsClockId_Num]; |
| 910 * |
| 911 * // Fill in low corner array |
| 912 * LowCorner[NvRmDfsClockId_Cpu] = NvRmFreqUnspecified; |
| 913 * LowCorner[NvRmDfsClockId_Avp] = ... ; |
| 914 * LowCorner[NvRmDfsClockId_System] = ...; |
| 915 * LowCorner[NvRmDfsClockId_Ahb] = ...; |
| 916 * LowCorner[NvRmDfsClockId_Apb] = ...; |
| 917 * LowCorner[NvRmDfsClockId_Vpipe] = ...; |
| 918 * LowCorner[NvRmDfsClockId_Emc] = ...; |
| 919 * |
| 920 * // Set new low corner for domains other than CPU, and preserve CPU boundary |
| 921 * Error = NvRmDfsSetLowCorner(RmHandle, NvRmDfsClockId_Num, LowCorner); |
| 922 * |
| 923 * @param hRmDeviceHandle The RM device handle. |
| 924 * @param DfsFreqListCount Number of entries in the pDfsLowFreqList array. |
| 925 * Must be always equal to NvRmDfsClockId_Num. |
| 926 * @param pDfsLowFreqList Pointer to a list of low corner frequencies, ordered |
| 927 * according to NvRmDfsClockId enumeration. If the list entry is set to |
| 928 * NvRmFreqUnspecified, the respective low corner boundary is not modified. |
| 929 * |
| 930 * @retval NvSuccess if low corner frequencies were updated successfully. |
| 931 * @retval NvError_NotSupported if DFS is disabled. |
| 932 */ |
| 933 |
| 934 NvError NvRmDfsSetLowCorner( |
| 935 NvRmDeviceHandle hRmDeviceHandle, |
| 936 NvU32 DfsFreqListCount, |
| 937 const NvRmFreqKHz * pDfsLowFreqList ); |
| 938 |
| 939 /** |
| 940 * Sets DFS target frequencies. If DFS is stopped clocks for the DFS domains |
| 941 * will be targeted with the specified frequencies. In any other DFS state |
| 942 * this function has no effect. |
| 943 * |
| 944 * Usage example: |
| 945 * |
| 946 * NvError Error; |
| 947 * NvRmFreqKHz Target[NvRmDfsClockId_Num]; |
| 948 * |
| 949 * // Fill in target frequencies array |
| 950 * Target[NvRmDfsClockId_Cpu] = ... ; |
| 951 * Target[NvRmDfsClockId_Avp] = ... ; |
| 952 * Target[NvRmDfsClockId_System] = ...; |
| 953 * Target[NvRmDfsClockId_Ahb] = ...; |
| 954 * Target[NvRmDfsClockId_Apb] = ...; |
| 955 * Target[NvRmDfsClockId_Vpipe] = ...; |
| 956 * Target[NvRmDfsClockId_Emc] = ...; |
| 957 * |
| 958 * // Set new target |
| 959 * Error = NvRmDfsSetTarget(RmHandle, NvRmDfsClockId_Num, Target); |
| 960 * |
| 961 * @param hRmDeviceHandle The RM device handle. |
| 962 * @param DfsFreqListCount Number of entries in the pDfsTargetFreqList array. |
| 963 * Must be always equal to NvRmDfsClockId_Num. |
| 964 * @param pDfsTargetFreqList Pointer to a list of target frequencies, ordered |
| 965 * according to NvRmDfsClockId enumeration. If the list entry is set to |
| 966 * NvRmFreqUnspecified, the current domain frequency is used as a target. |
| 967 * |
| 968 * @retval NvSuccess if target frequencies were updated successfully. |
| 969 * @retval NvError_NotSupported if DFS is not stopped (disabled, or running). |
| 970 */ |
| 971 |
| 972 NvError NvRmDfsSetTarget( |
| 973 NvRmDeviceHandle hRmDeviceHandle, |
| 974 NvU32 DfsFreqListCount, |
| 975 const NvRmFreqKHz * pDfsTargetFreqList ); |
| 976 |
| 977 /** |
| 978 * Sets DFS high and low boundaries for CPU domain clock frequency. |
| 979 * |
| 980 * Usage example: |
| 981 * |
| 982 * NvError Error; |
| 983 * |
| 984 * // Set CPU envelope boundaries to LowKHz : HighKHz |
| 985 * Error = NvRmDfsSetCpuEnvelope(RmHandle, LowKHz, HighKHz); |
| 986 * |
| 987 * // Change CPU envelope high boundary to HighKHz |
| 988 * Error = NvRmDfsSetCpuEnvelope(RmHandle, NvRmFreqUnspecified, HighKHz); |
| 989 * |
| 990 * // Release CPU envelope back to HW limits |
| 991 * Error = NvRmDfsSetCpuEnvelope(RmHandle, 0, NvRmFreqMaximum); |
| 992 * |
| 993 * @param hRmDeviceHandle The RM device handle. |
| 994 * @param DfsCpuEnvelopeLowKHz Requested low boundary in kHz. |
| 995 * @param DfsCpuEnvelopeHighKHz Requested high limit in kHz. |
| 996 * |
| 997 * Envelope parameters are clipped to the HW defined CPU domain range. |
| 998 * If envelope parameter is set to NvRmFreqUnspecified, the respective |
| 999 * CPU boundary is not modified, unless it violates the new setting for |
| 1000 * the other boundary; in the latter case both boundaries are set to the |
| 1001 * new specified value. |
| 1002 * |
| 1003 * @retval NvSuccess if DFS envelope for for CPU domain was updated |
| 1004 * successfully. |
| 1005 * @retval NvError_BadValue if reversed boundaries are specified. |
| 1006 * @retval NvError_NotSupported if DFS is disabled. |
| 1007 */ |
| 1008 |
| 1009 NvError NvRmDfsSetCpuEnvelope( |
| 1010 NvRmDeviceHandle hRmDeviceHandle, |
| 1011 NvRmFreqKHz DfsCpuLowCornerKHz, |
| 1012 NvRmFreqKHz DfsCpuHighCornerKHz ); |
| 1013 |
| 1014 /** |
| 1015 * Sets DFS high and low boundaries for EMC domain clock frequency. |
| 1016 * |
| 1017 * Usage example: |
| 1018 * |
| 1019 * NvError Error; |
| 1020 * |
| 1021 * // Set EMC envelope boundaries to LowKHz : HighKHz |
| 1022 * Error = NvRmDfsSetEmcEnvelope(RmHandle, LowKHz, HighKHz); |
| 1023 * |
| 1024 * // Change EMC envelope high boundary to HighKHz |
| 1025 * Error = NvRmDfsSetEmcEnvelope(RmHandle, NvRmFreqUnspecified, HighKHz); |
| 1026 * |
| 1027 * // Release EMC envelope back to HW limits |
| 1028 * Error = NvRmDfsSetEmcEnvelope(RmHandle, 0, NvRmFreqMaximum); |
| 1029 * |
| 1030 * @param hRmDeviceHandle The RM device handle. |
| 1031 * @param DfsEmcEnvelopeLowKHz Requested low boundary in kHz. |
| 1032 * @param DfsEmcEnvelopeHighKHz Requested high limit in kHz. |
| 1033 * |
| 1034 * Envelope parameters are clipped to the ODM defined EMC configurations |
| 1035 * within HW defined EMC domain range. If envelope parameter is set to |
| 1036 * NvRmFreqUnspecified, the respective EMC boundary is not modified, unless |
| 1037 * it violates the new setting for the other boundary; in the latter case |
| 1038 * both boundaries are set to the new specified value. |
| 1039 * |
| 1040 * @retval NvSuccess if DFS envelope for for EMC domain was updated |
| 1041 * successfully. |
| 1042 * @retval NvError_BadValue if reversed boundaries are specified. |
| 1043 * @retval NvError_NotSupported if DFS is disabled. |
| 1044 */ |
| 1045 |
| 1046 NvError NvRmDfsSetEmcEnvelope( |
| 1047 NvRmDeviceHandle hRmDeviceHandle, |
| 1048 NvRmFreqKHz DfsEmcLowCornerKHz, |
| 1049 NvRmFreqKHz DfsEmcHighCornerKHz ); |
| 1050 |
| 1051 /** |
| 1052 * Sets DFS high boundaries for CPU and EMC. |
| 1053 * |
| 1054 * @note When either CPU or EMC envelope is set via NvRmDfsSetXxxEnvelope() |
| 1055 * API, neither CPU nor EMC boundary is changed by this function. |
| 1056 * |
| 1057 * Usage example: |
| 1058 * |
| 1059 * NvError Error; |
| 1060 * |
| 1061 * // Set CPU subsystem clock limit to CpuHighKHz and Emc clock limit |
| 1062 * // to EmcHighKHz |
| 1063 * Error = NvRmDfsSetCpuEmcHighCorner(RmHandle, CpuHighKHz, EmcHighKHz); |
| 1064 * |
| 1065 * @param hRmDeviceHandle The RM device handle. |
| 1066 * @param DfsCpuHighKHz Requested high boundary in kHz for CPU. |
| 1067 * @param DfsEmcHighKHz Requested high limit in kHz for EMC. |
| 1068 * |
| 1069 * Requested parameters are clipped to the respective HW defined domain |
| 1070 * ranges, as well as to ODM defined EMC configurations. If any parameter |
| 1071 * is set to NvRmFreqUnspecified, the respective boundary is not modified. |
| 1072 * |
| 1073 * @retval NvSuccess if high corner for AV subsystem was updated successfully. |
| 1074 * @retval NvError_NotSupported if DFS is disabled. |
| 1075 */ |
| 1076 |
| 1077 NvError NvRmDfsSetCpuEmcHighCorner( |
| 1078 NvRmDeviceHandle hRmDeviceHandle, |
| 1079 NvRmFreqKHz DfsCpuHighKHz, |
| 1080 NvRmFreqKHz DfsEmcHighKHz ); |
| 1081 |
| 1082 /** |
| 1083 * Sets DFS high boundaries for AV subsystem clocks. |
| 1084 * |
| 1085 * Usage example: |
| 1086 * |
| 1087 * NvError Error; |
| 1088 * |
| 1089 * // Set AVP clock limit to AvpHighKHz, Vde clock limit to VpipeHighKHz, |
| 1090 * // and preserve System bus clock limit provided it is above requested |
| 1091 * // AVP and Vpipe levels. |
| 1092 * Error = NvRmDfsSetAvHighCorner( |
| 1093 * RmHandle, NvRmFreqUnspecified, AvpHighKHz, VpipeHighKHz); |
| 1094 * |
| 1095 *@note System bus clock limit must be always above AvpHighKHz, and above |
| 1096 * VpipeHighKHz. Therefore it may be adjusted up, as a result of this call, |
| 1097 * even though, it is marked unspecified. |
| 1098 * |
| 1099 * @param hRmDeviceHandle The RM device handle. |
| 1100 * @param DfsSysHighKHz Requested high boundary in kHz for System bus. |
| 1101 * @param DfsAvpHighKHz Requested high boundary in kHz for AVP. |
| 1102 * @param DfsVdeHighCornerKHz Requested high limit in kHz for Vde pipe. |
| 1103 * |
| 1104 * Requested parameter is clipped to the respective HW defined domain |
| 1105 * range. If parameter is set to NvRmFreqUnspecified, the respective |
| 1106 * boundary is not modified. |
| 1107 * |
| 1108 * @retval NvSuccess if high corner for AV subsystem was updated successfully. |
| 1109 * @retval NvError_NotSupported if DFS is disabled. |
| 1110 */ |
| 1111 |
| 1112 NvError NvRmDfsSetAvHighCorner( |
| 1113 NvRmDeviceHandle hRmDeviceHandle, |
| 1114 NvRmFreqKHz DfsSystemHighKHz, |
| 1115 NvRmFreqKHz DfsAvpHighKHz, |
| 1116 NvRmFreqKHz DfsVpipeHighKHz ); |
| 1117 |
| 1118 /** |
| 1119 * Gets DFS profiling information. |
| 1120 * |
| 1121 * DFS profiling starts/re-starts every time NvRmDfsRunState_ProfiledLoop |
| 1122 * state is set via NvRmDfsSetState(). DFS profiling stops when any other |
| 1123 * sate is set. |
| 1124 * |
| 1125 * @param hRmDeviceHandle The RM device handle. |
| 1126 * @param DfsProfileCount Number of DFS profiles. Must be always equal to |
| 1127 * NvRmDfsProfileId_Num. |
| 1128 * @param pSamplesNoList Output storage pointer to an array of sample counts |
| 1129 * for each profile target ordered according to NvRmDfsProfileId enumeration. |
| 1130 * @param pProfileTimeUsList Output storage pointer to an array of cummulative |
| 1131 * execution time in microseconds for each profile target ordered according |
| 1132 * to NvRmDfsProfileId enumeration. |
| 1133 * @param pDfsPeriodUs Output storage pointer for average DFS sample |
| 1134 * period in microseconds. |
| 1135 * |
| 1136 * @retval NvSuccess if profile information is returned successfully. |
| 1137 * @retval NvError_NotSupported if DFS is not ruuning in profiled loop. |
| 1138 */ |
| 1139 |
| 1140 NvError NvRmDfsGetProfileData( |
| 1141 NvRmDeviceHandle hRmDeviceHandle, |
| 1142 NvU32 DfsProfileCount, |
| 1143 NvU32 * pSamplesNoList, |
| 1144 NvU32 * pProfileTimeUsList, |
| 1145 NvU32 * pDfsPeriodUs ); |
| 1146 |
| 1147 /** |
| 1148 * Starts/Re-starts NV DFS logging. |
| 1149 * |
| 1150 * @param hRmDeviceHandle The RM device handle. |
| 1151 */ |
| 1152 |
| 1153 void NvRmDfsLogStart( |
| 1154 NvRmDeviceHandle hRmDeviceHandle ); |
| 1155 |
| 1156 /** |
| 1157 * Stops DFS logging and gets cumulative mean values of DFS domains frequencies |
| 1158 * over logging time. |
| 1159 * |
| 1160 * @param hRmDeviceHandle The RM device handle. |
| 1161 * @param LogMeanFreqListCount Number of entries in the pLogMeanFreqList array. |
| 1162 * Must be always equal to NvRmDfsClockId_Num. |
| 1163 * @param pLogMeanFreqList Pointer to a list filled with mean values of DFS |
| 1164 * frequencies, ordered according to NvRmDfsClockId enumeration. |
| 1165 * @param pLogLp2TimeMs Pointer to a variable filled with cumulative time spent |
| 1166 * in LP2 in milliseconds. |
| 1167 * @param pLogLp2Entries Pointer to a variable filled with cumulative number of |
| 1168 * LP2 mode entries. |
| 1169 * |
| 1170 * @retval NvSuccess if mean values are returned successfully. |
| 1171 * @retval NvError_NotSupported if DFS is disabled. |
| 1172 */ |
| 1173 |
| 1174 NvError NvRmDfsLogGetMeanFrequencies( |
| 1175 NvRmDeviceHandle hRmDeviceHandle, |
| 1176 NvU32 LogMeanFreqListCount, |
| 1177 NvRmFreqKHz * pLogMeanFreqList, |
| 1178 NvU32 * pLogLp2TimeMs, |
| 1179 NvU32 * pLogLp2Entries ); |
| 1180 |
| 1181 /** |
| 1182 * Gets specified entry of the detailed DFS activity log. |
| 1183 * |
| 1184 * @param hRmDeviceHandle The RM device handle. |
| 1185 * @param EntryIndex Log entrty index. |
| 1186 * @param LogDomainsCount The size of activity arrays. |
| 1187 * Must be always equal to NvRmDfsClockId_Num. |
| 1188 * @param pIntervalMs Pointer to a variable filled with sample interval time |
| 1189 * in milliseconds. |
| 1190 * @param pLp2TimeMs Pointer to a variable filled with time spent in LP2 |
| 1191 * in milliseconds. |
| 1192 * @param pActiveCyclesList Pointer to a list filled with domain active cycles |
| 1193 * within sample interval. |
| 1194 * @param pAveragesList Pointer to a list filled with average domain activity |
| 1195 * over DFS moving window. |
| 1196 * @param pFrequenciesList Pointer to a list filled with instantaneous domains |
| 1197 * frequencies. |
| 1198 * All lists are ordered according to NvRmDfsClockId enumeration. |
| 1199 * |
| 1200 * @retval NvSuccess if log entry is retrieved successfully. |
| 1201 * @retval NvError_InvalidAddress if requetsed entry is empty. |
| 1202 * @retval NvError_NotSupported if DFS is disabled, or detailed logging |
| 1203 * is not supported. |
| 1204 */ |
| 1205 |
| 1206 NvError NvRmDfsLogActivityGetEntry( |
| 1207 NvRmDeviceHandle hRmDeviceHandle, |
| 1208 NvU32 EntryIndex, |
| 1209 NvU32 LogDomainsCount, |
| 1210 NvU32 * pIntervalMs, |
| 1211 NvU32 * pLp2TimeMs, |
| 1212 NvU32 * pActiveCyclesList, |
| 1213 NvRmFreqKHz * pAveragesList, |
| 1214 NvRmFreqKHz * pFrequenciesList ); |
| 1215 |
| 1216 /** |
| 1217 * Gets specified entry of the detailed DFS starvation hints log. |
| 1218 * |
| 1219 * @param hRmDeviceHandle The RM device handle. |
| 1220 * @param EntryIndex Log entrty index. |
| 1221 * @param pSampleIndex Pointer to a variable filled with sample interval |
| 1222 * index in the activity log when this hint is associated with. |
| 1223 * @param pStarvationHint Pointer to a variable filled with starvation |
| 1224 * hint record. |
| 1225 * |
| 1226 * @retval NvSuccess if next entry is retrieved successfully. |
| 1227 * @retval NvError_InvalidAddress if requetsed entry is empty. |
| 1228 * @retval NvError_NotSupported if DFS is disabled, or detailed logging |
| 1229 * is not supported. |
| 1230 */ |
| 1231 |
| 1232 NvError NvRmDfsLogStarvationGetEntry( |
| 1233 NvRmDeviceHandle hRmDeviceHandle, |
| 1234 NvU32 EntryIndex, |
| 1235 NvU32 * pSampleIndex, |
| 1236 NvU32 * pClientId, |
| 1237 NvU32 * pClientTag, |
| 1238 NvRmDfsStarvationHint * pStarvationHint ); |
| 1239 |
| 1240 /** |
| 1241 * Gets specified entry of the detailed DFS busy hints log. |
| 1242 * |
| 1243 * @param hRmDeviceHandle The RM device handle. |
| 1244 * @param EntryIndex Log entrty index. |
| 1245 * @param pSampleIndex Pointer to a variable filled with sample interval |
| 1246 * index in the activity log when this hint is associated with. |
| 1247 * @param pBusyHint Pointer to a variable filled with busy |
| 1248 * hint record. |
| 1249 * |
| 1250 * @retval NvSuccess if next entry is retrieved successfully. |
| 1251 * @retval NvError_InvalidAddress if requetsed entry is empty. |
| 1252 * @retval NvError_NotSupported if DFS is disabled, or detailed logging |
| 1253 * is not supported. |
| 1254 */ |
| 1255 |
| 1256 NvError NvRmDfsLogBusyGetEntry( |
| 1257 NvRmDeviceHandle hRmDeviceHandle, |
| 1258 NvU32 EntryIndex, |
| 1259 NvU32 * pSampleIndex, |
| 1260 NvU32 * pClientId, |
| 1261 NvU32 * pClientTag, |
| 1262 NvRmDfsBusyHint * pBusyHint ); |
| 1263 |
| 1264 /** |
| 1265 * Gets low threshold and present voltage on the given rail. |
| 1266 * |
| 1267 * @param hRmDeviceHandle The RM device handle. |
| 1268 * @param RailId The targeted voltage rail ID. |
| 1269 * @param pLowMv Output storage pointer for low voltage threshold (in |
| 1270 * millivolt). NvRmVoltsUnspecified is returned if targeted rail does |
| 1271 * not exist on SoC. |
| 1272 * @param pPresentMv Output storage pointer for present rail voltage (in |
| 1273 * millivolt). NvRmVoltsUnspecified is returned if targeted rail does |
| 1274 * not exist on SoC. |
| 1275 */ |
| 1276 |
| 1277 void NvRmDfsGetLowVoltageThreshold( |
| 1278 NvRmDeviceHandle hRmDeviceHandle, |
| 1279 NvRmDfsVoltageRailId RailId, |
| 1280 NvRmMilliVolts * pLowMv, |
| 1281 NvRmMilliVolts * pPresentMv ); |
| 1282 |
| 1283 /** |
| 1284 * Sets low threshold for the given rail. The actual rail voltage is scaled |
| 1285 * to match SoC clock frequencies, but not below the specified threshold. |
| 1286 * |
| 1287 * @param hRmDeviceHandle The RM device handle. |
| 1288 * @param RailId The targeted voltage rail ID. |
| 1289 * @param LowMv Low voltage threshold (in millivolts) for the targeted rail. |
| 1290 * Ignored if targeted rail does not exist on SoC. |
| 1291 */ |
| 1292 |
| 1293 void NvRmDfsSetLowVoltageThreshold( |
| 1294 NvRmDeviceHandle hRmDeviceHandle, |
| 1295 NvRmDfsVoltageRailId RailId, |
| 1296 NvRmMilliVolts LowMv ); |
| 1297 |
| 1298 /** |
| 1299 * Notifies RM Kernel about entering Suspend state. |
| 1300 * |
| 1301 * @param hRmDeviceHandle The RM device handle. |
| 1302 * |
| 1303 * @retval NvSuccess if notifying RM entering Suspend state successfully. |
| 1304 */ |
| 1305 |
| 1306 NvError NvRmKernelPowerSuspend( |
| 1307 NvRmDeviceHandle hRmDeviceHandle ); |
| 1308 |
| 1309 /** |
| 1310 * Notifies RM kernel about entering Resume state. |
| 1311 * |
| 1312 * @param hRmDeviceHandle The RM device handle. |
| 1313 * |
| 1314 * @retval NvSuccess if notifying RM entering Resume state successfully. |
| 1315 */ |
| 1316 |
| 1317 NvError NvRmKernelPowerResume( |
| 1318 NvRmDeviceHandle hRmDeviceHandle ); |
| 1319 |
| 1320 /** @} */ |
| 1321 |
| 1322 #if defined(__cplusplus) |
| 1323 } |
| 1324 #endif |
| 1325 |
| 1326 #endif |
OLD | NEW |