Skip to contentSkip to conversation

PM / AVS: SVS: Introduce SVS engine

RFC Superseded Roger Lu 3 participants 11 messages Apr 30, 2019 – May 13, 2019

Subsystems (3)

v1 of 25 Superseded Latest is v25 →

lore
Share & tools
lore

Roger Lu

author
#0 lore raw

The SVS (Smart Voltage Scaling) engine is a piece of hardware which is used to calculate optimized voltage values of several power domains, e.g. CPU/GPU/CCI, according to chip process corner, temperatures, and other factors. Then DVFS driver could apply those optimized voltage values to reduce power consumption.

Roger Lu (3):
dt-bindings: soc: add mtk svs dt-bindings
arm64: dts: mt8183: add svs device information
PM / AVS: SVS: Introduce SVS engine

 .../devicetree/bindings/power/mtk-svs.txt     |   70 +
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts   |   16 +
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |   46 +
 drivers/power/avs/Kconfig                     |   10 +
 drivers/power/avs/Makefile                    |    1 +
 drivers/power/avs/mtk_svs.c                   | 2084 +++++++++++++++++
 include/linux/power/mtk_svs.h                 |   23 +
 7 files changed, 2250 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mtk-svs.txt
 create mode 100644 drivers/power/avs/mtk_svs.c
 create mode 100644 include/linux/power/mtk_svs.h

--
2.18.0

author
#1 lore raw

RFC 1/3 dt-bindings: soc: add mtk svs dt-bindings

Document the binding for enabling mtk svs on MediaTek SoC.

---
 .../devicetree/bindings/power/mtk-svs.txt     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mtk-svs.txt
Documentation/devicetree/bindings/power/mtk-svs.txt new file +70 -0
new file mode 100644
index 000000000000..355329db74ba
@@ -0,0 +1,70 @@
+* Mediatek Smart Voltage Scaling (MTK SVS)
+
+This describes the device tree binding for the MTK SVS controller
+which helps provide the optimized CPU/GPU/CCI voltages. This device also
+needs thermal data to calculate thermal slope for accurately compensate
+the voltages when temperature change.
+
+Required properties:
+- compatible:
+  - "mediatek,mt8183-svs" : For MT8183 family of SoCs
+- reg: Address range of the MTK SVS controller.
+- interrupts: IRQ for the MTK SVS controller.
+- clocks, clock-names: Clocks needed for the svs controller. required
+                       clocks are:
+		       "main_clk": Main clock needed for register access
+- nvmem-cells: Phandle to the calibration data provided by a nvmem device.
+- nvmem-cell-names: Should be "svs-calibration-data" and "calibration-data"
+- svs_xxx: Phandle of svs_bank device for controlling corresponding opp
+           table and power-domains.
+- vxxx-supply: Phandle to each regulator. vxxx can be "vcpu_little",
+	       "vcpu_big", "vcci" and "vgpu".
+
+Example:
+
+	svs: svs@1100b000 {
+		compatible = "mediatek,mt8183-svs";
+		reg = <0 0x1100b000 0 0x1000>;
+		interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW 0>;
+		clocks = <&infracfg CLK_INFRA_THERM>;
+		clock-names = "main_clk";
+		nvmem-cells = <&svs_calibration>, <&thermal_calibration>;
+		nvmem-cell-names = "svs-calibration-data", "calibration-data";
+
+		svs_cpu_little: svs_cpu_little {
+			compatible = "mediatek,mt8183-svs-cpu-little";
+			operating-points-v2 = <&cluster0_opp>;
+		};
+
+		svs_cpu_big: svs_cpu_big {
+			compatible = "mediatek,mt8183-svs-cpu-big";
+			operating-points-v2 = <&cluster1_opp>;
+		};
+
+		svs_cci: svs_cci {
+			compatible = "mediatek,mt8183-svs-cci";
+			operating-points-v2 = <&cluster2_opp>;
+		};
+
+		svs_gpu: svs_gpu {
+			compatible = "mediatek,mt8183-svs-gpu";
+			power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+			operating-points-v2 = <&gpu_opp_table>;
+		};
+	};
+
+	&svs_cpu_little {
+		vcpu_little-supply = <&mt6358_vproc12_reg>;
+	};
+
+	&svs_cpu_big {
+		vcpu_big-supply = <&mt6358_vproc11_reg>;
+	};
+
+	&svs_cci {
+		vcci-supply = <&mt6358_vproc12_reg>;
+	};
+
+	&svs_gpu {
+		vgpu-spply = <&mt6358_vgpu_reg>;
+	};
Signature · 1 line
2.18.0
#2 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 22 lines

Document the binding for enabling mtk svs on MediaTek SoC.

---
 .../devicetree/bindings/power/mtk-svs.txt     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mtk-svs.txt
Documentation/devicetree/bindings/power/mtk-svs.txt new file +8 -0
new file mode 100644
index 000000000000..355329db74ba
@@ -0,0 +1,70 @@
+* Mediatek Smart Voltage Scaling (MTK SVS)
+
+This describes the device tree binding for the MTK SVS controller
+which helps provide the optimized CPU/GPU/CCI voltages. This device also
+needs thermal data to calculate thermal slope for accurately compensate
+the voltages when temperature change.
+
+Required properties:

Documentation/devicetree/bindings/power/mtk-svs.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +10 -0
+- compatible:
+  - "mediatek,mt8183-svs" : For MT8183 family of SoCs
+- reg: Address range of the MTK SVS controller.
+- interrupts: IRQ for the MTK SVS controller.
+- clocks, clock-names: Clocks needed for the svs controller. required
+                       clocks are:
+                      "main_clk": Main clock needed for register access
+- nvmem-cells: Phandle to the calibration data provided by a nvmem device.
+- nvmem-cell-names: Should be "svs-calibration-data" and "calibration-data"
+- svs_xxx: Phandle of svs_bank device for controlling corresponding opp

Properties shouldn't have underscores in them. Use dashes?

