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