Skip to contentSkip to conversation

ARM: mx28: cpufreq-cpu0 support?

DISCUSSION Stefan Wahren 3 participants 14 messages Aug 24, 2014 – Sep 25, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

could you please tell me, is i.MX28 supported by cpufreq-cpu0?

Do we need only the necessary DT entries like operating points or is it more?

Thanks in advance

Stefan

#1 lore raw
Quoted 6 lines · Stefan Wahren

Hi,

could you please tell me, is i.MX28 supported by cpufreq-cpu0?

Do we need only the necessary DT entries like operating points or is it more?

Clock might as simple as adding DT entries, but I'm not sure we have voltage scaling support for i.MX28 in kernel.

Shawn

#2 lore raw

Am 25.08.2014 10:01, schrieb Shawn Guo:

Quoted 5 lines · Stefan Wahren
Quoted 4 lines

Hi,

could you please tell me, is i.MX28 supported by cpufreq-cpu0?

Quoted 8 lines
Quoted 2 lines

Do we need only the necessary DT entries like operating points or is it more?

Clock might as simple as adding DT entries, but I'm not sure we have voltage scaling support for i.MX28 in kernel.

Shawn

As far as i know, the old Freescale BSP (2.6.35) contains a cpufreq driver for mxs, which never goes to mainline. So i'm not sure what would be the best way: porting the old driver or using cpufreq-cpu0.

Stefan

#3 lore raw

Hi Stefan,

Quoted 3 lines · Stefan Wahren

As far as i know, the old Freescale BSP (2.6.35) contains a cpufreq driver for mxs, which never goes to mainline. So i'm not sure what would be the best way: porting the old driver or using cpufreq-cpu0.

First step would be to port the PMU driver into mainline.

#4 lore raw
Quoted 9 lines · Fabio Estevam

Hi Stefan,

Quoted 3 lines · Stefan Wahren

As far as i know, the old Freescale BSP (2.6.35) contains a cpufreq driver for mxs, which never goes to mainline. So i'm not sure what would be the best way: porting the old driver or using cpufreq-cpu0.

First step would be to port the PMU driver into mainline.

I mean this regulator driver:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/regulator/mxs-regulator.c?h=imx_2.6.35_maintain

,so that you can do the voltage scaling.

#5 lore raw

Hi Fabio,

Am 30.08.2014 19:07, schrieb Fabio Estevam:

Quoted 9 lines · Fabio Estevam
Quoted 8 lines

Hi Stefan,

Quoted 3 lines · Stefan Wahren

As far as i know, the old Freescale BSP (2.6.35) contains a cpufreq driver for mxs, which never goes to mainline. So i'm not sure what would be the best way: porting the old driver or using cpufreq-cpu0.

Quoted 7 lines
Quoted 1 line

First step would be to port the PMU driver into mainline.

I mean this regulator driver:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/regulator/mxs-regulator.c?h=imx_2.6.35_maintain

,so that you can do the voltage scaling.

thanks. Okay, that leads to more questions:

How can i test a ported mxs-regulator driver, that it's really working? Is there any userspace interface?

Is there a good DT implementation of a similiar regulator driver, so i can orientate on?

What are the recommend mailing lists for this porting (linux-pm and linux-arm-kernel)?

BR Stefan

#6 lore raw

Hi Stefan,

Quoted 4 lines · Stefan Wahren

thanks. Okay, that leads to more questions:

How can i test a ported mxs-regulator driver, that it's really working? Is there any userspace interface?

After you ported the mxs regulator you can check whether it probed correctly and if the reported voltages in the kernel log match the register settings. You can also check if the voltages are really in the correct reported value with a scope.

On mx6q we have the following:

[    0.070554] vdd1p1: 800 <--> 1375 mV at 1100 mV
[    0.071521] vdd3p0: 2800 <--> 3150 mV at 3000 mV
[    0.072397] vdd2p5: 2000 <--> 2750 mV at 2400 mV
[    0.073369] vddarm: 725 <--> 1450 mV at 1150 mV
[    0.074282] vddpu: 725 <--> 1450 mV at 1150 mV
[    0.075247] vddsoc: 725 <--> 1450 mV at 1200 mV

