1. Purpose[edit source]
This article explains how to change the CPU operating point (also known as OPP). An operating point corresponds to the frequency of the processor and the voltage that needs to be supplied to sustain it.
It also shows how it is possible to define multiple operating points, allowing the system to jump among them at run time: this is the dynamic voltage and frequency scaling (DVFS). Some cautions are given at the end of the article, to help the user in its DVFS deployment.
2. Hardware side[edit source]
On STM32MP1 Series products, the Cortex-A7 core is:
- clocked by PLL1 from the RCC internal peripheral. The PLL1P output frequency can be directly propagated to the core, or it can go through an intermediate MPUDIV divider
- supplied with VDDcore voltage.
The part number tells which devices can be clocked up to 800 MHz, with associated usage conditions. Otherwise, the frequency must be kept below 650 MHz.
3. Software side[edit source]
3.1. Overview[edit source]
Two ways are offered to the user in order to set the CPU frequency:
- By default, in OpenSTLinux distribution, the "soc extension" device tree file defines an OPP table that contains one or several frequency / voltage pair(s)
- Nevertheless, it is possible to directly define the expected PLL1 static configuration in the FSBL device tree
3.2. OPP table[edit source]
At boot time, TF-A automatically selects the fastest operating point that is suitable for the current part number according to the OPP table (frequency and voltage couples) defined in the SOC extension device tree (fdts/stm32mp15xa.dtsi or fdts/stm32mp15xd.dtsi ).
At runtime, the Linux will automatically switch between the available operating points according to the CPU load and thanks to Linux cpufreq framework, configured with "ondemand" governor policy (see Documentation/admin-guide/pm/cpufreq.rst ). This feature is called dynamic voltage and frequency scaling (DVFS).
For instance, in the example below, two operating points ([800 MHz ; 1.35 V]; [400 MHz ; 1.2 V]) are defined for a 800 MHz capable part number (opp-supported-hw = <0x2>), so TF-A will apply the [800 MHz ; 1.35 V] configuration at boot time and Linux will then dynamically jump between the two operating points ([800 MHz ; 1.35 V]; [400 MHz ; 1.2 V]) depending on the CPU load.
&cpu0_opp_table {
opp-800000000 {
opp-hz = /bits/ 64 <800000000>;
opp-microvolt = <1350000>;
opp-supported-hw = <0x2>;
};
opp-400000000 {
opp-hz = /bits/ 64 <400000000>;
opp-microvolt = <1200000>;
opp-supported-hw = <0x2>;
opp-suspend;
};
};
Notes:
- The operating point(s) supported by devices able to run above 650 MHz (and up to 800 MHz) is/are identified by the opp-supported-hw property set to 0x2.
- This same OPP table must be present in both the TF-A and Linux device tree
- This description is valid for cold boot, but also when coming back from Standby low power mode.
- During cold boot, TF-A computes and saves the PLL1 settings for all operating points available in the device tree in compliance with the hardware capabilities. These saved paramaters are used later to increase the performance of the system-state transitions.
3.3. PLL1 static configuration[edit source]
The Cortex-A7 core frequency is selected at boot time, by the FSBL (TF-A), following the Clock device tree configuration - Bootloader specific syntax.
&rcc {
...
/* VCO = 1300.0 MHz => P = 650 (CPU) */
pll1: st,pll@0 {
cfg = < 2 80 0 0 0 PQR(1,0,0) >;
frac = < 0x800 >;
};
...
};
The user can reduce this frequency by changing the above configuration, either manually or via the STM32CubeMX graphical user interface that allows generation of the corresponding device tree file.
Notes:
- The VDDcore voltage is specified in the regulators node of the board device tree, and it has to be kept consistent with the selected frequency, as explained in the overview above.
- When the PLL1 static configuration is used, TF-A ignores the OPP table (see previous chapter) that may also be present in the device tree, so the secure monitor won't be able to answer to any upcoming frequency switch from Linux. It is therefore recommended to keep only one OPP in the table given to Linux, corresponding to the frequency setup by TF-A at boot time.
4. Dynamic voltage and frequency scaling (DVFS) caution[edit source]
- As stated above, as soon as at least two operating points are defined in the OPP table, Linux kernel will automatically switch between them at runtime thanks to Linux cpufreq framework, configured with "ondemand" governor policy (see Documentation/admin-guide/pm/cpufreq.rst ). It is important to notice that cpufreq framework is only monitoring the CPU load to select the OPP because this can lead to some limitation during use cases where the CPU is not loaded a lot but high reactivity is needed to respect some real time constraints, like interrupt management. If you face some system issue where the CPU reactivity may be the root cause whereas DVFS is enabled, consider doing a trial with "performance" governor (see Documentation/admin-guide/pm/cpufreq.rst ).
- Selecting OPP frequencies that can be reached with RCC MPUDIV dividor and without configuring again the PLL1 is recommended in order to get the fastest switch time between the OPP.