37 #define min2(a,b) ((a) < (b) ? (a) : (b))
43 u32 ctrl = nv_rd32(device, reg + 0x00);
44 int P = (ctrl & 0x00070000) >> 16;
45 int N = (ctrl & 0x0000ff00) >> 8;
46 int M = (ctrl & 0x000000ff) >> 0;
49 if (ctrl & 0x80000000)
59 u32 ctrl = nv_rd32(device, reg + 0x00);
60 u32 coef = nv_rd32(device, reg + 0x04);
61 int N2 = (coef & 0xff000000) >> 24;
62 int M2 = (coef & 0x00ff0000) >> 16;
63 int N1 = (coef & 0x0000ff00) >> 8;
64 int M1 = (coef & 0x000000ff) >> 0;
65 int P = (ctrl & 0x00070000) >> 16;
68 if ((ctrl & 0x80000000) && M1) {
70 if ((ctrl & 0x40000100) == 0x40000000) {
86 return read_pll_2(dev, 0x004000);
88 return read_pll_1(dev, 0x004008);
100 u32 ctrl = nv_rd32(device, 0x00c040);
102 perflvl->
core = read_clk(dev, (ctrl & 0x00000003) >> 0);
103 perflvl->
shader = read_clk(dev, (ctrl & 0x00000030) >> 4);
104 perflvl->
memory = read_pll_2(dev, 0x4020);
119 u32 clk,
int *N1,
int *M1,
int *N2,
int *M2,
int *log2P)
132 pll->
vco2.max_freq = 0;
134 pclk->
pll_calc(pclk, pll, clk, &coef);
141 if (pll->
vco2.max_freq) {
158 int N1,
N2, M1,
M2, log2P;
166 ret = nv40_calc_pll(dev, 0x004000, &pll, perflvl->
core,
167 &N1, &M1, &N2, &M2, &log2P);
172 info->
npll_ctrl = 0x80000100 | (log2P << 16);
175 info->
npll_ctrl = 0xc0000000 | (log2P << 16);
176 info->
npll_coef = (N2 << 24) | (M2 << 16) | (N1 << 8) | M1;
181 ret = nv40_calc_pll(dev, 0x004008, &pll, perflvl->
shader,
186 info->
spll = 0xc0000000 | (log2P << 16) | (N1 << 8) | M1;
187 info->
ctrl = 0x00000223;
189 info->
spll = 0x00000000;
190 info->
ctrl = 0x00000333;
199 ret = nv40_calc_pll(dev, 0x004020, &pll, perflvl->
memory,
200 &N1, &M1, &N2, &M2, &log2P);
204 info->
mpll_ctrl = 0x80000000 | (log2P << 16);
211 info->
mpll_coef = (N2 << 24) | (M2 << 16) | (N1 << 8) | M1;
223 nv40_pm_gr_idle(
void *
data)
228 if ((nv_rd32(device, 0x400760) & 0x000000f0) >> 4 !=
229 (nv_rd32(device, 0x400760) & 0x0000000f))
232 if (nv_rd32(device, 0x400700))
252 for (i = 0; i < 2; i++) {
253 u32 vbl = nv_rd32(device, 0x600808 + (i * 0x2000));
256 if (vbl != nv_rd32(device, 0x600808 + (i * 0x2000))) {
257 nv_wr08(device, 0x0c03c4 + (i * 0x2000), 0x01);
258 sr1[
i] = nv_rd08(device, 0x0c03c5 + (i * 0x2000));
259 if (!(sr1[i] & 0x20))
260 crtc_mask |= (1 <<
i);
264 }
while (cnt++ < 32);
268 pfifo->
pause(pfifo, &flags);
270 if (!
nv_wait_cb(device, nv40_pm_gr_idle, dev))
276 nv_mask(device, 0x00c040, 0x00000333, 0x00000000);
277 nv_wr32(device, 0x004004, info->
npll_coef);
278 nv_mask(device, 0x004000, 0xc0070100, info->
npll_ctrl);
279 nv_mask(device, 0x004008, 0xc007ffff, info->
spll);
281 nv_mask(device, 0x00c040, 0x00000333, info->
ctrl);
287 for (i = 0; i < 2; i++) {
288 if (!(crtc_mask & (1 << i)))
290 nv_wait(device, 0x600808 + (i * 0x2000), 0x00010000, 0x00000000);
291 nv_wait(device, 0x600808 + (i * 0x2000), 0x00010000, 0x00010000);
292 nv_wr08(device, 0x0c03c4 + (i * 0x2000), 0x01);
293 nv_wr08(device, 0x0c03c5 + (i * 0x2000), sr1[i] | 0x20);
297 nv_wr32(device, 0x1002d4, 0x00000001);
298 nv_wr32(device, 0x1002d0, 0x00000001);
299 nv_wr32(device, 0x1002d0, 0x00000001);
300 nv_mask(device, 0x100210, 0x80000000, 0x00000000);
301 nv_wr32(device, 0x1002dc, 0x00000001);
304 nv_mask(device, 0x00c040, 0x0000c000, 0x00000000);
305 switch (nv_device(drm->
device)->chipset) {
311 nv_mask(device, 0x004044, 0xc0771100, info->
mpll_ctrl);
312 nv_mask(device, 0x00402c, 0xc0771100, info->
mpll_ctrl);
313 nv_wr32(device, 0x004048, info->
mpll_coef);
314 nv_wr32(device, 0x004030, info->
mpll_coef);
318 nv_mask(device, 0x004038, 0xc0771100, info->
mpll_ctrl);
319 nv_wr32(device, 0x00403c, info->
mpll_coef);
321 nv_mask(device, 0x004020, 0xc0771100, info->
mpll_ctrl);
322 nv_wr32(device, 0x004024, info->
mpll_coef);
326 nv_mask(device, 0x00c040, 0x0000c000, 0x0000c000);
329 nv_wr32(device, 0x1002dc, 0x00000000);
330 nv_mask(device, 0x100210, 0x80000000, 0x80000000);
340 for (i = 0; i < 2; i++) {
341 if (!(crtc_mask & (1 << i)))
343 nv_wait(device, 0x600808 + (i * 0x2000), 0x00010000, 0x00010000);
344 nv_wr08(device, 0x0c03c4 + (i * 0x2000), 0x01);
345 nv_wr08(device, 0x0c03c5 + (i * 0x2000), sr1[i]);
350 pfifo->
start(pfifo, &flags);