clk: qcom: clk-rcg2: Update logic to calculate D value for RCG
Subsystems (3)
PATCH v2 1/2 clk: qcom: clk-rcg2: Update logic to calculate D value for RCG
The display pixel clock has a requirement on certain newer platforms to support M/N as (2/3) and the final D value calculated results in underflow errors.
As the current implementation does not check for D value is within the accepted range for a given M & N value. Update the logic to calculate the final D value based on the range.
---
[v2]
* Update the if else check with clamp.
* Typecast the f->m to u32.
drivers/clk/qcom/clk-rcg2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-rcg2.c +11 -2
@@ -264,7 +264,7 @@ static int clk_rcg2_determine_floor_rate(struct clk_hw *hw,static int __clk_rcg2_configure (struct clk_rcg2 *rcg,const struct freq_tbl *f) { -u32 cfg, mask; +u32 cfg, mask, d_val, not2d_val, n_minus_m;struct clk_hw *hw = &rcg->clkr.hw;int ret, index =qcom_find_src_index (hw, rcg->parent_map, f->src);
@@ -283,8 +283,17 @@ static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)if (ret)return ret; +/* Calculate 2d value */ + d_val = f->n; + + n_minus_m = f->n - f->m; + n_minus_m *=2 ; + + d_val =clamp (d_val, (u32 )f->m, n_minus_m); + not2d_val = ~d_val & mask; + ret =regmap_update_bits (rcg->clkr.regmap, -RCG_D_OFFSET (rcg), mask, ~f->n); +RCG_D_OFFSET (rcg), mask, not2d_val);if (ret)return ret; }
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
PATCH v2 2/2 clk: qcom: clk-rcg2: Update the frac table for pixel clock
Support the new numerator and denominator for pixel clock.
--- drivers/clk/qcom/clk-rcg2.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/clk-rcg2.c +1 -0
@@ -729,6 +729,7 @@ static const struct frac_entry frac_table_pixel[] = { { 2, 9 }, { 4, 9 }, { 1, 1 }, + { 2, 3 }, { } };
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
Stephen Boyd
maintainerRe: [PATCH v2 2/2] clk: qcom: clk-rcg2: Update the frac table for pixel clock
Quoting Taniya Das (2022-02-21 10:13:22)
Quoted 1 line
Support the new numerator and denominator for pixel clock.
What SoCs does this patch affect? It would be good to know if it's fixing something wrong with existing SoC support or if it's only for future SoCs that will want to set a 2/3 divide.
Quoted 4 lines
Fixes 99cbd064b059f ("clk: qcom: Support display RCG clocks")Signed-off-by Taniya Das <[email protected]>Reviewed-by Stephen Boyd <[email protected]>
Stephen Boyd
maintainerQuoting Taniya Das (2022-02-21 10:13:21)
Quoted 31 lines
The display pixel clock has a requirement on certain newer platforms to support M/N as (2/3) and the final D value calculated results in underflow errors.
As the current implementation does not check for D value is within the accepted range for a given M & N value. Update the logic to calculate the final D value based on the range.Fixes 99cbd064b059f ("clk: qcom: Support display RCG clocks")Signed-off-by Taniya Das <[email protected]>---
[v2]
* Update the if else check with clamp.
* Typecast thef->mto u32.drivers/clk/qcom/clk-rcg2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/clk/qcom/clk-rcg2.c +1
-1@@ -264,7 +264,7 @@ static int clk_rcg2_determine_floor_rate(struct clk_hw *hw,static int __clk_rcg2_configure (struct clk_rcg2 *rcg,const struct freq_tbl *f) { -u32 cfg, mask; +u32 cfg, mask, d_val, not2d_val, n_minus_m;struct clk_hw *hw = &rcg->clkr.hw;int ret, index =qcom_find_src_index (hw, rcg->parent_map, f->src);
drivers/clk/qcom/clk-rcg2.c static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f) · line 292
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +7
-0@@ -283,8 +283,17 @@ static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)if (ret)return ret; +/* Calculate 2d value */ + d_val = f->n; + + n_minus_m = f->n - f->m; + n_minus_m *=2 ; + + d_val =clamp (d_val, (u32 )f->m, n_minus_m);
Use clamp_t(u32, d_val, f->m, n_minus_m)
Quoted 6 lines
drivers/clk/qcom/clk-rcg2.c +3
-1+ not2d_val = ~d_val & mask; + ret =regmap_update_bits (rcg->clkr.regmap, -RCG_D_OFFSET (rcg), mask, ~f->n); +RCG_D_OFFSET (rcg), mask, not2d_val);if (ret)