imx6q How to set CPU frequency to 1.2GHz in uboot and kernel?

cancel
Showing results for 
Search instead for 
Did you mean: 

imx6q How to set CPU frequency to 1.2GHz in uboot and kernel?

3,171 Views
sqzhang
Contributor I

The CPU default frequency is 996kHz, which needs to be changed to 1.2GHz in uboot and kernel, and then modified to 996KHz after the system is up.

How should I modify the code in uboot and kernel?

Labels (3)
0 Kudos
8 Replies

1,119 Views
angelocoppi
Contributor II

Try with this  functions.....

static u32 get_cpu_clk(void)
{
u32 reg, div,freq;
struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
reg = __raw_readl(&imx_ccm->cacrr);
reg &= MXC_CCM_CACRR_ARM_PODF_MASK;
reg >>= MXC_CCM_CACRR_ARM_PODF_OFFSET;
div = __raw_readl(&imx_ccm->analog_pll_sys);
div &= BM_ANADIG_PLL_SYS_DIV_SELECT;
freq= ((MXC_HCLK* div) >> 1);
return freq / (reg + 1);
}

static void dump_clock_cpu(void){
printf("CPU RUNNING AT : %08d Mhz\n", get_cpu_clk()/1000000);
}

static void set_clock_cpu(u32 multiplier){
struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
u32 div = __raw_readl(&imx_ccm->analog_pll_sys);
div&=0x7fffffff;
__raw_writel(div,&imx_ccm->analog_pll_sys);
div&=0xffffff80;
div|=multiplier;
div|=0x80000000;
__raw_writel(div,&imx_ccm->analog_pll_sys);
div = __raw_readl(&imx_ccm->analog_pll_sys);
printf("PPL_SYS=0x%08x\n",div);
dump_clock_cpu();
}

example of use....

set_clock_cpu(1000/12); /* CPU CLOCK 1GHz */
mmdc_do_dqs_calibration();
#ifdef CONFIG_MX6Q
set_clock_cpu(1100/12); /* CPU CLOCK 1.1GHz */
mmdc_do_dqs_calibration();
set_clock_cpu(1200/12); /* CPU CLOCK 1.2GHz */
mmdc_do_dqs_calibration();
set_clock_cpu(1296/12); /* CPU CLOCK MAX */
mmdc_do_dqs_calibration();

bye....

0 Kudos

1,119 Views
b45499
NXP TechSupport
NXP TechSupport

Hi,

Here you need firstly to confirm if your chip is supported the 1.2GHz,

You can to view what values the CPU frequency can be changed to in KHz (The values in the first column are the frequency values) use this command:
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state

Take the 79200 as an example, if the 79200 is in the support CPU frequency list, you can use the follow command to set the CPU frequency:

echo 792000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

So it is the same with the 1.2GHz setting.

Hope this can do help for you.
Have a great day,
Rita

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,119 Views
sqzhang
Contributor I

The machine starting frequency in uboot is 792MHz. How to change it to 1.2GHz in uboot?

uboot log:

CPU:   Freescale i.MX6D rev1.5 at 792 MHz
Reset cause: WDOG
Board: MX6-SabreSD
I2C:   ready
DRAM:  2 GiB

................

0 Kudos

1,119 Views
b45499
NXP TechSupport
NXP TechSupport

Do as I told you above.

0 Kudos

1,119 Views
赵振业
Contributor I

Does imx6q.dtsi file cpufreq works in Android M?  Our system show max freq 996M with cmd "cat scaling_available_freq". 

0 Kudos

1,119 Views
b45499
NXP TechSupport
NXP TechSupport

Yes, it works. The Power -CPU Freq is support in Android BSP.

0 Kudos

1,119 Views
sqzhang
Contributor I

Hi  rita

Thank you very much for your reply.

The CPU is supported 1.2GHz frequency.

The above method is to modify the CPU frequency by command after kernel starts.

I need to change the frequency to 1.2G in uboot or when kernel starts. The goal is to optimize start-up speed

Can you offer some help? thanks.

Sqzhang

0 Kudos

1,119 Views
b45499
NXP TechSupport
NXP TechSupport

Hi zhang,

The U-boot does not provide standard procedure to change CPU frequency, since it affects other modules. Here recommend you do not change the uboot CPU frequency, the normal design is 79200. Suggest you to change it in kernel boot up as I told you above.
Have a great day,
Rita

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos