diff options
author | Peter De Schrijver <pdeschrijver@nvidia.com> | 2018-07-12 14:53:00 +0300 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2018-07-25 23:43:34 +0300 |
commit | cb3ac5947afb3bb7e2f89c1b59f61dcf3e115fe1 (patch) | |
tree | 7111e58446fef9a299069b9104c9e32a09732a11 /drivers/clk/tegra/clk-divider.c | |
parent | 0cbb61a313979b53d6b2dc838a92f07471440708 (diff) | |
download | linux-cb3ac5947afb3bb7e2f89c1b59f61dcf3e115fe1.tar.xz |
clk: tegra: Refactor fractional divider calculation
Move this to a separate file so it can be used to calculate the sdmmc
clock dividers.
Signed-off-by: Peter De-Schrijver <pdeschrijver@nvidia.com>
Signed-off-by: Aapo Vienamo <avienamo@nvidia.com>
Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/tegra/clk-divider.c')
-rw-r--r-- | drivers/clk/tegra/clk-divider.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/drivers/clk/tegra/clk-divider.c b/drivers/clk/tegra/clk-divider.c index 16e0aee14773..8f175ff62f73 100644 --- a/drivers/clk/tegra/clk-divider.c +++ b/drivers/clk/tegra/clk-divider.c @@ -32,35 +32,15 @@ static int get_div(struct tegra_clk_frac_div *divider, unsigned long rate, unsigned long parent_rate) { - u64 divider_ux1 = parent_rate; - u8 flags = divider->flags; - int mul; - - if (!rate) - return 0; - - mul = get_mul(divider); - - if (!(flags & TEGRA_DIVIDER_INT)) - divider_ux1 *= mul; - - if (flags & TEGRA_DIVIDER_ROUND_UP) - divider_ux1 += rate - 1; - - do_div(divider_ux1, rate); - - if (flags & TEGRA_DIVIDER_INT) - divider_ux1 *= mul; + int div; - divider_ux1 -= mul; + div = div_frac_get(rate, parent_rate, divider->width, + divider->frac_width, divider->flags); - if ((s64)divider_ux1 < 0) + if (div < 0) return 0; - if (divider_ux1 > get_max_div(divider)) - return get_max_div(divider); - - return divider_ux1; + return div; } static unsigned long clk_frac_div_recalc_rate(struct clk_hw *hw, |