xref: /linux/drivers/gpu/drm/nouveau/include/nvkm/engine/falcon.h (revision 2ba9268dd603d23e17643437b2246acb6844953b)
1 #ifndef __NVKM_FALCON_H__
2 #define __NVKM_FALCON_H__
3 #include <core/engctx.h>
4 
5 struct nvkm_falcon_chan {
6 	struct nvkm_engctx base;
7 };
8 
9 #define nvkm_falcon_context_create(p,e,c,g,s,a,f,d)                         \
10 	nvkm_engctx_create((p), (e), (c), (g), (s), (a), (f), (d))
11 #define nvkm_falcon_context_destroy(d)                                      \
12 	nvkm_engctx_destroy(&(d)->base)
13 #define nvkm_falcon_context_init(d)                                         \
14 	nvkm_engctx_init(&(d)->base)
15 #define nvkm_falcon_context_fini(d,s)                                       \
16 	nvkm_engctx_fini(&(d)->base, (s))
17 
18 #define _nvkm_falcon_context_ctor _nvkm_engctx_ctor
19 #define _nvkm_falcon_context_dtor _nvkm_engctx_dtor
20 #define _nvkm_falcon_context_init _nvkm_engctx_init
21 #define _nvkm_falcon_context_fini _nvkm_engctx_fini
22 #define _nvkm_falcon_context_rd32 _nvkm_engctx_rd32
23 #define _nvkm_falcon_context_wr32 _nvkm_engctx_wr32
24 
25 struct nvkm_falcon_data {
26 	bool external;
27 };
28 
29 #include <core/engine.h>
30 
31 struct nvkm_falcon {
32 	struct nvkm_engine base;
33 
34 	u32 addr;
35 	u8  version;
36 	u8  secret;
37 
38 	struct nvkm_gpuobj *core;
39 	bool external;
40 
41 	struct {
42 		u32 limit;
43 		u32 *data;
44 		u32  size;
45 	} code;
46 
47 	struct {
48 		u32 limit;
49 		u32 *data;
50 		u32  size;
51 	} data;
52 };
53 
54 #define nv_falcon(priv) (&(priv)->base)
55 
56 #define nvkm_falcon_create(p,e,c,b,d,i,f,r)                                 \
57 	nvkm_falcon_create_((p), (e), (c), (b), (d), (i), (f),              \
58 			       sizeof(**r),(void **)r)
59 #define nvkm_falcon_destroy(p)                                              \
60 	nvkm_engine_destroy(&(p)->base)
61 #define nvkm_falcon_init(p) ({                                              \
62 	struct nvkm_falcon *falcon = (p);                                   \
63 	_nvkm_falcon_init(nv_object(falcon));                               \
64 })
65 #define nvkm_falcon_fini(p,s) ({                                            \
66 	struct nvkm_falcon *falcon = (p);                                   \
67 	_nvkm_falcon_fini(nv_object(falcon), (s));                          \
68 })
69 
70 int nvkm_falcon_create_(struct nvkm_object *, struct nvkm_object *,
71 			   struct nvkm_oclass *, u32, bool, const char *,
72 			   const char *, int, void **);
73 
74 void nvkm_falcon_intr(struct nvkm_subdev *subdev);
75 
76 #define _nvkm_falcon_dtor _nvkm_engine_dtor
77 int  _nvkm_falcon_init(struct nvkm_object *);
78 int  _nvkm_falcon_fini(struct nvkm_object *, bool);
79 u32  _nvkm_falcon_rd32(struct nvkm_object *, u64);
80 void _nvkm_falcon_wr32(struct nvkm_object *, u64, u32);
81 #endif
82