1c66ec88fSEmmanuel VadotQCOM Idle States for cpuidle driver 2c66ec88fSEmmanuel Vadot 3c66ec88fSEmmanuel VadotARM provides idle-state node to define the cpuidle states, as defined in [1]. 4c66ec88fSEmmanuel Vadotcpuidle-qcom is the cpuidle driver for Qualcomm SoCs and uses these idle 5c66ec88fSEmmanuel Vadotstates. Idle states have different enter/exit latency and residency values. 6c66ec88fSEmmanuel VadotThe idle states supported by the QCOM SoC are defined as - 7c66ec88fSEmmanuel Vadot 8c66ec88fSEmmanuel Vadot * Standby 9c66ec88fSEmmanuel Vadot * Retention 10c66ec88fSEmmanuel Vadot * Standalone Power Collapse (Standalone PC or SPC) 11c66ec88fSEmmanuel Vadot * Power Collapse (PC) 12c66ec88fSEmmanuel Vadot 13c66ec88fSEmmanuel VadotStandby: Standby does a little more in addition to architectural clock gating. 14c66ec88fSEmmanuel VadotWhen the WFI instruction is executed the ARM core would gate its internal 15c66ec88fSEmmanuel Vadotclocks. In addition to gating the clocks, QCOM cpus use this instruction as a 16c66ec88fSEmmanuel Vadottrigger to execute the SPM state machine. The SPM state machine waits for the 17c66ec88fSEmmanuel Vadotinterrupt to trigger the core back in to active. This triggers the cache 18c66ec88fSEmmanuel Vadothierarchy to enter standby states, when all cpus are idle. An interrupt brings 19c66ec88fSEmmanuel Vadotthe SPM state machine out of its wait, the next step is to ensure that the 20c66ec88fSEmmanuel Vadotcache hierarchy is also out of standby, and then the cpu is allowed to resume 21c66ec88fSEmmanuel Vadotexecution. This state is defined as a generic ARM WFI state by the ARM cpuidle 22c66ec88fSEmmanuel Vadotdriver and is not defined in the DT. The SPM state machine should be 23c66ec88fSEmmanuel Vadotconfigured to execute this state by default and after executing every other 24c66ec88fSEmmanuel Vadotstate below. 25c66ec88fSEmmanuel Vadot 26c66ec88fSEmmanuel VadotRetention: Retention is a low power state where the core is clock gated and 27c66ec88fSEmmanuel Vadotthe memory and the registers associated with the core are retained. The 28c66ec88fSEmmanuel Vadotvoltage may be reduced to the minimum value needed to keep the processor 29c66ec88fSEmmanuel Vadotregisters active. The SPM should be configured to execute the retention 30c66ec88fSEmmanuel Vadotsequence and would wait for interrupt, before restoring the cpu to execution 31c66ec88fSEmmanuel Vadotstate. Retention may have a slightly higher latency than Standby. 32c66ec88fSEmmanuel Vadot 33c66ec88fSEmmanuel VadotStandalone PC: A cpu can power down and warmboot if there is a sufficient time 34c66ec88fSEmmanuel Vadotbetween the time it enters idle and the next known wake up. SPC mode is used 35c66ec88fSEmmanuel Vadotto indicate a core entering a power down state without consulting any other 36c66ec88fSEmmanuel Vadotcpu or the system resources. This helps save power only on that core. The SPM 37c66ec88fSEmmanuel Vadotsequence for this idle state is programmed to power down the supply to the 38c66ec88fSEmmanuel Vadotcore, wait for the interrupt, restore power to the core, and ensure the 39c66ec88fSEmmanuel Vadotsystem state including cache hierarchy is ready before allowing core to 40c66ec88fSEmmanuel Vadotresume. Applying power and resetting the core causes the core to warmboot 41c66ec88fSEmmanuel Vadotback into Elevation Level (EL) which trampolines the control back to the 42c66ec88fSEmmanuel Vadotkernel. Entering a power down state for the cpu, needs to be done by trapping 43c66ec88fSEmmanuel Vadotinto a EL. Failing to do so, would result in a crash enforced by the warm boot 44c66ec88fSEmmanuel Vadotcode in the EL for the SoC. On SoCs with write-back L1 cache, the cache has to 45c66ec88fSEmmanuel Vadotbe flushed in s/w, before powering down the core. 46c66ec88fSEmmanuel Vadot 47c66ec88fSEmmanuel VadotPower Collapse: This state is similar to the SPC mode, but distinguishes 48c66ec88fSEmmanuel Vadotitself in that the cpu acknowledges and permits the SoC to enter deeper sleep 49c66ec88fSEmmanuel Vadotmodes. In a hierarchical power domain SoC, this means L2 and other caches can 50c66ec88fSEmmanuel Vadotbe flushed, system bus, clocks - lowered, and SoC main XO clock gated and 51c66ec88fSEmmanuel Vadotvoltages reduced, provided all cpus enter this state. Since the span of low 52c66ec88fSEmmanuel Vadotpower modes possible at this state is vast, the exit latency and the residency 53c66ec88fSEmmanuel Vadotof this low power mode would be considered high even though at a cpu level, 54c66ec88fSEmmanuel Vadotthis essentially is cpu power down. The SPM in this state also may handshake 55c66ec88fSEmmanuel Vadotwith the Resource power manager (RPM) processor in the SoC to indicate a 56c66ec88fSEmmanuel Vadotcomplete application processor subsystem shut down. 57c66ec88fSEmmanuel Vadot 58c66ec88fSEmmanuel VadotThe idle-state for QCOM SoCs are distinguished by the compatible property of 59c66ec88fSEmmanuel Vadotthe idle-states device node. 60c66ec88fSEmmanuel Vadot 61c66ec88fSEmmanuel VadotThe devicetree representation of the idle state should be - 62c66ec88fSEmmanuel Vadot 63c66ec88fSEmmanuel VadotRequired properties: 64c66ec88fSEmmanuel Vadot 65c66ec88fSEmmanuel Vadot- compatible: Must be one of - 66c66ec88fSEmmanuel Vadot "qcom,idle-state-ret", 67c66ec88fSEmmanuel Vadot "qcom,idle-state-spc", 68c66ec88fSEmmanuel Vadot "qcom,idle-state-pc", 69c66ec88fSEmmanuel Vadot and "arm,idle-state". 70c66ec88fSEmmanuel Vadot 71c66ec88fSEmmanuel VadotOther required and optional properties are specified in [1]. 72c66ec88fSEmmanuel Vadot 73c66ec88fSEmmanuel VadotExample: 74c66ec88fSEmmanuel Vadot 75c66ec88fSEmmanuel Vadot idle-states { 76c66ec88fSEmmanuel Vadot CPU_SPC: spc { 77c66ec88fSEmmanuel Vadot compatible = "qcom,idle-state-spc", "arm,idle-state"; 78c66ec88fSEmmanuel Vadot entry-latency-us = <150>; 79c66ec88fSEmmanuel Vadot exit-latency-us = <200>; 80c66ec88fSEmmanuel Vadot min-residency-us = <2000>; 81c66ec88fSEmmanuel Vadot }; 82c66ec88fSEmmanuel Vadot }; 83c66ec88fSEmmanuel Vadot 84*c9ccf3a3SEmmanuel Vadot[1]. Documentation/devicetree/bindings/cpu/idle-states.yaml 85