and you should get something like that in your kernel log after you ported the mxs regulator driver.

Quoted 2 lines

Is there a good DT implementation of a similiar regulator driver, so i can orientate on?

You could take a look at the drivers/regulator/anatop-regulator.c driver, which handles the internal regulators on mx6.

The dts is arch/arm/boot/dts/imx6qdl.dtsi . Search for "anatop-regulator"

Quoted 3 lines

What are the recommend mailing lists for this porting (linux-pm and linux-arm-kernel)?

After you generate a patch, just run '/scripts/get_maintainer.pl' on your patch and it will give you some hints. Mark Brown is the regulator drivers maintainer.

#7 lore raw

Hello Fabio,

Am 01.09.2014 15:33, schrieb Fabio Estevam:

Quoted 26 lines

Hi Stefan,

Quoted 4 lines · Stefan Wahren

thanks. Okay, that leads to more questions:

How can i test a ported mxs-regulator driver, that it's really working? Is there any userspace interface?

After you ported the mxs regulator you can check whether it probed correctly and if the reported voltages in the kernel log match the register settings. You can also check if the voltages are really in the correct reported value with a scope.

On mx6q we have the following:

[    0.070554] vdd1p1: 800 <--> 1375 mV at 1100 mV
[    0.071521] vdd3p0: 2800 <--> 3150 mV at 3000 mV
[    0.072397] vdd2p5: 2000 <--> 2750 mV at 2400 mV
[    0.073369] vddarm: 725 <--> 1450 mV at 1150 mV
[    0.074282] vddpu: 725 <--> 1450 mV at 1150 mV
[    0.075247] vddsoc: 725 <--> 1450 mV at 1200 mV

and you should get something like that in your kernel log after you ported the mxs regulator driver.

Quoted 8 lines
Quoted 2 lines

Is there a good DT implementation of a similiar regulator driver, so i can orientate on?

You could take a look at the drivers/regulator/anatop-regulator.c driver, which handles the internal regulators on mx6.

The dts is arch/arm/boot/dts/imx6qdl.dtsi . Search for "anatop-regulator"

thanks again. Now i unterstand much more, but otherwise the portation won't be straight forward. The old source in drivers/regulator/mxs-regulator.c needs a low level part located in arch/arm/plat-mx28/power.c . As far as i know, the low level part needs to move into the devicetree binding and into the mxs-regulator.c . Am i right?

Yesterday i had looked into the mx28 reference manual and into the low level part of the mxs regulator. The reference manual defines four voltage regulators: vddd, vdda, vddio and vddmem plus a overall current regulator. But the low level part make use of vddd, vdda, vddio, vddio_bo and the overall current.

Do i need the brown out regulator (vddio_bo) and the vddmem?

Stefan

#8 lore raw
Quoted 5 lines · Stefan Wahren

thanks again. Now i unterstand much more, but otherwise the portation won't be straight forward. The old source in drivers/regulator/mxs-regulator.c needs a low level part located in arch/arm/plat-mx28/power.c . As far as i know, the low level part needs to move into the devicetree binding and into the mxs-regulator.c . Am i right?

Yes, I think you are right.

Quoted 7 lines

Yesterday i had looked into the mx28 reference manual and into the low level part of the mxs regulator. The reference manual defines four voltage
regulators: vddd, vdda, vddio and vddmem plus a overall current regulator. But the low level part make use of vddd, vdda, vddio, vddio_bo and the overall current.

Do i need the brown out regulator (vddio_bo) and the vddmem?

As far as I understand vddmem is not used on mx28evk. From the mx28 reference manual;

"11.12.8 VDDMEM Supply Targets Control Register (HW_POWER_VDDMEMCTRL)
This register controls the voltage target for a memory supply generated from VDDA. This
supply is intended for use with external memories such as LV-DDR that have unique voltage
requirements not compatible with VDDIO, VDDA , or VDDD."

#9 lore raw
In reply to Fabio Estevam

Hi,

Am 01.09.2014 15:33, schrieb Fabio Estevam:

Quoted 23 lines

Hi Stefan,

Quoted 4 lines · Stefan Wahren

thanks. Okay, that leads to more questions:

How can i test a ported mxs-regulator driver, that it's really working? Is there any userspace interface?

After you ported the mxs regulator you can check whether it probed correctly and if the reported voltages in the kernel log match the register settings. You can also check if the voltages are really in the correct reported value with a scope.

On mx6q we have the following:

[    0.070554] vdd1p1: 800 <--> 1375 mV at 1100 mV
[    0.071521] vdd3p0: 2800 <--> 3150 mV at 3000 mV
[    0.072397] vdd2p5: 2000 <--> 2750 mV at 2400 mV
[    0.073369] vddarm: 725 <--> 1450 mV at 1150 mV
[    0.074282] vddpu: 725 <--> 1450 mV at 1150 mV
[    0.075247] vddsoc: 725 <--> 1450 mV at 1200 mV
Quoted 4 lines

and you should get something like that in your kernel log after you ported the mxs regulator driver.

i've ported the mxs-regulator driver and now i'm getting an probing output like above with Linux 3.17-rc4.

Now i want to test the mxs-regulator driver with the cpufreq-cpu0 as consumer. So i defined cpu@0 according to cpufreq-cpu0 binding in imx28.dtsi and enabled cpufreq-cpu0 driver and userspace gov in Kernel config.

But if i modprobe cpufreq-cpu0 i don't get any output and the entry /sys/devices/system/cpu/cpu0/cpufreq is also missing.

Any ideas, what's wrong or missing?

Best regards
Stefan

PS: Here the relevant config:

# .config
#
# CPU Frequency scaling
#
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
# CONFIG_CPU_FREQ_STAT_DETAILS is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
# CONFIG_CPU_FREQ_GOV_PERFORMANCE is not set
# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
CONFIG_CPU_FREQ_GOV_USERSPACE=y
# CONFIG_CPU_FREQ_GOV_ONDEMAND is not set
# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
CONFIG_GENERIC_CPUFREQ_CPU0=m
# imx28.dtsi

[...]

cpus {
	#address-cells = <1>;
	#size-cells = <0>;

	cpu: cpu@0 {
		compatible = "arm,arm926ej-s";
		device_type = "cpu";
		operating-points = <
			/* kHz	uV */
			454736	1550000
			392727	1475000
			360000	1375000
			261818	1275000
			64000	1050000
		>;
		clock-latency = <61036>; /* two CLK32 periods */
		cpu0-supply = <&reg_vddd>;
	};
};

[...]

power: power@80044000 {
	compatible = "simple-bus";
	#address-cells = <1>;
	#size-cells = <1>;
	reg = <0x80044000 0x2000>;
	ranges;

	reg_vddd: regulator@80044040 {
		reg = <0x80044040 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vddd";
		regulator-min-microvolt = <800000>;
		regulator-max-microvolt = <1575000>;
		regulator-boot-on;
		vddd-supply = <&reg_vdda>;
	};

	reg_vdda: regulator@80044050 {
		reg = <0x80044050 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vdda";
		regulator-min-microvolt = <1500000>;
		regulator-max-microvolt = <2275000>;
		regulator-boot-on;
		vdda-supply = <&reg_vddio>;
	};

	reg_vddio: regulator@80044060 {
		reg = <0x80044060 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vddio";
		regulator-min-microvolt = <2800000>;
		regulator-max-microvolt = <3600000>;
		regulator-microvolt-offset = <80000>;
		regulator-boot-on;
	};

	power_sts: power_sts@800440c0 {
		reg = <0x800440c0 0x10>;
		status = "disabled";
	};
};
#10 lore raw

