Commit c65f7616 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski Committed by Adam Wujek

softpll: fix for 1-out-of-1000 can't-locks

Solution V2
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent 18503d5f
......@@ -12,6 +12,7 @@
#include <wrc.h>
#include "softpll_ng.h"
#define MPLL_DISCARD_EARLY_TAGS 10
#define MPLL_TAG_WRAPAROUND 100000000
#undef WITH_SEQUENCING
......@@ -126,6 +127,7 @@ void mpll_start(struct spll_main_state *s)
{
pll_verbose("MPLL_Start [dac %d]\n", s->dac_index);
s->discard_early_cnt = MPLL_DISCARD_EARLY_TAGS;
s->ps_freeze = 0;
s->vco_freeze = 0;
......@@ -294,6 +296,33 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
if (s->tag_ref >= 0 && s->tag_out >= 0) {
#ifndef CONFIG_FRAC_SPLL
if(s->discard_early_cnt == 1)
{
int adj_ref = s->tag_ref + s->adder_ref;
int adj_out = s->tag_out + s->adder_out;
if( adj_ref > adj_out )
{
int delta = adj_ref - adj_out;
s->adder_ref -= (delta >> HPLL_N) << HPLL_N;
}
else
{
int delta = adj_out - adj_ref;
s->adder_out -= (delta >> HPLL_N) << HPLL_N;
}
if (s->adder_ref < 0 || s->adder_out < 0)
{
s->adder_ref += MPLL_TAG_WRAPAROUND;
s->adder_out += MPLL_TAG_WRAPAROUND;
}
}
if( s->discard_early_cnt > 0 )
s->discard_early_cnt--;
#endif
#ifdef CONFIG_FRAC_SPLL
if( abs(s->dout_dt - s->dref_dt) > s->frequency_lock_threshold )
{
......
......@@ -34,7 +34,7 @@ struct spll_main_state {
int dref_dt, dout_dt, tag_ref_raw_d, tag_out_raw_d2;
int frequency_lock_threshold;
#endif
int discard_early_cnt;
int adder_ref, adder_out;
int tag_ref, tag_ref_d;
int tag_out, tag_out_d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment