diff options
author | Martin Peres <martin.peres@ensi-bourges.fr> | 2011-11-07 17:38:50 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2011-12-21 04:01:44 -0500 |
commit | eeb7a50bddb281d7beecb0ad73c9f1233e9932c2 (patch) | |
tree | 64e74c8fd82a07cc58c56cd3fe7ea492048cbbcf /drivers/gpu/drm/nouveau/nouveau_hwsq.h | |
parent | abbd3f8e3bea4b2b0490260e67357067a2dc2039 (diff) |
drm/nv50/pm: introduce hwsq-based memory reclocking
More work needs to be done on supporting the different memory types.
v2 (Ben Skeggs):
- fixed up conflicts from not having pausing patch first
- restructured code somewhat to fit with how all the other code works
- fixed bug where incorrect mpll_ctrl could get set sometimes
- removed stuff that's cargo-culted from the binary driver
- merged nv92+ display disable into hwsq
- fixed incorrect opcode 0x5f magic at end of ucode
Signed-off-by: Martin Peres <martin.peres@ensi-bourges.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_hwsq.h')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_hwsq.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_hwsq.h b/drivers/gpu/drm/nouveau/nouveau_hwsq.h new file mode 100644 index 00000000000..d59a3b3ff64 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nouveau_hwsq.h | |||
@@ -0,0 +1,98 @@ | |||
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_HWSQ_H__ | ||
26 | #define __NOUVEAU_HWSQ_H__ | ||
27 | |||
28 | struct hwsq_ucode { | ||
29 | u8 data[0x200]; | ||
30 | union { | ||
31 | u8 *u08; | ||
32 | u16 *u16; | ||
33 | u32 *u32; | ||
34 | } ptr; | ||
35 | u16 len; | ||
36 | |||
37 | u32 reg; | ||
38 | u32 val; | ||
39 | }; | ||
40 | |||
41 | static inline void | ||
42 | hwsq_init(struct hwsq_ucode *hwsq) | ||
43 | { | ||
44 | hwsq->ptr.u08 = hwsq->data; | ||
45 | hwsq->reg = 0xffffffff; | ||
46 | hwsq->val = 0xffffffff; | ||
47 | } | ||
48 | |||
49 | static inline void | ||
50 | hwsq_fini(struct hwsq_ucode *hwsq) | ||
51 | { | ||
52 | do { | ||
53 | *hwsq->ptr.u08++ = 0x7f; | ||
54 | hwsq->len = hwsq->ptr.u08 - hwsq->data; | ||
55 | } while (hwsq->len & 3); | ||
56 | hwsq->ptr.u08 = hwsq->data; | ||
57 | } | ||
58 | |||
59 | static inline void | ||
60 | hwsq_unkn(struct hwsq_ucode *hwsq, u8 v0) | ||
61 | { | ||
62 | *hwsq->ptr.u08++ = v0; | ||
63 | } | ||
64 | |||
65 | static inline void | ||
66 | hwsq_op5f(struct hwsq_ucode *hwsq, u8 v0, u8 v1) | ||
67 | { | ||
68 | *hwsq->ptr.u08++ = 0x5f; | ||
69 | *hwsq->ptr.u08++ = v0; | ||
70 | *hwsq->ptr.u08++ = v1; | ||
71 | } | ||
72 | |||
73 | static inline void | ||
74 | hwsq_wr32(struct hwsq_ucode *hwsq, u32 reg, u32 val) | ||
75 | { | ||
76 | if (val != hwsq->val) { | ||
77 | if ((val & 0xffff0000) == (hwsq->val & 0xffff0000)) { | ||
78 | *hwsq->ptr.u08++ = 0x42; | ||
79 | *hwsq->ptr.u16++ = (val & 0x0000ffff); | ||
80 | } else { | ||
81 | *hwsq->ptr.u08++ = 0xe2; | ||
82 | *hwsq->ptr.u32++ = val; | ||
83 | } | ||
84 | |||
85 | hwsq->val = val; | ||
86 | } | ||
87 | |||
88 | if ((reg & 0xffff0000) == (hwsq->reg & 0xffff0000)) { | ||
89 | *hwsq->ptr.u08++ = 0x40; | ||
90 | *hwsq->ptr.u16++ = (reg & 0x0000ffff); | ||
91 | } else { | ||
92 | *hwsq->ptr.u08++ = 0xe0; | ||
93 | *hwsq->ptr.u32++ = reg; | ||
94 | } | ||
95 | hwsq->reg = reg; | ||
96 | } | ||
97 | |||
98 | #endif | ||