Hi Stefan,

Quoted 2 lines · Stefan Wahren

i've ported the mxs-regulator driver and now i'm getting an probing output like above with Linux 3.17-rc4.

Great, it looks like you are making good progress :-)

Quoted 9 lines

Now i want to test the mxs-regulator driver with the cpufreq-cpu0 as consumer. So i defined cpu@0 according to cpufreq-cpu0 binding in imx28.dtsi and enabled cpufreq-cpu0 driver and userspace gov in Kernel config.

But if i modprobe cpufreq-cpu0 i don't get any output and the entry /sys/devices/system/cpu/cpu0/cpufreq is also missing.

Any ideas, what's wrong or missing?

Have you registered cpufreq-cpu0 inside arch/arm/mach-mxs/mach-mxs.c?

Take a look at this patch for an example:
http://www.spinics.net/lists/arm-kernel/msg363761.html

#11 lore raw

Hi,

Am 23.09.2014 00:18, schrieb Fabio Estevam:

Quoted 9 lines

Hi Stefan,

Quoted 7 lines

Now i want to test the mxs-regulator driver with the cpufreq-cpu0 as consumer. So i defined cpu@0 according to cpufreq-cpu0 binding in imx28.dtsi and enabled cpufreq-cpu0 driver and userspace gov in Kernel config.

But if i modprobe cpufreq-cpu0 i don't get any output and the entry /sys/devices/system/cpu/cpu0/cpufreq is also missing.

Quoted 7 lines
Quoted 1 line

Any ideas, what's wrong or missing?

Have you registered cpufreq-cpu0 inside arch/arm/mach-mxs/mach-mxs.c?

Take a look at this patch for an example:
http://www.spinics.net/lists/arm-kernel/msg363761.html

thanks, registering cpufreq-cpu0 and adding missing properties reg & clocks did the trick.

Now the sys interface of cpufreq is available and the mxs-regulator seems to handle frequency change. But the frequency selection do not work as expected. If i set cpu frequency to 454736, 392727 or 261818 kHz, the cpufreq driver change it silently to 240000 kHz.

Why? Is it the wrong clock ( 21 should be cpu )?

Thanks in advance
Stefan

PS: Here my DT and the debug output

####################### imx28.dtsi

[...]

cpus {
	#address-cells = <1>;
	#size-cells = <0>;

	cpu@0 {
		compatible = "arm,arm926ej-s";
		device_type = "cpu";
		reg = <0x0>;
		operating-points = <
			/* kHz	uV */
			454736	1550000
			392727	1475000
			360000	1375000
			261818	1275000
			64000	1050000
		>;
		clocks = <&clks 21>;
		clock-latency = <61036>; /* two CLK32 periods */
		cpu0-supply = <&reg_vddd>;
	};
};

[...]

power: power@80044000 {
	compatible = "simple-bus";
	#address-cells = <1>;
	#size-cells = <1>;
	reg = <0x80044000 0x2000>;
	ranges;

	reg_vddd: regulator@80044040 {
		reg = <0x80044040 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vddd";
		regulator-min-microvolt = <800000>;
		regulator-max-microvolt = <1575000>;
		regulator-boot-on;
		vddd-supply = <&reg_vdda>;
	};

	reg_vdda: regulator@80044050 {
		reg = <0x80044050 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vdda";
		regulator-min-microvolt = <1500000>;
		regulator-max-microvolt = <2275000>;
		regulator-boot-on;
		vdda-supply = <&reg_vddio>;
	};

	reg_vddio: regulator@80044060 {
		reg = <0x80044060 0x10>;
		compatible = "fsl,mxs-regulator";
		regulator-name = "vddio";
		regulator-min-microvolt = <2800000>;
		regulator-max-microvolt = <3600000>;
		regulator-microvolt-offset = <80000>;
		regulator-boot-on;
	};

	power_sts: power_sts@800440c0 {
		reg = <0x800440c0 0x10>;
		status = "disabled";
	};
};

