Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 6e13ecb

Browse files
awujekSasha Levin
authored andcommitted
clk: si5341: fix reported clk_rate when output divider is 2
[ Upstream commit 2a8b539 ] SI5341_OUT_CFG_RDIV_FORCE2 shall be checked first to distinguish whether a divider for a given output is set to 2 (SI5341_OUT_CFG_RDIV_FORCE2 is set) or the output is disabled (SI5341_OUT_CFG_RDIV_FORCE2 not set, SI5341_OUT_R_REG is set 0). Before the change, divider set to 2 (SI5341_OUT_R_REG set to 0) was interpreted as output is disabled. Signed-off-by: Adam Wujek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Robert Hancock <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8cdc9af commit 6e13ecb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/clk/clk-si5341.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,15 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw,
798798
u32 r_divider;
799799
u8 r[3];
800800

801+
err = regmap_read(output->data->regmap,
802+
SI5341_OUT_CONFIG(output), &val);
803+
if (err < 0)
804+
return err;
805+
806+
/* If SI5341_OUT_CFG_RDIV_FORCE2 is set, r_divider is 2 */
807+
if (val & SI5341_OUT_CFG_RDIV_FORCE2)
808+
return parent_rate / 2;
809+
801810
err = regmap_bulk_read(output->data->regmap,
802811
SI5341_OUT_R_REG(output), r, 3);
803812
if (err < 0)
@@ -814,13 +823,6 @@ static unsigned long si5341_output_clk_recalc_rate(struct clk_hw *hw,
814823
r_divider += 1;
815824
r_divider <<= 1;
816825

817-
err = regmap_read(output->data->regmap,
818-
SI5341_OUT_CONFIG(output), &val);
819-
if (err < 0)
820-
return err;
821-
822-
if (val & SI5341_OUT_CFG_RDIV_FORCE2)
823-
r_divider = 2;
824826

825827
return parent_rate / r_divider;
826828
}

0 commit comments

Comments
 (0)