Quoted 25 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +25 -0
+           table and power-domains.
+- vxxx-supply: Phandle to each regulator. vxxx can be "vcpu_little",
+              "vcpu_big", "vcci" and "vgpu".
+
+Example:
+
+       svs: svs@1100b000 {
+               compatible = "mediatek,mt8183-svs";
+               reg = <0 0x1100b000 0 0x1000>;
+               interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW 0>;
+               clocks = <&infracfg CLK_INFRA_THERM>;
+               clock-names = "main_clk";
+               nvmem-cells = <&svs_calibration>, <&thermal_calibration>;
+               nvmem-cell-names = "svs-calibration-data", "calibration-data";
+
+               svs_cpu_little: svs_cpu_little {
+                       compatible = "mediatek,mt8183-svs-cpu-little";
+                       operating-points-v2 = <&cluster0_opp>;
+               };
+
+               svs_cpu_big: svs_cpu_big {
+                       compatible = "mediatek,mt8183-svs-cpu-big";
+                       operating-points-v2 = <&cluster1_opp>;
+               };
+

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 10 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +10 -0
+               svs_cci: svs_cci {
+                       compatible = "mediatek,mt8183-svs-cci";
+                       operating-points-v2 = <&cluster2_opp>;
+               };
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with? Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow. Similarly, the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Quoted 3 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +3 -0
+       };
+
+       &svs_cpu_little {
author
#3 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Dear Stephen,

Thanks for the review.

Quoted 27 lines · Stephen Boyd

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 26 lines

Document the binding for enabling mtk svs on MediaTek SoC.

---
 .../devicetree/bindings/power/mtk-svs.txt     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mtk-svs.txt
Documentation/devicetree/bindings/power/mtk-svs.txt new file +12 -0
new file mode 100644
index 000000000000..355329db74ba
@@ -0,0 +1,70 @@
+* Mediatek Smart Voltage Scaling (MTK SVS)
+
+This describes the device tree binding for the MTK SVS controller
+which helps provide the optimized CPU/GPU/CCI voltages. This device also
+needs thermal data to calculate thermal slope for accurately compensate
+the voltages when temperature change.
+
+Required properties:
+- compatible:
+  - "mediatek,mt8183-svs" : For MT8183 family of SoCs
+- reg: Address range of the MTK SVS controller.
+- interrupts: IRQ for the MTK SVS controller.
Quoted 8 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 18

Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+- clocks, clock-names: Clocks needed for the svs controller. required
+                       clocks are:
+                      "main_clk": Main clock needed for register access
+- nvmem-cells: Phandle to the calibration data provided by a nvmem device.
+- nvmem-cell-names: Should be "svs-calibration-data" and "calibration-data"
+- svs_xxx: Phandle of svs_bank device for controlling corresponding opp

Properties shouldn't have underscores in them. Use dashes?

Ok. I'll use dashes.

Quoted 32 lines
Quoted 32 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +31 -0
+           table and power-domains.
+- vxxx-supply: Phandle to each regulator. vxxx can be "vcpu_little",
+              "vcpu_big", "vcci" and "vgpu".
+
+Example:
+
+       svs: svs@1100b000 {
+               compatible = "mediatek,mt8183-svs";
+               reg = <0 0x1100b000 0 0x1000>;
+               interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW 0>;
+               clocks = <&infracfg CLK_INFRA_THERM>;
+               clock-names = "main_clk";
+               nvmem-cells = <&svs_calibration>, <&thermal_calibration>;
+               nvmem-cell-names = "svs-calibration-data", "calibration-data";
+
+               svs_cpu_little: svs_cpu_little {
+                       compatible = "mediatek,mt8183-svs-cpu-little";
+                       operating-points-v2 = <&cluster0_opp>;
+               };
+
+               svs_cpu_big: svs_cpu_big {
+                       compatible = "mediatek,mt8183-svs-cpu-big";
+                       operating-points-v2 = <&cluster1_opp>;
+               };
+
+               svs_cci: svs_cci {
+                       compatible = "mediatek,mt8183-svs-cci";
+                       operating-points-v2 = <&cluster2_opp>;
+               };
+
+               svs_gpu: svs_gpu {
Quoted 8 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 4 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +4 -0
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with?

Yes. SVS has different controllers inside the hardware in order to calculate and optimize different OPP table voltage part.

Quoted 3 lines

Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow.

Those OPP tables are attached by our DVFS node (please refers below patch). SVS just shares with their OPP table and help optimize these OPP tables' voltage part.

Add cpufreq DTS node to the mt8183 and mt8183-evb
https://patchwork.kernel.org/patch/10921675/

Quoted 4 lines

Similarly,
the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Oh. There is a svs controller in GPU power-domain. We need to turn on GPU power so that svs controller can work functionally. Therefore, we add GPU power-domains in our svs_gpu sub-node.

Quoted 9 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 56

Quoted 4 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +3 -0
+       };
+
+       &svs_cpu_little {

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#4 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Quoting Roger Lu (2019-05-01 23:19:31)

Quoted 7 lines · Stephen Boyd
Quoted 6 lines

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 5 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +0 -0
new file mode 100644
index 000000000000..355329db74ba

[..]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };
Quoted 5 lines
Quoted 3 lines

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with?

Yes. SVS has different controllers inside the hardware in order to calculate and optimize different OPP table voltage part.

So is there more than one SVS register region that needs certain devices to be powered on or at least have their power domain enabled so that the SVS hardware can read the voltage and adjust accordingly? I should read the driver I suppose.

Quoted 10 lines
Quoted 4 lines

Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow.

Those OPP tables are attached by our DVFS node (please refers below patch). SVS just shares with their OPP table and help optimize these OPP tables' voltage part.

Add cpufreq DTS node to the mt8183 and mt8183-evb
https://patchwork.kernel.org/patch/10921675/

Cool thanks for the pointer.

Quoted 11 lines
Quoted 6 lines

Similarly,
the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Oh. There is a svs controller in GPU power-domain. We need to turn on GPU power so that svs controller can work functionally. Therefore, we add GPU power-domains in our svs_gpu sub-node.

Sorry, I'm not really following what you're saying too closely. I think I get it but it sounds complicated.

I'm mostly wondering if having properties like svs-gpu = <&gpu_node>, and svs-cci = <&cci_node> would work for you. The idea would be to link this hardware block to the nodes that it's going to adjust the OPPs of. Once you have the node, use some sort of OPP API to get the OPP table for a device_node and adjust it at runtime for the current OPP. It sounds like it might be a little more complicated if the hardware goes haywire when the device like GPU is powered down and the power domain is shut off. Hopefully it isn't though, so that the driver can mostly sit on top of the SVS hardware and poke OPP every once and a while when the voltage needs to change, regardless of the power state of the device.

author
#5 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Dear Stephen,

Sorry for the late reply.

Quoted 19 lines · Stephen Boyd

Quoting Roger Lu (2019-05-01 23:19:31)

Quoted 7 lines · Stephen Boyd
Quoted 6 lines

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 5 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +0 -0
new file mode 100644
index 000000000000..355329db74ba

[..]

Quoted 10 lines
Quoted 10 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with?

Quoted 7 lines
Quoted 2 lines

Yes. SVS has different controllers inside the hardware in order to calculate and optimize different OPP table voltage part.

So is there more than one SVS register region that needs certain devices to be powered on or at least have their power domain enabled so that the SVS hardware can read the voltage and adjust accordingly? I should read the driver I suppose.

No, basically, each SVS controller (aka SVS bank) only has one SVS register region that needs to be powered on for the init. In MT8183 SVS case, SVS has four controllers (banks). Each SVS bank needs corresponding power domain to be on for its init.

#SVS bank corresponding power domain
svs_cpu_little: Needs CPU-A53 power on for init
svs_cpu_big: Needs CPU-A73 power on for init
svs_cci: Needs CPU-A53 power on for init
svs_gpu: Needs MFG_2D power on for init

P.S SVS driver will use pm_runtime_get_sync() to turn on power before svs bank init and pm_runtime_put_sync() to turn off power power after svs bank init.

Quoted 26 lines
Quoted 11 lines
Quoted 5 lines

Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow.

Those OPP tables are attached by our DVFS node (please refers below patch). SVS just shares with their OPP table and help optimize these OPP tables' voltage part.

Add cpufreq DTS node to the mt8183 and mt8183-evb
https://patchwork.kernel.org/patch/10921675/

Cool thanks for the pointer.

Quoted 11 lines
Quoted 6 lines

Similarly,
the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Oh. There is a svs controller in GPU power-domain. We need to turn on GPU power so that svs controller can work functionally. Therefore, we add GPU power-domains in our svs_gpu sub-node.

Quoted 8 lines

Sorry, I'm not really following what you're saying too closely. I think I get it but it sounds complicated.

I'm mostly wondering if having properties like svs-gpu = <&gpu_node>, and svs-cci = <&cci_node> would work for you. The idea would be to link this hardware block to the nodes that it's going to adjust the OPPs of. Once you have the node, use some sort of OPP API to get the OPP table for a device_node and adjust it at runtime for the current OPP.

Yes, I understand your idea. Thank you. I share my design purpose and the troubles I encountered when linking other hardware block.

#my design purpose
1. SVS bank doesn't need all the resources in other device node like cci_node. Therefore, I model SVS sub-nodes to declare what svs bank needs.

#troubles - linking other hardware block
1. I don't know how to get cpu devcie after we link CPU node (svs_cpu_little = <cpu0>). I use "get_cpu_device(unsigned cpu)" in Linux driver to attain cpuX device generally.
2. Our MT8183 has three gpu-related node as below, svs_gpu need the reference of gpu (OPP table) & gpu_core2 (power-domain MFG_2D) to make sure svs_gpu can init and update gpu OPP table. I don't know how to refer two nodes by one property. Therefore, I model a svs_gpu to declare what it needs.

gpu: mali@13040000 {
	...
	power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE0>;
	operating-points-v2 = <&gpu_opp_table>;
	...
}
gpu_core1: mali_gpu_core1 {
	...
	power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE1>;
};
gpu_core2: mali_gpu_core2 {
	...
	power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
};

P.S MT8183 GPU won't do upstream. So, there is no patchwork weblink to refer.

Quoted 10 lines

It sounds like it might be a little more complicated if the hardware goes haywire when the device like GPU is powered down and the power domain is shut off. Hopefully it isn't though, so that the driver can mostly sit on top of the SVS hardware and poke OPP every once and a while when the voltage needs to change, regardless of the power state of the device.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#6 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Quoting Roger Lu (2019-05-07 00:50:57)

Quoted 42 lines

Dear Stephen,

Sorry for the late reply.

Quoted 19 lines · Stephen Boyd

Quoting Roger Lu (2019-05-01 23:19:31)

Quoted 7 lines · Stephen Boyd
Quoted 6 lines

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 5 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +0 -0
new file mode 100644
index 000000000000..355329db74ba

[..]

Quoted 10 lines
Quoted 10 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with?

Quoted 7 lines
Quoted 2 lines

Yes. SVS has different controllers inside the hardware in order to calculate and optimize different OPP table voltage part.

So is there more than one SVS register region that needs certain devices to be powered on or at least have their power domain enabled so that the SVS hardware can read the voltage and adjust accordingly? I should read the driver I suppose.

No, basically, each SVS controller (aka SVS bank) only has one SVS register region that needs to be powered on for the init. In MT8183 SVS case, SVS has four controllers (banks). Each SVS bank needs corresponding power domain to be on for its init.

#SVS bank corresponding power domain
svs_cpu_little: Needs CPU-A53 power on for init
svs_cpu_big: Needs CPU-A73 power on for init
svs_cci: Needs CPU-A53 power on for init
svs_gpu: Needs MFG_2D power on for init

Quoted 3 lines

P.S SVS driver will use pm_runtime_get_sync() to turn on power before svs bank init and pm_runtime_put_sync() to turn off power power after svs bank init.

Ok. How are you making sure that certain CPUs are powered on?

Quoted 35 lines
Quoted 27 lines
Quoted 6 lines
Quoted 6 lines

Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow.

Quoted 6 lines

Those OPP tables are attached by our DVFS node (please refers below patch). SVS just shares with their OPP table and help optimize these OPP tables' voltage part.

Add cpufreq DTS node to the mt8183 and mt8183-evb
https://patchwork.kernel.org/patch/10921675/

Cool thanks for the pointer.

Quoted 11 lines
Quoted 6 lines

Similarly,
the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Oh. There is a svs controller in GPU power-domain. We need to turn on GPU power so that svs controller can work functionally. Therefore, we add GPU power-domains in our svs_gpu sub-node.

Quoted 8 lines

Sorry, I'm not really following what you're saying too closely. I think I get it but it sounds complicated.

I'm mostly wondering if having properties like svs-gpu = <&gpu_node>, and svs-cci = <&cci_node> would work for you. The idea would be to link this hardware block to the nodes that it's going to adjust the OPPs of. Once you have the node, use some sort of OPP API to get the OPP table for a device_node and adjust it at runtime for the current OPP.

Quoted 7 lines

Yes, I understand your idea. Thank you. I share my design purpose and the troubles I encountered when linking other hardware block.

#my design purpose
1. SVS bank doesn't need all the resources in other device node like cci_node. Therefore, I model SVS sub-nodes to declare what svs bank needs.

Do you mean that there are other properties in the cci_node that the SVS hardware block doesn't use? That doesn't sound like a problem to me. I view nodes in the SoC bus as all memory mapped IO devices and it sounds like SVS is a hardware IP core that's off to the side in the system that has some sensors that goes into various other IP blocks in the system. It's correct to model the registers and interrupts, etc. as one node for the one hardware block that's delivered by the hardware engineers.

Quoted 5 lines

#troubles - linking other hardware block
1. I don't know how to get cpu devcie after we link CPU node (svs_cpu_little = <cpu0>). I use "get_cpu_device(unsigned cpu)" in Linux driver to attain cpuX device generally.

This should probably be some sort of list property that points to all the CPUs in the little and big clusters. Then the code can iterate through the node pointers and look for an OPP table in any of them by combining of_cpu_node_to_id() with get_cpu_device()?

Quoted 18 lines

2. Our MT8183 has three gpu-related node as below, svs_gpu need the reference of gpu (OPP table) & gpu_core2 (power-domain MFG_2D) to make sure svs_gpu can init and update gpu OPP table. I don't know how to refer two nodes by one property. Therefore, I model a svs_gpu to declare what it needs.

gpu: mali@13040000 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE0>;
        operating-points-v2 = <&gpu_opp_table>;
        ...
}
gpu_core1: mali_gpu_core1 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE1>;
};
Quoted 4 lines
gpu_core2: mali_gpu_core2 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
};

