18c2ecf20Sopenharmony_ciQCOM Idle States for cpuidle driver 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciARM provides idle-state node to define the cpuidle states, as defined in [1]. 48c2ecf20Sopenharmony_cicpuidle-qcom is the cpuidle driver for Qualcomm SoCs and uses these idle 58c2ecf20Sopenharmony_cistates. Idle states have different enter/exit latency and residency values. 68c2ecf20Sopenharmony_ciThe idle states supported by the QCOM SoC are defined as - 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci * Standby 98c2ecf20Sopenharmony_ci * Retention 108c2ecf20Sopenharmony_ci * Standalone Power Collapse (Standalone PC or SPC) 118c2ecf20Sopenharmony_ci * Power Collapse (PC) 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciStandby: Standby does a little more in addition to architectural clock gating. 148c2ecf20Sopenharmony_ciWhen the WFI instruction is executed the ARM core would gate its internal 158c2ecf20Sopenharmony_ciclocks. In addition to gating the clocks, QCOM cpus use this instruction as a 168c2ecf20Sopenharmony_citrigger to execute the SPM state machine. The SPM state machine waits for the 178c2ecf20Sopenharmony_ciinterrupt to trigger the core back in to active. This triggers the cache 188c2ecf20Sopenharmony_cihierarchy to enter standby states, when all cpus are idle. An interrupt brings 198c2ecf20Sopenharmony_cithe SPM state machine out of its wait, the next step is to ensure that the 208c2ecf20Sopenharmony_cicache hierarchy is also out of standby, and then the cpu is allowed to resume 218c2ecf20Sopenharmony_ciexecution. This state is defined as a generic ARM WFI state by the ARM cpuidle 228c2ecf20Sopenharmony_cidriver and is not defined in the DT. The SPM state machine should be 238c2ecf20Sopenharmony_ciconfigured to execute this state by default and after executing every other 248c2ecf20Sopenharmony_cistate below. 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciRetention: Retention is a low power state where the core is clock gated and 278c2ecf20Sopenharmony_cithe memory and the registers associated with the core are retained. The 288c2ecf20Sopenharmony_civoltage may be reduced to the minimum value needed to keep the processor 298c2ecf20Sopenharmony_ciregisters active. The SPM should be configured to execute the retention 308c2ecf20Sopenharmony_cisequence and would wait for interrupt, before restoring the cpu to execution 318c2ecf20Sopenharmony_cistate. Retention may have a slightly higher latency than Standby. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciStandalone PC: A cpu can power down and warmboot if there is a sufficient time 348c2ecf20Sopenharmony_cibetween the time it enters idle and the next known wake up. SPC mode is used 358c2ecf20Sopenharmony_cito indicate a core entering a power down state without consulting any other 368c2ecf20Sopenharmony_cicpu or the system resources. This helps save power only on that core. The SPM 378c2ecf20Sopenharmony_cisequence for this idle state is programmed to power down the supply to the 388c2ecf20Sopenharmony_cicore, wait for the interrupt, restore power to the core, and ensure the 398c2ecf20Sopenharmony_cisystem state including cache hierarchy is ready before allowing core to 408c2ecf20Sopenharmony_ciresume. Applying power and resetting the core causes the core to warmboot 418c2ecf20Sopenharmony_ciback into Elevation Level (EL) which trampolines the control back to the 428c2ecf20Sopenharmony_cikernel. Entering a power down state for the cpu, needs to be done by trapping 438c2ecf20Sopenharmony_ciinto a EL. Failing to do so, would result in a crash enforced by the warm boot 448c2ecf20Sopenharmony_cicode in the EL for the SoC. On SoCs with write-back L1 cache, the cache has to 458c2ecf20Sopenharmony_cibe flushed in s/w, before powering down the core. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciPower Collapse: This state is similar to the SPC mode, but distinguishes 488c2ecf20Sopenharmony_ciitself in that the cpu acknowledges and permits the SoC to enter deeper sleep 498c2ecf20Sopenharmony_cimodes. In a hierarchical power domain SoC, this means L2 and other caches can 508c2ecf20Sopenharmony_cibe flushed, system bus, clocks - lowered, and SoC main XO clock gated and 518c2ecf20Sopenharmony_civoltages reduced, provided all cpus enter this state. Since the span of low 528c2ecf20Sopenharmony_cipower modes possible at this state is vast, the exit latency and the residency 538c2ecf20Sopenharmony_ciof this low power mode would be considered high even though at a cpu level, 548c2ecf20Sopenharmony_cithis essentially is cpu power down. The SPM in this state also may handshake 558c2ecf20Sopenharmony_ciwith the Resource power manager (RPM) processor in the SoC to indicate a 568c2ecf20Sopenharmony_cicomplete application processor subsystem shut down. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciThe idle-state for QCOM SoCs are distinguished by the compatible property of 598c2ecf20Sopenharmony_cithe idle-states device node. 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciThe devicetree representation of the idle state should be - 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciRequired properties: 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci- compatible: Must be one of - 668c2ecf20Sopenharmony_ci "qcom,idle-state-ret", 678c2ecf20Sopenharmony_ci "qcom,idle-state-spc", 688c2ecf20Sopenharmony_ci "qcom,idle-state-pc", 698c2ecf20Sopenharmony_ci and "arm,idle-state". 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciOther required and optional properties are specified in [1]. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciExample: 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci idle-states { 768c2ecf20Sopenharmony_ci CPU_SPC: spc { 778c2ecf20Sopenharmony_ci compatible = "qcom,idle-state-spc", "arm,idle-state"; 788c2ecf20Sopenharmony_ci entry-latency-us = <150>; 798c2ecf20Sopenharmony_ci exit-latency-us = <200>; 808c2ecf20Sopenharmony_ci min-residency-us = <2000>; 818c2ecf20Sopenharmony_ci }; 828c2ecf20Sopenharmony_ci }; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci[1]. Documentation/devicetree/bindings/arm/idle-states.yaml 85