From: Ye Li <ye...@nxp.com>

Since ATF power domain will hold the enable counter for each power domain,
We need to power off them before entering kernel to avoid this
power domain can't be really powered off.

Signed-off-by: Ye Li <ye...@nxp.com>
Signed-off-by: Peng Fan <peng....@nxp.com>
---
 board/freescale/imx8ulp_evk/imx8ulp_evk.c | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/board/freescale/imx8ulp_evk/imx8ulp_evk.c 
b/board/freescale/imx8ulp_evk/imx8ulp_evk.c
index b61a4cfbe8d..1bd308148f3 100644
--- a/board/freescale/imx8ulp_evk/imx8ulp_evk.c
+++ b/board/freescale/imx8ulp_evk/imx8ulp_evk.c
@@ -13,6 +13,8 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/gpio.h>
+#include <power-domain.h>
+#include <dt-bindings/power/imx8ulp-power.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -129,3 +131,31 @@ int board_late_init(void)
 {
        return 0;
 }
+
+void board_quiesce_devices(void)
+{
+       /* Disable the power domains may used in u-boot before entering kernel 
*/
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+       struct udevice *scmi_devpd;
+       int ret, i;
+       struct power_domain pd;
+       ulong ids[] = { IMX8ULP_PD_FLEXSPI2, IMX8ULP_PD_USB0, IMX8ULP_PD_USDHC0,
+                       IMX8ULP_PD_USDHC1, IMX8ULP_PD_USDHC2_USB1, 
IMX8ULP_PD_DCNANO,
+                       IMX8ULP_PD_MIPI_DSI };
+
+       ret = uclass_get_device(UCLASS_POWER_DOMAIN, 0, &scmi_devpd);
+       if (ret) {
+               printf("Cannot get scmi devpd: err=%d\n", ret);
+               return;
+       }
+
+       pd.dev = scmi_devpd;
+
+       for (i = 0; i < ARRAY_SIZE(ids); i++) {
+               pd.id = ids[i];
+               ret = power_domain_off(&pd);
+               if (ret)
+                       printf("power_domain_off %lu failed: err=%d\n", ids[i], 
ret);
+       }
+#endif
+}
-- 
2.35.1

Reply via email to