These three nodes should be combined into one node for the GPU. The power domains will need to be referred to by name. Luckily we have support for multiple power domains in the kernel now so this should work. Let us know if it doesn't work for some reason.

Quoted 3 lines

P.S MT8183 GPU won't do upstream. So, there is no patchwork weblink to refer.

Sure.

author
#7 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

Dear Stephen,

Sorry for the late reply.

Quoted 43 lines · Stephen Boyd

Quoting Roger Lu (2019-05-07 00:50:57)

Quoted 42 lines

Dear Stephen,

Sorry for the late reply.

Quoted 19 lines · Stephen Boyd

Quoting Roger Lu (2019-05-01 23:19:31)

Quoted 7 lines · Stephen Boyd
Quoted 6 lines

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 5 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +0 -0
new file mode 100644
index 000000000000..355329db74ba

[..]

Quoted 10 lines
Quoted 10 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with?

Quoted 7 lines
Quoted 2 lines

Yes. SVS has different controllers inside the hardware in order to calculate and optimize different OPP table voltage part.

So is there more than one SVS register region that needs certain devices to be powered on or at least have their power domain enabled so that the SVS hardware can read the voltage and adjust accordingly? I should read the driver I suppose.

No, basically, each SVS controller (aka SVS bank) only has one SVS register region that needs to be powered on for the init. In MT8183 SVS case, SVS has four controllers (banks). Each SVS bank needs corresponding power domain to be on for its init.

