af3938fb19e08caaafe3549d73ab12e8d71aa6af
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / nouveau / nvkm / engine / pm / priv.h
1 #ifndef __NVKM_PM_PRIV_H__
2 #define __NVKM_PM_PRIV_H__
3
4 #include <engine/pm.h>
5
6 struct nouveau_perfctr {
7         struct nouveau_object base;
8         struct list_head head;
9         struct nouveau_perfsig *signal[4];
10         int slot;
11         u32 logic_op;
12         u32 clk;
13         u32 ctr;
14 };
15
16 extern struct nouveau_oclass nouveau_pm_sclass[];
17
18 struct nouveau_perfctx {
19         struct nouveau_engctx base;
20 };
21
22 extern struct nouveau_oclass nouveau_pm_cclass;
23
24 struct nouveau_specsig {
25         u8 signal;
26         const char *name;
27 };
28
29 struct nouveau_perfsig {
30         const char *name;
31 };
32
33 struct nouveau_perfdom;
34 struct nouveau_perfctr *
35 nouveau_perfsig_wrap(struct nouveau_pm *, const char *,
36                      struct nouveau_perfdom **);
37
38 struct nouveau_specdom {
39         u16 signal_nr;
40         const struct nouveau_specsig *signal;
41         const struct nouveau_funcdom *func;
42 };
43
44 extern const struct nouveau_specdom nva3_pm_pwr[];
45 extern const struct nouveau_specdom nvc0_pm_pwr[];
46 extern const struct nouveau_specdom nve0_pm_pwr[];
47
48 struct nouveau_perfdom {
49         struct list_head head;
50         struct list_head list;
51         const struct nouveau_funcdom *func;
52         char name[32];
53         u32 addr;
54         u8  quad;
55         u32 signal_nr;
56         struct nouveau_perfsig signal[];
57 };
58
59 struct nouveau_funcdom {
60         void (*init)(struct nouveau_pm *, struct nouveau_perfdom *,
61                      struct nouveau_perfctr *);
62         void (*read)(struct nouveau_pm *, struct nouveau_perfdom *,
63                      struct nouveau_perfctr *);
64         void (*next)(struct nouveau_pm *, struct nouveau_perfdom *);
65 };
66
67 int nouveau_perfdom_new(struct nouveau_pm *, const char *, u32,
68                         u32, u32, u32, const struct nouveau_specdom *);
69
70 #define nouveau_pm_create(p,e,o,d)                                        \
71         nouveau_pm_create_((p), (e), (o), sizeof(**d), (void **)d)
72 #define nouveau_pm_dtor(p) ({                                             \
73         struct nouveau_pm *c = (p);                                       \
74         _nouveau_pm_dtor(nv_object(c));                                   \
75 })
76 #define nouveau_pm_init(p) ({                                             \
77         struct nouveau_pm *c = (p);                                       \
78         _nouveau_pm_init(nv_object(c));                                   \
79 })
80 #define nouveau_pm_fini(p,s) ({                                           \
81         struct nouveau_pm *c = (p);                                       \
82         _nouveau_pm_fini(nv_object(c), (s));                              \
83 })
84
85 int nouveau_pm_create_(struct nouveau_object *, struct nouveau_object *,
86                             struct nouveau_oclass *, int, void **);
87 void _nouveau_pm_dtor(struct nouveau_object *);
88 int  _nouveau_pm_init(struct nouveau_object *);
89 int  _nouveau_pm_fini(struct nouveau_object *, bool);
90
91 #endif