MLK-18161-12 imx8qm/imx8qxp - Power down devices enabled by uboot before launching...
authorYe Li <ye.li@nxp.com>
Thu, 19 Apr 2018 02:34:11 +0000 (19:34 -0700)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 09:38:20 +0000 (02:38 -0700)
Make sure that all devices that are powered up by uboot
are powered down before bringing up kernel.
Else the subsystem/device will never be powered down by SCFW even though
from the kernel's point of view it should be powered down.

Benefiting from power domain driver, We have implemented the function "power_off_pd_devices"
to power off all active devices. No need to explicitly power off them in board_quiesce_devices.

Signed-off-by: Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 3ab7cc26500eb78407bc6454a48f4d5f0ebf4f60)

arch/arm/include/asm/arch-imx8/sys_proto.h
arch/arm/mach-imx/imx8/cpu.c
board/freescale/imx8qm_arm2/imx8qm_arm2.c
board/freescale/imx8qm_mek/imx8qm_mek.c
board/freescale/imx8qxp_arm2/imx8qxp_arm2.c
board/freescale/imx8qxp_mek/imx8qxp_mek.c

index 73ffaba..fd00e8f 100644 (file)
@@ -17,3 +17,4 @@ struct pass_over_info_t {
 
 enum boot_device get_boot_device(void);
 int print_bootinfo(void);
+void power_off_pd_devices(const char* permanent_on_devices[], int size);
index ad6238d..47dc225 100644 (file)
@@ -13,6 +13,8 @@
 #include <errno.h>
 #include <asm/arch/sci/sci.h>
 #include <power-domain.h>
+#include <dm/device.h>
+#include <dm/uclass-internal.h>
 #include <thermal.h>
 #include <elf.h>
 #include <asm/arch/sid.h>
@@ -1347,3 +1349,34 @@ U_BOOT_DRIVER(cpu_imx8_drv) = {
        .flags          = DM_FLAG_PRE_RELOC,
 };
 #endif
+
+static bool check_device_power_off(struct udevice *dev,
+       const char* permanent_on_devices[], int size)
+{
+       int i;
+
+       for (i = 0; i < size; i++) {
+               if (!strcmp(dev->name, permanent_on_devices[i]))
+                       return false;
+       }
+
+       return true;
+}
+
+void power_off_pd_devices(const char* permanent_on_devices[], int size)
+{
+       struct udevice *dev;
+       struct power_domain pd;
+
+       for (uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev); dev;
+               uclass_find_next_device(&dev)) {
+
+               if (device_active(dev)) {
+                       /* Power off active pd devices except the permanent power on devices */
+                       if (check_device_power_off(dev, permanent_on_devices, size)) {
+                               pd.dev = dev;
+                               power_domain_off(&pd);
+                       }
+               }
+       }
+}
index 88564dc..3bca6a6 100644 (file)
@@ -29,6 +29,7 @@
 #include <power-domain.h>
 #include <cdns3-uboot.h>
 #include <asm/arch/lpcg.h>
+#include <bootm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -569,6 +570,15 @@ int board_init(void)
        return 0;
 }
 
+void board_quiesce_devices()
+{
+       const char *power_on_devices[] = {
+               "dma_lpuart0",
+       };
+
+       power_off_pd_devices(power_on_devices, ARRAY_SIZE(power_on_devices));
+}
+
 void detail_board_ddr_info(void)
 {
        puts("\nDDR    ");
index a388a2e..fbf1402 100644 (file)
@@ -29,6 +29,7 @@
 #include "../common/tcpc.h"
 #include <cdns3-uboot.h>
 #include <asm/arch/lpcg.h>
+#include <bootm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -444,6 +445,15 @@ int board_init(void)
        return 0;
 }
 
+void board_quiesce_devices(void)
+{
+       const char *power_on_devices[] = {
+               "dma_lpuart0",
+       };
+
+       power_off_pd_devices(power_on_devices, ARRAY_SIZE(power_on_devices));
+}
+
 void detail_board_ddr_info(void)
 {
        puts("\nDDR    ");
index 8164e77..e8b3d4a 100644 (file)
@@ -31,6 +31,7 @@
 #include <power-domain.h>
 #include <cdns3-uboot.h>
 #include <asm/arch/lpcg.h>
+#include <bootm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -574,6 +575,19 @@ int board_init(void)
        return 0;
 }
 
+void board_quiesce_devices()
+{
+       const char *power_on_devices[] = {
+               "dma_lpuart0",
+
+               /* HIFI DSP boot */
+               "audio_sai0",
+               "audio_ocram",
+       };
+
+       power_off_pd_devices(power_on_devices, ARRAY_SIZE(power_on_devices));
+}
+
 void detail_board_ddr_info(void)
 {
        puts("\nDDR    ");
index 9c5e248..a4b7da7 100644 (file)
@@ -23,6 +23,7 @@
 #include "../common/tcpc.h"
 #include <cdns3-uboot.h>
 #include <asm/arch/lpcg.h>
+#include <bootm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -455,6 +456,19 @@ int board_init(void)
        return 0;
 }
 
+void board_quiesce_devices()
+{
+       const char *power_on_devices[] = {
+               "dma_lpuart0",
+
+               /* HIFI DSP boot */
+               "audio_sai0",
+               "audio_ocram",
+       };
+
+       power_off_pd_devices(power_on_devices, ARRAY_SIZE(power_on_devices));
+}
+
 void detail_board_ddr_info(void)
 {
        puts("\nDDR    ");