hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/clk/meson/clk-mpll.c
....@@ -12,7 +12,11 @@
1212 */
1313
1414 #include <linux/clk-provider.h>
15
-#include "clkc.h"
15
+#include <linux/module.h>
16
+#include <linux/spinlock.h>
17
+
18
+#include "clk-regmap.h"
19
+#include "clk-mpll.h"
1620
1721 #define SDM_DEN 16384
1822 #define N2_MIN 4
....@@ -111,20 +115,11 @@
111115 else
112116 __acquire(mpll->lock);
113117
114
- /* Enable and set the fractional part */
118
+ /* Set the fractional part */
115119 meson_parm_write(clk->map, &mpll->sdm, sdm);
116
- meson_parm_write(clk->map, &mpll->sdm_en, 1);
117
-
118
- /* Set additional fractional part enable if required */
119
- if (MESON_PARM_APPLICABLE(&mpll->ssen))
120
- meson_parm_write(clk->map, &mpll->ssen, 1);
121120
122121 /* Set the integer divider part */
123122 meson_parm_write(clk->map, &mpll->n2, n2);
124
-
125
- /* Set the magic misc bit if required */
126
- if (MESON_PARM_APPLICABLE(&mpll->misc))
127
- meson_parm_write(clk->map, &mpll->misc, 1);
128123
129124 if (mpll->lock)
130125 spin_unlock_irqrestore(mpll->lock, flags);
....@@ -134,13 +129,46 @@
134129 return 0;
135130 }
136131
132
+static int mpll_init(struct clk_hw *hw)
133
+{
134
+ struct clk_regmap *clk = to_clk_regmap(hw);
135
+ struct meson_clk_mpll_data *mpll = meson_clk_mpll_data(clk);
136
+
137
+ if (mpll->init_count)
138
+ regmap_multi_reg_write(clk->map, mpll->init_regs,
139
+ mpll->init_count);
140
+
141
+ /* Enable the fractional part */
142
+ meson_parm_write(clk->map, &mpll->sdm_en, 1);
143
+
144
+ /* Set spread spectrum if possible */
145
+ if (MESON_PARM_APPLICABLE(&mpll->ssen)) {
146
+ unsigned int ss =
147
+ mpll->flags & CLK_MESON_MPLL_SPREAD_SPECTRUM ? 1 : 0;
148
+ meson_parm_write(clk->map, &mpll->ssen, ss);
149
+ }
150
+
151
+ /* Set the magic misc bit if required */
152
+ if (MESON_PARM_APPLICABLE(&mpll->misc))
153
+ meson_parm_write(clk->map, &mpll->misc, 1);
154
+
155
+ return 0;
156
+}
157
+
137158 const struct clk_ops meson_clk_mpll_ro_ops = {
138159 .recalc_rate = mpll_recalc_rate,
139160 .round_rate = mpll_round_rate,
140161 };
162
+EXPORT_SYMBOL_GPL(meson_clk_mpll_ro_ops);
141163
142164 const struct clk_ops meson_clk_mpll_ops = {
143165 .recalc_rate = mpll_recalc_rate,
144166 .round_rate = mpll_round_rate,
145167 .set_rate = mpll_set_rate,
168
+ .init = mpll_init,
146169 };
170
+EXPORT_SYMBOL_GPL(meson_clk_mpll_ops);
171
+
172
+MODULE_DESCRIPTION("Amlogic MPLL driver");
173
+MODULE_AUTHOR("Michael Turquette <mturquette@baylibre.com>");
174
+MODULE_LICENSE("GPL v2");