#SVS bank corresponding power domain
svs_cpu_little: Needs CPU-A53 power on for init
svs_cpu_big: Needs CPU-A73 power on for init
svs_cci: Needs CPU-A53 power on for init
svs_gpu: Needs MFG_2D power on for init

Quoted 5 lines
Quoted 3 lines

P.S SVS driver will use pm_runtime_get_sync() to turn on power before svs bank init and pm_runtime_put_sync() to turn off power power after svs bank init.

Ok. How are you making sure that certain CPUs are powered on?

Before SVS banks init, We add a qos request to prevent CPU from entering idle for making sure CPU powers are on. Also, we'll remove this qos request after SVS banks init are done.

pm_qos_add_request(&qos_request, PM_QOS_CPU_DMA_LATENCY, 0); //prevent CPU idle pm_qos_remove_request(&qos_request); //release above request

Quoted 58 lines
Quoted 36 lines
Quoted 28 lines
Quoted 7 lines
Quoted 7 lines

Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow.

Quoted 6 lines

Those OPP tables are attached by our DVFS node (please refers below patch). SVS just shares with their OPP table and help optimize these OPP tables' voltage part.

Add cpufreq DTS node to the mt8183 and mt8183-evb
https://patchwork.kernel.org/patch/10921675/

Cool thanks for the pointer.

