CPU Voltage/Frequency Mapping

Started by lorenzownd, August 10, 2014, 12:39:08 AM

Previous topic - Next topic

lorenzownd

Hi. I don't known if this is the right section for my question, so apologize me if I posted in the wrong section. In these days I'm experimenting with my A20-OLinuXino-Micro. Today I was trying to correctly set up the dvfs_table, but I'm confused about which file/service actually controls the cpu frequencies/voltages. In the script bin/fex file there is the dvfs_table that determines the cpu max, min frequencies and some other intermediate frequencies with their relative voltages. Then, in the linux-sunxi kernel source code there is another similar table in cpufreq.c and cpufreq_table.c. What's the difference between these 2 tables? Which one do I have to edit to set the frequencies I want the cpu to scale? Does the script.bin table overrides the kernel settings, or the kernel's table is used once the os is loaded? Maybe the script.bin table just defines what voltage to apply when the cpu is at a specific frequency, while the kernel controls the cpu scaling settings, or maybe it's just the opposite. By the way, I found that the cpufreq_table.c controls what frequencies have to be used; for example, if I set the cpu min freq to 330 MHz, the board goes to 336 MHz, which is the closest freq in the cpufreq_table.c file.

Insomniac10102

Pretty sure you want that dvfs_table in the fex file. Here's the linux sunxi page on the dvfs_table section: http://linux-sunxi.org/Fex_Guide#.5Bdvfs_table.5D

You should also read through the quick FEX description on there if you haven't already.

lorenzownd

#2
Yes I read that page about the fex file, but have a look at this file:
https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.4/arch/arm/mach-sun7i/cpu-freq/cpu-freq.c
From line 72 to 81 there's a similar table also called dvfs_table.
What does it control? Is it totally useless?
I also think that the cpu-freq-table.c frequencies are used to scale the cpu, not the dvfs_table ones. Maybe the dvfs_table in the kernel and fex file is only used to control voltages.

Insomniac10102

Looks to me like the dfvs_table (and likely any other overlapping information in the two files, for that matter) in the kernel is a fallback in the case of some failure to get values from the FEX file. I wasn't able to make much sense of cpu-freq-table.c, albeit I didn't try as hard as I could, but I'd assume it's the same deal.

I'm moreso relying on what I can deduce from the kernel code than actual knowledge of how the linux kernel works, so hopefully we can get a third opinion on this.