Skip to content

Commit 8ca011e

Browse files
committed
clk: bcm-2835: Remove rounding up the dividers
The driver, once it found a divider, tries to round it up by increasing the least significant bit of the fractional part by one when the round_up argument is set and there's a remainder. However, since it increases the divider it will actually reduce the clock rate below what we were asking for, leading to issues with clk_set_min_rate() that will complain that our rounded clock rate is below the minimum of the rate. Since the dividers are fairly precise already, let's remove that part so that we can have clk_set_min_rate() working. This is effectively a revert of 9c95b32 ("clk: bcm2835: add a round up ability to the clock divisor"). Fixes: 9c95b32 ("clk: bcm2835: add a round up ability to the clock divisor") Signed-off-by: Maxime Ripard <maxime@cerno.tech> Acked-by: Stephen Boyd <sboyd@kernel.org> Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org> Tested-by: Nicolas Saenz Julienne <nsaenz@kernel.org> # boot and basic functionality Tested-by: Michael Stapelberg <michael@stapelberg.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20210922125419.4125779-3-maxime@cerno.tech
1 parent 5517357 commit 8ca011e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ static int bcm2835_clock_is_on(struct clk_hw *hw)
932932

933933
static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
934934
unsigned long rate,
935-
unsigned long parent_rate,
936-
bool round_up)
935+
unsigned long parent_rate)
937936
{
938937
struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
939938
const struct bcm2835_clock_data *data = clock->data;
@@ -945,10 +944,6 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
945944

946945
rem = do_div(temp, rate);
947946
div = temp;
948-
949-
/* Round up and mask off the unused bits */
950-
if (round_up && ((div & unused_frac_mask) != 0 || rem != 0))
951-
div += unused_frac_mask + 1;
952947
div &= ~unused_frac_mask;
953948

954949
/* different clamping limits apply for a mash clock */
@@ -1079,7 +1074,7 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw,
10791074
struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
10801075
struct bcm2835_cprman *cprman = clock->cprman;
10811076
const struct bcm2835_clock_data *data = clock->data;
1082-
u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate, false);
1077+
u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate);
10831078
u32 ctl;
10841079

10851080
spin_lock(&cprman->regs_lock);
@@ -1130,7 +1125,7 @@ static unsigned long bcm2835_clock_choose_div_and_prate(struct clk_hw *hw,
11301125

11311126
if (!(BIT(parent_idx) & data->set_rate_parent)) {
11321127
*prate = clk_hw_get_rate(parent);
1133-
*div = bcm2835_clock_choose_div(hw, rate, *prate, true);
1128+
*div = bcm2835_clock_choose_div(hw, rate, *prate);
11341129

11351130
*avgrate = bcm2835_clock_rate_from_divisor(clock, *prate, *div);
11361131

0 commit comments

Comments
 (0)