Quoted 11 lines
Quoted 6 lines

Similarly,
the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Oh. There is a svs controller in GPU power-domain. We need to turn on GPU power so that svs controller can work functionally. Therefore, we add GPU power-domains in our svs_gpu sub-node.

Quoted 8 lines

Sorry, I'm not really following what you're saying too closely. I think I get it but it sounds complicated.

I'm mostly wondering if having properties like svs-gpu = <&gpu_node>, and svs-cci = <&cci_node> would work for you. The idea would be to link this hardware block to the nodes that it's going to adjust the OPPs of. Once you have the node, use some sort of OPP API to get the OPP table for a device_node and adjust it at runtime for the current OPP.

Quoted 7 lines

Yes, I understand your idea. Thank you. I share my design purpose and the troubles I encountered when linking other hardware block.

#my design purpose
1. SVS bank doesn't need all the resources in other device node like cci_node. Therefore, I model SVS sub-nodes to declare what svs bank needs.

Do you mean that there are other properties in the cci_node that the SVS hardware block doesn't use? That doesn't sound like a problem to me. I view nodes in the SoC bus as all memory mapped IO devices and it sounds like SVS is a hardware IP core that's off to the side in the system that has some sensors that goes into various other IP blocks in the system. It's correct to model the registers and interrupts, etc. as one node for the one hardware block that's delivered by the hardware engineers.

Quoted 5 lines

#troubles - linking other hardware block
1. I don't know how to get cpu devcie after we link CPU node (svs_cpu_little = <cpu0>). I use "get_cpu_device(unsigned cpu)" in Linux driver to attain cpuX device generally.

Quoted 4 lines

This should probably be some sort of list property that points to all the CPUs in the little and big clusters. Then the code can iterate through the node pointers and look for an OPP table in any of them by combining of_cpu_node_to_id() with get_cpu_device()?

Okay. However, it becomes complicated when SVS banks link to other hardware block to get desired OPP table and power-domains

1. We cannot guarantee the design decision of our SVS Hardware designer. They might put controller in the hardware block whose dts node doesn't provide the OPP table and power-domains that SVS bank wants.

#For example:
If there is a SVS bank that wants GPU OPP table but it needs two power-domains(GPU, Vencoder) for init. Then, it becomes complicated and confusing when SVS sub-node tries to link many nodes. Therefore, we want to add a sub-node to focus on what SVS bank requires.

2. SVS banks depend on other hardware's power only. All the SVS banks' control registers are in SVS hardware. So, we think It's good that SVS sub-node describe what their bank requires.

3. We want SVS driver to have a generic way to attain device for using pm_runtime and OPP API. If SVS banks link to CPU and other subsys device node. It means that SVS driver have to maintain different topology in order to get CPU and other subsys device (e.g cci).

Quoted 24 lines
Quoted 19 lines

2. Our MT8183 has three gpu-related node as below, svs_gpu need the reference of gpu (OPP table) & gpu_core2 (power-domain MFG_2D) to make sure svs_gpu can init and update gpu OPP table. I don't know how to refer two nodes by one property. Therefore, I model a svs_gpu to declare what it needs.

