static void setPLL_double_lowregs(struct drm_device *dev, uint32_t NMNMreg, struct nouveau_pll_vals *pv) { /* When setting PLLs, there is a merry game of disabling and enabling * various bits of hardware during the process. This function is a * synthesis of six nv4x traces, nearly each card doing a subtly * different thing. With luck all the necessary bits for each card are * combined herein. Without luck it deviates from each card's formula * so as to not work on any :) */ uint32_t Preg = NMNMreg - 4; bool mpll = Preg == 0x4020; uint32_t oldPval = nvReadMC(dev, Preg); uint32_t NMNM = pv->NM2 << 16 | pv->NM1; <<<<<<< HEAD
static void setPLL_single(struct drm_device *dev, uint32_t reg, struct nouveau_pll_vals *pv) { struct drm_nouveau_private *dev_priv = dev->dev_private; int chip_version = dev_priv->vbios.chip_version; uint32_t oldpll = NVReadRAMDAC(dev, 0, reg); int oldN = (oldpll >> 8) & 0xff, oldM = oldpll & 0xff; uint32_t pll = (oldpll & 0xfff80000) | pv->log2P << 16 | pv->NM1; uint32_t saved_powerctrl_1 = 0; int shift_powerctrl_1 = powerctrl_1_shift(chip_version, reg); if (oldpll == pll) return; /* already set */ if (shift_powerctrl_1 >= 0) { saved_powerctrl_1 = nvReadMC(dev, NV_PBUS_POWERCTRL_1); nvWriteMC(dev, NV_PBUS_POWERCTRL_1, (saved_powerctrl_1 & ~(0xf << shift_powerctrl_1)) | 1 << shift_powerctrl_1); } if (oldM && pv->M1 && (oldN / oldM < pv->N1 / pv->M1)) /* upclock -- write new post divider first */ NVWriteRAMDAC(dev, 0, reg, pv->log2P << 16 | (oldpll & 0xffff)); else /* downclock -- write new NM first */ NVWriteRAMDAC(dev, 0, reg, (oldpll & 0xffff0000) | pv->NM1); if (chip_version < 0x17 && chip_version != 0x11) /* wait a bit on older chips */ msleep(64); NVReadRAMDAC(dev, 0, reg); /* then write the other half as well */ NVWriteRAMDAC(dev, 0, reg, pll); if (shift_powerctrl_1 >= 0) nvWriteMC(dev, NV_PBUS_POWERCTRL_1, saved_powerctrl_1); }
static void setPLL_double_lowregs(struct drm_device *dev, uint32_t NMNMreg, struct nouveau_pll_vals *pv) { /* When setting PLLs, there is a merry game of disabling and enabling * various bits of hardware during the process. This function is a * synthesis of six nv4x traces, nearly each card doing a subtly * different thing. With luck all the necessary bits for each card are * combined herein. Without luck it deviates from each card's formula * so as to not work on any :) */ uint32_t Preg = NMNMreg - 4; bool mpll = Preg == 0x4020; uint32_t oldPval = nvReadMC(dev, Preg); uint32_t NMNM = pv->NM2 << 16 | pv->NM1; uint32_t Pval = (oldPval & (mpll ? ~(0x77 << 16) : ~(7 << 16))) | 0xc << 28 | pv->log2P << 16; uint32_t saved4600 = 0; /* some cards have different maskc040s */ uint32_t maskc040 = ~(3 << 14), savedc040; bool single_stage = !pv->NM2 || pv->N2 == pv->M2; if (nvReadMC(dev, NMNMreg) == NMNM && (oldPval & 0xc0070000) == Pval) return; if (Preg == 0x4000) maskc040 = ~0x333; if (Preg == 0x4058) maskc040 = ~(0xc << 24); if (mpll) { struct pll_lims pll_lim; uint8_t Pval2; if (get_pll_limits(dev, Preg, &pll_lim)) return; Pval2 = pv->log2P + pll_lim.log2p_bias; if (Pval2 > pll_lim.max_log2p) Pval2 = pll_lim.max_log2p; Pval |= 1 << 28 | Pval2 << 20; saved4600 = nvReadMC(dev, 0x4600); nvWriteMC(dev, 0x4600, saved4600 | 8 << 28); } if (single_stage) Pval |= mpll ? 1 << 12 : 1 << 8; nvWriteMC(dev, Preg, oldPval | 1 << 28); nvWriteMC(dev, Preg, Pval & ~(4 << 28)); if (mpll) { Pval |= 8 << 20; nvWriteMC(dev, 0x4020, Pval & ~(0xc << 28)); nvWriteMC(dev, 0x4038, Pval & ~(0xc << 28)); } savedc040 = nvReadMC(dev, 0xc040); nvWriteMC(dev, 0xc040, savedc040 & maskc040); nvWriteMC(dev, NMNMreg, NMNM); if (NMNMreg == 0x4024) nvWriteMC(dev, 0x403c, NMNM); nvWriteMC(dev, Preg, Pval); if (mpll) { Pval &= ~(8 << 20); nvWriteMC(dev, 0x4020, Pval); nvWriteMC(dev, 0x4038, Pval); nvWriteMC(dev, 0x4600, saved4600); } nvWriteMC(dev, 0xc040, savedc040); if (mpll) { nvWriteMC(dev, 0x4020, Pval & ~(1 << 28)); nvWriteMC(dev, 0x4038, Pval & ~(1 << 28)); } }
static void setPLL_double_highregs(struct drm_device *dev, uint32_t reg1, struct nouveau_pll_vals *pv) { struct drm_nouveau_private *dev_priv = dev->dev_private; int chip_version = dev_priv->vbios.chip_version; bool nv3035 = chip_version == 0x30 || chip_version == 0x35; uint32_t reg2 = reg1 + ((reg1 == NV_RAMDAC_VPLL2) ? 0x5c : 0x70); uint32_t oldpll1 = NVReadRAMDAC(dev, 0, reg1); uint32_t oldpll2 = !nv3035 ? NVReadRAMDAC(dev, 0, reg2) : 0; uint32_t pll1 = (oldpll1 & 0xfff80000) | pv->log2P << 16 | pv->NM1; uint32_t pll2 = (oldpll2 & 0x7fff0000) | 1 << 31 | pv->NM2; uint32_t oldramdac580 = 0, ramdac580 = 0; bool single_stage = !pv->NM2 || pv->N2 == pv->M2; /* nv41+ only */ uint32_t saved_powerctrl_1 = 0, savedc040 = 0; int shift_powerctrl_1 = powerctrl_1_shift(chip_version, reg1); /* model specific additions to generic pll1 and pll2 set up above */ if (nv3035) { pll1 = (pll1 & 0xfcc7ffff) | (pv->N2 & 0x18) << 21 | (pv->N2 & 0x7) << 19 | 8 << 4 | (pv->M2 & 7) << 4; pll2 = 0; } if (chip_version > 0x40 && reg1 >= NV_PRAMDAC_VPLL_COEFF) { /* !nv40 */ oldramdac580 = NVReadRAMDAC(dev, 0, NV_PRAMDAC_580); ramdac580 = new_ramdac580(reg1, single_stage, oldramdac580); if (oldramdac580 != ramdac580) oldpll1 = ~0; /* force mismatch */ if (single_stage) /* magic value used by nvidia in single stage mode */ pll2 |= 0x011f; } if (chip_version > 0x70) /* magic bits set by the blob (but not the bios) on g71-73 */ pll1 = (pll1 & 0x7fffffff) | (single_stage ? 0x4 : 0xc) << 28; if (oldpll1 == pll1 && oldpll2 == pll2) return; /* already set */ if (shift_powerctrl_1 >= 0) { saved_powerctrl_1 = nvReadMC(dev, NV_PBUS_POWERCTRL_1); nvWriteMC(dev, NV_PBUS_POWERCTRL_1, (saved_powerctrl_1 & ~(0xf << shift_powerctrl_1)) | 1 << shift_powerctrl_1); } if (chip_version >= 0x40) { int shift_c040 = 14; switch (reg1) { case NV_PRAMDAC_MPLL_COEFF: shift_c040 += 2; case NV_PRAMDAC_NVPLL_COEFF: shift_c040 += 2; case NV_RAMDAC_VPLL2: shift_c040 += 2; case NV_PRAMDAC_VPLL_COEFF: shift_c040 += 2; } savedc040 = nvReadMC(dev, 0xc040); if (shift_c040 != 14) nvWriteMC(dev, 0xc040, savedc040 & ~(3 << shift_c040)); } if (oldramdac580 != ramdac580) NVWriteRAMDAC(dev, 0, NV_PRAMDAC_580, ramdac580); if (!nv3035) NVWriteRAMDAC(dev, 0, reg2, pll2); NVWriteRAMDAC(dev, 0, reg1, pll1); if (shift_powerctrl_1 >= 0) nvWriteMC(dev, NV_PBUS_POWERCTRL_1, saved_powerctrl_1); if (chip_version >= 0x40) nvWriteMC(dev, 0xc040, savedc040); }