aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/Makefile2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_hw.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_pm.h5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c19
-rw-r--r--drivers/gpu/drm/nouveau/nv04_pm.c79
5 files changed, 110 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index c5319901e95c..3cedabeb1617 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -25,7 +25,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
25 nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \ 25 nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \
26 nv10_gpio.o nv50_gpio.o \ 26 nv10_gpio.o nv50_gpio.o \
27 nv50_calc.o \ 27 nv50_calc.o \
28 nv50_pm.o 28 nv04_pm.o nv50_pm.o
29 29
30nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o 30nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o
31nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o 31nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.c b/drivers/gpu/drm/nouveau/nouveau_hw.c
index e228aafc03e0..ebcf8a8190c2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hw.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hw.c
@@ -431,7 +431,8 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum pll_types plltype,
431 struct pll_lims pll_lim; 431 struct pll_lims pll_lim;
432 int ret; 432 int ret;
433 433
434 BUG_ON(reg1 == 0); 434 if (reg1 == 0)
435 return -ENOENT;
435 436
436 pll1 = nvReadMC(dev, reg1); 437 pll1 = nvReadMC(dev, reg1);
437 438
@@ -480,6 +481,7 @@ int
480nouveau_hw_get_clock(struct drm_device *dev, enum pll_types plltype) 481nouveau_hw_get_clock(struct drm_device *dev, enum pll_types plltype)
481{ 482{
482 struct nouveau_pll_vals pllvals; 483 struct nouveau_pll_vals pllvals;
484 int ret;
483 485
484 if (plltype == PLL_MEMORY && 486 if (plltype == PLL_MEMORY &&
485 (dev->pci_device & 0x0ff0) == CHIPSET_NFORCE) { 487 (dev->pci_device & 0x0ff0) == CHIPSET_NFORCE) {
@@ -499,7 +501,9 @@ nouveau_hw_get_clock(struct drm_device *dev, enum pll_types plltype)
499 return clock; 501 return clock;
500 } 502 }
501 503
502 nouveau_hw_get_pllvals(dev, plltype, &pllvals); 504 ret = nouveau_hw_get_pllvals(dev, plltype, &pllvals);
505 if (ret)
506 return ret;
503 507
504 return nouveau_hw_pllvals_to_clk(&pllvals); 508 return nouveau_hw_pllvals_to_clk(&pllvals);
505} 509}
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.h b/drivers/gpu/drm/nouveau/nouveau_pm.h
index 81d27722964b..70e1862572f8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.h
@@ -41,6 +41,11 @@ int nouveau_voltage_gpio_set(struct drm_device *, int voltage);
41void nouveau_perf_init(struct drm_device *); 41void nouveau_perf_init(struct drm_device *);
42void nouveau_perf_fini(struct drm_device *); 42void nouveau_perf_fini(struct drm_device *);
43 43
44/* nv04_pm.c */
45int nv04_pm_clock_get(struct drm_device *, u32 id);
46void *nv04_pm_clock_pre(struct drm_device *, u32 id, int khz);
47void nv04_pm_clock_set(struct drm_device *, void *);
48
44/* nv50_pm.c */ 49/* nv50_pm.c */
45int nv50_pm_clock_get(struct drm_device *, u32 id); 50int nv50_pm_clock_get(struct drm_device *, u32 id);
46void *nv50_pm_clock_pre(struct drm_device *, u32 id, int khz); 51void *nv50_pm_clock_pre(struct drm_device *, u32 id, int khz);
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index bbe9ba015bca..f9f77de6bbc0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -96,6 +96,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
96 engine->gpio.get = NULL; 96 engine->gpio.get = NULL;
97 engine->gpio.set = NULL; 97 engine->gpio.set = NULL;
98 engine->gpio.irq_enable = NULL; 98 engine->gpio.irq_enable = NULL;
99 engine->pm.clock_get = nv04_pm_clock_get;
100 engine->pm.clock_pre = nv04_pm_clock_pre;
101 engine->pm.clock_set = nv04_pm_clock_set;
99 break; 102 break;
100 case 0x10: 103 case 0x10:
101 engine->instmem.init = nv04_instmem_init; 104 engine->instmem.init = nv04_instmem_init;
@@ -147,6 +150,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
147 engine->gpio.get = nv10_gpio_get; 150 engine->gpio.get = nv10_gpio_get;
148 engine->gpio.set = nv10_gpio_set; 151 engine->gpio.set = nv10_gpio_set;
149 engine->gpio.irq_enable = NULL; 152 engine->gpio.irq_enable = NULL;
153 engine->pm.clock_get = nv04_pm_clock_get;
154 engine->pm.clock_pre = nv04_pm_clock_pre;
155 engine->pm.clock_set = nv04_pm_clock_set;
150 break; 156 break;
151 case 0x20: 157 case 0x20:
152 engine->instmem.init = nv04_instmem_init; 158 engine->instmem.init = nv04_instmem_init;
@@ -198,6 +204,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
198 engine->gpio.get = nv10_gpio_get; 204 engine->gpio.get = nv10_gpio_get;
199 engine->gpio.set = nv10_gpio_set; 205 engine->gpio.set = nv10_gpio_set;
200 engine->gpio.irq_enable = NULL; 206 engine->gpio.irq_enable = NULL;
207 engine->pm.clock_get = nv04_pm_clock_get;
208 engine->pm.clock_pre = nv04_pm_clock_pre;
209 engine->pm.clock_set = nv04_pm_clock_set;
201 break; 210 break;
202 case 0x30: 211 case 0x30:
203 engine->instmem.init = nv04_instmem_init; 212 engine->instmem.init = nv04_instmem_init;
@@ -249,6 +258,11 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
249 engine->gpio.get = nv10_gpio_get; 258 engine->gpio.get = nv10_gpio_get;
250 engine->gpio.set = nv10_gpio_set; 259 engine->gpio.set = nv10_gpio_set;
251 engine->gpio.irq_enable = NULL; 260 engine->gpio.irq_enable = NULL;
261 engine->pm.clock_get = nv04_pm_clock_get;
262 engine->pm.clock_pre = nv04_pm_clock_pre;
263 engine->pm.clock_set = nv04_pm_clock_set;
264 engine->pm.voltage_get = nouveau_voltage_gpio_get;
265 engine->pm.voltage_set = nouveau_voltage_gpio_set;
252 break; 266 break;
253 case 0x40: 267 case 0x40:
254 case 0x60: 268 case 0x60:
@@ -301,6 +315,11 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
301 engine->gpio.get = nv10_gpio_get; 315 engine->gpio.get = nv10_gpio_get;
302 engine->gpio.set = nv10_gpio_set; 316 engine->gpio.set = nv10_gpio_set;
303 engine->gpio.irq_enable = NULL; 317 engine->gpio.irq_enable = NULL;
318 engine->pm.clock_get = nv04_pm_clock_get;
319 engine->pm.clock_pre = nv04_pm_clock_pre;
320 engine->pm.clock_set = nv04_pm_clock_set;
321 engine->pm.voltage_get = nouveau_voltage_gpio_get;
322 engine->pm.voltage_set = nouveau_voltage_gpio_set;
304 break; 323 break;
305 case 0x50: 324 case 0x50:
306 case 0x80: /* gotta love NVIDIA's consistency.. */ 325 case 0x80: /* gotta love NVIDIA's consistency.. */
diff --git a/drivers/gpu/drm/nouveau/nv04_pm.c b/drivers/gpu/drm/nouveau/nv04_pm.c
new file mode 100644
index 000000000000..35c200eb476c
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nv04_pm.c
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2010 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include "drmP.h"
26#include "nouveau_drv.h"
27#include "nouveau_hw.h"
28
29struct nv04_pm_state {
30 struct pll_lims pll;
31 struct nouveau_pll_vals calc;
32};
33
34int
35nv04_pm_clock_get(struct drm_device *dev, u32 id)
36{
37 return nouveau_hw_get_clock(dev, id);
38}
39
40void *
41nv04_pm_clock_pre(struct drm_device *dev, u32 id, int khz)
42{
43 struct nv04_pm_state *state;
44 int ret;
45
46 state = kzalloc(sizeof(*state), GFP_KERNEL);
47 if (!state)
48 return ERR_PTR(-ENOMEM);
49
50 ret = get_pll_limits(dev, id, &state->pll);
51 if (ret) {
52 kfree(state);
53 return ERR_PTR(ret);
54 }
55
56 ret = nouveau_calc_pll_mnp(dev, &state->pll, khz, &state->calc);
57 if (!ret) {
58 kfree(state);
59 return ERR_PTR(-EINVAL);
60 }
61
62 return state;
63}
64
65void
66nv04_pm_clock_set(struct drm_device *dev, void *pre_state)
67{
68 struct drm_nouveau_private *dev_priv = dev->dev_private;
69 struct nv04_pm_state *state = pre_state;
70 u32 reg = state->pll.reg;
71
72 /* thank the insane nouveau_hw_setpll() interface for this */
73 if (dev_priv->card_type >= NV_40)
74 reg += 4;
75
76 nouveau_hw_setpll(dev, reg, &state->calc);
77 kfree(state);
78}
79