Iāve just done something ugly, Iāve generated 169 opps that cover frequencies from 2208 to 2784 in 48 MHz steps, and voltages from 900mV to 1050mV. The opps are called 1000000 + <mv100> so for example 2208 MHz at 912.5 mV is called ā2208912500ā and is reported as ā2208912ā in the frequency table (which truncates to kHz). This way all values are different and I can manually select the combination of voltage and frequency by switching to the userspace governor. I restricted all of them to turbo mode so that theyāre not selected by default, which lets me first switch to userspace before setting 1 into boost_mode.
The script I used to produce them is the following:
for ((o=2208; o<=2800; o+=48)); do for ((v=900000; v<=1050000; v+=12500)); do printf "opp-$((o*1000000+v/10)) {\n";printf "\topp-supported-hw = <0xff 0xffff>;\n"; printf "\topp-hz = <0 $((o*1000000+v/10))>;\n"; printf "\topp-microvolt = <$v $v $v $v $v $v>;\n"; printf "\tclock-latency-ns = <40000>;\n"; printf "\tturbo-mode;\n"; printf "};\n"; done; done
Whatās particularly interesting is that now I have the proof that the configured voltage affects the frequency, and in addition some voltages are rejected (itās possible that I did something wrong, I noticed in the DTS that there are 6 values in the microvolt entry and have set them all to the same value but some seem to still have an upper bound of 1V (3 and 6)). Hmm often the first change produces an error and doing it again makes it accepted.
### 900 mV
# echo 2208090 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=12364 us250=61832 diff=49468 cpu_MHz=2088.279
count=516515 us50=12366 us250=61830 diff=49464 cpu_MHz=2088.448
count=516515 us50=12366 us250=61833 diff=49467 cpu_MHz=2088.322
### 912 mV
# echo 2208091 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=12216 us250=61089 diff=48873 cpu_MHz=2113.703
count=516515 us50=12218 us250=61092 diff=48874 cpu_MHz=2113.660
count=516515 us50=12217 us250=61092 diff=48875 cpu_MHz=2113.616
### 925mV
# echo 2208092 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
root@rock-5b:~# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=12072 us250=60367 diff=48295 cpu_MHz=2139.000
count=516515 us50=12072 us250=60368 diff=48296 cpu_MHz=2138.956
count=516515 us50=12073 us250=60367 diff=48294 cpu_MHz=2139.044
### 937 mV
# echo 2208093 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11936 us250=59683 diff=47747 cpu_MHz=2163.550
count=516515 us50=11937 us250=59691 diff=47754 cpu_MHz=2163.232
count=516515 us50=11938 us250=59694 diff=47756 cpu_MHz=2163.142
### 950mV
# echo 2208095 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11805 us250=59036 diff=47231 cpu_MHz=2187.186
count=516515 us50=11806 us250=59036 diff=47230 cpu_MHz=2187.233
count=516515 us50=11808 us250=59039 diff=47231 cpu_MHz=2187.186
### 962mV
# echo 2208096 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11683 us250=58424 diff=46741 cpu_MHz=2210.115
count=516515 us50=11684 us250=58426 diff=46742 cpu_MHz=2210.068
count=516515 us50=11686 us250=58432 diff=46746 cpu_MHz=2209.879
### 975mV
# echo 2208097 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11568 us250=57846 diff=46278 cpu_MHz=2232.227
count=516515 us50=11569 us250=57849 diff=46280 cpu_MHz=2232.131
count=516515 us50=11569 us250=57857 diff=46288 cpu_MHz=2231.745
### 987mV
# echo 2208098 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11457 us250=57291 diff=45834 cpu_MHz=2253.851
count=516515 us50=11459 us250=57298 diff=45839 cpu_MHz=2253.605
count=516515 us50=11459 us250=57300 diff=45841 cpu_MHz=2253.507
### 1000mV
# echo 2208100 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11350 us250=56751 diff=45401 cpu_MHz=2275.346
count=516515 us50=11350 us250=56754 diff=45404 cpu_MHz=2275.196
count=516515 us50=11351 us250=56759 diff=45408 cpu_MHz=2274.996
Any voltages above 1000mV are rejected:
[ 1334.294298] vdd_cpu_big0_s0: Restricting voltage, 1012500-1000000uV
[ 1334.294429] vdd_cpu_big0_s0: Restricting voltage, 1012500-1000000uV
[ 1334.294447] cpu cpu4: rockchip_cpufreq_set_volt: failed to set voltage (1012500 1012500 1012500 uV): -22
[ 1334.294465] cpufreq: __target_index: Failed to change cpu frequency: -22
Trying different frequencies seem to give me the same frequency as the ones provided by 2208 MHz at the same voltage:
### 2352 at 1000mV:
# echo 2352100 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
# taskset -c 4 ~rock/mhz/mhz 100
count=516515 us50=11348 us250=56752 diff=45404 cpu_MHz=2275.196
count=516515 us50=11351 us250=56761 diff=45410 cpu_MHz=2274.895
count=516515 us50=11351 us250=56761 diff=45410 cpu_MHz=2274.895
Also, trying to set higher frequencies than accepted is rejected as well:
# echo 2400100 > /sys/devices/system/cpu/cpufreq/policy4/scaling_setspeed
[ 1659.362498] cpu cpu4: cpu_opp_helper: failed to set clk rate: -22
[ 1659.369293] cpufreq: __target_index: Failed to change cpu frequency: -22
Maybe the whole thing is only controlled by the voltage and the PVTM values, which would explain why weāve been seeing higher and lower frequencies than requested, and different values on different boards.
Iām possibly missing something but now it proves that the configured voltage does have an impact on the effective frequency.