1 #ifndef __NVKM_INSTMEM_H__
2 #define __NVKM_INSTMEM_H__
3 #include <core/subdev.h>
4 
5 struct nvkm_instobj {
6 	struct nvkm_object object;
7 	struct list_head head;
8 	u32 *suspend;
9 	u64 addr;
10 	u32 size;
11 };
12 
13 static inline struct nvkm_instobj *
14 nv_memobj(void *obj)
15 {
16 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
17 	BUG_ON(!nv_iclass(obj, NV_MEMOBJ_CLASS));
18 #endif
19 	return obj;
20 }
21 
22 struct nvkm_instmem {
23 	struct nvkm_subdev subdev;
24 	struct list_head list;
25 
26 	u32 reserved;
27 	int (*alloc)(struct nvkm_instmem *, struct nvkm_object *,
28 		     u32 size, u32 align, struct nvkm_object **);
29 
30 	const struct nvkm_instmem_func *func;
31 };
32 
33 struct nvkm_instmem_func {
34 	u32  (*rd32)(struct nvkm_instmem *, u32 addr);
35 	void (*wr32)(struct nvkm_instmem *, u32 addr, u32 data);
36 };
37 
38 static inline struct nvkm_instmem *
39 nvkm_instmem(void *obj)
40 {
41 	/* nv04/nv40 impls need to create objects in their constructor,
42 	 * which is before the subdev pointer is valid
43 	 */
44 	if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
45 	    nv_subidx(obj) == NVDEV_SUBDEV_INSTMEM)
46 		return obj;
47 
48 	return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_INSTMEM);
49 }
50 
51 extern struct nvkm_oclass *nv04_instmem_oclass;
52 extern struct nvkm_oclass *nv40_instmem_oclass;
53 extern struct nvkm_oclass *nv50_instmem_oclass;
54 extern struct nvkm_oclass *gk20a_instmem_oclass;
55 #endif
56