gpu: mali@13040000 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE0>;
        operating-points-v2 = <&gpu_opp_table>;
        ...
}
gpu_core1: mali_gpu_core1 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_CORE1>;
};
Quoted 4 lines
gpu_core2: mali_gpu_core2 {
        ...
        power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
};
Quoted 4 lines

These three nodes should be combined into one node for the GPU. The power domains will need to be referred to by name. Luckily we have support for multiple power domains in the kernel now so this should work. Let us know if it doesn't work for some reason.

Cools. I'll inform our GPU maintainer to check it. Thanks a lot.

Quoted 7 lines
Quoted 4 lines

P.S MT8183 GPU won't do upstream. So, there is no patchwork weblink to refer.

Sure.

maintainer
#8 lore raw

Re: [RFC v1 1/3] dt-bindings: soc: add mtk svs dt-bindings

In reply to Stephen Boyd
Quoted 27 lines · Stephen Boyd

Quoting Roger Lu (2019-04-30 04:20:10)

Quoted 26 lines

Document the binding for enabling mtk svs on MediaTek SoC.

---
 .../devicetree/bindings/power/mtk-svs.txt     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/mtk-svs.txt
Documentation/devicetree/bindings/power/mtk-svs.txt new file +12 -0
new file mode 100644
index 000000000000..355329db74ba
@@ -0,0 +1,70 @@
+* Mediatek Smart Voltage Scaling (MTK SVS)
+
+This describes the device tree binding for the MTK SVS controller
+which helps provide the optimized CPU/GPU/CCI voltages. This device also
+needs thermal data to calculate thermal slope for accurately compensate
+the voltages when temperature change.
+
+Required properties:
+- compatible:
+  - "mediatek,mt8183-svs" : For MT8183 family of SoCs
+- reg: Address range of the MTK SVS controller.
+- interrupts: IRQ for the MTK SVS controller.
Quoted 8 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 18

Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+- clocks, clock-names: Clocks needed for the svs controller. required
+                       clocks are:
+                      "main_clk": Main clock needed for register access
+- nvmem-cells: Phandle to the calibration data provided by a nvmem device.
+- nvmem-cell-names: Should be "svs-calibration-data" and "calibration-data"
+- svs_xxx: Phandle of svs_bank device for controlling corresponding opp

Properties shouldn't have underscores in them. Use dashes?

It's also a node, not a property.

Quoted 4 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +3 -0
+           table and power-domains.
+- vxxx-supply: Phandle to each regulator. vxxx can be "vcpu_little",
+              "vcpu_big", "vcci" and "vgpu".

Just list each property instead of the indirection with 'xxx'. Though here to, these should be in the nodes actually getting the power.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +6 -0
+
+Example:
+
+       svs: svs@1100b000 {
+               compatible = "mediatek,mt8183-svs";
+               reg = <0 0x1100b000 0 0x1000>;
Quoted 8 lines

Documentation/devicetree/bindings/power/mtk-svs.txt line 35

Quoted 8 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +8 -0
+               interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW 0>;
+               clocks = <&infracfg CLK_INFRA_THERM>;
+               clock-names = "main_clk";
+               nvmem-cells = <&svs_calibration>, <&thermal_calibration>;
+               nvmem-cell-names = "svs-calibration-data", "calibration-data";
+
+               svs_cpu_little: svs_cpu_little {
+                       compatible = "mediatek,mt8183-svs-cpu-little";

Not documented. Though I think the child nodes should be removed if you do as Stephen suggests below.

Quoted 31 lines
Quoted 8 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +8 -0
+                       operating-points-v2 = <&cluster0_opp>;
+               };
+
+               svs_cpu_big: svs_cpu_big {
+                       compatible = "mediatek,mt8183-svs-cpu-big";
+                       operating-points-v2 = <&cluster1_opp>;
+               };
+

Documentation/devicetree/bindings/power/mtk-svs.txt line 53

Quoted 10 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +10 -0
+               svs_cci: svs_cci {
+                       compatible = "mediatek,mt8183-svs-cci";
+                       operating-points-v2 = <&cluster2_opp>;
+               };
+
+               svs_gpu: svs_gpu {
+                       compatible = "mediatek,mt8183-svs-gpu";
+                       power-domains = <&scpsys MT8183_POWER_DOMAIN_MFG_2D>;
+                       operating-points-v2 = <&gpu_opp_table>;
+               };

It looks like you need multiple OPPs for a single device, because it has different independent power supplies it wants to associate the OPP tables with? Why can't these OPP tables be attached to the devices that use them, i.e. CPU, GPU, CCI, etc.? Seems odd that those devices don't have OPP tables that this hardware block can look up somehow. Similarly, the power domains should probably be part of the devices that are using them and not these sub-nodes that are mirroring the other hardware blocks in the system?

Quoted 3 lines
Documentation/devicetree/bindings/power/mtk-svs.txt new file +3 -0
+       };
+
+       &svs_cpu_little {
author
#9 lore raw

RFC 2/3 arm64: dts: mt8183: add svs device information

In reply to Roger Lu

add pmic/clock/irq/efuse setting in svs noce

---
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 16 +++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi    | 46 +++++++++++++++++++++
 2 files changed, 62 insertions(+)
arch/arm64/boot/dts/mediatek/mt8183-evb.dts +16 -0
index 9b525597e5ec..42bdf4f3c0bc 100644
@@ -26,6 +26,22 @@
 	};
 };
 
