Skip to contentSkip to conversation

k3: power control support for arm clusters

PATCH Superseded Manorit Chawdhry 1 participant 12 messages Apr 12, 2023 – Apr 13, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover k3: power control support for arm clusters

The series changes the flow on how the arm64 core boots up and allows cluster level control on the power domains to hold the processor in reset during rproc_load.

Cc: [email protected]
To: Tom Rini <[email protected]>
Cc: Andrew Davis <[email protected]>
Cc: Vignesh Raghavendra <[email protected]>
Cc: "Kamlesh Gurudasani" <[email protected]>

---
Manorit Chawdhry (10):
arm: dts: k3-j721s2-r5: add a72 cluster power domain node
arm: dts: k3-j721e-r5-sk: add a72 cluster power domain node
arm: dts: k3-j721e-r5: add a72 cluster power domain node
arm: dts: k3-j7200-r5: add a72 cluster power domain node
arm: dts: k3-am642-r5-sk: add a53 cluster power domain node
arm: dts: k3-am642-r5: add a53 cluster power domain node
arm: dts: k3-am62a7-r5-sk: add a53 cluster power domain node
arm: dts: k3-am625-r5-sk: add a53 cluster power
remoteproc: ti_k3_arm64: Change the startup of arm64 core
arm: mach-k3: common: re-locate authentication for atf/optee

 arch/arm/dts/k3-am625-r5-sk.dts                 |  3 +-
 arch/arm/dts/k3-am62a7-r5-sk.dts                |  3 +-
 arch/arm/dts/k3-am642-r5-evm.dts                |  3 +-
 arch/arm/dts/k3-am642-r5-sk.dts                 |  3 +-
 arch/arm/dts/k3-j7200-r5-common-proc-board.dts  |  3 +-
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts  |  3 +-
 arch/arm/dts/k3-j721e-r5-sk.dts                 |  3 +-
 arch/arm/dts/k3-j721s2-r5-common-proc-board.dts |  3 +-
 arch/arm/mach-k3/common.c                       | 23 ++++++++-
 drivers/remoteproc/ti_k3_arm64_rproc.c          | 62 +++++++++++++++++--------
 10 files changed, 79 insertions(+), 30 deletions(-)

---
base-commit: c84a00a647057d83ecfb081ca03c4865e4c1c1be
change-id: 20230411-upstream-firewalling-864368fe7fe2

Best regards,

Signature · 1 line
Manorit Chawdhry <[email protected]>
#1 lore raw

PATCH 1/10 arm: dts: k3-j721s2-r5: add a72 cluster power domain node

adds a72 cluster to control from the rproc driver

---
 arch/arm/dts/k3-j721s2-r5-common-proc-board.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-j721s2-r5-common-proc-board.dts +2 -1
index 9e3bdec2d557..eda21a828987 100644
@@ -30,7 +30,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x0 0x00a90000 0x0 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 202 0>;
 		clocks = <&k3_clks 61 1>;
 		assigned-clocks = <&k3_clks 61 1>, <&k3_clks 202 0>;
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/10 arm: dts: k3-j721e-r5-sk: add a72 cluster power domain node

In reply to Manorit Chawdhry

adds a72 cluster to control from the rproc driver

---
 arch/arm/dts/k3-j721e-r5-sk.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-j721e-r5-sk.dts +2 -1
index d894dcb991f3..bf5582470251 100644
@@ -159,7 +159,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x0 0x00a90000 0x0 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 202 0>;
 		clocks = <&k3_clks 61 1>;
 		assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>;
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/10 arm: dts: k3-j721e-r5: add a72 cluster power domain node

In reply to Manorit Chawdhry

adds a72 cluster to control from the rproc driver

---
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +2 -1
index ab9d6e65d8e2..a6e390a6189b 100644
@@ -25,7 +25,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x0 0x00a90000 0x0 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 202 0>;
 		clocks = <&k3_clks 61 1>;
 		assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>;
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/10 arm: dts: k3-j7200-r5: add a72 cluster power domain node

In reply to Manorit Chawdhry

adds a72 cluster to control from the rproc driver

