162306a36Sopenharmony_ciQCOM Idle States for cpuidle driver 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciARM provides idle-state node to define the cpuidle states, as defined in [1]. 462306a36Sopenharmony_cicpuidle-qcom is the cpuidle driver for Qualcomm SoCs and uses these idle 562306a36Sopenharmony_cistates. Idle states have different enter/exit latency and residency values. 662306a36Sopenharmony_ciThe idle states supported by the QCOM SoC are defined as - 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci * Standby 962306a36Sopenharmony_ci * Retention 1062306a36Sopenharmony_ci * Standalone Power Collapse (Standalone PC or SPC) 1162306a36Sopenharmony_ci * Power Collapse (PC) 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciStandby: Standby does a little more in addition to architectural clock gating. 1462306a36Sopenharmony_ciWhen the WFI instruction is executed the ARM core would gate its internal 1562306a36Sopenharmony_ciclocks. In addition to gating the clocks, QCOM cpus use this instruction as a 1662306a36Sopenharmony_citrigger to execute the SPM state machine. The SPM state machine waits for the 1762306a36Sopenharmony_ciinterrupt to trigger the core back in to active. This triggers the cache 1862306a36Sopenharmony_cihierarchy to enter standby states, when all cpus are idle. An interrupt brings 1962306a36Sopenharmony_cithe SPM state machine out of its wait, the next step is to ensure that the 2062306a36Sopenharmony_cicache hierarchy is also out of standby, and then the cpu is allowed to resume 2162306a36Sopenharmony_ciexecution. This state is defined as a generic ARM WFI state by the ARM cpuidle 2262306a36Sopenharmony_cidriver and is not defined in the DT. The SPM state machine should be 2362306a36Sopenharmony_ciconfigured to execute this state by default and after executing every other 2462306a36Sopenharmony_cistate below. 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciRetention: Retention is a low power state where the core is clock gated and 2762306a36Sopenharmony_cithe memory and the registers associated with the core are retained. The 2862306a36Sopenharmony_civoltage may be reduced to the minimum value needed to keep the processor 2962306a36Sopenharmony_ciregisters active. The SPM should be configured to execute the retention 3062306a36Sopenharmony_cisequence and would wait for interrupt, before restoring the cpu to execution 3162306a36Sopenharmony_cistate. Retention may have a slightly higher latency than Standby. 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciStandalone PC: A cpu can power down and warmboot if there is a sufficient time 3462306a36Sopenharmony_cibetween the time it enters idle and the next known wake up. SPC mode is used 3562306a36Sopenharmony_cito indicate a core entering a power down state without consulting any other 3662306a36Sopenharmony_cicpu or the system resources. This helps save power only on that core. The SPM 3762306a36Sopenharmony_cisequence for this idle state is programmed to power down the supply to the 3862306a36Sopenharmony_cicore, wait for the interrupt, restore power to the core, and ensure the 3962306a36Sopenharmony_cisystem state including cache hierarchy is ready before allowing core to 4062306a36Sopenharmony_ciresume. Applying power and resetting the core causes the core to warmboot 4162306a36Sopenharmony_ciback into Elevation Level (EL) which trampolines the control back to the 4262306a36Sopenharmony_cikernel. Entering a power down state for the cpu, needs to be done by trapping 4362306a36Sopenharmony_ciinto a EL. Failing to do so, would result in a crash enforced by the warm boot 4462306a36Sopenharmony_cicode in the EL for the SoC. On SoCs with write-back L1 cache, the cache has to 4562306a36Sopenharmony_cibe flushed in s/w, before powering down the core. 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciPower Collapse: This state is similar to the SPC mode, but distinguishes 4862306a36Sopenharmony_ciitself in that the cpu acknowledges and permits the SoC to enter deeper sleep 4962306a36Sopenharmony_cimodes. In a hierarchical power domain SoC, this means L2 and other caches can 5062306a36Sopenharmony_cibe flushed, system bus, clocks - lowered, and SoC main XO clock gated and 5162306a36Sopenharmony_civoltages reduced, provided all cpus enter this state. Since the span of low 5262306a36Sopenharmony_cipower modes possible at this state is vast, the exit latency and the residency 5362306a36Sopenharmony_ciof this low power mode would be considered high even though at a cpu level, 5462306a36Sopenharmony_cithis essentially is cpu power down. The SPM in this state also may handshake 5562306a36Sopenharmony_ciwith the Resource power manager (RPM) processor in the SoC to indicate a 5662306a36Sopenharmony_cicomplete application processor subsystem shut down. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ciThe idle-state for QCOM SoCs are distinguished by the compatible property of 5962306a36Sopenharmony_cithe idle-states device node. 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciThe devicetree representation of the idle state should be - 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ciRequired properties: 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci- compatible: Must be one of - 6662306a36Sopenharmony_ci "qcom,idle-state-ret", 6762306a36Sopenharmony_ci "qcom,idle-state-spc", 6862306a36Sopenharmony_ci "qcom,idle-state-pc", 6962306a36Sopenharmony_ci and "arm,idle-state". 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciOther required and optional properties are specified in [1]. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciExample: 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci idle-states { 7662306a36Sopenharmony_ci CPU_SPC: spc { 7762306a36Sopenharmony_ci compatible = "qcom,idle-state-spc", "arm,idle-state"; 7862306a36Sopenharmony_ci entry-latency-us = <150>; 7962306a36Sopenharmony_ci exit-latency-us = <200>; 8062306a36Sopenharmony_ci min-residency-us = <2000>; 8162306a36Sopenharmony_ci }; 8262306a36Sopenharmony_ci }; 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci[1]. Documentation/devicetree/bindings/cpu/idle-states.yaml 85