From: Liju-Clr Chen Date: Fri, 6 Jan 2023 07:50:33 +0000 (+0800) Subject: refactor(mediatek): change the parameters of LPM API X-Git-Tag: baikal/aarch64/sdk5.10~1^2~262^2~1 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=b0208c73af8b9b6a3286cc846e0715aed6f75c4f;p=arm-tf.git refactor(mediatek): change the parameters of LPM API Change the parameters of the LPM API for further extension. Change-Id: Id8897c256c2118d00c6b9f3e7424ebc6100f02eb Signed-off-by: Liju-Clr Chen --- diff --git a/plat/mediatek/common/lpm/mt_lp_rm.c b/plat/mediatek/common/lpm/mt_lp_rm.c index 807614a72..9f64cbdd2 100644 --- a/plat/mediatek/common/lpm/mt_lp_rm.c +++ b/plat/mediatek/common/lpm/mt_lp_rm.c @@ -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; } diff --git a/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.c b/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.c index f7c53dc34..fe6e59828 100644 --- a/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.c +++ b/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.c @@ -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; } diff --git a/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.h b/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.h index afb3fd9da..793d5e81c 100644 --- a/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.h +++ b/plat/mediatek/drivers/spm/mt8188/mt_spm_cond.h @@ -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 diff --git a/plat/mediatek/include/lpm/mt_lp_rm.h b/plat/mediatek/include/lpm/mt_lp_rm.h index bda3ba168..ce7e5207e 100644 --- a/plat/mediatek/include/lpm/mt_lp_rm.h +++ b/plat/mediatek/include/lpm/mt_lp_rm.h @@ -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; }; diff --git a/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.c b/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.c index a420e16f0..14a84b238 100644 --- a/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.c +++ b/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.c @@ -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; diff --git a/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.h b/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.h index 24c39bac9..28a302022 100644 --- a/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.h +++ b/plat/mediatek/mt8186/drivers/spm/mt_spm_cond.h @@ -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 */ diff --git a/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.c b/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.c index 2d67fdf51..4332b7014 100644 --- a/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.c +++ b/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.c @@ -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; diff --git a/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.h b/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.h index 91ebdd94f..ffd5f3fe5 100644 --- a/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.h +++ b/plat/mediatek/mt8192/drivers/spm/mt_spm_cond.h @@ -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 */ diff --git a/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.c b/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.c index c80faf599..0ca0e1d60 100644 --- a/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.c +++ b/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.c @@ -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; diff --git a/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.h b/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.h index e471b551a..83007af93 100644 --- a/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.h +++ b/plat/mediatek/mt8195/drivers/spm/mt_spm_cond.h @@ -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 */