Skip to content

Commit 6bd913f

Browse files
committed
clk: renesas: r9a06g032: Switch to .determine_rate()
As the .round_rate() callback returns a long clock rate, it cannot return clock rates that do not fit in signed long, but do fit in unsigned long. Hence switch the divider clocks on RZ/N1 from the old .round_rate() callback to the newer .determine_rate() callback, which does not suffer from this limitation. Note that range checking is not yet implemented. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/7a384d02b85cdaac4a0e2b357582c8244b9a6f98.1617282116.git.geert+renesas@glider.be
1 parent 02c6959 commit 6bd913f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,20 +604,19 @@ r9a06g032_div_clamp_div(struct r9a06g032_clk_div *clk,
604604
return div;
605605
}
606606

607-
static long
608-
r9a06g032_div_round_rate(struct clk_hw *hw,
609-
unsigned long rate, unsigned long *prate)
607+
static int
608+
r9a06g032_div_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
610609
{
611610
struct r9a06g032_clk_div *clk = to_r9a06g032_div(hw);
612-
u32 div = DIV_ROUND_UP(*prate, rate);
611+
u32 div = DIV_ROUND_UP(req->best_parent_rate, req->rate);
613612

614613
pr_devel("%s %pC %ld (prate %ld) (wanted div %u)\n", __func__,
615-
hw->clk, rate, *prate, div);
614+
hw->clk, req->rate, req->best_parent_rate, div);
616615
pr_devel(" min %d (%ld) max %d (%ld)\n",
617-
clk->min, DIV_ROUND_UP(*prate, clk->min),
618-
clk->max, DIV_ROUND_UP(*prate, clk->max));
616+
clk->min, DIV_ROUND_UP(req->best_parent_rate, clk->min),
617+
clk->max, DIV_ROUND_UP(req->best_parent_rate, clk->max));
619618

620-
div = r9a06g032_div_clamp_div(clk, rate, *prate);
619+
div = r9a06g032_div_clamp_div(clk, req->rate, req->best_parent_rate);
621620
/*
622621
* this is a hack. Currently the serial driver asks for a clock rate
623622
* that is 16 times the baud rate -- and that is wildly outside the
@@ -630,11 +629,13 @@ r9a06g032_div_round_rate(struct clk_hw *hw,
630629
if (clk->index == R9A06G032_DIV_UART ||
631630
clk->index == R9A06G032_DIV_P2_PG) {
632631
pr_devel("%s div uart hack!\n", __func__);
633-
return clk_get_rate(hw->clk);
632+
req->rate = clk_get_rate(hw->clk);
633+
return 0;
634634
}
635+
req->rate = DIV_ROUND_UP(req->best_parent_rate, div);
635636
pr_devel("%s %pC %ld / %u = %ld\n", __func__, hw->clk,
636-
*prate, div, DIV_ROUND_UP(*prate, div));
637-
return DIV_ROUND_UP(*prate, div);
637+
req->best_parent_rate, div, req->rate);
638+
return 0;
638639
}
639640

640641
static int
@@ -663,7 +664,7 @@ r9a06g032_div_set_rate(struct clk_hw *hw,
663664

664665
static const struct clk_ops r9a06g032_clk_div_ops = {
665666
.recalc_rate = r9a06g032_div_recalc_rate,
666-
.round_rate = r9a06g032_div_round_rate,
667+
.determine_rate = r9a06g032_div_determine_rate,
667668
.set_rate = r9a06g032_div_set_rate,
668669
};
669670

0 commit comments

Comments
 (0)