Lines Matching +full:3 +full:base +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0
6 * Alexandre Belloni <alexandre.belloni@free-electrons.com>
8 #include <linux/clk-provider.h>
15 #include "berlin2-avpll.h"
19 * VCO with 8 channels each, channel 8 is the odd-one-out and does
31 #define AVPLL_CTRL(x) ((x) * 0x4) argument
40 #define VCO_REG1V45_SEL(x) ((x) << VCO_REG1V45_SEL_SHIFT) argument
44 #define VCO_REG1V45_SEL_1V55 VCO_REG1V45_SEL(3)
45 #define VCO_REG1V45_SEL_MASK VCO_REG1V45_SEL(3)
49 #define VCO_VTHCAL(x) ((x) << VCO_VTHCAL_SHIFT) argument
53 #define VCO_VTHCAL_1V05 VCO_VTHCAL(3)
54 #define VCO_VTHCAL_MASK VCO_VTHCAL(3)
62 #define VCO_SPEED(x) ((x) << VCO_SPEED_SHIFT) argument
66 #define VCO_SPEED_1G61_1G86 VCO_SPEED(3)
74 #define VCO_REFDIV(x) ((x) << VCO_REFDIV_SHIFT) argument
78 #define VCO_REFDIV_3 VCO_REFDIV(3)
81 #define VCO_FBDIV(x) ((x) << VCO_FBDIV_SHIFT) argument
84 /* PLL Charge Pump Current = 10uA * (x + 1) */
85 #define VCO_ICP(x) ((x) << VCO_ICP_SHIFT) argument
89 #define VCO_FREQOFFSETn(x) AVPLL_CTRL(3 + (x)) argument
98 #define VCO_SYNC1n(x) AVPLL_CTRL(15 + (x)) argument
100 #define VCO_SYNC2n(x) AVPLL_CTRL(23 + (x)) argument
107 void __iomem *base; member
118 reg = readl_relaxed(vco->base + VCO_CTRL0); in berlin2_avpll_vco_is_enabled()
119 if (vco->flags & BERLIN2_AVPLL_BIT_QUIRK) in berlin2_avpll_vco_is_enabled()
130 reg = readl_relaxed(vco->base + VCO_CTRL0); in berlin2_avpll_vco_enable()
131 if (vco->flags & BERLIN2_AVPLL_BIT_QUIRK) in berlin2_avpll_vco_enable()
135 writel_relaxed(reg, vco->base + VCO_CTRL0); in berlin2_avpll_vco_enable()
145 reg = readl_relaxed(vco->base + VCO_CTRL0); in berlin2_avpll_vco_disable()
146 if (vco->flags & BERLIN2_AVPLL_BIT_QUIRK) in berlin2_avpll_vco_disable()
150 writel_relaxed(reg, vco->base + VCO_CTRL0); in berlin2_avpll_vco_disable()
153 static u8 vco_refdiv[] = { 1, 2, 4, 3 };
163 reg = readl_relaxed(vco->base + VCO_CTRL1); in berlin2_avpll_vco_recalc_rate()
180 int __init berlin2_avpll_vco_register(void __iomem *base, in berlin2_avpll_vco_register() argument
189 return -ENOMEM; in berlin2_avpll_vco_register()
191 vco->base = base; in berlin2_avpll_vco_register()
192 vco->flags = vco_flags; in berlin2_avpll_vco_register()
193 vco->hw.init = &init; in berlin2_avpll_vco_register()
200 return clk_hw_register(NULL, &vco->hw); in berlin2_avpll_vco_register()
205 void __iomem *base; member
217 if (ch->index == 7) in berlin2_avpll_channel_is_enabled()
220 reg = readl_relaxed(ch->base + VCO_CTRL10); in berlin2_avpll_channel_is_enabled()
221 reg &= VCO_POWERUP_CH1 << ch->index; in berlin2_avpll_channel_is_enabled()
231 reg = readl_relaxed(ch->base + VCO_CTRL10); in berlin2_avpll_channel_enable()
232 reg |= VCO_POWERUP_CH1 << ch->index; in berlin2_avpll_channel_enable()
233 writel_relaxed(reg, ch->base + VCO_CTRL10); in berlin2_avpll_channel_enable()
243 reg = readl_relaxed(ch->base + VCO_CTRL10); in berlin2_avpll_channel_disable()
244 reg &= ~(VCO_POWERUP_CH1 << ch->index); in berlin2_avpll_channel_disable()
245 writel_relaxed(reg, ch->base + VCO_CTRL10); in berlin2_avpll_channel_disable()
258 reg = readl_relaxed(ch->base + VCO_CTRL30); in berlin2_avpll_channel_recalc_rate()
259 if ((reg & (VCO_DPLL_CH1_ENABLE << ch->index)) == 0) in berlin2_avpll_channel_recalc_rate()
267 reg = readl_relaxed(ch->base + VCO_SYNC1n(ch->index)); in berlin2_avpll_channel_recalc_rate()
269 if (ch->flags & BERLIN2_AVPLL_BIT_QUIRK && ch->index == 0) in berlin2_avpll_channel_recalc_rate()
273 reg = readl_relaxed(ch->base + VCO_SYNC2n(ch->index)); in berlin2_avpll_channel_recalc_rate()
277 if (ch->index == 7) in berlin2_avpll_channel_recalc_rate()
284 reg = readl_relaxed(ch->base + VCO_CTRL11) >> 7; in berlin2_avpll_channel_recalc_rate()
285 reg = (reg >> (ch->index * 3)); in berlin2_avpll_channel_recalc_rate()
293 if (ch->index == 0) { in berlin2_avpll_channel_recalc_rate()
294 reg = readl_relaxed(ch->base + VCO_CTRL11); in berlin2_avpll_channel_recalc_rate()
297 reg = readl_relaxed(ch->base + VCO_CTRL12); in berlin2_avpll_channel_recalc_rate()
298 reg >>= (ch->index-1) * 3; in berlin2_avpll_channel_recalc_rate()
307 if (ch->index < 2) { in berlin2_avpll_channel_recalc_rate()
308 reg = readl_relaxed(ch->base + VCO_CTRL12); in berlin2_avpll_channel_recalc_rate()
309 reg >>= 18 + (ch->index * 7); in berlin2_avpll_channel_recalc_rate()
310 } else if (ch->index < 7) { in berlin2_avpll_channel_recalc_rate()
311 reg = readl_relaxed(ch->base + VCO_CTRL13); in berlin2_avpll_channel_recalc_rate()
312 reg >>= (ch->index - 2) * 7; in berlin2_avpll_channel_recalc_rate()
314 reg = readl_relaxed(ch->base + VCO_CTRL14); in berlin2_avpll_channel_recalc_rate()
325 if (ch->index < 6) { in berlin2_avpll_channel_recalc_rate()
326 reg = readl_relaxed(ch->base + VCO_CTRL14); in berlin2_avpll_channel_recalc_rate()
327 reg >>= 7 + (ch->index * 4); in berlin2_avpll_channel_recalc_rate()
329 reg = readl_relaxed(ch->base + VCO_CTRL15); in berlin2_avpll_channel_recalc_rate()
354 static const u8 quirk_index[] __initconst = { 0, 6, 5, 4, 3, 2, 1, 7 };
356 int __init berlin2_avpll_channel_register(void __iomem *base, in berlin2_avpll_channel_register() argument
365 return -ENOMEM; in berlin2_avpll_channel_register()
367 ch->base = base; in berlin2_avpll_channel_register()
369 ch->index = quirk_index[index]; in berlin2_avpll_channel_register()
371 ch->index = index; in berlin2_avpll_channel_register()
373 ch->flags = ch_flags; in berlin2_avpll_channel_register()
374 ch->hw.init = &init; in berlin2_avpll_channel_register()
381 return clk_hw_register(NULL, &ch->hw); in berlin2_avpll_channel_register()