40 if (chip_version < 0x17 || chip_version == 0x1a || chip_version == 0x20)
58 if (shift > 4 && (chip_version < 0x32 || chip_version == 0x35 ||
59 chip_version == 0x36 || chip_version >= 0x40))
70 uint32_t oldpll = nv_rd32(priv, reg);
71 int oldN = (oldpll >> 8) & 0xff, oldM = oldpll & 0xff;
74 int shift_powerctrl_1 = powerctrl_1_shift(chip_version, reg);
79 if (shift_powerctrl_1 >= 0) {
80 saved_powerctrl_1 = nv_rd32(priv, 0x001584);
81 nv_wr32(priv, 0x001584,
82 (saved_powerctrl_1 & ~(0xf << shift_powerctrl_1)) |
83 1 << shift_powerctrl_1);
86 if (oldM && pv->
M1 && (oldN / oldM < pv->N1 / pv->
M1))
88 nv_wr32(priv, reg, pv->
log2P << 16 | (oldpll & 0xffff));
91 nv_wr32(priv, reg, (oldpll & 0xffff0000) | pv->
NM1);
93 if (chip_version < 0x17 && chip_version != 0x11)
99 nv_wr32(priv, reg, pll);
101 if (shift_powerctrl_1 >= 0)
102 nv_wr32(priv, 0x001584, saved_powerctrl_1);
108 bool head_a = (reg1 == 0x680508);
111 ramdac580 |= head_a ? 0x00000100 : 0x10000000;
113 ramdac580 &= head_a ? 0xfffffeff : 0xefffffff;
123 bool nv3035 = chip_version == 0x30 || chip_version == 0x35;
124 uint32_t reg2 = reg1 + ((reg1 == 0x680520) ? 0x5c : 0x70);
125 uint32_t oldpll1 = nv_rd32(priv, reg1);
129 uint32_t oldramdac580 = 0, ramdac580 = 0;
130 bool single_stage = !pv->
NM2 || pv->
N2 == pv->
M2;
131 uint32_t saved_powerctrl_1 = 0, savedc040 = 0;
132 int shift_powerctrl_1 = powerctrl_1_shift(chip_version, reg1);
136 pll1 = (pll1 & 0xfcc7ffff) | (pv->
N2 & 0x18) << 21 |
137 (pv->
N2 & 0x7) << 19 | 8 << 4 | (pv->
M2 & 7) << 4;
140 if (chip_version > 0x40 && reg1 >= 0x680508) {
141 oldramdac580 = nv_rd32(priv, 0x680580);
142 ramdac580 = new_ramdac580(reg1, single_stage, oldramdac580);
143 if (oldramdac580 != ramdac580)
149 if (chip_version > 0x70)
151 pll1 = (pll1 & 0x7fffffff) | (single_stage ? 0x4 : 0
xc) << 28;
153 if (oldpll1 == pll1 && oldpll2 ==
pll2)
156 if (shift_powerctrl_1 >= 0) {
157 saved_powerctrl_1 = nv_rd32(priv, 0x001584);
158 nv_wr32(priv, 0x001584,
159 (saved_powerctrl_1 & ~(0xf << shift_powerctrl_1)) |
160 1 << shift_powerctrl_1);
163 if (chip_version >= 0x40) {
177 savedc040 = nv_rd32(priv, 0xc040);
178 if (shift_c040 != 14)
179 nv_wr32(priv, 0xc040, savedc040 & ~(3 << shift_c040));
182 if (oldramdac580 != ramdac580)
183 nv_wr32(priv, 0x680580, ramdac580);
187 nv_wr32(priv, reg1, pll1);
189 if (shift_powerctrl_1 >= 0)
190 nv_wr32(priv, 0x001584, saved_powerctrl_1);
191 if (chip_version >= 0x40)
192 nv_wr32(priv, 0xc040, savedc040);
208 bool mpll = Preg == 0x4020;
209 uint32_t oldPval = nv_rd32(priv, Preg);
211 uint32_t Pval = (oldPval & (mpll ? ~(0x77 << 16) : ~(7 << 16))) |
212 0xc << 28 | pv->
log2P << 16;
215 uint32_t maskc040 = ~(3 << 14), savedc040;
216 bool single_stage = !pv->
NM2 || pv->
N2 == pv->
M2;
218 if (nv_rd32(priv, NMNMreg) == NMNM && (oldPval & 0xc0070000) == Pval)
224 maskc040 = ~(0xc << 24);
234 if (Pval2 >
info.max_p)
236 Pval |= 1 << 28 | Pval2 << 20;
238 saved4600 = nv_rd32(priv, 0x4600);
239 nv_wr32(priv, 0x4600, saved4600 | 8 << 28);
242 Pval |= mpll ? 1 << 12 : 1 << 8;
244 nv_wr32(priv, Preg, oldPval | 1 << 28);
245 nv_wr32(priv, Preg, Pval & ~(4 << 28));
248 nv_wr32(priv, 0x4020, Pval & ~(0xc << 28));
249 nv_wr32(priv, 0x4038, Pval & ~(0xc << 28));
252 savedc040 = nv_rd32(priv, 0xc040);
253 nv_wr32(priv, 0xc040, savedc040 & maskc040);
255 nv_wr32(priv, NMNMreg, NMNM);
256 if (NMNMreg == 0x4024)
257 nv_wr32(priv, 0x403c, NMNM);
259 nv_wr32(priv, Preg, Pval);
262 nv_wr32(priv, 0x4020, Pval);
263 nv_wr32(priv, 0x4038, Pval);
264 nv_wr32(priv, 0x4600, saved4600);
267 nv_wr32(priv, 0xc040, savedc040);
270 nv_wr32(priv, 0x4020, Pval & ~(1 << 28));
271 nv_wr32(priv, 0x4038, Pval & ~(1 << 28));
284 type : type - 4, &info);
288 ret = clk->
pll_calc(clk, &info, freq, &pv);
292 return clk->
pll_prog(clk, type, &pv);
299 int N1, M1,
N2,
M2,
P;
319 if (cv == 0x30 || cv == 0x31 || cv == 0x35 || cv == 0x36 ||
322 setPLL_double_highregs(priv, reg1, pv);
324 setPLL_double_lowregs(priv, reg1, pv);
326 setPLL_single(priv, reg1, pv);
340 *pobject = nv_object(priv);
354 .ctor = nv04_clock_ctor,