1 #ifndef __NVKM_INSTMEM_H__
2 #define __NVKM_INSTMEM_H__
3 #include <core/subdev.h>
4 struct nvkm_memory;
5 
6 struct nvkm_instmem {
7 	struct nvkm_subdev subdev;
8 	struct list_head list;
9 
10 	u32 reserved;
11 	int (*alloc)(struct nvkm_instmem *, u32 size, u32 align, bool zero,
12 		     struct nvkm_memory **);
13 
14 	const struct nvkm_instmem_func *func;
15 
16 	struct nvkm_memory *vbios;
17 	struct nvkm_ramht  *ramht;
18 	struct nvkm_memory *ramro;
19 	struct nvkm_memory *ramfc;
20 };
21 
22 struct nvkm_instmem_func {
23 	u32  (*rd32)(struct nvkm_instmem *, u32 addr);
24 	void (*wr32)(struct nvkm_instmem *, u32 addr, u32 data);
25 };
26 
27 static inline struct nvkm_instmem *
28 nvkm_instmem(void *obj)
29 {
30 	/* nv04/nv40 impls need to create objects in their constructor,
31 	 * which is before the subdev pointer is valid
32 	 */
33 	if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
34 	    nv_subidx(obj) == NVDEV_SUBDEV_INSTMEM)
35 		return obj;
36 
37 	return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_INSTMEM);
38 }
39 
40 extern struct nvkm_oclass *nv04_instmem_oclass;
41 extern struct nvkm_oclass *nv40_instmem_oclass;
42 extern struct nvkm_oclass *nv50_instmem_oclass;
43 extern struct nvkm_oclass *gk20a_instmem_oclass;
44 #endif
45