diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2013-01-23 21:15:45 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-06-30 23:44:06 -0400 |
commit | da746d4ec9605302386bab46ea8dfdd66f94560c (patch) | |
tree | 380aa9f84f949dafe680e6889295c9c67fa4333f | |
parent | dceef5d87cc01358cc1434416f3272e2ddc3d97a (diff) |
drm/nva3/clk: minor improvements to fractional N calculation
Helps us to get identical numbers to the binary driver for (at least)
Kepler memory PLLs, and fixes a rounding error.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/clock/pllnva3.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/pllnva3.c b/drivers/gpu/drm/nouveau/core/subdev/clock/pllnva3.c index 4497378ba1e8..2fe1f712eefa 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/pllnva3.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/pllnva3.c | |||
@@ -50,8 +50,15 @@ nva3_pll_calc(struct nouveau_subdev *subdev, struct nvbios_pll *info, | |||
50 | u32 tmp = freq * *P * M; | 50 | u32 tmp = freq * *P * M; |
51 | N = tmp / info->refclk; | 51 | N = tmp / info->refclk; |
52 | fN = tmp % info->refclk; | 52 | fN = tmp % info->refclk; |
53 | if (!pfN && fN >= info->refclk / 2) | 53 | |
54 | N++; | 54 | if (!pfN) { |
55 | if (fN >= info->refclk / 2) | ||
56 | N++; | ||
57 | } else { | ||
58 | if (fN < info->refclk / 2) | ||
59 | N--; | ||
60 | fN = tmp - (N * info->refclk); | ||
61 | } | ||
55 | 62 | ||
56 | if (N < info->vco1.min_n) | 63 | if (N < info->vco1.min_n) |
57 | continue; | 64 | continue; |
@@ -66,7 +73,8 @@ nva3_pll_calc(struct nouveau_subdev *subdev, struct nvbios_pll *info, | |||
66 | } | 73 | } |
67 | 74 | ||
68 | if (pfN) { | 75 | if (pfN) { |
69 | *pfN = (((fN << 13) / info->refclk) - 4096) & 0xffff; | 76 | *pfN = ((fN << 13) + info->refclk / 2) / info->refclk; |
77 | *pfN = (*pfN - 4096) & 0xffff; | ||
70 | return freq; | 78 | return freq; |
71 | } | 79 | } |
72 | } | 80 | } |