• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __NVKM_FALCON_H__
2 #define __NVKM_FALCON_H__
3 #include <engine/falcon.h>
4 
5 int nvkm_falcon_ctor(const struct nvkm_falcon_func *, struct nvkm_subdev *owner,
6 		     const char *name, u32 addr, struct nvkm_falcon *);
7 void nvkm_falcon_dtor(struct nvkm_falcon *);
8 
9 void nvkm_falcon_v1_load_imem(struct nvkm_falcon *,
10 			      void *, u32, u32, u16, u8, bool);
11 void nvkm_falcon_v1_load_dmem(struct nvkm_falcon *, void *, u32, u32, u8);
12 void nvkm_falcon_v1_read_dmem(struct nvkm_falcon *, u32, u32, u8, void *);
13 void nvkm_falcon_v1_bind_context(struct nvkm_falcon *, struct nvkm_memory *);
14 int nvkm_falcon_v1_wait_for_halt(struct nvkm_falcon *, u32);
15 int nvkm_falcon_v1_clear_interrupt(struct nvkm_falcon *, u32);
16 void nvkm_falcon_v1_set_start_addr(struct nvkm_falcon *, u32 start_addr);
17 void nvkm_falcon_v1_start(struct nvkm_falcon *);
18 int nvkm_falcon_v1_enable(struct nvkm_falcon *);
19 void nvkm_falcon_v1_disable(struct nvkm_falcon *);
20 
21 void gp102_sec2_flcn_bind_context(struct nvkm_falcon *, struct nvkm_memory *);
22 int gp102_sec2_flcn_enable(struct nvkm_falcon *);
23 
24 #define FLCN_PRINTK(t,f,fmt,a...) do {                               \
25 	if ((f)->owner->name != (f)->name)                           \
26 		nvkm_##t((f)->owner, "%s: "fmt"\n", (f)->name, ##a); \
27 	else                                                         \
28 		nvkm_##t((f)->owner, fmt"\n", ##a);                  \
29 } while(0)
30 #define FLCN_DBG(f,fmt,a...) FLCN_PRINTK(debug, (f), fmt, ##a)
31 #define FLCN_ERR(f,fmt,a...) FLCN_PRINTK(error, (f), fmt, ##a)
32 
33 /**
34  * struct nvfw_falcon_msg - header for all messages
35  *
36  * @unit_id:	id of firmware process that sent the message
37  * @size:	total size of message
38  * @ctrl_flags:	control flags
39  * @seq_id:	used to match a message from its corresponding command
40  */
41 struct nvfw_falcon_msg {
42 	u8 unit_id;
43 	u8 size;
44 	u8 ctrl_flags;
45 	u8 seq_id;
46 };
47 
48 #define nvfw_falcon_cmd nvfw_falcon_msg
49 #define NV_FALCON_CMD_UNIT_ID_REWIND                                       0x00
50 
51 struct nvkm_falcon_qmgr;
52 int nvkm_falcon_qmgr_new(struct nvkm_falcon *, struct nvkm_falcon_qmgr **);
53 void nvkm_falcon_qmgr_del(struct nvkm_falcon_qmgr **);
54 
55 typedef int
56 (*nvkm_falcon_qmgr_callback)(void *priv, struct nvfw_falcon_msg *);
57 
58 struct nvkm_falcon_cmdq;
59 int nvkm_falcon_cmdq_new(struct nvkm_falcon_qmgr *, const char *name,
60 			 struct nvkm_falcon_cmdq **);
61 void nvkm_falcon_cmdq_del(struct nvkm_falcon_cmdq **);
62 void nvkm_falcon_cmdq_init(struct nvkm_falcon_cmdq *,
63 			   u32 index, u32 offset, u32 size);
64 void nvkm_falcon_cmdq_fini(struct nvkm_falcon_cmdq *);
65 int nvkm_falcon_cmdq_send(struct nvkm_falcon_cmdq *, struct nvfw_falcon_cmd *,
66 			  nvkm_falcon_qmgr_callback, void *priv,
67 			  unsigned long timeout_jiffies);
68 
69 struct nvkm_falcon_msgq;
70 int nvkm_falcon_msgq_new(struct nvkm_falcon_qmgr *, const char *name,
71 			 struct nvkm_falcon_msgq **);
72 void nvkm_falcon_msgq_del(struct nvkm_falcon_msgq **);
73 void nvkm_falcon_msgq_init(struct nvkm_falcon_msgq *,
74 			   u32 index, u32 offset, u32 size);
75 int nvkm_falcon_msgq_recv_initmsg(struct nvkm_falcon_msgq *, void *, u32 size);
76 void nvkm_falcon_msgq_recv(struct nvkm_falcon_msgq *);
77 #endif
78