---
 arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-j7200-r5-common-proc-board.dts +2 -1
index b1f9e714d913..36fcf63bc2f9 100644
@@ -30,7 +30,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x0 0x00a90000 0x0 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 202 0>;
 		clocks = <&k3_clks 61 1>;
 		assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>;
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/10 arm: dts: k3-am642-r5-sk: add a53 cluster power domain node

In reply to Manorit Chawdhry

adds a53 cluster to control from the rproc driver

---
 arch/arm/dts/k3-am642-r5-sk.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-am642-r5-sk.dts +2 -1
index 97f44e220a3d..ba976a8d29d3 100644
@@ -34,7 +34,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x00 0x00a90000 0x00 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 137 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 135 0>;
 		clocks = <&k3_clks 61 0>;
 		assigned-clocks = <&k3_clks 61 0>, <&k3_clks 135 0>;
Signature · 1 line
2.34.1
#6 lore raw

PATCH 6/10 arm: dts: k3-am642-r5: add a53 cluster power domain node

In reply to Manorit Chawdhry

adds a53 cluster to control from the rproc driver

---
 arch/arm/dts/k3-am642-r5-evm.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-am642-r5-evm.dts +2 -1
index 7493362ac655..36e6fc4b5803 100644
@@ -32,7 +32,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x00 0x00a90000 0x00 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 137 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 135 0>;
 		clocks = <&k3_clks 61 0>;
 		assigned-clocks = <&k3_clks 61 0>, <&k3_clks 135 0>;
Signature · 1 line
2.34.1
#7 lore raw

PATCH 7/10 arm: dts: k3-am62a7-r5-sk: add a53 cluster power domain node

In reply to Manorit Chawdhry

adds a53 cluster to control from the rproc driver

---
 arch/arm/dts/k3-am62a7-r5-sk.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-am62a7-r5-sk.dts +2 -1
index 58b7c8ad050f..d26a91dcc7ed 100644
@@ -45,7 +45,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x00 0x00a90000 0x00 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 166 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 135 0>;
 		clocks = <&k3_clks 61 0>;
 		assigned-clocks = <&k3_clks 61 0>, <&k3_clks 135 0>;
Signature · 1 line
2.34.1
#8 lore raw

PATCH 8/10 arm: dts: k3-am625-r5-sk: add a53 cluster power

In reply to Manorit Chawdhry

adds a53 cluster to control from the rproc driver

---
 arch/arm/dts/k3-am625-r5-sk.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/k3-am625-r5-sk.dts +2 -1
index d39b334ed032..0103e4b2785a 100644
@@ -47,7 +47,8 @@
 		compatible = "ti,am654-rproc";
 		reg = <0x00 0x00a90000 0x00 0x10>;
 		power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>;
+				<&k3_pds 135 TI_SCI_PD_EXCLUSIVE>,
+				<&k3_pds 166 TI_SCI_PD_EXCLUSIVE>;
 		resets = <&k3_reset 135 0>;
 		clocks = <&k3_clks 61 0>;
 		assigned-clocks = <&k3_clks 61 0>, <&k3_clks 135 0>;
Signature · 1 line
2.34.1
#9 lore raw

PATCH 9/10 remoteproc: ti_k3_arm64: Change the startup of arm64 core

In reply to Manorit Chawdhry

Configuring master firewalls require the power of the cluster to be enabled before configuring them, change the load of rproc to configure the gtc clocks and start the cluster along with configuring the boot vector.

The start of rproc will only start the core.

---
 drivers/remoteproc/ti_k3_arm64_rproc.c | 62 +++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 20 deletions(-)
