Skip to contentSkip to conversation

dt-bindings: imx_rsrc: add SC_R_NONE

PATCH New Peng Fan 2 participants 12 messages May 4, 2020 – May 11, 2020

Subsystems (4)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/6 dt-bindings: imx_rsrc: add SC_R_NONE

Add SC_R_NONE entry

---

V2:
New
For other patches in patchset, only patch 6 is changed.

 include/dt-bindings/soc/imx_rsrc.h | 1 +
 1 file changed, 1 insertions(+)
include/dt-bindings/soc/imx_rsrc.h +1 -0
index 4870eb985b..9200cd3f20 100644
@@ -553,5 +553,6 @@
 #define SC_R_VPU_ENC_1                  539
 #define SC_R_VPU                        540
 #define SC_R_LAST                       541
+#define SC_R_NONE                       0xFFF0
 
 #endif /* DT_BINDINGS_RSCRC_IMX_H */
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH v2 2/6 imx8: power: Add PD device lookup interface to power domain uclass

Add power_domain_lookup_name interface to power domain uclass to find a power domain device by its DTB node name, not using its associated client device.

Through this interface, we can operate the power domain devices directly. This is needed for non-DM drivers.

Modified from Ye's NXP downstream patch

only for legacy imx8 power domain driver, since we have not migrated to use new power domain driver.

---
 arch/arm/include/asm/arch-imx8/sys_proto.h      |  7 +++++++
 drivers/power/domain/imx8-power-domain-legacy.c | 28 +++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
arch/arm/include/asm/arch-imx8/sys_proto.h +7 -0
index 0e981ae950..fc33e6ed18 100644
@@ -5,6 +5,11 @@
 
 #include <asm/arch/sci/sci.h>
 #include <asm/mach-imx/sys_proto.h>
+#include <asm/arch/power-domain.h>
+#include <dm/platdata.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <power-domain.h>
 #include <linux/types.h>
 
 struct pass_over_info_t {
@@ -21,3 +26,5 @@ void build_info(void);
 enum boot_device get_boot_device(void);
 int print_bootinfo(void);
 int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate);
+int imx8_power_domain_lookup_name(const char *name,
+				  struct power_domain *power_domain);
drivers/power/domain/imx8-power-domain-legacy.c +28 -0
index 6f01a60b34..2c479744d3 100644
@@ -19,6 +19,34 @@ struct imx8_power_domain_priv {
 	bool state_on;
 };
 
