Hi Zhiming,
I added many "printk" all over the "imx6q-cpufreq.c" driver to try to follow the process and I still think there is issues with the code.
1) clock rate of 24MHz can be expected per following comment found in the source code:
/*
* ON i.MX6ULL, the 24MHz setpoint is not seen by cpufreq
* so we neet to prevent the cpufreq change frequency
* from 24MHz to 198Mhz directly. busfreq will handle this
* when exit from low bus mode.
*/
if (old_freq == FREQ_24_MHZ && new_freq == FREQ_198_MHZ)
return 0;
But because of this condition if the frequency is set to 24MHz and there is a request to change to 192MHz nothing happens.
And the busfreq is not triggered because the function is exited.
For instance if I start with the governor "powersave" the cpuinfo_cur_freq remains stuck at 24000.
Also if I change the governor to "userspace" and try to set 192MHz, cpuinfo_cur_freq remains stuck at 24000.
But if I set 396000 or 528000 first,then cpuinfo_cur_freq get set to the proper frequency and from there I can set the frequency back to 198MHz.
returns from my added printk's:
# insmod imx6q-cpufreq.ko
[ 115.393111] low power run support = 1
[ 115.483249] nvmem-cells, speed_grade is 4325378
[ 115.506858] CPU grade = 2 [00000002]
[ 115.512868] Number of clock steps = 4
[ 115.536780] Clock step[0] = 198000
[ 115.542604] Clock step[1] = 396000
[ 115.568559] Clock step[2] = 528000
[ 115.586576] Clock step[3] = 792000
[ 115.621704] policy clock = 2189893632
[ 115.662062] policy current = 24000
[ 115.695058] policy suspend = 792000
[ 115.700857] frequency[0] = 198000
[ 115.737995] Set target frequency skipped [OF=24000, NF=198000]
[ 115.775595] cpufreq: cpufreq_online: CPU0: Running at unlisted initial frequency: 24000 KHz, changing to: 198000 KHz
[ 115.810147] Set target frequency skipped [OF=24000, NF=198000]
[ 116.090206] imx_thermal 20c8000.anatop:tempmon: Industrial CPU temperature grade - max:105C critical:100C passive:95C
# echo 198000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
[ 1852.345245] Set target frequency skipped [OF=24000, NF=198000]
# echo 396000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
[ 1887.200273] 198 MHz, 1150 mV --> 396 MHz, 1025 mV
[ 1887.209614] Bus Frequency High requested (LPR + Lowest Freq)
[ 1887.225491] VDD_PU set to 1175000 uV
[ 1887.227245] VDD_SOC set to 1175000 uV
[ 1887.233090] VDD_ARM set to 1025000 uV
[ 1887.267384] Set ARM clock rate to 99000000 [Err = 0]
[ 1887.326338] Set source PLL1_SW to parent PLL1_SYS [Err = 0]
[ 1887.342686] Set source SECONDARY_SEL to parent PLL2_PFD2_396M [Err = 0]
[ 1887.354623] Set source STEP to parent SECONDARY_SEL [Err = 0]
[ 1887.362123] Set source PLL1_SW to parent STEP [Err = 0]
[ 1887.392227] Set ARM clock rate to 396000000
# echo 198000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
[ 1963.627098] 396 MHz, 1025 mV --> 198 MHz, 950 mV
[ 1963.635415] Set ARM clock rate to 198000000 [Err = 0]
[ 1963.641562] Set source PLL1_SW to parent PLL1_SYS [Err = 0]
[ 1963.672254] Set source SECONDARY_SEL to parent PLL2_PFD2_396M [Err = 0]
[ 1963.726929] Set source STEP to parent SECONDARY_SEL [Err = 0]
[ 1963.784374] Set source PLL1_SW to parent STEP [Err = 0]
[ 1963.791249] Set ARM clock rate to 198000000
[ 1963.806756] VDD_ARM set to 950000 uV [Err = 0]
[ 1963.807276] VDD_SOC set to 1175000 uV [Err = 0]
[ 1963.812413] Bus Frequency High released (LPR + Lowest Freq)
2) If for any reason the 792MHz is not achievable, why is not reverting back to the previous frequency/voltage ?
Instead the system is programmed back to 24MHz.
I also think, the code expect the 792MHz to have being set properly because:
- there are no error reported by any "deverr" of the "imx6q_set_target" function.
- cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq returns 792000
- none of the instructions failed during the process (see printk's output below)
returns from my added printk's:
# echo 792000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
[ 5439.390660] 528 MHz, 1175 mV --> 792 MHz, 1225 mV
[ 5439.398097] VDD_PU set to 1175000 uV
[ 5439.398338] VDD_SOC set to 1175000 uV
[ 5439.402688] VDD_ARM set to 1225000 uV
[ 5439.415987] Set ARM clock rate to 264000000 [Err = 0]
[ 5439.446903] Set source PLL1_SW to parent PLL1_SYS [Err = 0]
[ 5439.496090] Set source SECONDARY_SEL to parent PLL2_BUS [Err = 0]
[ 5439.525964] Set source STEP to parent SECONDARY_SEL [Err = 0]
[ 5439.569613] Set source PLL1_SW to parent STEP [Err = 0]
[ 5439.579642] New Freq (792000000) > PLL2_BUS Freq (528000000)
[ 5439.600478] Set PLL1_SYS clock rate to 792000000 [Err = 0]
[ 5439.625774] Set source PLL1_SW to parent PLL1_SYS [Err = 0]
[ 5439.658958] Set ARM clock rate to 792000000
"Err" value is the return of the instruction that make the change reported by the printk from the "imx6q_set_target" function.
Best Regards,
Emmanuel