####################### dmesg

[ 3845.602210] cpu cpu0: Looking up cpu0-supply from device tree
[ 3845.604389] freq_table: table entry 0: 64000 kHz
[ 3845.604448] freq_table: table entry 1: 261818 kHz
[ 3845.604482] freq_table: table entry 2: 360000 kHz
[ 3845.604512] freq_table: table entry 3: 392727 kHz
[ 3845.604541] freq_table: table entry 4: 454736 kHz
[ 3845.608402] freq_table: request for verificatiorequest for verification of policy (64000 - 454736 kHz) for cpu 0
[ 3845.608571] freq_table: verification lead to (64000 - 454736 kHz) for cpu 0
[ 4049.590886] freq_table: request for target 392727 kHz (relation: 0) for cpu 0
[ 4049.590957] freq_table: target index is 3, freq is:392727 kHz
[ 4049.597120] mxs_get_voltage: vddd register val 28
[ 4049.597202] cpufreq_cpu0: 454 MHz, 1500 mV --> 240 MHz, 1275 mV
[ 4049.597686] mxs_is_enabled: vddd register val 0
[ 4049.597783] mxs_get_voltage: vddd register val 28
[ 4049.597864] mxs_set_voltage: min_uV 1275000, max_uV 1275000, min 800000, max 1575000
[ 4049.597928] mxs_set_voltage: vddd calculated val 19
[ 4049.598384] mxs_get_voltage: vddd register val 19
[ 4464.831192] freq_table: request for target 360000 kHz (relation: 0) for cpu 0
[ 4464.831609] freq_table: target index is 2, freq is:360000 kHz
[ 4464.831871] mxs_get_voltage: vddd register val 19
[ 4464.831965] cpufreq_cpu0: 240 MHz, 1275 mV --> 360 MHz, 1375 mV
[ 4464.832063] mxs_is_enabled: vddd register val 0
[ 4464.832137] mxs_get_voltage: vddd register val 19
[ 4464.832213] mxs_set_voltage: min_uV 1375000, max_uV 1375000, min 800000, max 1575000
[ 4464.832274] mxs_set_voltage: vddd calculated val 23
[ 4464.832488] mxs_get_voltage: vddd register val 23
[ 4603.949470] freq_table: request for target 261818 kHz (relation: 0) for cpu 0
[ 4603.949548] freq_table: target index is 1, freq is:261818 kHz
[ 4603.949747] mxs_get_voltage: vddd register val 23
[ 4603.949815] cpufreq_cpu0: 360 MHz, 1375 mV --> 240 MHz, 1275 mV
[ 4603.950088] mxs_is_enabled: vddd register val 0
[ 4603.950165] mxs_get_voltage: vddd register val 23
[ 4603.950244] mxs_set_voltage: min_uV 1275000, max_uV 1275000, min 800000, max 1575000
[ 4603.950306] mxs_set_voltage: vddd calculated val 19
[ 4603.950473] mxs_get_voltage: vddd register val 19
[ 4757.663161] freq_table: request for target 454736 kHz (relation: 0) for cpu 0
[ 4757.663267] freq_table: target index is 4, freq is:454736 kHz
[ 4757.663518] mxs_get_voltage: vddd register val 19
[ 4757.663614] cpufreq_cpu0: 240 MHz, 1275 mV --> 240 MHz, 1275 mV
#12 lore raw
Quoted 6 lines · Stefan Wahren

thanks, registering cpufreq-cpu0 and adding missing properties reg & clocks did the trick.

Now the sys interface of cpufreq is available and the mxs-regulator seems to handle frequency change. But the frequency selection do not work as expected. If i set cpu frequency to 454736, 392727 or 261818 kHz, the

Why 454736 instead of 454MHz? Same for the other values.

Quoted 1 line

cpufreq driver change it silently to 240000 kHz.

24MHz is the osc clock. It seems you did not turn on the PLL0.

Check the POWER bit of HW_CLKCTRL_PLL0CTRL0 register.

