ARM: trusted_foundations: Make prepare_idle call to take mode argument
authorDmitry Osipenko <digetx@gmail.com>
Sun, 17 Mar 2019 22:52:05 +0000 (01:52 +0300)
committerThierry Reding <treding@nvidia.com>
Tue, 9 Apr 2019 14:36:19 +0000 (16:36 +0200)
The Trusted Foundations firmware call varies depending on the required
suspend-mode. Make the firmware API to take the mode argument in order
to expose all of the modes to firmware user.

Tested-by: Robert Yang <decatf@gmail.com>
Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
arch/arm/firmware/trusted_foundations.c
arch/arm/include/asm/firmware.h
arch/arm/include/asm/trusted_foundations.h
arch/arm/mach-tegra/cpuidle-tegra114.c

index d7ac051..720904a 100644 (file)
@@ -67,9 +67,34 @@ static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
        return 0;
 }
 
-static int tf_prepare_idle(void)
+static int tf_prepare_idle(unsigned long mode)
 {
-       tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, cpu_boot_addr);
+       switch (mode) {
+       case TF_PM_MODE_LP0:
+               tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S3, cpu_boot_addr);
+               break;
+
+       case TF_PM_MODE_LP1:
+               tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2, cpu_boot_addr);
+               break;
+
+       case TF_PM_MODE_LP1_NO_MC_CLK:
+               tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2_NO_MC_CLK,
+                              cpu_boot_addr);
+               break;
+
+       case TF_PM_MODE_LP2:
+               tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1, cpu_boot_addr);
+               break;
+
+       case TF_PM_MODE_LP2_NOFLUSH_L2:
+               tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2,
+                              cpu_boot_addr);
+               break;
+
+       default:
+               return -EINVAL;
+       }
 
        return 0;
 }
index 34c1d96..6698272 100644 (file)
@@ -24,7 +24,7 @@ struct firmware_ops {
        /*
         * Inform the firmware we intend to enter CPU idle mode
         */
-       int (*prepare_idle)(void);
+       int (*prepare_idle)(unsigned long mode);
        /*
         * Enters CPU idle mode
         */
index 9e6a41e..201ceb2 100644 (file)
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/outercache.h>
 
+#define TF_PM_MODE_LP0                 0
+#define TF_PM_MODE_LP1                 1
+#define TF_PM_MODE_LP1_NO_MC_CLK       2
+#define TF_PM_MODE_LP2                 3
+#define TF_PM_MODE_LP2_NOFLUSH_L2      4
+
 struct trusted_foundations_platform_data {
        unsigned int version_major;
        unsigned int version_minor;
index e3fbcfe..3b9af47 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/cpuidle.h>
 #include <asm/smp_plat.h>
 #include <asm/suspend.h>
+#include <asm/trusted_foundations.h>
 #include <asm/psci.h>
 
 #include "cpuidle.h"
@@ -46,7 +47,7 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev,
        tegra_set_cpu_in_lp2();
        cpu_pm_enter();
 
-       call_firmware_op(prepare_idle);
+       call_firmware_op(prepare_idle, TF_PM_MODE_LP2_NOFLUSH_L2);
 
        /* Do suspend by ourselves if the firmware does not implement it */
        if (call_firmware_op(do_idle, 0) == -ENOSYS)