Skip to content

Commit 78d5db8

Browse files
DhruvaG2000VeeruPrudhvi
authored andcommitted
feat(pm_cpuidle): add detailed documentation for AM62 standby mode
Add comprehensive documentation for CPUIdle on AM62X, AM62AX, and AM62PX platforms explaining: - Standby mode implementation through CPUIdle WFI state - Integration between Linux CPUIdle framework and TF-A - PSCI interaction via cpu_standby and validate_power_state hooks - Source file references for both Linux and TF-A components - Kernel configuration options and usage information This documentation helps users understand that the TI "standby" mode is automatically handled by the CPUIdle framework without requiring special configuration. Signed-off-by: Dhruva Gole <d-gole@ti.com>
1 parent 3effe68 commit 78d5db8

1 file changed

Lines changed: 122 additions & 15 deletions

File tree

source/linux/Foundational_Components/Power_Management/pm_cpuidle.rst

Lines changed: 122 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,114 @@ transition to the selected state.
2020
C-state. This state gets enabled by default in the CPUIdle driver without
2121
requiring any additional DT configuration.
2222

23+
.. rubric:: Standby Mode
24+
25+
On |__PART_FAMILY_DEVICE_NAMES__| platforms, "Standby" mode is implemented through the Linux CPUIdle
26+
framework. Standby is the default low-power state that the system enters automatically when idle,
27+
using the WFI (Wait For Interrupt) C-state. This power-saving mechanism activates whenever the
28+
system is "just sitting idle" without requiring any special configuration or activation from
29+
the user.
30+
31+
When your device appears inactive, it is actually cycling in and out of this standby state
32+
many times per second, seamlessly managing power while remaining responsive.
33+
34+
.. rubric:: Standby Implementation Architecture
35+
36+
For |__PART_FAMILY_DEVICE_NAMES__|, the Standby implementation involves a multi-layer architecture:
37+
38+
1. **Linux CPUIdle Framework**:
39+
- Determines when to place CPUs into idle states based on system activity
40+
- Uses governors (like the menu governor) to predict how long CPUs will be idle
41+
- Invokes platform-specific drivers to transition to appropriate C-states
42+
43+
2. **ARM Generic CPUIdle Driver**:
44+
- Implements the Linux CPUIdle driver interface for ARM platforms
45+
- Communicates with TF-A through PSCI SMC (Secure Monitor Call) interface
46+
47+
3. **PSCI Interface in Linux**:
48+
- Provides a standardized method for the kernel to request power management operations
49+
- Translates Linux-side requests into PSCI calls to TF-A
50+
51+
4. **TF-A PSCI Implementation**:
52+
- Runs in secure world (EL3)
53+
- Implements the PSCI specification
54+
- Provides platform-specific handlers via the ``plat_psci_ops`` structure
55+
56+
When your system goes idle, the following sequence occurs:
57+
58+
- Linux idle loop detects no runnable tasks
59+
- CPUIdle governor selects the appropriate C-state ("stby" for these platforms)
60+
- CPUIdle driver communicates with TF-A via the PSCI interface
61+
- TF-A's PSCI implementation validates the requested power state through ``validate_power_state()``
62+
- TF-A executes the ``cpu_standby()`` handler from ``plat_psci_ops``
63+
- The actual WFI instruction is executed within the TF-A's standby handler
64+
- On interrupt: CPU automatically exits WFI state
65+
- Control returns to Linux
66+
67+
This automated process happens continuously during system operation, seamlessly
68+
transitioning between active and idle states to save power whenever possible.
69+
70+
.. rubric:: Standby vs. Deep Sleep: Understanding the Difference
71+
72+
It's important to distinguish between the lightweight "standby" provided by CPUIdle and deeper sleep states:
73+
74+
* **CPUIdle Standby (WFI)**:
75+
- Processor-level power saving only
76+
- Very fast entry and exit (microseconds)
77+
- Occurs automatically hundreds of times per second
78+
- No user intervention required
79+
- All peripherals remain operational
80+
- Perfect for normal "idle" periods
81+
82+
* **Deep Sleep Modes**:
83+
- System-wide power saving
84+
- Slower entry and exit (milliseconds to seconds)
85+
- Requires explicit software requests
86+
- May require peripheral reconfiguration
87+
- Suitable for extended inactive periods
88+
89+
.. rubric:: Source Location
90+
91+
**Linux Side**:
92+
93+
- :file:`drivers/cpuidle/cpuidle-arm.c` - ARM CPU idle driver
94+
- :file:`drivers/cpuidle/dt_idle_states.c` - Device tree parsing for idle states
95+
- :file:`drivers/cpuidle/cpuidle.c` - Core CPUIdle framework
96+
- :file:`kernel/sched/idle.c` - Kernel idle loop implementation
97+
- :file:`drivers/firmware/psci.c` - PSCI interface to TF-A
98+
99+
**TF-A Side** (not part of Linux kernel):
100+
101+
- :file:`plat/ti/k3/common/k3_psci.c` - PSCI implementation for K3 platforms
102+
103+
.. rubric:: Driver Usage
104+
105+
CPUIdle works automatically once enabled in the kernel, with no user intervention required.
106+
The CPUIdle framework statistics can be accessed through the sysfs interface:
107+
108+
.. code-block:: console
109+
110+
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/
111+
drwxr-xr-x 2 root root 0 Jan 1 00:01 state0
112+
drwxr-xr-x 2 root root 0 Jan 1 00:01 state1
113+
114+
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/
115+
-r--r--r-- 1 root root 4096 Jan 1 00:02 desc
116+
-r--r--r-- 1 root root 4096 Jan 1 00:02 latency
117+
-r--r--r-- 1 root root 4096 Jan 1 00:02 name
118+
-r--r--r-- 1 root root 4096 Jan 1 00:02 power
119+
-r--r--r-- 1 root root 4096 Jan 1 00:02 time
120+
-r--r--r-- 1 root root 4096 Jan 1 00:02 usage
121+
122+
To view the current C-state statistics:
123+
124+
.. code-block:: console
125+
126+
# cat /sys/devices/system/cpu/cpu0/cpuidle/state1/name
127+
stby
128+
# cat /sys/devices/system/cpu/cpu0/cpuidle/state1/usage
129+
6245738
130+
23131
.. ifconfig:: CONFIG_part_family in ('AM335X_family', 'AM437X_family')
24132

