Linux-libre 3.18.62-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / nouveau / core / include / subdev / instmem.h
1 #ifndef __NOUVEAU_INSTMEM_H__
2 #define __NOUVEAU_INSTMEM_H__
3
4 #include <core/subdev.h>
5 #include <core/device.h>
6 #include <core/mm.h>
7
8 struct nouveau_instobj {
9         struct nouveau_object base;
10         struct list_head head;
11         u32 *suspend;
12         u64 addr;
13         u32 size;
14 };
15
16 static inline struct nouveau_instobj *
17 nv_memobj(void *obj)
18 {
19 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
20         if (unlikely(!nv_iclass(obj, NV_MEMOBJ_CLASS)))
21                 nv_assert("BAD CAST -> NvMemObj, %08x", nv_hclass(obj));
22 #endif
23         return obj;
24 }
25
26 struct nouveau_instmem {
27         struct nouveau_subdev base;
28         struct list_head list;
29
30         u32 reserved;
31         int (*alloc)(struct nouveau_instmem *, struct nouveau_object *,
32                      u32 size, u32 align, struct nouveau_object **);
33 };
34
35 static inline struct nouveau_instmem *
36 nouveau_instmem(void *obj)
37 {
38         /* nv04/nv40 impls need to create objects in their constructor,
39          * which is before the subdev pointer is valid
40          */
41         if (nv_iclass(obj, NV_SUBDEV_CLASS) &&
42             nv_subidx(obj) == NVDEV_SUBDEV_INSTMEM)
43                 return obj;
44
45         return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_INSTMEM];
46 }
47
48 extern struct nouveau_oclass *nv04_instmem_oclass;
49 extern struct nouveau_oclass *nv40_instmem_oclass;
50 extern struct nouveau_oclass *nv50_instmem_oclass;
51
52 #endif