xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h (revision 40d269c000bda9fcd276a0412a9cebd3f6e344c5)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_INSTMEM_PRIV_H__
3 #define __NVKM_INSTMEM_PRIV_H__
4 #define nvkm_instmem(p) container_of((p), struct nvkm_instmem, subdev)
5 #include <subdev/instmem.h>
6 
7 struct nvkm_instmem_func {
8 	void *(*dtor)(struct nvkm_instmem *);
9 	int (*oneinit)(struct nvkm_instmem *);
10 	int (*suspend)(struct nvkm_instmem *);
11 	void (*resume)(struct nvkm_instmem *);
12 	void (*fini)(struct nvkm_instmem *);
13 	u32  (*rd32)(struct nvkm_instmem *, u32 addr);
14 	void (*wr32)(struct nvkm_instmem *, u32 addr, u32 data);
15 	int (*memory_new)(struct nvkm_instmem *, u32 size, u32 align,
16 			  bool zero, struct nvkm_memory **);
17 	int (*memory_wrap)(struct nvkm_instmem *, struct nvkm_memory *, struct nvkm_memory **);
18 	bool zero;
19 };
20 
21 int nv50_instmem_new_(const struct nvkm_instmem_func *, struct nvkm_device *,
22 		      enum nvkm_subdev_type, int, struct nvkm_instmem **);
23 
24 void nvkm_instmem_ctor(const struct nvkm_instmem_func *, struct nvkm_device *,
25 		       enum nvkm_subdev_type, int, struct nvkm_instmem *);
26 void nvkm_instmem_boot(struct nvkm_instmem *);
27 
28 int nv04_instmem_suspend(struct nvkm_instmem *);
29 void nv04_instmem_resume(struct nvkm_instmem *);
30 
31 int r535_instmem_new(const struct nvkm_instmem_func *,
32 		     struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_instmem **);
33 
34 #include <core/memory.h>
35 
36 struct nvkm_instobj {
37 	struct nvkm_memory memory;
38 	struct list_head head;
39 	bool preserve;
40 	u32 *suspend;
41 };
42 
43 void nvkm_instobj_ctor(const struct nvkm_memory_func *func,
44 		       struct nvkm_instmem *, struct nvkm_instobj *);
45 void nvkm_instobj_dtor(struct nvkm_instmem *, struct nvkm_instobj *);
46 int nvkm_instobj_save(struct nvkm_instobj *);
47 void nvkm_instobj_load(struct nvkm_instobj *);
48 #endif
49