25133
.. rubric:: Driver Features
@@ -77,7 +185,6 @@ transition to the selected state.
77185
-*- Menu governor (for tickless system)
78186
ARM CPU Idle Drivers ----
79187
80-
81188
.. rubric:: DT Configuration
82189

83190
.. code-block:: dts
@@ -112,18 +219,18 @@ transition to the selected state.
112219

113220
.. code-block:: console
114221
115-
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/state0/
116-
-r--r--r-- 1 root root 4096 Jan 1 00:02 desc
117-
-r--r--r-- 1 root root 4096 Jan 1 00:02 latency
118-
-r--r--r-- 1 root root 4096 Jan 1 00:02 name
119-
-r--r--r-- 1 root root 4096 Jan 1 00:02 power
120-
-r--r--r-- 1 root root 4096 Jan 1 00:02 time
121-
-r--r--r-- 1 root root 4096 Jan 1 00:02 usage
122-
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/
123-
-r--r--r-- 1 root root 4096 Jan 1 00:05 desc
124-
-r--r--r-- 1 root root 4096 Jan 1 00:05 latency
125-
-r--r--r-- 1 root root 4096 Jan 1 00:03 name
126-
-r--r--r-- 1 root root 4096 Jan 1 00:05 power
127-
-r--r--r-- 1 root root 4096 Jan 1 00:05 time
128-
-r--r--r-- 1 root root 4096 Jan 1 00:02 usage
222+
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/state0/
223+
-r--r--r-- 1 root root 4096 Jan 1 00:02 desc
224+
-r--r--r-- 1 root root 4096 Jan 1 00:02 latency
225+
-r--r--r-- 1 root root 4096 Jan 1 00:02 name
226+
-r--r--r-- 1 root root 4096 Jan 1 00:02 power
227+
-r--r--r-- 1 root root 4096 Jan 1 00:02 time
228+
-r--r--r-- 1 root root 4096 Jan 1 00:02 usage
229+
# ls -l /sys/devices/system/cpu/cpu0/cpuidle/state1/
230+
-r--r--r-- 1 root root 4096 Jan 1 00:05 desc
231+
-r--r--r-- 1 root root 4096 Jan 1 00:05 latency
232+
-r--r--r-- 1 root root 4096 Jan 1 00:03 name
233+
-r--r--r-- 1 root root 4096 Jan 1 00:05 power
234+
-r--r--r-- 1 root root 4096 Jan 1 00:05 time
235+
-r--r--r-- 1 root root 4096 Jan 1 00:02 usage
129236

0 commit comments

Comments
 (0)