drivers/remoteproc/ti_k3_arm64_rproc.c +42 -20
index 1f2415dc1a68..99f11000dfbf 100644
@@ -36,6 +36,8 @@
  * @gtc_base:		Timer base address.
  */
 struct k3_arm64_privdata {
+	bool has_cluster_node;
+	struct power_domain cluster_pwrdmn;
 	struct power_domain rproc_pwrdmn;
 	struct power_domain gtc_pwrdmn;
 	struct reset_ctl rproc_rst;
@@ -55,6 +57,7 @@ struct k3_arm64_privdata {
 static int k3_arm64_load(struct udevice *dev, ulong addr, ulong size)
 {
 	struct k3_arm64_privdata *rproc = dev_get_priv(dev);
+	ulong gtc_rate;
 	int ret;
 
 	dev_dbg(dev, "%s addr = 0x%lx, size = 0x%lx\n", __func__, addr, size);
@@ -64,26 +67,10 @@ static int k3_arm64_load(struct udevice *dev, ulong addr, ulong size)
 	if (ret)
 		return ret;
 
-	return ti_sci_proc_set_config(&rproc->tsp, addr, 0, 0);
-}
-
-/**
- * k3_arm64_start() - Start the remote processor
- * @dev:	rproc device pointer
- *
- * Return: 0 if all went ok, else return appropriate error
- */
-static int k3_arm64_start(struct udevice *dev)
-{
-	struct k3_arm64_privdata *rproc = dev_get_priv(dev);
-	ulong gtc_rate;
-	int ret;
-
-	dev_dbg(dev, "%s\n", __func__);
-
 	ret = power_domain_on(&rproc->gtc_pwrdmn);
 	if (ret) {
-		dev_err(dev, "power_domain_on() failed: %d\n", ret);
+		dev_err(dev, "power_domain_on(&rproc->gtc_pwrdmn) failed: %d\n",
+			ret);
 		return ret;
 	}
 
@@ -100,9 +87,36 @@ static int k3_arm64_start(struct udevice *dev)
 	 * assigned-clock-rates during the device probe. So no need to
 	 * set the frequency again here.
 	 */
+	if (rproc->has_cluster_node) {
+		ret = power_domain_on(&rproc->cluster_pwrdmn);
+		if (ret) {
+			dev_err(dev,
+				"power_domain_on(&rproc->cluster_pwrdmn) failed: %d\n",
+				ret);
+			return ret;
+		}
+	}
+
+	return ti_sci_proc_set_config(&rproc->tsp, addr, 0, 0);
+}
+
+/**
+ * k3_arm64_start() - Start the remote processor
+ * @dev:	rproc device pointer
+ *
+ * Return: 0 if all went ok, else return appropriate error
+ */
+static int k3_arm64_start(struct udevice *dev)
+{
+	struct k3_arm64_privdata *rproc = dev_get_priv(dev);
+	int ret;
+
+	dev_dbg(dev, "%s\n", __func__);
 	ret = power_domain_on(&rproc->rproc_pwrdmn);
 	if (ret) {
-		dev_err(dev, "power_domain_on() failed: %d\n", ret);
+		dev_err(dev,
+			"power_domain_on(&rproc->rproc_pwrdmn) failed: %d\n",
+			ret);
 		return ret;
 	}
 
@@ -166,9 +180,17 @@ static int k3_arm64_of_to_priv(struct udevice *dev,
 
 	dev_dbg(dev, "%s\n", __func__);
 
+	/* Cluster needs to be powered on if firewalls are being configured */
+	rproc->has_cluster_node = true;
+	ret = power_domain_get_by_index(dev, &rproc->cluster_pwrdmn, 2);
+	if (ret) {
+		dev_dbg(dev, "warning: power_domain_get_cluster() failed: %d\n", ret);
+		rproc->has_cluster_node = false;
+	}
+
 	ret = power_domain_get_by_index(dev, &rproc->rproc_pwrdmn, 1);
 	if (ret) {
-		dev_err(dev, "power_domain_get() failed: %d\n", ret);
+		dev_err(dev, "power_domain_get_rproc() failed: %d\n", ret);
 		return ret;
 	}
 
Signature · 1 line
2.34.1
#10 lore raw

PATCH 10/10 arm: mach-k3: common: re-locate authentication for atf/optee

In reply to Manorit Chawdhry

For setting up the master firewalls present in the K3 SoCs, the arm64 clusters need to be powered on.

Re-locates the code for atf/optee authentication.

---
 arch/arm/mach-k3/common.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
arch/arm/mach-k3/common.c +21 -2
index a2adb791f6c0..6e04cc7a24aa 100644
@@ -227,6 +227,21 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	if (ret)
 		panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
 
+	if (IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS) &&
+	    IS_ENABLED(CONFIG_SYS_K3_SPL_ATF)) {
+		for (int i = IMAGE_ID_ATF; i < IMAGE_ID_SPL; i++) {
+			void *image_addr =
+				(void *)fit_image_info[i].image_start;
+
+			debug("%s: Authenticating image: addr=%x, size=%d, os=%s\n",
+			      __func__, fit_image_info[i].image_start,
+			      fit_image_info[i].image_len, image_os_match[i]);
+
+			ti_secure_image_post_process(&image_addr,
+						     &fit_image_info[i].image_len);
+		}
+	}
+
 	if (!fit_image_info[IMAGE_ID_DM_FW].image_len &&
 	    !(size > 0 && valid_elf_image(loadaddr))) {
 		shut_cpu = 1;
@@ -288,9 +303,13 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
 			break;
 		}
 	}
+	/*
+	 * Only DM and the DTBs are being authenticated here,
+	 * rest will be authenticated when A72 cluster is up
+	 */
+	if (i >= IMAGE_ID_SPL)
 #endif
-
-	ti_secure_image_post_process(p_image, p_size);
+		ti_secure_image_post_process(p_image, p_size);
 }
 #endif
 
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH 10/10] arm: mach-k3: common: re-locate authentication for atf/optee