#13 lore raw

Hi,

i added linux-pm list.

Am 24.09.2014 23:47, schrieb Fabio Estevam:

Quoted 10 lines · Stefan Wahren
Quoted 7 lines

thanks, registering cpufreq-cpu0 and adding missing properties reg & clocks did the trick.

Now the sys interface of cpufreq is available and the mxs-regulator seems to handle frequency change. But the frequency selection do not work as expected. If i set cpu frequency to 454736, 392727 or 261818 kHz, the

Why 454736 instead of 454MHz? Same for the other values.

I took these values from the cpufreq driver in the Freescale BSP and they are in the datasheet, too. If i take 454000 and so one, i will get this nice oops:

root@duckbill:~# modprobe cpufreq-cpu0
[   95.764654] cpufreq: __cpufreq_add_dev: CPU0: Running at unlisted freq: 454736 KHz
[   95.773146] cpufreq_cpu0: failed to find OPP for 454736842
[   95.778692] cpufreq: __target_index: Failed to change cpu frequency: -34
[   95.786235] ------------[ cut here ]------------
[   95.790913] kernel BUG at drivers/cpufreq/cpufreq.c:1249!
[   95.796342] Internal error: Oops - BUG: 0 [#1] ARM
[   95.801154] Modules linked in: cpufreq_cpu0(+)
[   95.805673] CPU: 0 PID: 446 Comm: modprobe Not tainted 3.17.0-rc4-00268-ge789d1c-dirty #17
[   95.813965] task: c6fa8980 ti: c6c86000 task.ti: c6c86000
[   95.819409] PC is at cpufreq_add_dev+0x530/0x5b4
[   95.824069] LR is at mark_held_locks+0x74/0x9c
[...]
Quoted 7 lines
Quoted 2 lines

cpufreq driver change it silently to 240000 kHz.

24MHz is the osc clock. It seems you did not turn on the PLL0.

Check the POWER bit of HW_CLKCTRL_PLL0CTRL0 register.

240000 kHz = 240 MHz

I fixed this specific problem by setting the clock reference in the DT to ref_cpu instead of cpu. After that i'm able to set 392727, 360000, 261818 and 64000 kHz. Unfortunately the highest and default value 454736 is not selectable:

[   38.901842] cpu cpu0: Looking up cpu0-supply from device tree
[   38.904082] freq_table: table entry 0: 64000 kHz
[   38.904141] freq_table: table entry 1: 261818 kHz
[   38.904176] freq_table: table entry 2: 360000 kHz
[   38.904206] freq_table: table entry 3: 392727 kHz
[   38.904235] freq_table: table entry 4: 454736 kHz
[   38.908050] freq_table: request for verification of policy (64000 - 454736 kHz) for cpu 0
[   38.908116] freq_table: verification lead to (64000 - 454736 kHz) for cpu 0
[   38.908176] freq_table: request for verification of policy (64000 - 454736 kHz) for cpu 0
[   38.908220] freq_table: verification lead to tage: vddd register val 30
root@duckbill:/sys/devices/system/cpu/cpu0/cpufreq# echo "454736" > scaling_setspeed
[  595.671708] cpufreq_cpu0: failed to find OPP for 454736842
[  595.677272] cpufreq: __target_index: Failed to change cpu frequency: -34

That looks like a bug in cpufreq.

Best regards
Stefan

PS: Here is my relevant DT:

############# imx28.dtsi

[...]

cpus {
	#address-cells = <1>;
	#size-cells = <0>;

	cpu@0 {
		compatible = "arm,arm926ej-s";
		device_type = "cpu";
		reg = <0x0>;
		operating-points = <
			/* kHz	uV */
			454736  1550000
			392727  1475000
			360000  1375000
			261818  1275000
			64000   1050000
		>;
		clocks = <&clks 4>;
		clock-latency = <61036>; /* two CLK32 periods */
		cpu0-supply = <&reg_vddd>;
	};
};

[...]