+&svs_cpu_little {
+	vcpu_little-supply = <&mt6358_vproc12_reg>;
+};
+
+&svs_cpu_big {
+	vcpu_big-supply = <&mt6358_vproc11_reg>;
+};
+
+&svs_cci {
+	vcci-supply = <&mt6358_vproc12_reg>;
+};
+
+&svs_gpu {
+	vgpu-spply = <&mt6358_vgpu_reg>;
+};
+
 &uart0 {
 	status = "okay";
 };
arch/arm64/boot/dts/mediatek/mt8183.dtsi +46 -0

58 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#10 lore raw

RFC 3/3 PM / AVS: SVS: Introduce SVS engine

In reply to Roger Lu

The SVS (Smart Voltage Scaling) engine is a piece of hardware which is used to calculate optimized voltage values of several power domains, e.g. CPU/GPU/CCI, according to chip process corner, temperatures, and other factors. Then DVFS driver could apply those optimized voltage values to reduce power consumption.

---
 drivers/power/avs/Kconfig     |   10 +
 drivers/power/avs/Makefile    |    1 +
 drivers/power/avs/mtk_svs.c   | 2084 +++++++++++++++++++++++++++++++++
 include/linux/power/mtk_svs.h |   23 +
 4 files changed, 2118 insertions(+)
 create mode 100644 drivers/power/avs/mtk_svs.c
 create mode 100644 include/linux/power/mtk_svs.h
drivers/power/avs/Kconfig +10 -0
index a67eeace6a89..da9baf5b5a03 100644
@@ -18,3 +18,13 @@ config ROCKCHIP_IODOMAIN
           Say y here to enable support io domains on Rockchip SoCs. It is
           necessary for the io domain setting of the SoC to match the
           voltage supplied by the regulators.
+
+config MTK_SVS
+	bool "MediaTek Smart Voltage Scaling(SVS)"
+	depends on POWER_AVS && MTK_EFUSE
+	help
+	  The SVS engine is a piece of hardware which is used to calculate
+	  optimized voltage values of several power domains, e.g.
+	  CPU clusters/GPU/CCI, according to chip process corner, temperatures,
+	  and other factors. Then DVFS driver could apply those optimized voltage
+	  values to reduce power consumption.
drivers/power/avs/Makefile +1 -0
index ba4c7bc69225..b487701cc4a6 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_POWER_AVS_OMAP)		+= smartreflex.o
 obj-$(CONFIG_ROCKCHIP_IODOMAIN)		+= rockchip-io-domain.o
+obj-$(CONFIG_MTK_SVS)			+= mtk_svs.o
drivers/power/avs/mtk_svs.c new file +2084 -0

2,084 lines not on this page · raw message

include/linux/power/mtk_svs.h new file +23 -0
new file mode 100644
index 000000000000..d5efca8d9dca
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2018 MediaTek Inc.
+ */
+
+#ifndef __MTK_SVS_H__
+#define __MTK_SVS_H__
+
+#if defined(CONFIG_MTK_SVS)
+unsigned long claim_mtk_svs_lock(void);
+void release_mtk_svs_lock(unsigned long flags);
+#else
+static inline unsigned long claim_mtk_svs_lock(void)
+{
+	return 0;
+}
+
+static inline void release_mtk_svs_lock(unsigned long flags)
+{
+}
+#endif /* CONFIG_MTK_SVS */
+
+#endif /* __MTK_SVS_H__ */
Signature · 1 line
2.18.0