DVFS dynamic voltage frequency scaling nel driver Mediatek

Durata batteria e cpu operante a meta frequenza. Questo e` l`obiettivo del DVFS, largamente usato su chipset IOT di molte compagnie(ad es. Mediatek).
I range di frequenza tipicamente usati ad esempio su chip mtk 2523 sono:

o 1.3V, 208MHz
o 1.2V, 104MHz
o 1.1V, 104MHz
o 0.9V, 26MHz
o 0.7V, 32kHz

Il DVFS quindi opera modificando il voltaggio della cpu cambiando lo stato da ‘sonno profondo ‘ a 0.7V ad attivo 0.9V. I vantaggi sono una forte riduzione dei consumi in tutto l`ambito operativo.
Qui possiamo vedere il driver di Mediatek come sta operando. Secondo il manuale Mediatek basta seguire questi passaggi per una configurazione perfetta dello scaling del voltaggio:

How to use the driver
The DVFS framework adjusts to the ideal CPU frequency at a suitable voltage level.
Step1: Call hal_dvfs_init() to initialize the DVFS module only once at system initialization.
Step2: Call hal_dvfs_get_cpu_frequency() to get the current CPU frequency.
Step3: Call hal_dvfs_get_cpu_frequency_list() to get the supported CPU frequencies.
Step4: Call hal_dvfs_target_cpu_frequency() to change the current CPU frequency.
Step5: Call hal_dvfs_get_cpu_frequency() to get the current CPU frequency.
Step6: Print out the frequencies obtained from Step2 and Step5 to identify the difference.
Sample code:
uint32_t old_freq, cur_freq, list_num;
const uint32_t *cpu_freq_list;
hal_dvfs_init();
old_freq = hal_dvfs_get_cpu_frequency();
hal_dvfs_get_cpu_frequency_list(&cpu_freq_list, &list_num);
hal_dvfs_target_cpu_frequency(cpu_freq_list[0], HAL_DVFS_FREQ_RELATION_L); // cpu_freq_list[0] is the highest and cpu_freq_list[list_num-1] is the lowest frequency.
cur_freq = hal_dvfs_get_cpu_frequency();
log_hal_info("old_freq=%d, cur_freq=%d\n", old_freq, cur_freq);

hal_dvfs_example1.png

Nell`immagine di sopra e` possibile vedere un esempio del funzionamento del driver DVFS, in quanto dopo aver settato un target frequency di 104Mhz, il valore di 103Mhz e’ un valore inferiore in quanto il settaggio HAL_DVFS_FREQ_RELATION_L appartiene a un valore minore del target.

Links
https://labs.mediatek.com/api/mt2523/group___d_v_f_s.html
https://static6.arrow.com/aropdfconversion/d25c5fc04cf5c6316e055cb6aab4de735dd46b1f/708399742691664bqrbf2im.pdf