Add power domain driver support for imx8m family
Subsystems (2)
cover Add power domain driver support for imx8m family
I just resend this patchset again to let us rethink & find out a quick way enable the power domain support in mainline to help other modules upstream.
The GPC module is used for system power management for CPU core & peripheral's power domain. For the whole i.MX8M family, different SOC has different power domain design. Some power domains need special on/off flow(need to access the register out of the GPC module).
It makes us hard to reuse the GPCv2 driver to cover all the different power up sequence. Each time a new SOC is added, we must modify the GPCv2 power domain driver to make it resuable for it. We need to add a lot of code for each new chip. We need to access the SRC & SS's GPR in GPCv2 power domain driver, it is burden to maintain the GPCv2 power domain driver. For example, in the future i.MX8MP, there are ~20 power domains, some of the power domain need some special handling only for this specific chip, same situation on i.MX8MM & i.MX8MN.
THis patchset add a more generic power domain driver that give us the possibility to use one driver to cover the whole i.MX8M family power domain in kernel side. kernel side driver don't need to handle the power domain difference time to time. All the power domain on/off sequence can be abstracted & handled in TF-A side. it can simplify the power domain handling in kernel side. All the power domain details can be hiden to TF-A side. TF-A image is SOC specific, we don't need to care more about the one image principle.
I know some guys suggest to use SCMI to implement the power domains, but it is a long way, need more time to investigate. especially, for the current SCMI power domain, it can not meet all our requirement for power domain management. On i.MX8M, some of the power domain on/off need to handle clock and external regulators, it is not a generic handling for other SOC vendors, I think.
Additonally, the SiP Service Calls provide interfaces to SoC implementation specific services on this platform. For example, Secure platform initialization, configuration and some power control. I don't think it can not be used for specific SOC.
Jacky Bai (3):
dt-bindings: power: Add power domain binding for i.mx8m family
soc: imx: Add power domain driver support for i.mx8m family
arm64: dts: freescale: Add power domain nodes for i.mx8mm
.../bindings/power/fsl,imx8m-genpd.txt | 46 ++++ arch/arm64/boot/dts/freescale/imx8mm.dtsi | 103 ++++++++ drivers/soc/imx/Kconfig | 6 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/imx8m_pm_domains.c | 224 ++++++++++++++++++ include/soc/imx/imx_sip.h | 12 + 6 files changed, 392 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt create mode 100644 drivers/soc/imx/imx8m_pm_domains.c create mode 100644 include/soc/imx/imx_sip.h
Signature · 1 line
2.21.0
PATCH RESEND 1/3 dt-bindings: power: Add power domain binding for i.mx8m family
Add the binding doc of power domain for i.MX8M SOC family.
--- .../bindings/power/fsl,imx8m-genpd.txt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +46 -0
@@ -0,0 +1,46 @@ +Device Tree Bindings for Freescale i.MX8M Generic Power Domain +============================================================== +The binding for the i.MX8M Generic power Domain[1]. + +[1] Documentation/devicetree/bindings/power/power_domain.txt + +Required properties: + + - compatible: should be of: + - "fsl,imx8m-power-domain" + - #power-domain-cells: Number of cells in a PM domain Specifier, must be 0 + - domain-index: should be the domain index number need to pass to TF-A + - domain-name: the name of this pm domain + +Optional properties: + - clocks: a number of phandles to clocks that need to be enabled during + domain power-up sequence to ensure reset propagation into devices + located inside this power domain + - power-supply: Power supply used to power the domain + - parent-domains: the phandle to the parent power domain + +example: + vpu_g1_pd: vpug1-pd { + compatible = "fsl,imx8mm-pm-domain"; + #power-domain-cells = <0>; + domain-index = <6>; + domain-name = "vpu_g1"; + parent-domains = <&vpumix_pd>; + clocks = <&clk IMX8MM_CLK_VPU_G1_ROOT>; + }; + + +Specifying Power domain for IP modules +====================================== + +IP cores belonging to a power domain should contain a 'power-domains' +property that is a phandle for PGC node representing the domain. + +Example of a device that is part of the vpu_g1 power domain: + vpu_g1: vpu_g1@38300000 { + /* ... */ + interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "irq_hantro"; + /* ... */ + power-domains = <&vpu_g1_pd>; + };
Signature · 1 line
2.21.0
Rob Herring
maintainerRe: [RESEND PATCH 1/3] dt-bindings: power: Add power domain binding for i.mx8m family
Quoted 22 lines · Jacky Bai
Add the binding doc of power domain for i.MX8M SOC family.
Signed-off-by Jacky Bai <[email protected]>--- .../bindings/power/fsl,imx8m-genpd.txt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txtDocumentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +8
-0@@ -0,0 +1,46 @@ +Device Tree Bindings for Freescale i.MX8M Generic Power Domain +============================================================== +The binding for the i.MX8M Generic power Domain[1]. + +[1] Documentation/devicetree/bindings/power/power_domain.txt + +Required properties: +
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 18
Quoted 10 lines
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +10
-0+ - compatible: should be of: + - "fsl,imx8m-power-domain" + - #power-domain-cells: Number of cells in a PM domain Specifier, must be 0 + - domain-index: should be the domain index number need to pass to TF-A + - domain-name: the name of this pm domain + +Optional properties: + - clocks: a number of phandles to clocks that need to be enabled during + domain power-up sequence to ensure reset propagation into devices + located inside this power domain
Isn't that firmware's problem?
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 23
Quoted 5 lines
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +5
-0+ - power-supply: Power supply used to power the domain + - parent-domains: the phandle to the parent power domain + +example: + vpu_g1_pd: vpug1-pd {
What's this a child of?
Use generic node names.
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 25
Quoted 2 lines
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +2
-0+ compatible = "fsl,imx8mm-pm-domain"; + #power-domain-cells = <0>;
I'm usually not a fan when I see a single domain per provider. Why can't you have firmware be a single provider with multiple domains?
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 26
Quoted 1 line
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +1
-0+ domain-index = <6>;
Don't create your own index properties.
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 27
Quoted 1 line
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +1
-0+ domain-name = "vpu_g1";
Not a standard name. Why do you need this? (Hint: we'd already have a standard name if you did.)
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 28
Quoted 1 line
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +1
-0+ parent-domains = <&vpumix_pd>;
We already have a standard way to do this.
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt line 40
Quoted 12 lines
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +12
-0+ clocks = <&clk IMX8MM_CLK_VPU_G1_ROOT>; + }; + + +Specifying Power domain for IP modules +====================================== + +IP cores belonging to a power domain should contain a 'power-domains' +property that is a phandle for PGC node representing the domain. + +Example of a device that is part of the vpu_g1 power domain: + vpu_g1: vpu_g1@38300000 {
video-codec@...
Quoted 9 lines
Documentation/devicetree/bindings/power/fsl,imx8m-genpd.txt new file +6
-0+ /* ... */ + interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "irq_hantro"; + /* ... */ + power-domains = <&vpu_g1_pd>; + };Signature · 1 line
2.21.0
PATCH RESEND 2/3 soc: imx: Add power domain driver support for i.mx8m family
In reply to Jacky BaiThe i.MX8M family is a set of NXP product focus on delivering the latest and greatest video and audio experience combining state-of-the-art media-specific features with high-performance processing while optimized for lowest power consumption.
i.MX8MQ, i.MX8MM, i.MX8MN, even the furture i.MX8MP are all belong to this family. A GPC module is used to manage all the PU power domain on/off. But the situation is that the number of power domains & the power up sequence has significate difference on those SoCs. Even on the same SoC. The power up sequence still has big difference. It makes us hard to reuse the GPCv2 driver to cover the whole i.MX8M family. Each time a new SoC is supported in the mainline kernel, we need to modify the GPCv2 driver to support it. We need to add or modify hundred lines of code in worst case. It is a bad practice for the driver maintainability.
This driver add a more generic power domain driver that the actual power on/off is done by TF-A code. the abstraction give us the possibility that using one driver to cover the whole i.MX8M family in kernel side.
--- drivers/soc/imx/Kconfig | 6 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/imx8m_pm_domains.c | 224 +++++++++++++++++++++++++++++ include/soc/imx/imx_sip.h | 12 ++ 4 files changed, 243 insertions(+) create mode 100644 drivers/soc/imx/imx8m_pm_domains.c create mode 100644 include/soc/imx/imx_sip.h
drivers/soc/imx/Kconfig +6 -0
@@ -17,4 +17,10 @@ config IMX_SCU_SOC Controller Unit SoC info module, it will provide the SoC info like SoC family, ID and revision etc. +config IMX8M_PM_DOMAINS + bool "i.MX8M PM domains" + depends on ARCH_MXC || (COMPILE_TEST && OF) + depends on PM + select PM_GENERIC_DOMAINS + endmenu
drivers/soc/imx/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o obj-$(CONFIG_ARCH_MXC) += soc-imx8.o obj-$(CONFIG_IMX_SCU_SOC) += soc-imx-scu.o +obj-$(CONFIG_IMX8M_PM_DOMAINS) += imx8m_pm_domains.o
drivers/soc/imx/imx8m_pm_domains.c new file +224 -0
224 lines not on this page · raw message
include/soc/imx/imx_sip.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright 2019 NXP +*/ + +#ifndef __IMX_SIP_H__ +#define __IMX_SIP_H__ + +#define IMX_SIP_GPC 0xC2000000 +#define IMX_SIP_CONFIG_GPC_PM_DOMAIN 0x03 + +#endif /* __IMX_SIP_H__ */
Signature · 1 line
2.21.0
Re: [RESEND PATCH 2/3] soc: imx: Add power domain driver support for i.mx8m family
Quoted 16 lines · Jacky Bai
The i.MX8M family is a set of NXP product focus on delivering the latest and greatest video and audio experience combining state-of-the-art media-specific features with high-performance processing while optimized for lowest power consumption.
i.MX8MQ, i.MX8MM, i.MX8MN, even the furture i.MX8MP are all belong to this family. A GPC module is used to manage all the PU power domain on/off. But the situation is that the number of power domains & the power up sequence has significate difference on those SoCs. Even on the same SoC. The power up sequence still has big difference. It makes us hard to reuse the GPCv2 driver to cover the whole i.MX8M family. Each time a new SoC is supported in the mainline kernel, we need to modify the GPCv2 driver to support it. We need to add or modify hundred lines of code in worst case. It is a bad practice for the driver maintainability.
Quoted 5 lines
This driver add a more generic power domain driver that the actual power on/off is done by TF-A code. the abstraction give us the possibility that using one driver to cover the whole i.MX8M family in kernel side.
TF-A has SCMI support, why can't that be used as abstraction instead of inventing new. Peng Fan has been working to get SMC mailbox.
Unless you give me strong reasons for not able to pursue that path, NACK for this patch. I have told this in the recent past.
Quoted 9 lines
Signed-off-by Jacky Bai <[email protected]>--- drivers/soc/imx/Kconfig | 6 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/imx8m_pm_domains.c | 224 +++++++++++++++++++++++++++++ include/soc/imx/imx_sip.h | 12 ++ 4 files changed, 243 insertions(+) create mode 100644 drivers/soc/imx/imx8m_pm_domains.c create mode 100644 include/soc/imx/imx_sip.h
[...]
Quoted 8 lines
drivers/soc/imx/imx8m_pm_domains.c new file +8
-0+ +mutex_lock (&gpc_pd_mutex); +arm_smccc_smc (IMX_SIP_GPC ,IMX_SIP_CONFIG_GPC_PM_DOMAIN , domain->domain_index, +PD_STATE_ON ,0 ,0 ,0 ,0 , &res); +mutex_unlock (&gpc_pd_mutex); + +return 0 ; +}
drivers/soc/imx/imx8m_pm_domains.c line 76
Quoted 10 lines
drivers/soc/imx/imx8m_pm_domains.c new file +10
-0+ +static int imx8m_pd_power_off (struct generic_pm_domain *genpd) +{ +struct imx8m_pm_domain *domain =to_imx8m_pm_domain (genpd); +struct arm_smccc_res res; +int index, ret =0 ; + +mutex_lock (&gpc_pd_mutex); +arm_smccc_smc (IMX_SIP_GPC ,IMX_SIP_CONFIG_GPC_PM_DOMAIN , domain->domain_index, +PD_STATE_OFF ,0 ,0 ,0 ,0 , &res);
How big is this IMX SMC SIP ? I keep seeing that it's ever growing. I don't want to see this for any future products as they seem to be designed "ON THE GO" as and when needed rather than completely thought through.
--
Regards,
Sudeep
RE: [RESEND PATCH 2/3] soc: imx: Add power domain driver support for i.mx8m family
Quoted 35 lines
-----Original Message-----
From: Sudeep Holla [mailto:[email protected]]
Sent: Tuesday, July 2, 2019 7:07 PM
To: Jacky Bai <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Leonard Crestez <[email protected]>; Aisheng Dong <[email protected]>; Peng Fan <[email protected]>; [email protected]; dl-linux-imx <[email protected]>; [email protected]; Sudeep Holla <[email protected]>
Subject: Re: [RESEND PATCH 2/3] soc: imx: Add power domain driver support for i.mx8m familyQuoted 16 lines · Jacky Bai
The i.MX8M family is a set of NXP product focus on delivering the latest and greatest video and audio experience combining state-of-the-art media-specific features with high-performance processing while optimized for lowest power consumption.
i.MX8MQ, i.MX8MM, i.MX8MN, even the furture i.MX8MP are all belong to this family. A GPC module is used to manage all the PU power domain on/off. But the situation is that the number of power domains & the power up sequence has significate difference on those SoCs. Even on the same SoC. The power up sequence still has big difference. It makes us hard to reuse the GPCv2 driver to cover the whole i.MX8M family. Each time a new SoC is supported in the mainline kernel, we need to modify the GPCv2 driver to support it. We need to add or modify hundred lines of code in worst case.
It is a bad practice for the driver maintainability.Quoted 5 lines
This driver add a more generic power domain driver that the actual power on/off is done by TF-A code. the abstraction give us the possibility that using one driver to cover the whole i.MX8M family in kernel side.
Quoted 6 lines
TF-A has SCMI support, why can't that be used as abstraction instead of inventing new. Peng Fan has been working to get SMC mailbox.
Unless you give me strong reasons for not able to pursue that path, NACK for this patch. I have told this in the recent past.
For some of the power domains, we need to handle the external regulator. In current SCMI power domain driver, there is not such support. If we use the SCMI power domain driver, how to handle regulator on/off, in TF-A? currently, all the regulator is managed by kernel side. most of the regulator is controlled by I2C bus. Accessing the I2C from kernel & TF-A both is not feasible. if regulator need to be handled in TF-A, I am not sure if it is necessary to extend the SCMI spec to include a regulator protocol.
Another concern is that moving all currently implementation to SCMI compatible is a huge work, waiting for SCMI implementation ready will block other peripherals upstream for a very long time.
Anyway, if current implementation can NOT be accepted, we can try to switch SCMI implementation.
Quoted 40 lines
Quoted 5 lines
Signed-off-by Jacky Bai <[email protected]>--- drivers/soc/imx/Kconfig | 6 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/imx8m_pm_domains.c | 224+++++++++++++++++++++++++++++
Quoted 4 lines
include/soc/imx/imx_sip.h | 12 ++ 4 files changed, 243 insertions(+) create mode 100644 drivers/soc/imx/imx8m_pm_domains.c create mode 100644 include/soc/imx/imx_sip.h[...]
drivers/soc/imx/imx8m_pm_domains.c
Quoted 3 lines
drivers/soc/imx/imx8m_pm_domains.c new file +3
-0+ +mutex_lock (&gpc_pd_mutex); + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_CONFIG_GPC_PM_DOMAIN,
domain->domain_index,drivers/soc/imx/imx8m_pm_domains.c
Quoted 13 lines
drivers/soc/imx/imx8m_pm_domains.c new file +13
-0+ PD_STATE_ON, 0, 0, 0, 0, &res); +mutex_unlock (&gpc_pd_mutex); + +return 0 ; +} + +static int imx8m_pd_power_off (struct generic_pm_domain *genpd) { +struct imx8m_pm_domain *domain =to_imx8m_pm_domain (genpd); +struct arm_smccc_res res; +int index, ret =0 ; + +mutex_lock (&gpc_pd_mutex); + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_CONFIG_GPC_PM_DOMAIN,
domain->domain_index,drivers/soc/imx/imx8m_pm_domains.c line 76
Quoted 1 line
drivers/soc/imx/imx8m_pm_domains.c new file +1
-0+ PD_STATE_OFF, 0, 0, 0, 0, &res);How big is this IMX SMC SIP ? I keep seeing that it's ever growing. I don't want to see this for any future products as they seem to be designed "ON THE GO" as and when needed rather than completely thought through.
--
Regards,
Sudeep
PATCH RESEND 3/3 arm64: dts: freescale: Add power domain nodes for i.mx8mm
In reply to Jacky BaiAdd the power domain nodes for i.MX8MM.
--- arch/arm64/boot/dts/freescale/imx8mm.dtsi | 103 ++++++++++++++++++++++ 1 file changed, 103 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm.dtsi +103 -0
@@ -181,6 +181,109 @@ interrupt-affinity = <&A53_0>, <&A53_1>, <&A53_2>, <&A53_3>; }; + power-domains { + compatible = "simple-bus"; + /* HSIO SS */ + hsiomix_pd: hsiomix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <0>; + domain-name = "hsiomix"; + clocks = <&clk IMX8MM_CLK_USB1_CTRL_ROOT>; + }; + + pcie_pd: pcie-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <1>; + domain-name = "pcie"; + parent-domains = <&hsiomix_pd>; + }; + + usb_otg1_pd: usbotg1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <2>; + domain-name = "usb_otg1"; + parent-domains = <&hsiomix_pd>; + }; + + usb_otg2_pd: usbotg2-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <3>; + domain-name = "usb_otg2"; + parent-domains = <&hsiomix_pd>; + }; + + /* GPU SS */ + gpumix_pd: gpumix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <4>; + domain-name = "gpumix"; + clocks = <&clk IMX8MM_CLK_GPU_BUS_ROOT>, + <&clk IMX8MM_CLK_GPU_AHB>, + <&clk IMX8MM_CLK_GPU2D_ROOT>, + <&clk IMX8MM_CLK_GPU3D_ROOT>; + }; + + /* VPU SS */ + vpumix_pd: vpumix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <5>; + domain-name = "vpumix"; + clocks = <&clk IMX8MM_CLK_VPU_DEC_ROOT>; + }; + + vpu_g1_pd: vpug1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <6>; + domain-name = "vpu_g1"; + parent-domains = <&vpumix_pd>; + clocks = <&clk IMX8MM_CLK_VPU_G1_ROOT>; + }; + + vpu_g2_pd: vpug2-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <7>; + domain-name = "vpu_g2"; + parent-domains = <&vpumix_pd>; + clocks = <&clk IMX8MM_CLK_VPU_G2_ROOT>; + }; + + vpu_h1_pd: vpuh1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <8>; + domain-name = "vpu_h1"; + parent-domains = <&vpumix_pd>; + clocks = <&clk IMX8MM_CLK_VPU_H1_ROOT>; + }; + + /* DISP SS */ + dispmix_pd: dispmix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <9>; + domain-name = "dispmix"; + clocks = <&clk IMX8MM_CLK_DISP_ROOT>, + <&clk IMX8MM_CLK_DISP_AXI_ROOT>, + <&clk IMX8MM_CLK_DISP_APB_ROOT>; + }; + + mipi_pd: mipi-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0>; + domain-index = <10>; + domain-name = "mipi"; + parent-domains = <&dispmix_pd>; + }; + }; + timer { compatible = "arm,armv8-timer"; interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>, /* Physical Secure */
Signature · 1 line
2.21.0