This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to know CPU frequency in keystone - 2



Hi All,

        I want to know at which frequency all CPU are running. My processor is 66AK2E02. 

        CPU frequency support is not available keystone 2 ( In /sys/devices/system/cpu/cpu0/).

        I looked into dts file there refclkmain is  100Mhz.

        I referred below link

        

In U-boot command prompt i got below value 

-> getclk 0

         - clock index [0] - frequency 700000000

-> getclk 1 

         - clock index [1] - frequency 1000000000

In clock-k2e.h file  

enum clk_e {
core_pll_clk,
pass_pll_clk,
ddr3_pll_clk,
sys_clk0_clk,
sys_clk0_1_clk,
sys_clk0_2_clk,
sys_clk0_3_clk,
sys_clk0_4_clk,
sys_clk0_6_clk,
sys_clk0_8_clk,
sys_clk0_12_clk,
sys_clk0_24_clk,
sys_clk1_clk,
sys_clk1_3_clk,
sys_clk1_4_clk,
sys_clk1_6_clk,
sys_clk1_12_clk,
sys_clk2_clk,
sys_clk3_clk
};

In U-boot source code board_k2e.c file

static struct pll_init_data core_pll_config[] = {
{ CORE_PLL, 16, 1, 2 }, /* 800 */
{ CORE_PLL, 17, 1, 2 }, /* 850 */
{ CORE_PLL, 20, 2, 2 }, /* 1000 */
{ CORE_PLL, 25, 1, 2 }, /* 1250 */
{ CORE_PLL, 27, 1, 2 }, /* 1350 */
{ CORE_PLL, 28, 2, 2 }, /* 1400 */
{ CORE_PLL, 30, 1, 2 }, /* 1500 */
};

static struct pll_init_data pa_pll_config =
{ PASS_PLL, 20, 1, 2 }; /* 1000 */

#ifdef CONFIG_SPL_BOARD_INIT
static struct pll_init_data spl_pll_config[] = {
{ CORE_PLL, 16, 1, 2 },
};

So how can i know at which frequency my all CPU are running ????

Thanking in advance,

Vijaykumar

  • Hi,

    From user space, you can use:
    cat /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq

    Where cpuX is the CPU you need to monitor.

    In order to see the set of frequencies you can change, exececute:
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

    To change the frequency, you first need to change the governor:
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
    ondemand userspace performance conservative powersave
    Change it to userspace:
    echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

    Then set the needed cpu speed from the scaling_available_frequencies, i.e.:
    echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    Now the CPU frequency should be changed to 500MHz, you can verify it with:
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

    Best Regards,
    Yordan
  • Hi Vijaykumar,

    Are you working on EVM or Custom board? I think you can see the frequency in the u-boot log itself and all the ARM cores will run at the same frequency.

    Refer below instructions to get and set the frequency.

    Thank you.

  • Yordan,
    Thanks for quick reply.

    As I told CPU frequency is not available in keystone 2 . That means /sys/devices/system/cpu/cpu0/cpufreq Folder is not available so i can not do whatever operation you mention from user space.

    Any other way ??? or how to enable above support ??????

    Thanks,
    Vijaykumar
  • Keystone2 devices doesn't support CPU frequency (CPU Idle/Freq governors) scaling driver.
    You can change the CPU clock via u-boot, I hope linux kernel won't modify the CPU clock unless you modify the clock in driver.

  • Hi Titus,
    Thanks for confirmation of Keystone2 devices doesn't support CPU frequency (CPU Idle/Freq governors) scaling driver.

    U-boot is giving core PLL clock and pass PLL clock . Which clock i can use ?

    In below equation which value i have to use ?

    Here the calculation example assuming the refclkmain is 125MHz please use the refclkmain value mentioned above when changing on EVM):

    125000000*19/(1*2) = 1187500000 Hz

    Thanks,
    Vijaykumar
  • You can change the Tetris (ARM) clock using "pllset" command.

    u-boot# getclk 2
    u-boot# pllset arm 19 1 2
    u-boot# getclk 2

    Calc:
    125000000*19/(1*2) = 1187500000 Hz (~1.2GHz)

    Refer to this wiki page.
    processors.wiki.ti.com/.../MCSDK_UG_Chapter_Exploring
  • Hi Titus,
    Thanks for reply.

    I don't want to change frequency. I want get existing frequency.
    In getclk command which index(0,1,2) i can use ?
    After getclk command which pll multiplier and pre divider i have to use so i can get correct frequency ?

    Thanks,
    Vijaykumar
  • "getclk 2" is the command to get the ARM clock (Tetris)

    u-boot# getclk 2

    I did it and got the "1200000000" Hz in u-boot.
  • Titus,

    But getclk 2 command take index from enum clk_e from k2e-clock.h file.

    enum clk_e {
    core_pll_clk,
    pass_pll_clk,
    ddr3_pll_clk,
    sys_clk0_clk,
    sys_clk0_1_clk,

    u-boot# getclk 2

    I am getting 400000000.

    My all 4 CPU running at 400Mhz.
    so this is right or wrong ??

    Big Thanks for quick reply.
    Vijaykumar
  • Okay, I got it.
    I tested this in K2H board but you are using K2E board right.
    What package are you using and version please ?
    MCSDK or Processor SDK ?

    It seems "getclk 2" means DDR3 clock.
    Can you please try "getclk 3" and "getclk 4" ?
  • Hi Titus,

    I am using linux kernel 3.10.61 and related U-boot source code.
    u-boot# getclk 3
    700000000
    u-boot# getclk 4
    700000000

    can you tell me in K2H board at index 2 what is present ?
    so i can find in my U-boot source code.

    Thanks,
    Vijaykumar
  • In K2H latest processor SDK package, getclk 2 is mentioned as "Tetris clock"

    I just checked the KS2 PLL calculator for K2H and K2E, it has some difference in clock structure, in K2E, ARM PLL is not available but K2H.
    I'm checking with HW experts which SYSCLK is used for ARM clock in K2E, so that you can read the correct enum value to get the ARM clock.

    Also you need to check the "pll_type_e" enum structure to get the clock not "clk_e" structure.

    Compare the both "pll_type_e" structure of K2H and K2E, you could see TETRIS_PLL for K2H but not for K2E.
    I think, we need to read "CORE_PLL" to get the ARM clock in K2E.

    Please let me know if any issue in understanding.

    PS: PLL enum definitions are changed in latest processor SDK