32 int *pN,
int *pM,
int *pP)
43 int minvco = info->
vco1.min_freq, maxvco = info->
vco1.max_freq;
44 int minM = info->
vco1.min_m, maxM = info->
vco1.max_m;
45 int minN = info->
vco1.min_n, maxN = info->
vco1.max_n;
46 int minU = info->
vco1.min_inputfreq;
47 int maxU = info->
vco1.max_inputfreq;
48 int minP = info->
min_p;
50 int crystal = info->
refclk;
58 if (cv < 0x17 || cv == 0x1a || cv == 0x20) {
63 }
else if (cv < 0x40) {
73 if ((clk * P) < minvco) {
78 if (clk + clk/200 > maxvco)
79 maxvco = clk + clk/200;
82 for (thisP = minP; thisP <= maxP; thisP++) {
91 for (M = minM; M <= maxM; M++) {
98 N = (clkP * M + crystal/2) / crystal;
106 calcclk = ((N * crystal + P/2) / P + M/2) /
M;
107 delta =
abs(calcclk - clk);
111 if (delta < bestdelta) {
128 int *pN1,
int *pM1,
int *pN2,
int *pM2,
int *pP)
139 int minvco1 = info->
vco1.min_freq, maxvco1 = info->
vco1.max_freq;
140 int minvco2 = info->
vco2.min_freq, maxvco2 = info->
vco2.max_freq;
141 int minU1 = info->
vco1.min_inputfreq, minU2 = info->
vco2.min_inputfreq;
142 int maxU1 = info->
vco1.max_inputfreq, maxU2 = info->
vco2.max_inputfreq;
143 int minM1 = info->
vco1.min_m, maxM1 = info->
vco1.max_m;
144 int minN1 = info->
vco1.min_n, maxN1 = info->
vco1.max_n;
145 int minM2 = info->
vco2.min_m, maxM2 = info->
vco2.max_m;
146 int minN2 = info->
vco2.min_n, maxN2 = info->
vco2.max_n;
148 int crystal = info->
refclk;
149 bool fixedgain2 = (minM2 == maxM2 && minN2 == maxN2);
150 int M1, N1,
M2,
N2, log2P;
151 int clkP, calcclk1, calcclk2, calcclkout;
155 int vco2 = (maxvco2 - maxvco2/200) / 2;
156 for (log2P = 0; clk && log2P < maxlog2P && clk <= (vco2 >> log2P); log2P++)
160 if (maxvco2 < clk + clk/200)
161 maxvco2 = clk + clk/200;
163 for (M1 = minM1; M1 <= maxM1; M1++) {
164 if (crystal/M1 < minU1)
166 if (crystal/M1 > maxU1)
169 for (N1 = minN1; N1 <= maxN1; N1++) {
170 calcclk1 = crystal * N1 / M1;
171 if (calcclk1 < minvco1)
173 if (calcclk1 > maxvco1)
176 for (M2 = minM2; M2 <= maxM2; M2++) {
177 if (calcclk1/M2 < minU2)
179 if (calcclk1/M2 > maxU2)
183 N2 = (clkP * M2 + calcclk1/2) / calcclk1;
190 if (chip_version < 0x60)
191 if (N2/M2 < 4 || N2/M2 > 10)
194 calcclk2 = calcclk1 * N2 /
M2;
195 if (calcclk2 < minvco2)
197 if (calcclk2 > maxvco2)
202 calcclkout = calcclk2 >> log2P;
203 delta =
abs(calcclkout - clk);
207 if (delta < bestdelta) {
209 bestclk = calcclkout;
227 int *N1,
int *M1,
int *N2,
int *M2,
int *P)
231 if (!info->
vco2.max_freq) {
232 ret = getMNP_single(clk, info, freq, N1, M1, P);
236 ret = getMNP_double(clk, info, freq, N1, M1, N2, M2, P);
240 nv_error(clk,
"unable to compute acceptable pll values\n");