Skip to contentSkip to conversation

clk: tegra: clk-dfll: scale force_val with coefficient according to whether cg_scale is set

PATCH In review Alex Tran 2 participants 2 messages Oct 26, 2025 – Nov 11, 2025

Subsystems (3)
lore
Share & tools
lore

Alex Tran

author
#0 lore raw

PATCH 1/1 clk: tegra: clk-dfll: scale force_val with coefficient according to whether cg_scale is set

force_val was hard coded to use a coefficient of 128, regardless of the cg_scale configuration. This should instead match the DFLL_PARAMS_CG_SCALE bit, use a coefficient of 128 when cg_scale is set, or 1 when not set.

---
 drivers/clk/tegra/clk-dfll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/tegra/clk-dfll.c +1 -1
index 22dc29432eff..3362983eedcf 100644
@@ -882,7 +882,7 @@ static void dfll_set_frequency_request(struct tegra_dfll *td,
 {
 	u32 val = 0;
 	int force_val;
-	int coef = 128; /* FIXME: td->cg_scale? */
+	int coef = td->cg_scale ? 128 : 1;
 
 	force_val = (req->lut_index - td->lut_safe) * coef / td->cg;
 	force_val = clamp(force_val, FORCE_MIN, FORCE_MAX);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 16 lines · Alex Tran

force_val was hard coded to use a coefficient of 128, regardless of the cg_scale configuration. This should instead match the DFLL_PARAMS_CG_SCALE bit, use a coefficient of 128 when cg_scale is set, or 1 when not set.

---
 drivers/clk/tegra/clk-dfll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/tegra/clk-dfll.c +0 -0
index 22dc29432eff..3362983eedcf 100644

drivers/clk/tegra/clk-dfll.c static void dfll_set_frequency_request(struct tegra_dfll *td, · line 888

Quoted 8 lines
drivers/clk/tegra/clk-dfll.c +1 -1
@@ -882,7 +882,7 @@ static void dfll_set_frequency_request(struct tegra_dfll *td,
 {
 	u32 val = 0;
 	int force_val;
-	int coef = 128; /* FIXME: td->cg_scale? */
+	int coef = td->cg_scale ? 128 : 1;
 
 	force_val = (req->lut_index - td->lut_safe) * coef / td->cg;
 	force_val = clamp(force_val, FORCE_MIN, FORCE_MAX);

Are you seeing some concrete issue that this is fixing? While the current code indeed doesn't look correct, it matches what the downstream kernels do. A quick grep doesn't find any device trees that set 'nvidia,cg-scale', so this patch would change the behavior from 128 to 1, and no longer be aligned with downstream releases.

Mikko