]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
refactor(mediatek): change the parameters of LPM API
authorLiju-Clr Chen <liju-clr.chen@mediatek.com>
Fri, 6 Jan 2023 07:50:33 +0000 (15:50 +0800)
committerLiju-Clr Chen <liju-clr.chen@mediatek.com>
Wed, 11 Jan 2023 05:37:50 +0000 (13:37 +0800)
Change the parameters of the LPM API for further extension.

Change-Id: Id8897c256c2118d00c6b9f3e7424ebc6100f02eb
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
plat/mediatek/common/lpm/mt_lp_rm.c
plat/mediatek/drivers/spm/mt8188/mt_spm_cond.c
plat/mediatek/drivers/spm/mt8188/mt_spm_cond.h
plat/mediatek/include/lpm/mt_lp_rm.h
plat/mediatek/mt8186/drivers/spm/mt_spm_cond.c
plat/mediatek/mt8186/drivers/spm/mt_spm_cond.h
plat/mediatek/mt8192/drivers/spm/mt_spm_cond.c
plat/mediatek/mt8192/drivers/spm/mt_spm_cond.h
plat/mediatek/mt8195/drivers/spm/mt_spm_cond.c
plat/mediatek/mt8195/drivers/spm/mt_spm_cond.h

index 807614a72bb15b84475434951d479e43d46c6586..9f64cbdd2bec9ef0a75c8ce9ac0b04017e1817ca 100644 (file)
@@ -90,7 +90,7 @@ int mt_lp_rm_find_and_run_constraint(int idx, unsigned int cpuid,
 
        /* If subsys clk/mtcmos is on, add block-resource-off flag */
        if (rm->update != NULL) {
-               res = rm->update(rm->consts, stateid, priv);
+               res = rm->update(rm->consts, plat_mt_rm.count, stateid, priv);
                if (res != 0) {
                        return res;
                }
index f7c53dc34eb0739430294ee06cf0823df57b0a9e..fe6e598287b9308d53ef7e388bcb76518cdf1411 100644 (file)
@@ -187,7 +187,8 @@ unsigned int mt_spm_dump_all_pll(const struct mt_spm_cond_tables *src,
        (!(mmio_read_32(SPM_PWR_STATUS) & mask) && \
         !(mmio_read_32(SPM_PWR_STATUS_2ND) & mask))
 
-int mt_spm_cond_update(struct mt_resource_constraint **con, int stateid, void *priv)
+int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
+                      int stateid, void *priv)
 {
        static const struct {
                uintptr_t en_reg;
@@ -208,11 +209,12 @@ int mt_spm_cond_update(struct mt_resource_constraint **con, int stateid, void *p
                { PLL_APLL5, PLL_BIT_APLL5 },
        };
 
-       int i, res;
+       int res;
+       unsigned int i;
        struct mt_resource_constraint *const *_con;
 
        /* read all cg state */
-       for (i = 0; i < PLAT_SPM_COND_MAX; i++) {
+       for (i = 0U; i < PLAT_SPM_COND_MAX; i++) {
                spm_cond_t.table_cg[i] = 0U;
 
                /* check mtcmos, if off set idle_value and clk to 0 disable */
@@ -229,14 +231,14 @@ int mt_spm_cond_update(struct mt_resource_constraint **con, int stateid, void *p
        }
 
        spm_cond_t.table_pll = 0U;
-       for (i = 0; i < ARRAY_SIZE(plls); i++) {
+       for (i = 0U; i < ARRAY_SIZE(plls); i++) {
                if ((mmio_read_32(plls[i].en_reg) & BIT(9)) != 0U) {
                        spm_cond_t.table_pll |= plls[i].pll_b;
                }
        }
 
        spm_cond_t.priv = priv;
-       for (_con = con; *_con != NULL ; _con++) {
+       for (i = 0U, _con = con; (*_con != NULL) && (i < num); _con++, i++) {
                if ((*_con)->update == NULL) {
                        continue;
                }
index afb3fd9da3f7d1b5ffd051fd0e61e9f75cb91236..793d5e81cd3151988b083ae9dfa3c6bdf109ab0a 100644 (file)
@@ -87,6 +87,7 @@ unsigned int mt_spm_cond_check(const struct mt_spm_cond_tables *src,
 unsigned int mt_spm_dump_all_pll(const struct mt_spm_cond_tables *src,
                                 const struct mt_spm_cond_tables *dest,
                                 struct mt_spm_cond_tables *res);
-int mt_spm_cond_update(struct mt_resource_constraint **con, int stateid, void *priv);
+int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
+                      int stateid, void *priv);
 
 #endif
index bda3ba168e9279a435adff1c0213524ed5be6b6e..ce7e5207e13067a76870ab77261a6d51d6539b25 100644 (file)
@@ -49,7 +49,7 @@ struct mt_resource_constraint {
 };
 
 struct mt_resource_manager {
-       int (*update)(struct mt_resource_constraint **con,
+       int (*update)(struct mt_resource_constraint **con, unsigned int num,
                      int stateid, void *priv);
        struct mt_resource_constraint **consts;
 };
index a420e16f0810a3a832094dfaf089783997a735d6..14a84b2389305570f85056f44d42483513c066df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2022-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -148,7 +148,8 @@ unsigned int mt_spm_cond_check(int state_id,
        (((mmio_read_32(SPM_PWR_STATUS) & mask) == 0U) &&       \
         ((mmio_read_32(SPM_PWR_STATUS_2ND) & mask) == 0U))
 
-int mt_spm_cond_update(struct mt_resource_constraint **con, int stateid, void *priv)
+int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
+                      int stateid, void *priv)
 {
        int res;
        uint32_t i;
index 24c39bac931ab1005dca789b24b41a20234a97f1..28a302022bb3d0d5294c0b9009c58a06ed65fe8e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2022-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -54,7 +54,7 @@ extern unsigned int mt_spm_cond_check(int state_id,
                                      const struct mt_spm_cond_tables *dest,
                                      struct mt_spm_cond_tables *res);
 
-extern int mt_spm_cond_update(struct mt_resource_constraint **con,
+extern int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
                              int stateid, void *priv);
 
 #endif /* MT_SPM_CONDIT_H */
index 2d67fdf5125b99f9dcd04b544dff6a9035f1fa70..4332b7014414cd12e203f9dc49b0ca11ca96602e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -155,7 +155,7 @@ unsigned int mt_spm_cond_check(int state_id,
        (((mmio_read_32(SPM_PWR_STATUS) & mask) == 0U) &&       \
         ((mmio_read_32(SPM_PWR_STATUS_2ND) & mask) == 0U))
 
-int mt_spm_cond_update(struct mt_resource_constraint **con,
+int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
                       int stateid, void *priv)
 {
        int res;
index 91ebdd94f8f8079b75584a7b01c7a92863901466..ffd5f3fe567c7449d5e43757b2e7054d1fbc8354 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -51,6 +51,6 @@ extern unsigned int mt_spm_cond_check(int state_id,
                                      const struct mt_spm_cond_tables *src,
                                      const struct mt_spm_cond_tables *dest,
                                      struct mt_spm_cond_tables *res);
-extern int mt_spm_cond_update(struct mt_resource_constraint **con,
+extern int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
                              int stateid, void *priv);
 #endif /* MT_SPM_CONDIT_H */
index c80faf59911ec8929a564efa351c73adb5886839..0ca0e1d607ddb64fa4a05811502f4823f595c3df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2021-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -171,7 +171,7 @@ unsigned int mt_spm_cond_check(int state_id,
        (((mmio_read_32(SPM_PWR_STATUS) & mask) == 0U) &&       \
         ((mmio_read_32(SPM_PWR_STATUS_2ND) & mask) == 0U))
 
-int mt_spm_cond_update(struct mt_resource_constraint **con,
+int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
                       int stateid, void *priv)
 {
        int res;
index e471b551a6c0e6f87b4a11ca1812ee7639818e5e..83007af93517be7b2ed53e23ce08ffe41f694fe5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2021-2023, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -68,6 +68,6 @@ extern unsigned int mt_spm_cond_check(int state_id,
                                      const struct mt_spm_cond_tables *src,
                                      const struct mt_spm_cond_tables *dest,
                                      struct mt_spm_cond_tables *res);
-extern int mt_spm_cond_update(struct mt_resource_constraint **con,
+extern int mt_spm_cond_update(struct mt_resource_constraint **con, unsigned int num,
                              int stateid, void *priv);
 #endif /* MT_SPM_CONDIT_H */