1 #ifndef __NVKM_PM_PRIV_H__
2 #define __NVKM_PM_PRIV_H__
3 #include <engine/pm.h>
4 
5 struct nvkm_perfctr {
6 	struct list_head head;
7 	u8 domain;
8 	u8  signal[4];
9 	u64 source[4][8];
10 	int slot;
11 	u32 logic_op;
12 	u32 ctr;
13 };
14 
15 extern struct nvkm_oclass nvkm_pm_sclass[];
16 
17 #include <core/engctx.h>
18 
19 struct nvkm_perfctx {
20 	struct nvkm_engctx base;
21 };
22 
23 extern struct nvkm_oclass nvkm_pm_cclass;
24 
25 struct nvkm_specmux {
26 	u32 mask;
27 	u8 shift;
28 	const char *name;
29 	bool enable;
30 };
31 
32 struct nvkm_specsrc {
33 	u32 addr;
34 	const struct nvkm_specmux *mux;
35 	const char *name;
36 };
37 
38 struct nvkm_perfsrc {
39 	struct list_head head;
40 	char *name;
41 	u32 addr;
42 	u32 mask;
43 	u8 shift;
44 	bool enable;
45 };
46 
47 extern const struct nvkm_specsrc nv50_zcull_sources[];
48 extern const struct nvkm_specsrc nv50_zrop_sources[];
49 extern const struct nvkm_specsrc g84_vfetch_sources[];
50 extern const struct nvkm_specsrc gt200_crop_sources[];
51 extern const struct nvkm_specsrc gt200_prop_sources[];
52 extern const struct nvkm_specsrc gt200_tex_sources[];
53 
54 struct nvkm_specsig {
55 	u8 signal;
56 	const char *name;
57 	const struct nvkm_specsrc *source;
58 };
59 
60 struct nvkm_perfsig {
61 	const char *name;
62 	u8 source[8];
63 };
64 
65 struct nvkm_specdom {
66 	u16 signal_nr;
67 	const struct nvkm_specsig *signal;
68 	const struct nvkm_funcdom *func;
69 };
70 
71 struct nvkm_perfdom {
72 	struct nvkm_object base;
73 	struct list_head head;
74 	struct list_head list;
75 	const struct nvkm_funcdom *func;
76 	struct nvkm_perfctr *ctr[4];
77 	char name[32];
78 	u32 addr;
79 	u8  mode;
80 	u32 clk;
81 	u16 signal_nr;
82 	struct nvkm_perfsig signal[];
83 };
84 
85 struct nvkm_funcdom {
86 	void (*init)(struct nvkm_pm *, struct nvkm_perfdom *,
87 		     struct nvkm_perfctr *);
88 	void (*read)(struct nvkm_pm *, struct nvkm_perfdom *,
89 		     struct nvkm_perfctr *);
90 	void (*next)(struct nvkm_pm *, struct nvkm_perfdom *);
91 };
92 
93 int nvkm_perfdom_new(struct nvkm_pm *, const char *, u32, u32, u32, u32,
94 		     const struct nvkm_specdom *);
95 
96 #define nvkm_pm_create(p,e,o,d)                                        \
97 	nvkm_pm_create_((p), (e), (o), sizeof(**d), (void **)d)
98 #define nvkm_pm_dtor(p) ({                                             \
99 	struct nvkm_pm *c = (p);                                       \
100 	_nvkm_pm_dtor(nv_object(c));                                   \
101 })
102 #define nvkm_pm_init(p) ({                                             \
103 	struct nvkm_pm *c = (p);                                       \
104 	_nvkm_pm_init(nv_object(c));                                   \
105 })
106 #define nvkm_pm_fini(p,s) ({                                           \
107 	struct nvkm_pm *c = (p);                                       \
108 	_nvkm_pm_fini(nv_object(c), (s));                              \
109 })
110 
111 int nvkm_pm_create_(struct nvkm_object *, struct nvkm_object *,
112 			    struct nvkm_oclass *, int, void **);
113 void _nvkm_pm_dtor(struct nvkm_object *);
114 int  _nvkm_pm_init(struct nvkm_object *);
115 int  _nvkm_pm_fini(struct nvkm_object *, bool);
116 #endif
117