Change Verdin imx8mp cpu Frequency

Hello,

because of EMV restrictions I need to change CPU-Frequency to something between 1.3 - 1.5 GHz.
I followed your description here: CPU Frequency and DVFS (Linux) | Toradex Developer Center . But only 1.2GHz or 1.6GHz is available with yocto bsp for verdin imx8mp.

Is it possible to configure other frequencies within my desired range?

Maybe by changing Kernel Config similar to the description for default scaling governor: How to Lower CPU Power Consumption | Toradex Developer Center ?

Thanks for your help!

Immanuel

Hi @ImHei!

From what I could understand, the operation frequencies are defined in the device tree. This is useful: https://community.nxp.com/t5/i-MX-Processors/Lower-CPU-Freq-in-imx8mp/m-p/1703005

You can see the definition of the frequencies here (line 134): imx8mp.dtsi « freescale « dts « boot « arm64 « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

As a test, I modified imx8mp.dtsi with the patch below, built the imx8mp-verdin-wifi-dev.dtb, and applied it on my Verdin iMX8MP Q 4GB WB IT V1.0B. Be aware that I don’t know if the values for opp-microvolt, opp-supported-hw, clock-latency-ns, and opp-suspend are correct! This was a simple quick test!

diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
index 9e0880992566..5627b5ff50df 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
@@ -135,29 +135,13 @@ a53_opp_table: opp-table {
                compatible = "operating-points-v2";
                opp-shared;

-               opp-1200000000 {
-                       opp-hz = /bits/ 64 <1200000000>;
+               opp-1400000000 {
+                       opp-hz = /bits/ 64 <1400000000>;
                        opp-microvolt = <850000>;
                        opp-supported-hw = <0x8a0>, <0x7>;
                        clock-latency-ns = <150000>;
                        opp-suspend;
                };
-
-               opp-1600000000 {
-                       opp-hz = /bits/ 64 <1600000000>;
-                       opp-microvolt = <950000>;
-                       opp-supported-hw = <0xa0>, <0x7>;
-                       clock-latency-ns = <150000>;
-                       opp-suspend;
-               };
-
-               opp-1800000000 {
-                       opp-hz = /bits/ 64 <1800000000>;
-                       opp-microvolt = <1000000>;
-                       opp-supported-hw = <0x20>, <0x3>;
-                       clock-latency-ns = <150000>;
-                       opp-suspend;
-               };
        };

        memory@40000000 {

Upon the next boot, we can see that the frequency is the only one defined in the device tree:

root@verdin-imx8mp-06849036:~# cd /sys/devices/system/cpu/cpu0/cpufreq/
root@verdin-imx8mp-06849036:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_available_frequencies
1400000
root@verdin-imx8mp-06849036:/sys/devices/system/cpu/cpu0/cpufreq# cat scaling_cur_freq
1400000

For completeness, here is my tdx-info:

root@verdin-imx8mp-06849036:~# tdx-info

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.129-6.4.0+git.67c3153d20ff #1 SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023
Kernel command line:      root=PARTUUID=298bca9d-02 ro rootwait console=tty1 console=ttymxc2,115200 consolebln
Distro name:              NAME="TDX Wayland with XWayland"
Distro version:           VERSION_ID=6.4.0-build.8
Hostname:                 verdin-imx8mp-06849036
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version:          0058 V1.0B
Serial number:            06849036
Processor arch:           aarch64
------------------------------------------------------------

In addition, I also recommend you take a look at the document i.MX Linux Reference Manual from NXP, which you can download from “Documentation” on this link: Embedded Linux for i.MX Applications Processors | NXP Semiconductors. To know which Documentation version you should download, please check the version of NXP release related to the Torizon/BSP from Toradex you are using in Embedded Linux Release Matrix | Toradex Developer Center.

Let us know if this helps you.

Best regards,

Hi @henrique.tx ,
thanks for that advice. I will try and let you know if this works.
Regards
Immanuel

Hello @henrique.tx ,

turned out that CPU frequency wasn’t the reason for the EMV problems of our customer. So I don’t have to switch freauency.

Thanks for your help!

Hello,

if I am working with CPU frequency scaling disabled I cannot get any information about current CPU frequency.
Working with iMx8M Plus SoM (IT version), I saw u-boot working with 1.2GHz instead of 1.6GHz which is maximum frequency.

I don’t find any other information from kernel booting.
Do you know why u-boot set CPU frequency lower then maximum value? Is this value kept also after kernel boot?

Thanks

Dear @andreabernasconi,

Please note that the device trees and subsequent frequencies within Uboot and Linux are different from one another. That being said, you should be able to read the frequency in /sys/devices/system/cpu/cpuX/cpufreq. from there on you can cat the register scaling_max_freq and scaling_cur_freq. I tested this myself and was that indeed my system was also running with 1.2GHz. I then put the system under some more load via stress-ng and saw that the frequency throttled up to the expected 1.6GHz.

Essentially the system itself recognizes loads and consequently throttles up the frequency.

Best regards,
Collin

Hello Collin,
thanks for your feedback.
Up to now I am working with cpu frequency scaling disabled (i.e. # CONFIG_CPU_FREQ is not set)
In this scenario, under /sys/devices/system/cpu/cpuX/ I do not have cpufreq ,scaling_max_freq nor scaling_cur_freq.

So, my question is: how can I check CPU frequency with scaling disabled? I want to be sure that CPU will run at maximum speed (1.6 GHz for IT SoM).
Hope this clarify.

Hello @andreabernasconi,

Thank you for the clarification. First off: May I ask if there is any specific reason for you to disable CONFIG_CPU_FREQ?
If you want to remove the config and still run at the maximum frequency, what you can do is remove cpu freq profile in the device tree. You can then refer to this board and delete nodes to delete other frequency options.
https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm64/boot/dts/freescale/imx8mp.dtsi?h=toradex_5.15-2.1.x-imx#n134

Best regards,
Collin

1 Like

Hello Collin,

CONFIG_CPU_FREQ has been selected to avoid CPU frequency switch and thus reducing possible jitter on specific threads.
I will try to deleted frequency options from DTS but how can I check if CPU is working with the selecting one?
Thanks in advance

Andrea

Dear @andreabernasconi,

You should be able to find the frequency via the clock tree. We have tried this on our side and it should look something like this:

root@verdin-imx8mp:~# cat /sys/kernel/debug/clk/clk_summary |grep arm_a53_core
arm_a53_core  1  1  0  1600000000  0  0  50000  Y  deviceless  no_connection_id

Please let me know if this works for you.

Best regards,
Collin

Hello Collin,

the command you suggested works and showed me 1.2 GHz as expected. I tried to remove from a53_opp_table the 1.2 GHz and 1.8 GHz leaving just 1.6 GHz but I still get 1.2 GHz as working CPU frequency.
Do you get the same behaviour?
Thanks,
Andrea

Dear @andreabernasconi,

Apologies for the delay in replying. I have an idea to possibly resolve this issue in the meantime and tested it out myself:

Uboot is likely using 1.2GHz as a CPU frequency and since CONFIG_CPU_FREQ is disabled the op table in the device tree is not used (due to the driver not being available anymore).

Alternatively you could set the frequency in the userspace itself in the following manner:

echo userspace > /sys/bus/cpu/devices/cpu0/cpufreq/scaling_governor
echo 1600000 > /sys/bus/cpu/devices/cpu0/cpufreq/scaling_setspeed

The advantage of using this method is that thermal throtteling will likely still work.
I would be excited to know if this works for you.

Best regards,
Collin

Hello Collin,

thanks for the effort on this topic!
What you suggested needs CONFIG_CPU_FREQ enabled which actually I don’t want to have.
I understand this option causes no driver to be available but I was wondering why, this scenario, I got 1.2 GHz.
Moreover, could you please share more details about thermal throtteling?
Thanks
Andrea

Hello @andreabernasconi,

Unfortunately it looks like you will not be able to alter the frequency without CONFIG_CPU_FREQ being enabled. If it is disabled you can solely read the clocks while it can not be altered by Linux. This means that in order to alter the Frequency you will have to either activate the CPU_FREQ driver to alter it, or the frequency is set to the given 1.2GHz.

Regarding thermal throttling we have the following article, which outlines what the thermal throttling essentially does: Thermal Management | Toradex Developer Center
At the sub article mentioned hereafter you can see how the trip points for the throttling can be set via the generic thermal sysfs API.Thermal Management | Toradex Developer Center

Best regards,
Collin