.. | .. |
---|
12 | 12 | */ |
---|
13 | 13 | |
---|
14 | 14 | #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" |
---|
16 | 20 | |
---|
17 | 21 | #define SDM_DEN 16384 |
---|
18 | 22 | #define N2_MIN 4 |
---|
.. | .. |
---|
111 | 115 | else |
---|
112 | 116 | __acquire(mpll->lock); |
---|
113 | 117 | |
---|
114 | | - /* Enable and set the fractional part */ |
---|
| 118 | + /* Set the fractional part */ |
---|
115 | 119 | 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); |
---|
121 | 120 | |
---|
122 | 121 | /* Set the integer divider part */ |
---|
123 | 122 | 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); |
---|
128 | 123 | |
---|
129 | 124 | if (mpll->lock) |
---|
130 | 125 | spin_unlock_irqrestore(mpll->lock, flags); |
---|
.. | .. |
---|
134 | 129 | return 0; |
---|
135 | 130 | } |
---|
136 | 131 | |
---|
| 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 | + |
---|
137 | 158 | const struct clk_ops meson_clk_mpll_ro_ops = { |
---|
138 | 159 | .recalc_rate = mpll_recalc_rate, |
---|
139 | 160 | .round_rate = mpll_round_rate, |
---|
140 | 161 | }; |
---|
| 162 | +EXPORT_SYMBOL_GPL(meson_clk_mpll_ro_ops); |
---|
141 | 163 | |
---|
142 | 164 | const struct clk_ops meson_clk_mpll_ops = { |
---|
143 | 165 | .recalc_rate = mpll_recalc_rate, |
---|
144 | 166 | .round_rate = mpll_round_rate, |
---|
145 | 167 | .set_rate = mpll_set_rate, |
---|
| 168 | + .init = mpll_init, |
---|
146 | 169 | }; |
---|
| 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"); |
---|