Hi,

Quoted 15 lines · Manorit Chawdhry

For setting up the master firewalls present in the K3 SoCs, the arm64 clusters need to be powered on.

Re-locates the code for atf/optee authentication.

---
 arch/arm/mach-k3/common.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
arch/arm/mach-k3/common.c +0 -0
index a2adb791f6c0..6e04cc7a24aa 100644

arch/arm/mach-k3/common.c void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) · line 231

Quoted 5 lines
arch/arm/mach-k3/common.c +2 -0
@@ -227,6 +227,21 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 	if (ret)
 		panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
 
+	if (IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS) &&
+	    IS_ENABLED(CONFIG_SYS_K3_SPL_ATF)) {

This caused some build failures so will update this to #if which fixes it along with changing CONFIG_FIT_IMAGE_POST_PROCESS to CONFIG_SPL_FIT_IMAGE_POST_PROCESS.

arch/arm/mach-k3/common.c void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) · line 232

Quoted 1 line
arch/arm/mach-k3/common.c +1 -0
+		for (int i = IMAGE_ID_ATF; i < IMAGE_ID_SPL; i++) {

will explicitely make the calls for authentication of atf and optee to avoid the problems if enums change in future

Quoted 16 lines
arch/arm/mach-k3/common.c +12 -0
+			void *image_addr =
+				(void *)fit_image_info[i].image_start;
+
+			debug("%s: Authenticating image: addr=%x, size=%d, os=%s\n",
+			      __func__, fit_image_info[i].image_start,
+			      fit_image_info[i].image_len, image_os_match[i]);
+
+			ti_secure_image_post_process(&image_addr,
+						     &fit_image_info[i].image_len);
+		}
+	}
+
 	if (!fit_image_info[IMAGE_ID_DM_FW].image_len &&
 	    !(size > 0 && valid_elf_image(loadaddr))) {
 		shut_cpu = 1;

arch/arm/mach-k3/common.c void board_fit_image_post_process(const void *fit, int node, void **p_image, · line 310

Quoted 8 lines
arch/arm/mach-k3/common.c +5 -0
@@ -288,9 +303,13 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
 			break;
 		}
 	}
+	/*
+	 * Only DM and the DTBs are being authenticated here,
+	 * rest will be authenticated when A72 cluster is up
+	 */
+	if (i >= IMAGE_ID_SPL)

Instead of using this way will change to check specifically for atf and optee so that it remains unaffected incase the enums change.

Quoted 11 lines
arch/arm/mach-k3/common.c +1 -2
 #endif
-
-	ti_secure_image_post_process(p_image, p_size);
+		ti_secure_image_post_process(p_image, p_size);
 }
 #endif
 
Signature · 2 lines
-- 
2.34.1

Regards,
Manorit