1 #ifndef __NVKM_ACR_PRIV_H__
2 #define __NVKM_ACR_PRIV_H__
3 #include <subdev/acr.h>
4 struct lsb_header_tail;
5 
6 struct nvkm_acr_fwif {
7 	int version;
8 	int (*load)(struct nvkm_acr *, int version,
9 		    const struct nvkm_acr_fwif *);
10 	const struct nvkm_acr_func *func;
11 };
12 
13 int gm20b_acr_load(struct nvkm_acr *, int, const struct nvkm_acr_fwif *);
14 int gp102_acr_load(struct nvkm_acr *, int, const struct nvkm_acr_fwif *);
15 
16 struct nvkm_acr_lsf;
17 struct nvkm_acr_func {
18 	const struct nvkm_acr_hsf_fwif *load;
19 	const struct nvkm_acr_hsf_fwif *ahesasc;
20 	const struct nvkm_acr_hsf_fwif *asb;
21 	const struct nvkm_acr_hsf_fwif *unload;
22 	int (*wpr_parse)(struct nvkm_acr *);
23 	u32 (*wpr_layout)(struct nvkm_acr *);
24 	int (*wpr_alloc)(struct nvkm_acr *, u32 wpr_size);
25 	int (*wpr_build)(struct nvkm_acr *, struct nvkm_acr_lsf *rtos);
26 	void (*wpr_patch)(struct nvkm_acr *, s64 adjust);
27 	void (*wpr_check)(struct nvkm_acr *, u64 *start, u64 *limit);
28 	int (*init)(struct nvkm_acr *);
29 	void (*fini)(struct nvkm_acr *);
30 };
31 
32 int gm200_acr_wpr_parse(struct nvkm_acr *);
33 u32 gm200_acr_wpr_layout(struct nvkm_acr *);
34 int gm200_acr_wpr_build(struct nvkm_acr *, struct nvkm_acr_lsf *);
35 void gm200_acr_wpr_patch(struct nvkm_acr *, s64);
36 void gm200_acr_wpr_check(struct nvkm_acr *, u64 *, u64 *);
37 void gm200_acr_wpr_build_lsb_tail(struct nvkm_acr_lsfw *,
38 				  struct lsb_header_tail *);
39 int gm200_acr_init(struct nvkm_acr *);
40 
41 int gm20b_acr_wpr_alloc(struct nvkm_acr *, u32 wpr_size);
42 
43 int gp102_acr_wpr_parse(struct nvkm_acr *);
44 u32 gp102_acr_wpr_layout(struct nvkm_acr *);
45 int gp102_acr_wpr_alloc(struct nvkm_acr *, u32 wpr_size);
46 int gp102_acr_wpr_build(struct nvkm_acr *, struct nvkm_acr_lsf *);
47 int gp102_acr_wpr_build_lsb(struct nvkm_acr *, struct nvkm_acr_lsfw *);
48 void gp102_acr_wpr_patch(struct nvkm_acr *, s64);
49 
50 struct nvkm_acr_hsfw {
51 	const struct nvkm_acr_hsf_func *func;
52 	const char *name;
53 	struct list_head head;
54 
55 	u32 imem_size;
56 	u32 imem_tag;
57 	u32 *imem;
58 
59 	u8 *image;
60 	u32 image_size;
61 	u32 non_sec_addr;
62 	u32 non_sec_size;
63 	u32 sec_addr;
64 	u32 sec_size;
65 	u32 data_addr;
66 	u32 data_size;
67 
68 	struct {
69 		struct {
70 			void *data;
71 			u32 size;
72 		} prod, dbg;
73 		u32 patch_loc;
74 	} sig;
75 };
76 
77 struct nvkm_acr_hsf_fwif {
78 	int version;
79 	int (*load)(struct nvkm_acr *, const char *bl, const char *fw,
80 		    const char *name, int version,
81 		    const struct nvkm_acr_hsf_fwif *);
82 	const struct nvkm_acr_hsf_func *func;
83 };
84 
85 int nvkm_acr_hsfw_load(struct nvkm_acr *, const char *, const char *,
86 		       const char *, int, const struct nvkm_acr_hsf_fwif *);
87 void nvkm_acr_hsfw_del_all(struct nvkm_acr *);
88 
89 struct nvkm_acr_hsf {
90 	const struct nvkm_acr_hsf_func *func;
91 	const char *name;
92 	struct list_head head;
93 
94 	u32 imem_size;
95 	u32 imem_tag;
96 	u32 *imem;
97 
98 	u32 non_sec_addr;
99 	u32 non_sec_size;
100 	u32 sec_addr;
101 	u32 sec_size;
102 	u32 data_addr;
103 	u32 data_size;
104 
105 	struct nvkm_memory *ucode;
106 	struct nvkm_vma *vma;
107 	struct nvkm_falcon *falcon;
108 };
109 
110 struct nvkm_acr_hsf_func {
111 	int (*load)(struct nvkm_acr *, struct nvkm_acr_hsfw *);
112 	int (*boot)(struct nvkm_acr *, struct nvkm_acr_hsf *);
113 	void (*bld)(struct nvkm_acr *, struct nvkm_acr_hsf *);
114 };
115 
116 int gm200_acr_hsfw_load(struct nvkm_acr *, struct nvkm_acr_hsfw *,
117 			struct nvkm_falcon *);
118 int gm200_acr_hsfw_boot(struct nvkm_acr *, struct nvkm_acr_hsf *,
119 			u32 clear_intr, u32 mbox0_ok);
120 
121 int gm200_acr_load_boot(struct nvkm_acr *, struct nvkm_acr_hsf *);
122 
123 extern const struct nvkm_acr_hsf_func gm200_acr_unload_0;
124 int gm200_acr_unload_load(struct nvkm_acr *, struct nvkm_acr_hsfw *);
125 int gm200_acr_unload_boot(struct nvkm_acr *, struct nvkm_acr_hsf *);
126 void gm200_acr_hsfw_bld(struct nvkm_acr *, struct nvkm_acr_hsf *);
127 
128 extern const struct nvkm_acr_hsf_func gm20b_acr_load_0;
129 
130 int gp102_acr_load_load(struct nvkm_acr *, struct nvkm_acr_hsfw *);
131 
132 extern const struct nvkm_acr_hsf_func gp108_acr_unload_0;
133 void gp108_acr_hsfw_bld(struct nvkm_acr *, struct nvkm_acr_hsf *);
134 
135 int nvkm_acr_new_(const struct nvkm_acr_fwif *, struct nvkm_device *, int,
136 		  struct nvkm_acr **);
137 int nvkm_acr_hsf_boot(struct nvkm_acr *, const char *name);
138 
139 struct nvkm_acr_lsf {
140 	const struct nvkm_acr_lsf_func *func;
141 	struct nvkm_falcon *falcon;
142 	enum nvkm_acr_lsf_id id;
143 	struct list_head head;
144 };
145 
146 struct nvkm_acr_lsfw *nvkm_acr_lsfw_add(const struct nvkm_acr_lsf_func *,
147 					struct nvkm_acr *, struct nvkm_falcon *,
148 					enum nvkm_acr_lsf_id);
149 void nvkm_acr_lsfw_del(struct nvkm_acr_lsfw *);
150 void nvkm_acr_lsfw_del_all(struct nvkm_acr *);
151 #endif
152