From patchwork Mon May 4 13:16:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245012 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:49 +0800 Subject: [PATCH V2 1/6] dt-bindings: imx_rsrc: add SC_R_NONE Message-ID: <20200504131654.17085-1-peng.fan@nxp.com> Add SC_R_NONE entry Signed-off-by: Peng Fan --- 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(+) diff --git a/include/dt-bindings/soc/imx_rsrc.h b/include/dt-bindings/soc/imx_rsrc.h index 4870eb985b..9200cd3f20 100644 --- a/include/dt-bindings/soc/imx_rsrc.h +++ b/include/dt-bindings/soc/imx_rsrc.h @@ -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 */ From patchwork Mon May 4 13:16:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245013 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:50 +0800 Subject: [PATCH V2 2/6] imx8: power: Add PD device lookup interface to power domain uclass In-Reply-To: <20200504131654.17085-1-peng.fan@nxp.com> References: <20200504131654.17085-1-peng.fan@nxp.com> Message-ID: <20200504131654.17085-2-peng.fan@nxp.com> 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. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8/sys_proto.h | 7 +++++++ drivers/power/domain/imx8-power-domain-legacy.c | 28 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/arch/arm/include/asm/arch-imx8/sys_proto.h b/arch/arm/include/asm/arch-imx8/sys_proto.h index 0e981ae950..fc33e6ed18 100644 --- a/arch/arm/include/asm/arch-imx8/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8/sys_proto.h @@ -5,6 +5,11 @@ #include #include +#include +#include +#include +#include +#include #include 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); diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index 6f01a60b34..2c479744d3 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -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); From patchwork Mon May 4 13:16:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245016 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:51 +0800 Subject: [PATCH V2 3/6] power: imx8-power-domain: Set DM_FLAG_DEFAULT_PD_CTRL_OFF flag In-Reply-To: <20200504131654.17085-1-peng.fan@nxp.com> References: <20200504131654.17085-1-peng.fan@nxp.com> Message-ID: <20200504131654.17085-3-peng.fan@nxp.com> From: Ye Li 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 Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/power/domain/imx8-power-domain-legacy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index 2c479744d3..e6e619358c 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -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, }; From patchwork Mon May 4 13:16:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245014 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:52 +0800 Subject: [PATCH V2 4/6] power: imx8: remove the resource owned check before power off In-Reply-To: <20200504131654.17085-1-peng.fan@nxp.com> References: <20200504131654.17085-1-peng.fan@nxp.com> Message-ID: <20200504131654.17085-4-peng.fan@nxp.com> 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. Signed-off-by: Peng Fan --- drivers/power/domain/imx8-power-domain-legacy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index e6e619358c..b68be40766 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -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; From patchwork Mon May 4 13:16:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245017 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:53 +0800 Subject: [PATCH V2 5/6] power: imx8: Check owned resource in power on In-Reply-To: <20200504131654.17085-1-peng.fan@nxp.com> References: <20200504131654.17085-1-peng.fan@nxp.com> Message-ID: <20200504131654.17085-5-peng.fan@nxp.com> From: Ye Li 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. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/power/domain/imx8-power-domain-legacy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index b68be40766..a5f2f8a445 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -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) { From patchwork Mon May 4 13:16:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245015 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 4 May 2020 21:16:54 +0800 Subject: [PATCH V2 6/6] imx8: Replace SC_R_LAST with SC_R_NONE in DTB In-Reply-To: <20200504131654.17085-1-peng.fan@nxp.com> References: <20200504131654.17085-1-peng.fan@nxp.com> Message-ID: <20200504131654.17085-6-peng.fan@nxp.com> From: Leonard Crestez 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. Reviewed-by: Peng Fan Signed-off-by: Leonard Crestez Signed-off-by: Peng Fan --- 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(-) diff --git a/arch/arm/dts/fsl-imx8dx.dtsi b/arch/arm/dts/fsl-imx8dx.dtsi index ae1d1f460b..7d95cf0b7d 100644 --- a/arch/arm/dts/fsl-imx8dx.dtsi +++ b/arch/arm/dts/fsl-imx8dx.dtsi @@ -131,7 +131,7 @@ pd_lsio: PD_LSIO { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; @@ -180,7 +180,7 @@ pd_conn: PD_CONN { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; @@ -214,7 +214,7 @@ pd_dma: PD_DMA { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; diff --git a/arch/arm/dts/fsl-imx8qm.dtsi b/arch/arm/dts/fsl-imx8qm.dtsi index 6808f68f9d..2e887add79 100644 --- a/arch/arm/dts/fsl-imx8qm.dtsi +++ b/arch/arm/dts/fsl-imx8qm.dtsi @@ -88,7 +88,7 @@ pd_lsio: PD_LSIO { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; @@ -137,7 +137,7 @@ pd_conn: PD_CONN { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; @@ -173,7 +173,7 @@ pd_dma: PD_DMA { compatible = "nxp,imx8-pd"; - reg = ; + reg = ; #power-domain-cells = <0>; #address-cells = <1>; #size-cells = <0>; diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 2110380957..f87276e8ea 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -536,4 +536,3 @@ u32 get_cpu_rev(void) return (id << 12) | rev; } - diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index a5f2f8a445..f679df9e5d 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -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);