linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] ARM: sun8i-r40: Add cpufreq support
@ 2022-05-16  2:15 qianfanguijin
  2022-05-16  2:15 ` [PATCH v4 1/2] ARM: dts: sun8i-r40: Add "cpu-supply" node for sun8i-r40 based board qianfanguijin
  2022-05-16  2:15 ` [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu qianfanguijin
  0 siblings, 2 replies; 5+ messages in thread
From: qianfanguijin @ 2022-05-16  2:15 UTC (permalink / raw)
  To: linux-sunxi
  Cc: Rob Herring, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec,
	Rafael J . Wysocki, Viresh Kumar, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

Change history:
===============

v4(2022-05-16):
- Invert two patches.
- Drop the cpufreqs that exceeds 1G in opp tables.

v3:
- remove "allwinner-r40" compatible from allowlist.
- split dts in two part.

qianfan Zhao (2):
  ARM: dts: sun8i-r40: Add "cpu-supply" node for sun8i-r40 based board
  ARM: dts: sun8i-r40: add opp table for cpu

 .../boot/dts/sun8i-r40-bananapi-m2-ultra.dts  |  4 ++
 arch/arm/boot/dts/sun8i-r40-feta40i.dtsi      |  4 ++
 arch/arm/boot/dts/sun8i-r40.dtsi              | 42 +++++++++++++++++++
 arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts      |  4 ++
 .../boot/dts/sun8i-v40-bananapi-m2-berry.dts  |  4 ++
 5 files changed, 58 insertions(+)

--
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] ARM: dts: sun8i-r40: Add "cpu-supply" node for sun8i-r40 based board
  2022-05-16  2:15 [PATCH v4 0/2] ARM: sun8i-r40: Add cpufreq support qianfanguijin
