From db4f24026ea2aed5d7ea17718471b849f0bbe8de Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Wed, 22 Jun 2022 21:18:36 -0700 Subject: [PATCH] tegra: hwpm: Rename slcg HAls to cg HALs There are different clock gating types. Currently, t234 HWPM only supports SLCG, however it is possible that future chips will include more CG features. Rename disable_slcg() and enable_slcg() HALs to disable_cg() and enable_cg() respectively. Setting CG features to enabled mode is a PROD value. Hence, call enable_cg() from init_prod_values(). To make sure that the CG features are disabled during profiling session, rearrange init_prod_value() function call before disable_cg(). Bug 3682605 Change-Id: I3426603de14a14bce37880a8c47833ae3203665e Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2734039 (cherry picked from commit eb5cacc67a551714d453465d4ef070971718375a) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2737531 Tested-by: mobile promotions Reviewed-by: mobile promotions --- common/tegra_hwpm_init.c | 18 +++++++++--------- hal/t234/t234_hwpm_aperture_utils.c | 11 +++++++++-- hal/t234/t234_hwpm_interface_utils.c | 12 ++++++------ hal/t234/t234_hwpm_internal.h | 4 ++-- include/tegra_hwpm.h | 4 ++-- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/common/tegra_hwpm_init.c b/common/tegra_hwpm_init.c index 2d4cefb..85abfda 100644 --- a/common/tegra_hwpm_init.c +++ b/common/tegra_hwpm_init.c @@ -183,13 +183,6 @@ int tegra_hwpm_setup_hw(struct tegra_soc_hwpm *hwpm) goto fail; } - /* Disable SLCG */ - ret = hwpm->active_chip->disable_slcg(hwpm); - if (ret < 0) { - tegra_hwpm_err(hwpm, "Unable to disable SLCG"); - goto fail; - } - /* Program PROD values */ ret = hwpm->active_chip->init_prod_values(hwpm); if (ret < 0) { @@ -197,6 +190,13 @@ int tegra_hwpm_setup_hw(struct tegra_soc_hwpm *hwpm) goto fail; } + /* Disable SLCG */ + ret = hwpm->active_chip->disable_cg(hwpm); + if (ret < 0) { + tegra_hwpm_err(hwpm, "Unable to disable SLCG"); + goto fail; + } + return 0; fail: return ret; @@ -215,8 +215,8 @@ int tegra_hwpm_release_hw(struct tegra_soc_hwpm *hwpm) tegra_hwpm_fn(hwpm, " "); - /* Enable SLCG */ - ret = hwpm->active_chip->enable_slcg(hwpm); + /* Enable CG */ + ret = hwpm->active_chip->enable_cg(hwpm); if (ret < 0) { tegra_hwpm_err(hwpm, "Unable to enable SLCG"); goto fail; diff --git a/hal/t234/t234_hwpm_aperture_utils.c b/hal/t234/t234_hwpm_aperture_utils.c index b5141d8..9e18264 100644 --- a/hal/t234/t234_hwpm_aperture_utils.c +++ b/hal/t234/t234_hwpm_aperture_utils.c @@ -198,10 +198,17 @@ int t234_hwpm_init_prod_values(struct tegra_soc_hwpm *hwpm) return err; } + /* CG enable is expected PROD value */ + err = hwpm->active_chip->enable_cg(hwpm); + if (err < 0) { + tegra_hwpm_err(hwpm, "Unable to enable SLCG"); + return err; + } + return 0; } -int t234_hwpm_disable_slcg(struct tegra_soc_hwpm *hwpm) +int t234_hwpm_disable_cg(struct tegra_soc_hwpm *hwpm) { int err = 0; u32 field_mask = 0U; @@ -257,7 +264,7 @@ int t234_hwpm_disable_slcg(struct tegra_soc_hwpm *hwpm) return 0; } -int t234_hwpm_enable_slcg(struct tegra_soc_hwpm *hwpm) +int t234_hwpm_enable_cg(struct tegra_soc_hwpm *hwpm) { int err = 0; u32 reg_val = 0U; diff --git a/hal/t234/t234_hwpm_interface_utils.c b/hal/t234/t234_hwpm_interface_utils.c index c3a96b8..befc807 100644 --- a/hal/t234/t234_hwpm_interface_utils.c +++ b/hal/t234/t234_hwpm_interface_utils.c @@ -38,8 +38,8 @@ static struct tegra_soc_hwpm_chip t234_chip_info = { .get_resource_info = t234_hwpm_get_resource_info, .init_prod_values = t234_hwpm_init_prod_values, - .disable_slcg = t234_hwpm_disable_slcg, - .enable_slcg = t234_hwpm_enable_slcg, + .disable_cg = t234_hwpm_disable_cg, + .enable_cg = t234_hwpm_enable_cg, .reserve_rtr = tegra_hwpm_reserve_rtr, .release_rtr = tegra_hwpm_release_rtr, @@ -118,13 +118,13 @@ static bool t234_hwpm_validate_hals(struct tegra_soc_hwpm *hwpm) return false; } - if (hwpm->active_chip->disable_slcg == NULL) { - tegra_hwpm_err(hwpm, "disable_slcg uninitialized"); + if (hwpm->active_chip->disable_cg == NULL) { + tegra_hwpm_err(hwpm, "disable_cg uninitialized"); return false; } - if (hwpm->active_chip->enable_slcg == NULL) { - tegra_hwpm_err(hwpm, "enable_slcg uninitialized"); + if (hwpm->active_chip->enable_cg == NULL) { + tegra_hwpm_err(hwpm, "enable_cg uninitialized"); return false; } diff --git a/hal/t234/t234_hwpm_internal.h b/hal/t234/t234_hwpm_internal.h index 5851e65..c1383e1 100644 --- a/hal/t234/t234_hwpm_internal.h +++ b/hal/t234/t234_hwpm_internal.h @@ -86,8 +86,8 @@ int t234_hwpm_get_resource_info(struct tegra_soc_hwpm *hwpm, u32 resource_enum, u8 *status); int t234_hwpm_init_prod_values(struct tegra_soc_hwpm *hwpm); -int t234_hwpm_disable_slcg(struct tegra_soc_hwpm *hwpm); -int t234_hwpm_enable_slcg(struct tegra_soc_hwpm *hwpm); +int t234_hwpm_disable_cg(struct tegra_soc_hwpm *hwpm); +int t234_hwpm_enable_cg(struct tegra_soc_hwpm *hwpm); int t234_hwpm_disable_triggers(struct tegra_soc_hwpm *hwpm); int t234_hwpm_perfmon_enable(struct tegra_soc_hwpm *hwpm, diff --git a/include/tegra_hwpm.h b/include/tegra_hwpm.h index 7194ec2..26aad8a 100644 --- a/include/tegra_hwpm.h +++ b/include/tegra_hwpm.h @@ -361,8 +361,8 @@ struct tegra_soc_hwpm_chip { u32 resource_enum, u8 *status); int (*init_prod_values)(struct tegra_soc_hwpm *hwpm); - int (*disable_slcg)(struct tegra_soc_hwpm *hwpm); - int (*enable_slcg)(struct tegra_soc_hwpm *hwpm); + int (*disable_cg)(struct tegra_soc_hwpm *hwpm); + int (*enable_cg)(struct tegra_soc_hwpm *hwpm); int (*reserve_rtr)(struct tegra_soc_hwpm *hwpm); int (*release_rtr)(struct tegra_soc_hwpm *hwpm);