Changing CPU frequency in iMX93 processors
From SomLabs Wiki
Changing the CPU frequency in iMX93 processors
In iMX93 processors a number of core operating modes can be defined in order to select proper frequency and power consumption. This tutorial presents how to add additional modes to the default list and force the kernel driver to use the required one. It was prepared for the Yocto Scarthgap version with meta-somlabs layer.
There are four available operation modes:
Mode | Description |
---|---|
0 | OD mode (1700 MHz) with DDR 3733 MTS |
1 | ND mode (1400 MHz) with DDR 1866 MTS |
2 | LD mode (900 MHz) with DDR 1866 MTS |
3 | LD mode (900 MHz) with DDR 625 MTS |
The current mode can be changed by writing the mode number 0-4 to /sys/devices/platform/imx93-lpm/mode file. The same file can be read to obtain currently enabled mode.
root@visionsom-imx93:~# echo 1 > /sys/devices/platform/imx93-lpm/mode root@visionsom-imx93:~# cat /sys/devices/platform/imx93-lpm/mode System is in ND mode with DDR 1866 MTS!
The current core clock can be read from the /sys/kernel/debug/clk/a55_core/clk_rate file.
root@visionsom-imx93:~# cat /sys/kernel/debug/clk/a55_core/clk_rate 1400000000
Adding LD modes
By default only OD and ND modes are available in the kernel driver. To enable the LD modes the following change has to be made in the visionsom-imx93.dtsi file:
--- a/arch/arm64/boot/dts/freescale/visionsom-imx93.dtsi +++ b/arch/arm64/boot/dts/freescale/visionsom-imx93.dtsi @@ -163,6 +163,7 @@ &lcdif { &lpm { soc-supply = <&buck1>; + ld-mode-enabled; status = "okay"; };
Verifying core frequency
Setting the core frequency can be easily tested using simple empty loop script:
echo 0 > /sys/devices/platform/imx93-lpm/mode time bash -c "for i in {1..1000000}; do :; done" real 0m8.158s user 0m7.795s sys 0m0.289s
echo 1 > /sys/devices/platform/imx93-lpm/mode time bash -c "for i in {1..1000000}; do :; done" real 0m10.100s user 0m9.634s sys 0m0.390s
echo 2 > /sys/devices/platform/imx93-lpm/mode time bash -c "for i in {1..1000000}; do :; done" real 0m15.358s user 0m14.726s sys 0m0.506s
echo 3 > /sys/devices/platform/imx93-lpm/mode time bash -c "for i in {1..1000000}; do :; done" real 0m16.292s user 0m15.394s sys 0m0.691s