/* The bypass bit is inverted on the ddr_pll.. */ #define fapll_is_ddr_pll(va) (((u32)(va) & 0xffff) == 0x0440)
/* * The audio_pll_clk1 input is hard wired to the 27MHz bypass clock, * and the audio_pll_clk1 synthesizer is hardwared to 32KiHz output.
*/ #define is_ddr_pll_clk1(va) (((u32)(va) & 0xffff) == 0x044c) #define is_audio_pll_clk1(va) (((u32)(va) & 0xffff) == 0x04a8)
if (ti_fapll_clock_is_bypass(fd)) return parent_rate;
rate = parent_rate;
/* PLL pre-divider is P and multiplier is N */
v = readl_relaxed(fd->base);
fapll_p = (v >> 8) & 0xff; if (fapll_p)
do_div(rate, fapll_p);
fapll_n = v >> 16; if (fapll_n)
rate *= fapll_n;
staticint ti_fapll_set_div_mult(unsignedlong rate, unsignedlong parent_rate,
u32 *pre_div_p, u32 *mult_n)
{ /* * So far no luck getting decent clock with PLL divider, * PLL does not seem to lock and the signal does not look * right. It seems the divider can only be used together * with the multiplier?
*/ if (rate < parent_rate) {
pr_warn("FAPLL main divider rates unsupported\n"); return -EINVAL;
}
error = ti_fapll_set_div_mult(rate, parent_rate,
&pre_div_p, &mult_n); if (error) return error;
ti_fapll_set_bypass(fd);
v = readl_relaxed(fd->base);
v &= ~FAPLL_MAIN_CLEAR_MASK;
v |= pre_div_p << FAPLL_MAIN_DIV_P_SHIFT;
v |= mult_n << FAPLL_MAIN_MULT_N_SHIFT;
writel_relaxed(v, fd->base); if (ti_fapll_is_enabled(hw))
ti_fapll_wait_lock(fd);
ti_fapll_clear_bypass(fd);
/* * See dm816x TRM chapter 1.10.3 Flying Adder PLL fore more info
*/ staticunsignedlong ti_fapll_synth_recalc_rate(struct clk_hw *hw, unsignedlong parent_rate)
{ struct fapll_synth *synth = to_synth(hw);
u32 synth_div_m;
u64 rate;
/* The audio_pll_clk1 is hardwired to produce 32.768KiHz clock */ if (!synth->div) return 32768;
/* * PLL in bypass sets the synths in bypass mode too. The PLL rate * can be also be set to 27MHz, so we can't use parent_rate to * check for bypass mode.
*/ if (ti_fapll_clock_is_bypass(synth->fd)) return parent_rate;
rate = parent_rate;
/* * Synth frequency integer and fractional divider. * Note that the phase output K is 8, so the result needs * to be multiplied by SYNTH_PHASE_K.
*/ if (synth->freq) {
u32 v, synth_int_div, synth_frac_div, synth_div_freq;
if (synth_int_div > SYNTH_MAX_INT_DIV) return -EINVAL;
v = readl_relaxed(synth->freq);
v &= ~0x1fffffff;
v |= (synth_int_div & SYNTH_MAX_INT_DIV) << 24;
v |= (synth_frac_div & 0xffffff);
v |= SYNTH_LDFREQ;
writel_relaxed(v, synth->freq);
if (ti_fapll_clock_is_bypass(fd) || !synth->div || !rate) return -EINVAL;
/* Produce the rate with just post divider M? */
frac_rate = ti_fapll_synth_get_frac_rate(hw, parent_rate); if (frac_rate < rate) { if (!synth->freq) return -EINVAL;
} else {
post_div_m = DIV_ROUND_UP(frac_rate, rate); if (post_div_m && (post_div_m <= SYNTH_MAX_DIV_M))
post_rate = DIV_ROUND_UP(frac_rate, post_div_m); if (!synth->freq && !post_rate) return -EINVAL;
}
/* Need to recalculate the fractional divider? */ if ((post_rate != rate) && synth->freq)
post_div_m = ti_fapll_synth_set_frac_rate(synth,
rate,
parent_rate);
v = readl_relaxed(synth->div);
v &= ~SYNTH_MAX_DIV_M;
v |= post_div_m;
v |= SYNTH_LDMDIV1;
writel_relaxed(v, synth->div);
/* * Set up the child synthesizers starting at index 1 as the * PLL output is at index 0. We need to check the clock-indices * for numbering in case there are holes in the synth mapping, * and then probe the synth register to see if it has a FREQ * register available.
*/ for (i = 0; i < MAX_FAPLL_OUTPUTS; i++) { constchar *output_name; void __iomem *freq, *div; struct clk *synth_clk; int output_instance;
u32 v;
if (of_property_read_string_index(node, "clock-output-names",
i, &output_name)) continue;
if (of_property_read_u32_index(node, "clock-indices", i,
&output_instance))
output_instance = i;
/* Check for hardwired audio_pll_clk1 */ if (is_audio_pll_clk1(freq)) {
freq = NULL;
div = NULL;
} else { /* Does the synthesizer have a FREQ register? */
v = readl_relaxed(freq); if (!v)
freq = NULL;
}
synth_clk = ti_fapll_synth_setup(fd, freq, div, output_instance,
output_name, name, pll_clk); if (IS_ERR(synth_clk)) continue;
/* Register the child synthesizers as the FAPLL outputs */
of_clk_add_provider(node, of_clk_src_onecell_get, &fd->outputs); /* Add clock alias for the outputs */
kfree(init);
return;
unmap:
iounmap(fd->base);
free: if (fd->clk_bypass)
clk_put(fd->clk_bypass); if (fd->clk_ref)
clk_put(fd->clk_ref);
kfree(fd->outputs.clks);
kfree(fd);
kfree(init);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.