summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2019-01-14 17:42:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-15 07:58:37 +0100
commite27c0b64db0109560070b6e29624e8b02b758639 (patch)
tree9eae3466e08d32a68bd79ea5872ad37b4ec475a1 /include
parent80be8c6d20872a4ce83cb1a850840e53b325f660 (diff)
downloadbarebox-e27c0b64db0109560070b6e29624e8b02b758639.tar.gz
barebox-e27c0b64db0109560070b6e29624e8b02b758639.tar.xz
clk: add divider_recalc_rate helper
Closer to Linux kernel implementation and needed for imx8mq composite clock. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/clk.h5
-rw-r--r--include/linux/kernel.h5
2 files changed, 10 insertions, 0 deletions
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; \