Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nouveau_pm.h
Go to the documentation of this file.
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 #ifndef __NOUVEAU_PM_H__
26 #define __NOUVEAU_PM_H__
27 
28 #include <subdev/bios/pll.h>
29 #include <subdev/clock.h>
30 
32  u32 voltage; /* microvolts */
34 };
35 
37  bool supported;
40 
42  int nr_level;
43 };
44 
45 /* Exclusive upper limits */
46 #define NV_MEM_CL_DDR2_MAX 8
47 #define NV_MEM_WR_DDR2_MAX 9
48 #define NV_MEM_CL_DDR3_MAX 17
49 #define NV_MEM_WR_DDR3_MAX 17
50 #define NV_MEM_CL_GDDR3_MAX 16
51 #define NV_MEM_WR_GDDR3_MAX 18
52 #define NV_MEM_CL_GDDR5_MAX 21
53 #define NV_MEM_WR_GDDR5_MAX 20
54 
56  int id;
57 
58  u32 reg[9];
59  u32 mr[4];
60 
62 
65 };
66 
72 };
73 
80  u8 tRFC; /* Byte 5 */
82  u8 tRAS; /* Byte 7 */
84  u8 tRP; /* Byte 9 */
89  u8 RAM_FT1; /* 14, a bitmask of random RAM features */
96 };
97 
98 struct nouveau_pm_profile;
103  struct nouveau_pm_level *(*select)(struct nouveau_pm_profile *);
104 };
105 
108  struct list_head head;
109  char name[8];
110 };
111 
112 #define NOUVEAU_PM_MAX_LEVEL 8
116  char name[32];
117  int id;
118 
122 
130  u32 unka0; /* nva3:nvc0 */
131  u32 hub01; /* nvc0- */
132  u32 hub06; /* nvc0- */
133  u32 hub07; /* nvc0- */
134 
135  u32 volt_min; /* microvolts */
138 };
139 
146 };
147 
151 };
152 
153 struct nouveau_pm {
154  struct drm_device *dev;
155 
161 
166 
169 
170  struct device *hwmon;
172 
173  int (*clocks_get)(struct drm_device *, struct nouveau_pm_level *);
174  void *(*clocks_pre)(struct drm_device *, struct nouveau_pm_level *);
175  int (*clocks_set)(struct drm_device *, void *);
176 
177  int (*voltage_get)(struct drm_device *);
178  int (*voltage_set)(struct drm_device *, int voltage);
179 };
180 
181 static inline struct nouveau_pm *
182 nouveau_pm(struct drm_device *dev)
183 {
184  return nouveau_drm(dev)->pm;
185 }
186 
188  struct drm_device *dev;
194  u32 (*mrg)(struct nouveau_mem_exec_func *, int mr);
195  void (*mrs)(struct nouveau_mem_exec_func *, int mr, u32 data);
198  void *priv;
199 };
200 
201 /* nouveau_mem.c */
203  struct nouveau_pm_level *);
204 
205 /* nouveau_pm.c */
206 int nouveau_pm_init(struct drm_device *dev);
207 void nouveau_pm_fini(struct drm_device *dev);
208 void nouveau_pm_resume(struct drm_device *dev);
210 void nouveau_pm_trigger(struct drm_device *dev);
211 
212 /* nouveau_volt.c */
213 void nouveau_volt_init(struct drm_device *);
214 void nouveau_volt_fini(struct drm_device *);
215 int nouveau_volt_vid_lookup(struct drm_device *, int voltage);
216 int nouveau_volt_lvl_lookup(struct drm_device *, int vid);
218 int nouveau_voltage_gpio_set(struct drm_device *, int voltage);
219 
220 /* nouveau_perf.c */
221 void nouveau_perf_init(struct drm_device *);
222 void nouveau_perf_fini(struct drm_device *);
224  u8 *hdr, u8 *cnt, u8 *len);
225 u8 *nouveau_perf_ramcfg(struct drm_device *, u32 freq, u8 *ver, u8 *len);
226 u8 *nouveau_perf_timing(struct drm_device *, u32 freq, u8 *ver, u8 *len);
227 
228 /* nouveau_mem.c */
229 void nouveau_mem_timing_init(struct drm_device *);
230 void nouveau_mem_timing_fini(struct drm_device *);
231 
232 /* nv04_pm.c */
233 int nv04_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
234 void *nv04_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
235 int nv04_pm_clocks_set(struct drm_device *, void *);
236 
237 /* nv40_pm.c */
238 int nv40_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
239 void *nv40_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
240 int nv40_pm_clocks_set(struct drm_device *, void *);
241 int nv40_pm_pwm_get(struct drm_device *, int, u32 *, u32 *);
242 int nv40_pm_pwm_set(struct drm_device *, int, u32, u32);
243 
244 /* nv50_pm.c */
245 int nv50_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
246 void *nv50_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
247 int nv50_pm_clocks_set(struct drm_device *, void *);
248 int nv50_pm_pwm_get(struct drm_device *, int, u32 *, u32 *);
249 int nv50_pm_pwm_set(struct drm_device *, int, u32, u32);
250 
251 /* nva3_pm.c */
252 int nva3_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
253 void *nva3_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
254 int nva3_pm_clocks_set(struct drm_device *, void *);
255 
256 /* nvc0_pm.c */
257 int nvc0_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
258 void *nvc0_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
259 int nvc0_pm_clocks_set(struct drm_device *, void *);
260 
261 /* nouveau_mem.c */
263  struct nouveau_pm_memtiming *);
264 void nouveau_mem_timing_read(struct drm_device *,
265  struct nouveau_pm_memtiming *);
266 
267 static inline int
268 nva3_calc_pll(struct drm_device *dev, struct nvbios_pll *pll, u32 freq,
269  int *N, int *fN, int *M, int *P)
270 {
271  struct nouveau_device *device = nouveau_dev(dev);
272  struct nouveau_clock *clk = nouveau_clock(device);
273  struct nouveau_pll_vals pv;
274  int ret;
275 
276  ret = clk->pll_calc(clk, pll, freq, &pv);
277  *N = pv.N1;
278  *M = pv.M1;
279  *P = pv.log2P;
280  return ret;
281 }
282 
283 #endif