@ 2022-05-16  2:15 ` qianfanguijin
  2022-05-16  2:15 ` [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu qianfanguijin
  1 sibling, 0 replies; 5+ messages in thread
From: qianfanguijin @ 2022-05-16  2:15 UTC (permalink / raw)
  To: linux-sunxi
  Cc: Rob Herring, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec,
	Rafael J . Wysocki, Viresh Kumar, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

The CPU of sun8i-r40 is powered by PMIC, let's add "cpu-supply" node.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 4 ++++
 arch/arm/boot/dts/sun8i-r40-feta40i.dtsi          | 4 ++++
 arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts          | 4 ++++
 arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
index a6a1087a0c9b..4f30018ec4a2 100644
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
@@ -113,6 +113,10 @@ &ahci {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &de {
 	status = "okay";
 };
diff --git a/arch/arm/boot/dts/sun8i-r40-feta40i.dtsi b/arch/arm/boot/dts/sun8i-r40-feta40i.dtsi
index 265e0fa57a32..b872b51a346d 100644
--- a/arch/arm/boot/dts/sun8i-r40-feta40i.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40-feta40i.dtsi
@@ -6,6 +6,10 @@
 
 #include "sun8i-r40.dtsi"
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &i2c0 {
 	status = "okay";
 
diff --git a/arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts b/arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts
index 6931aaab2382..0eb1990742ff 100644
--- a/arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts
+++ b/arch/arm/boot/dts/sun8i-t3-cqa3t-bv3.dts
@@ -88,6 +88,10 @@ &ahci {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &de {
 	status = "okay";
 };
diff --git a/arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts b/arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts
index 47954551f573..fdf8bd12faaa 100644
--- a/arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts
+++ b/arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts
@@ -107,6 +107,10 @@ &ahci {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &de {
 	status = "okay";
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu
  2022-05-16  2:15 [PATCH v4 0/2] ARM: sun8i-r40: Add cpufreq support qianfanguijin
  2022-05-16  2:15 ` [PATCH v4 1/2] ARM: dts: sun8i-r40: Add "cpu-supply" node for sun8i-r40 based board qianfanguijin
@ 2022-05-16  2:15 ` qianfanguijin
  2022-05-16  8:53   ` Maxime Ripard
  1 sibling, 1 reply; 5+ messages in thread
From: qianfanguijin @ 2022-05-16  2:15 UTC (permalink / raw)
  To: linux-sunxi
  Cc: Rob Herring, Maxime Ripard, Chen-Yu Tsai, Jernej Skrabec,
	Rafael J . Wysocki, Viresh Kumar, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

OPP table value is get from allwinner lichee linux-3.10 kernel driver

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 42 ++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index 291f4784e86c..8949153eb0eb 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -54,6 +54,36 @@ / {
 	#size-cells = <1>;
 	interrupt-parent = <&gic>;
 
+	cpu0_opp_table: opp_table0 {
+		compatible = "operating-points-v2";
+		opp-shared;
+
+		opp-720000000 {
+			opp-hz = /bits/ 64 <720000000>;
+			opp-microvolt = <1000000 1000000 1300000>;
+			clock-latency-ns = <2000000>;
+		};
+
+		opp-912000000 {
+			opp-hz = /bits/ 64 <912000000>;
+			opp-microvolt = <1100000 1100000 1300000>;
+			clock-latency-ns = <2000000>;
+		};
+
+		opp-1008000000 {
+			opp-hz = /bits/ 64 <1008000000>;
+			opp-microvolt = <1160000 1160000 1300000>;
+			clock-latency-ns = <2000000>;
+		};
+
+		/* The opp table of the cpu frequency that exceeds 1G
+		 * is not defined here. They require higher operating
+		 * current, which may exceed the 500mA limited if the
+		 * system is powered by USB. You can add them to the
+		 * board's DTS is you make sure.
+		 */
+	};
+
 	clocks {
 		#address-cells = <1>;
 		#size-cells = <1>;
@@ -84,24 +114,36 @@ cpu0: cpu@0 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <0>;
+			clocks = <&ccu CLK_CPU>;
+			clock-names = "cpu";
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu1: cpu@1 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <1>;
+			clocks = <&ccu CLK_CPU>;
+			clock-names = "cpu";
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu2: cpu@2 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <2>;
+			clocks = <&ccu CLK_CPU>;
+			clock-names = "cpu";
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu3: cpu@3 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <3>;
+			clocks = <&ccu CLK_CPU>;
+			clock-names = "cpu";
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 	};
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu
  2022-05-16  2:15 ` [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu qianfanguijin
@ 2022-05-16  8:53   ` Maxime Ripard
  2022-05-16  9:07     ` qianfan
  0 siblings, 1 reply; 5+ messages in thread
From: Maxime Ripard @ 2022-05-16  8:53 UTC (permalink / raw)
  To: qianfanguijin
  Cc: linux-sunxi, Rob Herring, Chen-Yu Tsai, Jernej Skrabec,
	Rafael J . Wysocki, Viresh Kumar, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm

On Mon, May 16, 2022 at 10:15:16AM +0800, qianfanguijin@163.com wrote:
> From: qianfan Zhao <qianfanguijin@163.com>
> 
> OPP table value is get from allwinner lichee linux-3.10 kernel driver
> 
> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
> ---
>  arch/arm/boot/dts/sun8i-r40.dtsi | 42 ++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
> index 291f4784e86c..8949153eb0eb 100644
> --- a/arch/arm/boot/dts/sun8i-r40.dtsi
> +++ b/arch/arm/boot/dts/sun8i-r40.dtsi
> @@ -54,6 +54,36 @@ / {
>  	#size-cells = <1>;
>  	interrupt-parent = <&gic>;
>  
> +	cpu0_opp_table: opp_table0 {
> +		compatible = "operating-points-v2";
> +		opp-shared;
> +
> +		opp-720000000 {
> +			opp-hz = /bits/ 64 <720000000>;
> +			opp-microvolt = <1000000 1000000 1300000>;
> +			clock-latency-ns = <2000000>;
> +		};
> +
> +		opp-912000000 {
> +			opp-hz = /bits/ 64 <912000000>;
> +			opp-microvolt = <1100000 1100000 1300000>;
> +			clock-latency-ns = <2000000>;
> +		};
> +
> +		opp-1008000000 {
> +			opp-hz = /bits/ 64 <1008000000>;
> +			opp-microvolt = <1160000 1160000 1300000>;
> +			clock-latency-ns = <2000000>;
> +		};
> +
> +		/* The opp table of the cpu frequency that exceeds 1G
> +		 * is not defined here. They require higher operating
> +		 * current, which may exceed the 500mA limited if the
> +		 * system is powered by USB. You can add them to the
> +		 * board's DTS is you make sure.
> +		 */

That's not the issue though. The issue is that the board is setup with a
CPU voltage at 1160mV, and if we raise the frequency to a higher OPP
without raising the voltage as well, the CPU will crash.

Maxime

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu
  2022-05-16  8:53   ` Maxime Ripard
@ 2022-05-16  9:07     ` qianfan
  0 siblings, 0 replies; 5+ messages in thread
From: qianfan @ 2022-05-16  9:07 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-sunxi, Rob Herring, Chen-Yu Tsai, Jernej Skrabec,
	Rafael J . Wysocki, Viresh Kumar, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm



在 2022/5/16 16:53, Maxime Ripard 写道:
> On Mon, May 16, 2022 at 10:15:16AM +0800, qianfanguijin@163.com wrote:
>> From: qianfan Zhao <qianfanguijin@163.com>
>>
>> OPP table value is get from allwinner lichee linux-3.10 kernel driver
>>
>> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
>> ---
>>   arch/arm/boot/dts/sun8i-r40.dtsi | 42 ++++++++++++++++++++++++++++++++
>>   1 file changed, 42 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
>> index 291f4784e86c..8949153eb0eb 100644
>> --- a/arch/arm/boot/dts/sun8i-r40.dtsi
>> +++ b/arch/arm/boot/dts/sun8i-r40.dtsi
>> @@ -54,6 +54,36 @@ / {
>>   	#size-cells = <1>;
>>   	interrupt-parent = <&gic>;
>>   
>> +	cpu0_opp_table: opp_table0 {
>> +		compatible = "operating-points-v2";
>> +		opp-shared;
>> +
>> +		opp-720000000 {
>> +			opp-hz = /bits/ 64 <720000000>;
>> +			opp-microvolt = <1000000 1000000 1300000>;
>> +			clock-latency-ns = <2000000>;
>> +		};
>> +
>> +		opp-912000000 {
>> +			opp-hz = /bits/ 64 <912000000>;
>> +			opp-microvolt = <1100000 1100000 1300000>;
>> +			clock-latency-ns = <2000000>;
>> +		};
>> +
>> +		opp-1008000000 {
>> +			opp-hz = /bits/ 64 <1008000000>;
>> +			opp-microvolt = <1160000 1160000 1300000>;
>> +			clock-latency-ns = <2000000>;
>> +		};
>> +
>> +		/* The opp table of the cpu frequency that exceeds 1G
>> +		 * is not defined here. They require higher operating
>> +		 * current, which may exceed the 500mA limited if the
>> +		 * system is powered by USB. You can add them to the
>> +		 * board's DTS is you make sure.
>> +		 */
> That's not the issue though. The issue is that the board is setup with a
> CPU voltage at 1160mV, and if we raise the frequency to a higher OPP
> without raising the voltage as well, the CPU will crash.
Yes, this is a issue and if the dts doesn't has "cpu-supply" node.
The comment above is found while testing. 100% cpu load @ 4x1.2G
will consume about 800mA@5V current, the board will reboot if it
is powered by USB. So I leave those comments.

I am thinking your suggestion to write the opp part to a dtsi like
A64. Should I adding all supported freq?

I am preparing a new version which including cpu cooling.
>
> Maxime


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-16  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16  2:15 [PATCH v4 0/2] ARM: sun8i-r40: Add cpufreq support qianfanguijin
2022-05-16  2:15 ` [PATCH v4 1/2] ARM: dts: sun8i-r40: Add "cpu-supply" node for sun8i-r40 based board qianfanguijin
2022-05-16  2:15 ` [PATCH v4 2/2] ARM: dts: sun8i-r40: add opp table for cpu qianfanguijin
2022-05-16  8:53   ` Maxime Ripard
2022-05-16  9:07     ` qianfan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).