Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250673
b: refs/heads/master
c: 215f902
h: refs/heads/master
i:
  250671: 266de6d
v: v3
  • Loading branch information
Ben Skeggs committed May 16, 2011
1 parent be72857 commit c2ea6e4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ce521846b9bde836d010416b6120a694b5f06e96
refs/heads/master: 215f902e1555e0fa94c1de547dcd246c6f5306e2
56 changes: 46 additions & 10 deletions trunk/drivers/gpu/drm/nouveau/nva3_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,68 @@
#include "nouveau_bios.h"
#include "nouveau_pm.h"

/*XXX: boards using limits 0x40 need fixing, the register layout
* is correct here, but, there's some other funny magic
* that modifies things, so it's not likely we'll set/read
* the correct timings yet.. working on it...
/* This is actually a lot more complex than it appears here, but hopefully
* this should be able to deal with what the VBIOS leaves for us..
*
* If not, well, I'll jump off that bridge when I come to it.
*/

struct nva3_pm_state {
struct pll_lims pll;
int N, M, P;
};

static int
nva3_pm_pll_offset(u32 id)
{
static const u32 pll_map[] = {
0x00, PLL_CORE,
0x01, PLL_SHADER,
0x02, PLL_MEMORY,
0x00, 0x00
};
const u32 *map = pll_map;

while (map[1]) {
if (id == map[1])
return map[0];
map += 2;
}

return -ENOENT;
}

int
nva3_pm_clock_get(struct drm_device *dev, u32 id)
{
u32 src0, src1, ctrl, coef;
struct pll_lims pll;
int P, N, M, ret;
u32 reg;
int ret, off;
int P, N, M;

ret = get_pll_limits(dev, id, &pll);
if (ret)
return ret;

reg = nv_rd32(dev, pll.reg + 4);
P = (reg & 0x003f0000) >> 16;
N = (reg & 0x0000ff00) >> 8;
M = (reg & 0x000000ff);
off = nva3_pm_pll_offset(id);
if (off < 0)
return off;

src0 = nv_rd32(dev, 0x4120 + (off * 4));
src1 = nv_rd32(dev, 0x4160 + (off * 4));
ctrl = nv_rd32(dev, pll.reg + 0);
coef = nv_rd32(dev, pll.reg + 4);
NV_DEBUG(dev, "PLL %02x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
id, src0, src1, ctrl, coef);

if (ctrl & 0x00000008) {
u32 div = ((src1 & 0x003c0000) >> 18) + 1;
return (pll.refclk * 2) / div;
}

P = (coef & 0x003f0000) >> 16;
N = (coef & 0x0000ff00) >> 8;
M = (coef & 0x000000ff);
return pll.refclk * N / M / P;
}

Expand Down

0 comments on commit c2ea6e4

Please sign in to comment.