diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-07-31 02:16:21 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-02 23:12:59 -0400 |
commit | 77145f1cbdf8d28b46ff8070ca749bad821e0774 (patch) | |
tree | b496d5d69ce4f5753028b07b09d8cf12025310f2 /drivers/gpu/drm/nouveau/nouveau_pm.h | |
parent | 2094dd82eddc468b53ee99d92c38b23a65efac03 (diff) |
drm/nouveau: port remainder of drm code, and rip out compat layer
v2: Ben Skeggs <bskeggs@redhat.com>
- fill in nouveau_pm.dev to prevent oops
- fix ppc issues (build + OF shadow)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_pm.h')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.h | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.h b/drivers/gpu/drm/nouveau/nouveau_pm.h index 07cac72c72b4..e2ec9c0ed567 100644 --- a/drivers/gpu/drm/nouveau/nouveau_pm.h +++ b/drivers/gpu/drm/nouveau/nouveau_pm.h | |||
@@ -25,6 +25,178 @@ | |||
25 | #ifndef __NOUVEAU_PM_H__ | 25 | #ifndef __NOUVEAU_PM_H__ |
26 | #define __NOUVEAU_PM_H__ | 26 | #define __NOUVEAU_PM_H__ |
27 | 27 | ||
28 | #include <subdev/bios/pll.h> | ||
29 | #include <subdev/clock.h> | ||
30 | |||
31 | struct nouveau_pm_voltage_level { | ||
32 | u32 voltage; /* microvolts */ | ||
33 | u8 vid; | ||
34 | }; | ||
35 | |||
36 | struct nouveau_pm_voltage { | ||
37 | bool supported; | ||
38 | u8 version; | ||
39 | u8 vid_mask; | ||
40 | |||
41 | struct nouveau_pm_voltage_level *level; | ||
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 | |||
55 | struct nouveau_pm_memtiming { | ||
56 | int id; | ||
57 | |||
58 | u32 reg[9]; | ||
59 | u32 mr[4]; | ||
60 | |||
61 | u8 tCWL; | ||
62 | |||
63 | u8 odt; | ||
64 | u8 drive_strength; | ||
65 | }; | ||
66 | |||
67 | struct nouveau_pm_tbl_header { | ||
68 | u8 version; | ||
69 | u8 header_len; | ||
70 | u8 entry_cnt; | ||
71 | u8 entry_len; | ||
72 | }; | ||
73 | |||
74 | struct nouveau_pm_tbl_entry { | ||
75 | u8 tWR; | ||
76 | u8 tWTR; | ||
77 | u8 tCL; | ||
78 | u8 tRC; | ||
79 | u8 empty_4; | ||
80 | u8 tRFC; /* Byte 5 */ | ||
81 | u8 empty_6; | ||
82 | u8 tRAS; /* Byte 7 */ | ||
83 | u8 empty_8; | ||
84 | u8 tRP; /* Byte 9 */ | ||
85 | u8 tRCDRD; | ||
86 | u8 tRCDWR; | ||
87 | u8 tRRD; | ||
88 | u8 tUNK_13; | ||
89 | u8 RAM_FT1; /* 14, a bitmask of random RAM features */ | ||
90 | u8 empty_15; | ||
91 | u8 tUNK_16; | ||
92 | u8 empty_17; | ||
93 | u8 tUNK_18; | ||
94 | u8 tCWL; | ||
95 | u8 tUNK_20, tUNK_21; | ||
96 | }; | ||
97 | |||
98 | struct nouveau_pm_profile; | ||
99 | struct nouveau_pm_profile_func { | ||
100 | void (*destroy)(struct nouveau_pm_profile *); | ||
101 | void (*init)(struct nouveau_pm_profile *); | ||
102 | void (*fini)(struct nouveau_pm_profile *); | ||
103 | struct nouveau_pm_level *(*select)(struct nouveau_pm_profile *); | ||
104 | }; | ||
105 | |||
106 | struct nouveau_pm_profile { | ||
107 | const struct nouveau_pm_profile_func *func; | ||
108 | struct list_head head; | ||
109 | char name[8]; | ||
110 | }; | ||
111 | |||
112 | #define NOUVEAU_PM_MAX_LEVEL 8 | ||
113 | struct nouveau_pm_level { | ||
114 | struct nouveau_pm_profile profile; | ||
115 | struct device_attribute dev_attr; | ||
116 | char name[32]; | ||
117 | int id; | ||
118 | |||
119 | struct nouveau_pm_memtiming timing; | ||
120 | u32 memory; | ||
121 | u16 memscript; | ||
122 | |||
123 | u32 core; | ||
124 | u32 shader; | ||
125 | u32 rop; | ||
126 | u32 copy; | ||
127 | u32 daemon; | ||
128 | u32 vdec; | ||
129 | u32 dom6; | ||
130 | u32 unka0; /* nva3:nvc0 */ | ||
131 | u32 hub01; /* nvc0- */ | ||
132 | u32 hub06; /* nvc0- */ | ||
133 | u32 hub07; /* nvc0- */ | ||
134 | |||
135 | u32 volt_min; /* microvolts */ | ||
136 | u32 volt_max; | ||
137 | u8 fanspeed; | ||
138 | }; | ||
139 | |||
140 | struct nouveau_pm_temp_sensor_constants { | ||
141 | u16 offset_constant; | ||
142 | s16 offset_mult; | ||
143 | s16 offset_div; | ||
144 | s16 slope_mult; | ||
145 | s16 slope_div; | ||
146 | }; | ||
147 | |||
148 | struct nouveau_pm_threshold_temp { | ||
149 | s16 critical; | ||
150 | s16 down_clock; | ||
151 | s16 fan_boost; | ||
152 | }; | ||
153 | |||
154 | struct nouveau_pm_fan { | ||
155 | u32 percent; | ||
156 | u32 min_duty; | ||
157 | u32 max_duty; | ||
158 | u32 pwm_freq; | ||
159 | u32 pwm_divisor; | ||
160 | }; | ||
161 | |||
162 | struct nouveau_pm { | ||
163 | struct drm_device *dev; | ||
164 | |||
165 | struct nouveau_pm_voltage voltage; | ||
166 | struct nouveau_pm_level perflvl[NOUVEAU_PM_MAX_LEVEL]; | ||
167 | int nr_perflvl; | ||
168 | struct nouveau_pm_temp_sensor_constants sensor_constants; | ||
169 | struct nouveau_pm_threshold_temp threshold_temp; | ||
170 | struct nouveau_pm_fan fan; | ||
171 | |||
172 | struct nouveau_pm_profile *profile_ac; | ||
173 | struct nouveau_pm_profile *profile_dc; | ||
174 | struct nouveau_pm_profile *profile; | ||
175 | struct list_head profiles; | ||
176 | |||
177 | struct nouveau_pm_level boot; | ||
178 | struct nouveau_pm_level *cur; | ||
179 | |||
180 | struct device *hwmon; | ||
181 | struct notifier_block acpi_nb; | ||
182 | |||
183 | int (*clocks_get)(struct drm_device *, struct nouveau_pm_level *); | ||
184 | void *(*clocks_pre)(struct drm_device *, struct nouveau_pm_level *); | ||
185 | int (*clocks_set)(struct drm_device *, void *); | ||
186 | |||
187 | int (*voltage_get)(struct drm_device *); | ||
188 | int (*voltage_set)(struct drm_device *, int voltage); | ||
189 | int (*pwm_get)(struct drm_device *, int line, u32*, u32*); | ||
190 | int (*pwm_set)(struct drm_device *, int line, u32, u32); | ||
191 | int (*temp_get)(struct drm_device *); | ||
192 | }; | ||
193 | |||
194 | static inline struct nouveau_pm * | ||
195 | nouveau_pm(struct drm_device *dev) | ||
196 | { | ||
197 | return nouveau_drm(dev)->pm; | ||
198 | } | ||
199 | |||
28 | struct nouveau_mem_exec_func { | 200 | struct nouveau_mem_exec_func { |
29 | struct drm_device *dev; | 201 | struct drm_device *dev; |
30 | void (*precharge)(struct nouveau_mem_exec_func *); | 202 | void (*precharge)(struct nouveau_mem_exec_func *); |
@@ -106,4 +278,26 @@ void nouveau_temp_safety_checks(struct drm_device *dev); | |||
106 | int nv40_temp_get(struct drm_device *dev); | 278 | int nv40_temp_get(struct drm_device *dev); |
107 | int nv84_temp_get(struct drm_device *dev); | 279 | int nv84_temp_get(struct drm_device *dev); |
108 | 280 | ||
281 | /* nouveau_mem.c */ | ||
282 | int nouveau_mem_timing_calc(struct drm_device *, u32 freq, | ||
283 | struct nouveau_pm_memtiming *); | ||
284 | void nouveau_mem_timing_read(struct drm_device *, | ||
285 | struct nouveau_pm_memtiming *); | ||
286 | |||
287 | static inline int | ||
288 | nva3_calc_pll(struct drm_device *dev, struct nvbios_pll *pll, u32 freq, | ||
289 | int *N, int *fN, int *M, int *P) | ||
290 | { | ||
291 | struct nouveau_device *device = nouveau_dev(dev); | ||
292 | struct nouveau_clock *clk = nouveau_clock(device); | ||
293 | struct nouveau_pll_vals pv; | ||
294 | int ret; | ||
295 | |||
296 | ret = clk->pll_calc(clk, pll, freq, &pv); | ||
297 | *N = pv.N1; | ||
298 | *M = pv.M1; | ||
299 | *P = pv.log2P; | ||
300 | return ret; | ||
301 | } | ||
302 | |||
109 | #endif | 303 | #endif |