hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/clk/clk-multiplier.c
....@@ -1,18 +1,32 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2015 Maxime Ripard <maxime.ripard@free-electrons.com>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 */
85
96 #include <linux/bitops.h>
107 #include <linux/clk-provider.h>
118 #include <linux/err.h>
129 #include <linux/export.h>
10
+#include <linux/io.h>
1311 #include <linux/kernel.h>
1412 #include <linux/of.h>
1513 #include <linux/slab.h>
14
+
15
+static inline u32 clk_mult_readl(struct clk_multiplier *mult)
16
+{
17
+ if (mult->flags & CLK_MULTIPLIER_BIG_ENDIAN)
18
+ return ioread32be(mult->reg);
19
+
20
+ return readl(mult->reg);
21
+}
22
+
23
+static inline void clk_mult_writel(struct clk_multiplier *mult, u32 val)
24
+{
25
+ if (mult->flags & CLK_MULTIPLIER_BIG_ENDIAN)
26
+ iowrite32be(val, mult->reg);
27
+ else
28
+ writel(val, mult->reg);
29
+}
1630
1731 static unsigned long __get_mult(struct clk_multiplier *mult,
1832 unsigned long rate,
....@@ -30,7 +44,7 @@
3044 struct clk_multiplier *mult = to_clk_multiplier(hw);
3145 unsigned long val;
3246
33
- val = clk_readl(mult->reg) >> mult->shift;
47
+ val = clk_mult_readl(mult) >> mult->shift;
3448 val &= GENMASK(mult->width - 1, 0);
3549
3650 if (!val && mult->flags & CLK_MULTIPLIER_ZERO_BYPASS)
....@@ -121,10 +135,10 @@
121135 else
122136 __acquire(mult->lock);
123137
124
- val = clk_readl(mult->reg);
138
+ val = clk_mult_readl(mult);
125139 val &= ~GENMASK(mult->width + mult->shift - 1, mult->shift);
126140 val |= factor << mult->shift;
127
- clk_writel(val, mult->reg);
141
+ clk_mult_writel(mult, val);
128142
129143 if (mult->lock)
130144 spin_unlock_irqrestore(mult->lock, flags);