From e27c0b64db0109560070b6e29624e8b02b758639 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Mon, 14 Jan 2019 17:42:07 +0100 Subject: clk: add divider_recalc_rate helper Closer to Linux kernel implementation and needed for imx8mq composite clock. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- include/linux/clk.h | 5 +++++ include/linux/kernel.h | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/linux/clk.h b/include/linux/clk.h index 13b1e529f5..978a0a8a9a 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -259,6 +259,11 @@ struct clk_divider { extern struct clk_ops clk_divider_ops; +unsigned long divider_recalc_rate(struct clk *clk, unsigned long parent_rate, + unsigned int val, + const struct clk_div_table *table, + unsigned long flags, unsigned long width); + struct clk *clk_divider_alloc(const char *name, const char *parent, void __iomem *reg, u8 shift, u8 width, unsigned flags); void clk_divider_free(struct clk *clk_divider); diff --git a/include/linux/kernel.h b/include/linux/kernel.h index cc6d6f7467..ee0b48e089 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -55,6 +55,11 @@ #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_DOWN_ULL(ll, d) \ + ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) + +#define DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d)) + #define DIV_ROUND_CLOSEST(x, divisor)( \ { \ typeof(divisor) __divisor = divisor; \ -- cgit v1.2.3