[U-Boot] [PATCH] imx: add support for i.MX8MQ power domain controller

2019-10-03 Thread Patrick Wildt
Add support for the power domain controller that's used on the
i.MX8MQ.  This will be needed to be able to power on the PCIe
controller.  Bindings taken from Linux, driver implementation
taken from the i.MX8 power domain controller and adjusted for
the i.MX8M SoC.

Signed-off-by: Patrick Wildt 

diff --git a/arch/arm/dts/fsl-imx8mq.dtsi b/arch/arm/dts/fsl-imx8mq.dtsi
index 814a1b7df4..fbf5009886 100644
--- a/arch/arm/dts/fsl-imx8mq.dtsi
+++ b/arch/arm/dts/fsl-imx8mq.dtsi
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -71,12 +72,6 @@
interrupt-parent = <>;
};
 
-   power: power-controller {
-   compatible = "fsl,imx8mq-pm-domain";
-   num-domains = <11>;
-   #power-domain-cells = <1>;
-   };
-
pwm2: pwm@3067 {
compatible = "fsl,imx8mq-pwm", "fsl,imx27-pwm";
reg = <0x0 0x3067 0x0 0x1>;
@@ -276,6 +271,37 @@
interrupts = ;
#interrupt-cells = <3>;
interrupt-parent = <>;
+
+   pgc {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /*
+* As per comment in ATF source code:
+*
+* PCIE1 and PCIE2 share the
+* same reset signal, if we
+* power down PCIE2, PCIE1
+* will be held in reset too.
+*
+* So instead of creating two
+* separate power domains for
+* PCIE1 and PCIE2 we create a
+* link between both and use
+* it as a shared PCIE power
+* domain.
+*/
+   pgc_pcie: power-domain@1 {
+   #power-domain-cells = <0>;
+   reg = ;
+   power-domains = <_pcie2>;
+   };
+
+   pgc_pcie2: power-domain@a {
+   #power-domain-cells = <0>;
+   reg = ;
+   };
+   };
};
 
usdhc1: usdhc@30b4 {
diff --git a/arch/arm/include/asm/arch-imx8m/power-domain.h 
b/arch/arm/include/asm/arch-imx8m/power-domain.h
new file mode 100644
index 00..0f94945894
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8m/power-domain.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2017 NXP
+ */
+
+#ifndef _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+#define _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+
+struct imx8m_power_domain_platdata {
+   int resource_id;
+   int has_pd;
+   struct power_domain pd;
+};
+
+#endif
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index e45731edda..6c87a8a1ef 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -35,6 +35,8 @@ CONFIG_FSL_USDHC=y
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 06bba6220b..7e2d6a90bf 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -23,6 +23,13 @@ config IMX8_POWER_DOMAIN
   Enable support for manipulating NXP i.MX8 on-SoC power domains via 
IPC
   requests to the SCU.
 
+config IMX8M_POWER_DOMAIN
+   bool "Enable i.MX8M power domain driver"
+   depends on POWER_DOMAIN && ARCH_IMX8M
+   help
+ Enable support for manipulating NXP i.MX8M on-SoC power domains via
+ requests to the ATF.
+
 config MTK_POWER_DOMAIN
bool "Enable the MediaTek power domain driver"
depends on POWER_DOMAIN && ARCH_MEDIATEK
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 695aafe17d..4d87d7c7f9 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
+obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
new file mode 100644
index 00..164fb3d31d
--- /dev/null
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2017 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[U-Boot] [PATCH] imx: add support for i.MX8MQ power domain controller

2019-09-30 Thread Patrick Wildt
Add support for the power domain controller that's used on the
i.MX8MQ.  This will be needed to be able to power on the PCIe
controller.  Bindings taken from Linux, driver implementation
taken from the i.MX8 power domain controller and adjusted for
the i.MX8M SoC.

Signed-off-by: Patrick Wildt 

diff --git a/arch/arm/dts/fsl-imx8mq.dtsi b/arch/arm/dts/fsl-imx8mq.dtsi
index 814a1b7df4..fbf5009886 100644
--- a/arch/arm/dts/fsl-imx8mq.dtsi
+++ b/arch/arm/dts/fsl-imx8mq.dtsi
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -71,12 +72,6 @@
interrupt-parent = <>;
};
 
-   power: power-controller {
-   compatible = "fsl,imx8mq-pm-domain";
-   num-domains = <11>;
-   #power-domain-cells = <1>;
-   };
-
pwm2: pwm@3067 {
compatible = "fsl,imx8mq-pwm", "fsl,imx27-pwm";
reg = <0x0 0x3067 0x0 0x1>;
@@ -276,6 +271,37 @@
interrupts = ;
#interrupt-cells = <3>;
interrupt-parent = <>;
+
+   pgc {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /*
+* As per comment in ATF source code:
+*
+* PCIE1 and PCIE2 share the
+* same reset signal, if we
+* power down PCIE2, PCIE1
+* will be held in reset too.
+*
+* So instead of creating two
+* separate power domains for
+* PCIE1 and PCIE2 we create a
+* link between both and use
+* it as a shared PCIE power
+* domain.
+*/
+   pgc_pcie: power-domain@1 {
+   #power-domain-cells = <0>;
+   reg = ;
+   power-domains = <_pcie2>;
+   };
+
+   pgc_pcie2: power-domain@a {
+   #power-domain-cells = <0>;
+   reg = ;
+   };
+   };
};
 
usdhc1: usdhc@30b4 {
diff --git a/arch/arm/include/asm/arch-imx8m/power-domain.h 
b/arch/arm/include/asm/arch-imx8m/power-domain.h
new file mode 100644
index 00..0f94945894
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8m/power-domain.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2017 NXP
+ */
+
+#ifndef _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+#define _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+
+struct imx8m_power_domain_platdata {
+   int resource_id;
+   int has_pd;
+   struct power_domain pd;
+};
+
+#endif
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index e45731edda..6c87a8a1ef 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -35,6 +35,8 @@ CONFIG_FSL_USDHC=y
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 06bba6220b..7e2d6a90bf 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -23,6 +23,13 @@ config IMX8_POWER_DOMAIN
   Enable support for manipulating NXP i.MX8 on-SoC power domains via 
IPC
   requests to the SCU.
 
+config IMX8M_POWER_DOMAIN
+   bool "Enable i.MX8M power domain driver"
+   depends on POWER_DOMAIN && ARCH_IMX8M
+   help
+ Enable support for manipulating NXP i.MX8M on-SoC power domains via
+ requests to the ATF.
+
 config MTK_POWER_DOMAIN
bool "Enable the MediaTek power domain driver"
depends on POWER_DOMAIN && ARCH_MEDIATEK
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 695aafe17d..4d87d7c7f9 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
+obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
new file mode 100644
index 00..164fb3d31d
--- /dev/null
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2017 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include