1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVKM_PMU_H__
3 #define __NVKM_PMU_H__
4 #include <core/subdev.h>
5 #include <engine/falcon.h>
6 
7 struct nvkm_pmu {
8 	const struct nvkm_pmu_func *func;
9 	struct nvkm_subdev subdev;
10 	struct nvkm_falcon *falcon;
11 	struct nvkm_msgqueue *queue;
12 
13 	struct {
14 		u32 base;
15 		u32 size;
16 	} send;
17 
18 	struct {
19 		u32 base;
20 		u32 size;
21 
22 		struct work_struct work;
23 		wait_queue_head_t wait;
24 		u32 process;
25 		u32 message;
26 		u32 data[2];
27 	} recv;
28 };
29 
30 int nvkm_pmu_send(struct nvkm_pmu *, u32 reply[2], u32 process,
31 		  u32 message, u32 data0, u32 data1);
32 void nvkm_pmu_pgob(struct nvkm_pmu *, bool enable);
33 
34 int gt215_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
35 int gf100_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
36 int gf119_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
37 int gk104_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
38 int gk110_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
39 int gk208_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
40 int gk20a_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
41 int gm107_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
42 int gm20b_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
43 int gp100_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
44 int gp102_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
45 
46 /* interface to MEMX process running on PMU */
47 struct nvkm_memx;
48 int  nvkm_memx_init(struct nvkm_pmu *, struct nvkm_memx **);
49 int  nvkm_memx_fini(struct nvkm_memx **, bool exec);
50 void nvkm_memx_wr32(struct nvkm_memx *, u32 addr, u32 data);
51 void nvkm_memx_wait(struct nvkm_memx *, u32 addr, u32 mask, u32 data, u32 nsec);
52 void nvkm_memx_nsec(struct nvkm_memx *, u32 nsec);
53 void nvkm_memx_wait_vblank(struct nvkm_memx *);
54 void nvkm_memx_train(struct nvkm_memx *);
55 int  nvkm_memx_train_result(struct nvkm_pmu *, u32 *, int);
56 void nvkm_memx_block(struct nvkm_memx *);
57 void nvkm_memx_unblock(struct nvkm_memx *);
58 #endif
59