+int imx8_power_domain_lookup_name(const char *name,
+				  struct power_domain *power_domain)
+{
+	struct udevice *dev;
+	struct power_domain_ops *ops;
+	int ret;
+
+	debug("%s(power_domain=%p name=%s)\n", __func__, power_domain, name);
+
+	ret = uclass_get_device_by_name(UCLASS_POWER_DOMAIN, name, &dev);
+	if (ret) {
+		printf("%s fail: %s, ret = %d\n", __func__, name, ret);
+		return ret;
+	}
+
+	ops = (struct power_domain_ops *)dev->driver->ops;
+	power_domain->dev = dev;
+	ret = ops->request(power_domain);
+	if (ret) {
+		debug("ops->request() failed: %d\n", ret);
+		return ret;
+	}
+
+	debug("%s ok: %s\n", __func__, dev->name);
+
+	return 0;
+}
+
 static int imx8_power_domain_request(struct power_domain *power_domain)
 {
 	debug("%s(power_domain=%p)\n", __func__, power_domain);
Signature · 1 line
2.16.4
#2 lore raw

PATCH v2 2/6 imx8: power: Add PD device lookup interface to power domain uclass

Quoted 10 lines

Add power_domain_lookup_name interface to power domain uclass to find a power domain device by its DTB node name, not using its associated client device.
Through this interface, we can operate the power domain devices directly. This is needed for non-DM drivers.
Modified from Ye's NXP downstream patch
only for legacy imx8 power domain driver, since we have not migrated to use new power domain driver.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#3 lore raw

PATCH v2 3/6 power: imx8-power-domain: Set DM_FLAG_DEFAULT_PD_CTRL_OFF flag

In reply to Peng Fan

From: Ye Li <[email protected]>

If without this flag, calling dev_power_domain_ctrl will iteratively remove the power domain device will causes iteratively power off parent PD. This is not expected by imx8-power-domain-legacy driver. Power off parent PD is controlled by the driver internally.

So set DM_FLAG_DEFAULT_PD_CTRL_OFF to avoid such issue

---
 drivers/power/domain/imx8-power-domain-legacy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/power/domain/imx8-power-domain-legacy.c +1 -0
index 2c479744d3..e6e619358c 100644
@@ -341,4 +341,5 @@ U_BOOT_DRIVER(imx8_power_domain) = {
 	.platdata_auto_alloc_size = sizeof(struct imx8_power_domain_platdata),
 	.priv_auto_alloc_size = sizeof(struct imx8_power_domain_priv),
 	.ops = &imx8_power_domain_ops,
+	.flags	= DM_FLAG_DEFAULT_PD_CTRL_OFF,
 };
Signature · 1 line
2.16.4
#4 lore raw

PATCH v2 3/6 power: imx8-power-domain: Set DM_FLAG_DEFAULT_PD_CTRL_OFF flag

Quoted 8 lines

From: Ye Li <[email protected]>
If without this flag, calling dev_power_domain_ctrl will iteratively remove the power domain device will causes iteratively power off parent PD. This is not expected by imx8-power-domain-legacy driver. Power off parent PD is controlled by the driver internally.
So set DM_FLAG_DEFAULT_PD_CTRL_OFF to avoid such issue

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#5 lore raw

PATCH v2 4/6 power: imx8: remove the resource owned check before power off

In reply to Peng Fan

For all the devices used and set ACTIVE in U-Boot, U-Boot needs to power off all of them without the check of resource owner.

When we create software partition before booting Linux, the resource own checkw will return false, and cause the power domain not powered off. If without the check of resource owner, the power domain in the other software partition could be powered off with parent partition could access child partition resources.

---
 drivers/power/domain/imx8-power-domain-legacy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/power/domain/imx8-power-domain-legacy.c +4 -4
index e6e619358c..b68be40766 100644
@@ -137,13 +137,13 @@ static int imx8_power_domain_off_node(struct power_domain *power_domain)
 	}
 
 	if (pdata->resource_id != SC_R_LAST) {
-		if (!sc_rm_is_resource_owned(-1, pdata->resource_id)) {
-			printf("%s not owned by curr partition\n", dev->name);
-			return 0;
-		}
 		ret = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
 						    SC_PM_PW_MODE_OFF);
 		if (ret) {
+			if (!sc_rm_is_resource_owned(-1, pdata->resource_id)) {
+				printf("%s not owned by curr partition %d\n", dev->name, pdata->resource_id);
+				return 0;
+			}
 			printf("Error: %s Power off failed! (error = %d)\n",
 			       dev->name, ret);
 			return -EIO;
Signature · 1 line
2.16.4
#6 lore raw

PATCH v2 4/6 power: imx8: remove the resource owned check before power off

Quoted 8 lines

For all the devices used and set ACTIVE in U-Boot, U-Boot needs to power off all of them without the check of resource owner. When we create software partition before booting Linux, the resource own checkw will return false, and cause the power domain not powered off. If without the check of resource owner, the power domain in the other software partition could be powered off with parent partition could access child partition resources.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#7 lore raw

PATCH v2 5/6 power: imx8: Check owned resource in power on

In reply to Peng Fan

From: Ye Li <[email protected]>

When fspi is assigned to M4, we have to let the fspi probe failed when its power domain is failed to power up. Because not all devices have power domain (for example, external devices on the board). Current checking resource owner in power domain probe is not good, change to check it in power on.

---
 drivers/power/domain/imx8-power-domain-legacy.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/power/domain/imx8-power-domain-legacy.c +3 -0
index b68be40766..a5f2f8a445 100644
@@ -91,6 +91,9 @@ static int imx8_power_domain_on(struct power_domain *power_domain)
 		return 0;
 
 	if (pdata->resource_id != SC_R_LAST) {
+		if (!sc_rm_is_resource_owned(-1, pdata->resource_id))
+			printf("%s [%d] not owned by curr partition\n", dev->name, pdata->resource_id);
+
 		ret = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
 						    SC_PM_PW_MODE_ON);
 		if (ret) {
Signature · 1 line
2.16.4
#8 lore raw

PATCH v2 5/6 power: imx8: Check owned resource in power on

Quoted 8 lines

From: Ye Li <[email protected]>
When fspi is assigned to M4, we have to let the fspi probe failed when its power domain is failed to power up. Because not all devices have power domain (for example, external devices on the board). Current checking resource owner in power domain probe is not good, change to check it in power on.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author
#9 lore raw

PATCH v2 6/6 imx8: Replace SC_R_LAST with SC_R_NONE in DTB

In reply to Peng Fan

From: Leonard Crestez <[email protected]>

We are currently using SC_R_LAST as a marker for imx8 power domain tree nodes without a resource attached. This value is compiled into dtb as part of the linux build and used by uboot.

The SC_R_LAST constant changes frequently as SCFW resources are added (by design) and every time we need to update linux and uboot headers together or boot can fail.

Fix this by replacing SC_R_LAST usage with a new constant SC_R_NONE defined to be 0xFFF0.

---

V2:
fix dtsi

 arch/arm/dts/fsl-imx8dx.dtsi                    | 6 +++---
 arch/arm/dts/fsl-imx8qm.dtsi                    | 6 +++---
 arch/arm/mach-imx/imx8/cpu.c                    | 1 -
 drivers/power/domain/imx8-power-domain-legacy.c | 6 +++---
 4 files changed, 9 insertions(+), 10 deletions(-)
arch/arm/dts/fsl-imx8dx.dtsi +3 -3
index ae1d1f460b..7d95cf0b7d 100644
@@ -131,7 +131,7 @@
 
 		pd_lsio: PD_LSIO {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
@@ -180,7 +180,7 @@
 
 		pd_conn: PD_CONN {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
@@ -214,7 +214,7 @@
 
 		pd_dma: PD_DMA {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
arch/arm/dts/fsl-imx8qm.dtsi +3 -3
index 6808f68f9d..2e887add79 100644
@@ -88,7 +88,7 @@
 
 		pd_lsio: PD_LSIO {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
@@ -137,7 +137,7 @@
 
 		pd_conn: PD_CONN {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
@@ -173,7 +173,7 @@
 
 		pd_dma: PD_DMA {
 			compatible = "nxp,imx8-pd";
-			reg = <SC_R_LAST>;
+			reg = <SC_R_NONE>;
 			#power-domain-cells = <0>;
 			#address-cells = <1>;
 			#size-cells = <0>;
arch/arm/mach-imx/imx8/cpu.c +0 -1
index 2110380957..f87276e8ea 100644
@@ -536,4 +536,3 @@ u32 get_cpu_rev(void)
 
 	return (id << 12) | rev;
 }
-
drivers/power/domain/imx8-power-domain-legacy.c +3 -3
index a5f2f8a445..f679df9e5d 100644
@@ -90,7 +90,7 @@ static int imx8_power_domain_on(struct power_domain *power_domain)
 	if (ppriv->state_on)
 		return 0;
 
-	if (pdata->resource_id != SC_R_LAST) {
+	if (pdata->resource_id != SC_R_NONE) {
 		if (!sc_rm_is_resource_owned(-1, pdata->resource_id))
 			printf("%s [%d] not owned by curr partition\n", dev->name, pdata->resource_id);
 
@@ -139,7 +139,7 @@ static int imx8_power_domain_off_node(struct power_domain *power_domain)
 		}
 	}
 
-	if (pdata->resource_id != SC_R_LAST) {
+	if (pdata->resource_id != SC_R_NONE) {
 		ret = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
 						    SC_PM_PW_MODE_OFF);
 		if (ret) {
@@ -202,7 +202,7 @@ static int imx8_power_domain_off_parentnodes(struct power_domain *power_domain)
 		}
 
 		/* power off parent */
-		if (pdata->resource_id != SC_R_LAST) {
+		if (pdata->resource_id != SC_R_NONE) {
 			ret = sc_pm_set_resource_power_mode(-1,
 							    pdata->resource_id,
 							    SC_PM_PW_MODE_OFF);
Signature · 1 line
2.16.4
#10 lore raw

PATCH v2 6/6 imx8: Replace SC_R_LAST with SC_R_NONE in DTB

Quoted 9 lines

From: Leonard Crestez <[email protected]>
We are currently using SC_R_LAST as a marker for imx8 power domain tree nodes without a resource attached. This value is compiled into dtb as part of the linux build and used by uboot.
The SC_R_LAST constant changes frequently as SCFW resources are added (by design) and every time we need to update linux and uboot headers together or boot can fail.
Fix this by replacing SC_R_LAST usage with a new constant SC_R_NONE defined to be 0xFFF0.

Quoted 3 lines

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#11 lore raw

PATCH v2 1/6 dt-bindings: imx_rsrc: add SC_R_NONE

In reply to Peng Fan
Quoted 2 lines

Add SC_R_NONE entry

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================