DVFS User Guide
1. Overview¶
This document introduces how to use the DVFS function on the SigmaStar platform. DVFS (Dynamic voltage and frequency scaling) refers to dynamically adjusting the CPU frequency and voltage according to actual needs to achieve the purpose of improving performance or saving energy consumption.
2. Configuration Instructions¶
In Linux, you need to enable the following configuration to enable the DVFS function:
SSTAR_CPU_FREQ:
Symbol: SSTAR_CPU_FREQ [=y]
Type : tristate
Defined at drivers/sstar/cpufreq/Kconfig:1
Prompt: Sstar CPU frequency scaling driver
Depends on: SSTAR_DRIVERS [=y]
Location:
-> Device Drivers
-> Sstar SoC platform drivers (SSTAR_DRIVERS [=y])
SSTAR_VOLTAGE_IDAC_CTRL:
Symbol: SSTAR_VOLTAGE_IDAC_CTRL [=y]
Type : bool
Defined at drivers/sstar/voltage_idac/Kconfig:1
Prompt: Sstar Voltage IDAC Control
Depends on: SSTAR_DRIVERS [=y] && SSTAR_GPIO [=y] && !SSTAR_VOLTAGE_CTRL [=n]
Location:
-> Device Drivers
-> Sstar SoC platform drivers (SSTAR_DRIVERS [=y])
-> Sstar Voltage Control (SSTAR_VOLTAGE_CTRL [=n])
SSTAR_VOLTAGE_IDAC_STEP_BY_STEP:
Symbol: SSTAR_VOLTAGE_IDAC_STEP_BY_STEP [=y]
Type : bool
Defined at drivers/sstar/voltage_idac/Kconfig:6
Prompt: Sstar Voltage IDAC Control Step By Step
Depends on: SSTAR_DRIVERS [=y] && SSTAR_VOLTAGE_IDAC_CTRL [=y] ontrol RL [=n]
Location:
-> Device Drivers
-> Sstar SoC platform drivers (SSTAR_DRIVERS [=y])
-> Sstar Voltage Control (SSTAR_VOLTAGE_CTRL [=n])
-> Sstar Voltage IDAC Control (SSTAR_VOLTAGE_IDAC_CTRL [=y])
After enabling the above configuration, Linux will generate the following paths and files:
/ # ls -l /sys/devices/system/cpu/cpufreq/ total 0 -rw-r--r-- 1 root root 4096 Jan 1 00:02 cpufreq_testout drwxr-xr-x 3 root root 0 Jan 1 00:02 policy0 -rw-r--r-- 1 root root 4096 Jan 1 00:02 rosc_out -rw-r--r-- 1 root root 4096 Jan 1 00:02 rosc_threshold -r--r--r-- 1 root root 4096 Jan 1 00:02 sidd_out -rw-r--r-- 1 root root 4096 Jan 1 00:02 temp_adjust_threshold_hi -rw-r--r-- 1 root root 4096 Jan 1 00:02 temp_adjust_threshold_lo -r--r--r-- 1 root root 4096 Jan 1 00:02 temp_out
/ # ls -l /sys/devices/system/voltage/cpu_power/ total 0 drwxr-xr-x 2 root root 0 Jan 1 00:05 power -rw-r--r-- 1 root root 4096 Jan 1 00:05 scaling_voltage lrwxrwxrwx 1 root root 0 Jan 1 00:05 subsystem -> ../../../../bus/voltage -rw-r--r-- 1 root root 4096 Jan 1 00:05 uevent -r--r--r-- 1 root root 4096 Jan 1 00:05 vid_gpio_map -r--r--r-- 1 root root 4096 Jan 1 00:05 voltage_available -rw-r--r-- 1 root root 4096 Jan 1 00:05 voltage_current
3. Related commands¶
3.1. Check CPU frequency¶
/ # cat /sys/devices/system/cpu/cpufreq/cpufreq_testout 1500000000
The unit of 1500000000 is Hz, which means the current CPU frequency is 1.5GHz.
3.2. Set CPU frequency¶
/ # echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor / # echo 1200000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
If you want to set the CPU frequency manually, you need to set the frequency adjustment policy of cpufreq to userspace first, and then set the CPU frequency. In the above command, the unit of 1200000 is KHz, which means setting the CPU frequency to 1.2GHz.
3.3. Check CPU voltage¶
/ # cat /sys/devices/system/voltage/cpu_power/voltage_current 900 VOLTAGE_DEMANDER_INIT - VOLTAGE_DEMANDER_CPUFREQ 900 VOLTAGE_DEMANDER_TEMPERATURE - VOLTAGE_DEMANDER_USER -
The unit of 900 is mV, which means the current CPU voltage is 900mV.
3.4. Check CPU temperature¶
/ # cat /sys/devices/system/cpu/cpufreq/temp_out Temp = 27
The unit of 27 is Celsius, which means the current CPU temperature is 27 degrees Celsius.