]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
zynqmp: pm: Update PM version and support PM version check
authorRajan Vaja <rajan.vaja@xilinx.com>
Fri, 5 Oct 2018 11:42:57 +0000 (04:42 -0700)
committerRajan Vaja <rajan.vaja@xilinx.com>
Tue, 12 Jan 2021 05:34:40 +0000 (21:34 -0800)
ATF is not checking PM version. Add version check in such
a way that it is compatible with current and newer version
of PM.

Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com>
Change-Id: Ia095d118121e6f75e8d320e87d5e2018068fa079

plat/xilinx/zynqmp/pm_service/pm_defs.h
plat/xilinx/zynqmp/pm_service/pm_svc_main.c
plat/xilinx/zynqmp/sip_svc_setup.c

index ee31c9267bb4a31d957129b0929a8eab0104c514..3324431ddd9effe0ae4d8985fc8cf58659c28a10 100644 (file)
@@ -18,7 +18,7 @@
  * (PM_VERSION_MAJOR << 16) | PM_VERSION_MINOR
  */
 #define PM_VERSION_MAJOR       1
-#define PM_VERSION_MINOR       0
+#define PM_VERSION_MINOR       1
 
 #define PM_VERSION     ((PM_VERSION_MAJOR << 16) | PM_VERSION_MINOR)
 
index a4bc1ac0809c0bb9cbdc44e8f7b9f259ed8a309b..49824c70d293f5781105ec84ea07c497e077fdb7 100644 (file)
@@ -29,8 +29,8 @@
 #define PM_SET_SUSPEND_MODE    0xa02
 #define PM_GET_TRUSTZONE_VERSION       0xa03
 
-/* !0 - UP, 0 - DOWN */
-static int32_t pm_up = 0;
+/* pm_up = !0 - UP, pm_up = 0 - DOWN */
+static int32_t pm_up, ipi_irq_flag;
 
 #if ZYNQMP_WDT_RESTART
 static spinlock_t inc_lock;
@@ -210,6 +210,15 @@ int pm_setup(void)
 
        status = pm_ipi_init(primary_proc);
 
+       ret = pm_get_api_version(&pm_ctx.api_version);
+       if (pm_ctx.api_version < PM_VERSION) {
+               ERROR("BL31: Platform Management API version error. Expected: "
+                     "v%d.%d - Found: v%d.%d\n", PM_VERSION_MAJOR,
+                     PM_VERSION_MINOR, pm_ctx.api_version >> 16,
+                     pm_ctx.api_version & 0xFFFF);
+               return -EINVAL;
+       }
+
 #if ZYNQMP_WDT_RESTART
        status = pm_wdt_restart_setup();
        if (status)
@@ -321,22 +330,21 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_GET_API_VERSION:
                /* Check is PM API version already verified */
-               if (pm_ctx.api_version == PM_VERSION) {
+               if (pm_ctx.api_version >= PM_VERSION) {
+                       if (!ipi_irq_flag) {
+                               /*
+                                * Enable IPI IRQ
+                                * assume the rich OS is OK to handle callback IRQs now.
+                                * Even if we were wrong, it would not enable the IRQ in
+                                * the GIC.
+                                */
+                               pm_ipi_irq_enable(primary_proc);
+                               ipi_irq_flag = 1;
+                       }
                        SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
-                                ((uint64_t)PM_VERSION << 32));
+                                ((uint64_t)pm_ctx.api_version << 32));
                }
 
-               ret = pm_get_api_version(&pm_ctx.api_version);
-               /*
-                * Enable IPI IRQ
-                * assume the rich OS is OK to handle callback IRQs now.
-                * Even if we were wrong, it would not enable the IRQ in
-                * the GIC.
-                */
-               pm_ipi_irq_enable(primary_proc);
-               SMC_RET1(handle, (uint64_t)ret |
-                        ((uint64_t)pm_ctx.api_version << 32));
-
        case PM_SET_CONFIGURATION:
                ret = pm_set_configuration(pm_arg[0]);
                SMC_RET1(handle, (uint64_t)ret);
index 4c29da2317303798fa70cc1a3dfd8b6733e2025e..114da33d63928337d6bf05839d2bdfef7e7df388 100644 (file)
@@ -44,9 +44,7 @@ DEFINE_SVC_UUID2(zynqmp_sip_uuid,
 static int32_t sip_svc_setup(void)
 {
        /* PM implementation as SiP Service */
-       pm_setup();
-
-       return 0;
+       return pm_setup();
 }
 
 /**