summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gm20b/acr_gm20b.h
diff options
context:
space:
mode:
authorSupriya <ssharatkumar@nvidia.com>2014-06-13 03:14:27 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:10:14 -0400
commitb7793a493a1fa292a22d5ce84c43ee342b9824b2 (patch)
tree963d128e317d319d2f53aff96420aec17b732bf6 /drivers/gpu/nvgpu/gm20b/acr_gm20b.h
parentc32ac10b0bba400c1e83540a20c5ca210fa48613 (diff)
nvgpu: Host side changes to support HS mode
GM20B changes in PMU boot sequence to support booting in HS mode and LS mode Bug 1509680 Change-Id: I2832eda0efe17dd5e3a8f11dd06e7d4da267be70 Signed-off-by: Supriya <ssharatkumar@nvidia.com> Reviewed-on: http://git-master/r/423140 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Tested-by: Seshendra Gadagottu <sgadagottu@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Shridhar Rasal <srasal@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gm20b/acr_gm20b.h')
-rw-r--r--drivers/gpu/nvgpu/gm20b/acr_gm20b.h377
1 files changed, 377 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gm20b/acr_gm20b.h b/drivers/gpu/nvgpu/gm20b/acr_gm20b.h
new file mode 100644
index 00000000..e0dd50d0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gm20b/acr_gm20b.h
@@ -0,0 +1,377 @@
1/*
2 * GM20B ACR
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef __ACR_GM20B_H_
17#define __ACR_GM20B_H_
18#include "gk20a/gk20a.h"
19#include "mm_gm20b.h"
20
21/*Defines*/
22
23/*chip specific defines*/
24#define MAX_SUPPORTED_LSFM 1 /*PMU, FECS, GPCCS*/
25#define LSF_UCODE_DATA_ALIGNMENT 4096
26
27#define GM20B_PMU_UCODE_IMAGE "gpmu_ucode.bin"
28#define GM20B_HSBIN_PMU_UCODE_IMAGE "acr_ucode.bin"
29#define GM20B_HSBIN_PMU_BL_UCODE_IMAGE "pmu_bl.bin"
30
31#define LSFM_DISABLE_MASK_NONE (0x00000000) /*Disable all LS falcons*/
32#define LSFM_DISABLE_MASK_ALL (0xFFFFFFFF) /*Enable all LS falcons*/
33
34#define PMU_SECURE_MODE (0x1)
35#define PMU_LSFM_MANAGED (0x2)
36
37/*ACR load related*/
38/*!
39 * Supporting maximum of 2 regions.
40 * This is needed to pre-allocate space in DMEM
41 */
42#define T210_FLCN_ACR_MAX_REGIONS (2)
43#define LSF_BOOTSTRAP_OWNER_RESERVED_DMEM_SIZE (0x200)
44
45/*!
46 * Falcon Id Defines
47 * Defines a common Light Secure Falcon identifier.
48 */
49#define LSF_FALCON_ID_PMU (0)
50#define LSF_FALCON_ID_FECS (2)
51#define LSF_FALCON_ID_GPCCS (3)
52#define LSF_FALCON_ID_INVALID (0xFFFFFFFF)
53
54/*!
55 * Bootstrap Owner Defines
56 */
57#define LSF_BOOTSTRAP_OWNER_DEFAULT (LSF_FALCON_ID_PMU)
58
59/*!
60 * Image Status Defines
61 */
62#define LSF_IMAGE_STATUS_NONE (0)
63#define LSF_IMAGE_STATUS_COPY (1)
64#define LSF_IMAGE_STATUS_VALIDATION (2)
65#define LSF_IMAGE_STATUS_BOOTSTRAP_READY (3)
66
67/*LSB header related defines*/
68#define NV_FLCN_ACR_LSF_FLAG_LOAD_CODE_AT_0_FALSE 0
69#define NV_FLCN_ACR_LSF_FLAG_LOAD_CODE_AT_0_TRUE 1
70#define NV_FLCN_ACR_LSF_FLAG_DMACTL_REQ_CTX_FALSE 0
71#define NV_FLCN_ACR_LSF_FLAG_DMACTL_REQ_CTX_TRUE 4
72
73/*!
74 * Light Secure WPR Content Alignments
75 */
76#define LSF_LSB_HEADER_ALIGNMENT 256
77#define LSF_BL_DATA_ALIGNMENT 256
78#define LSF_BL_DATA_SIZE_ALIGNMENT 256
79#define LSF_BL_CODE_SIZE_ALIGNMENT 256
80
81/*!
82 * Falcon UCODE header index.
83 */
84#define FLCN_NL_UCODE_HDR_OS_CODE_OFF_IND (0)
85#define FLCN_NL_UCODE_HDR_OS_CODE_SIZE_IND (1)
86#define FLCN_NL_UCODE_HDR_OS_DATA_OFF_IND (2)
87#define FLCN_NL_UCODE_HDR_OS_DATA_SIZE_IND (3)
88#define FLCN_NL_UCODE_HDR_NUM_APPS_IND (4)
89/*!
90 * There are total N number of Apps with code and offset defined in UCODE header
91 * This macro provides the CODE and DATA offset and size of Ath application.
92 */
93#define FLCN_NL_UCODE_HDR_APP_CODE_START_IND (5)
94#define FLCN_NL_UCODE_HDR_APP_CODE_OFF_IND(N, A) \
95 (FLCN_NL_UCODE_HDR_APP_CODE_START_IND + (A*2))
96#define FLCN_NL_UCODE_HDR_APP_CODE_SIZE_IND(N, A) \
97 (FLCN_NL_UCODE_HDR_APP_CODE_START_IND + (A*2) + 1)
98#define FLCN_NL_UCODE_HDR_APP_CODE_END_IND(N) \
99 (FLCN_NL_UCODE_HDR_APP_CODE_START_IND + (N*2) - 1)
100
101#define FLCN_NL_UCODE_HDR_APP_DATA_START_IND(N) \
102 (FLCN_NL_UCODE_HDR_APP_CODE_END_IND(N) + 1)
103#define FLCN_NL_UCODE_HDR_APP_DATA_OFF_IND(N, A) \
104 (FLCN_NL_UCODE_HDR_APP_DATA_START_IND(N) + (A*2))
105#define FLCN_NL_UCODE_HDR_APP_DATA_SIZE_IND(N, A) \
106 (FLCN_NL_UCODE_HDR_APP_DATA_START_IND(N) + (A*2) + 1)
107#define FLCN_NL_UCODE_HDR_APP_DATA_END_IND(N) \
108 (FLCN_NL_UCODE_HDR_APP_DATA_START_IND(N) + (N*2) - 1)
109
110#define FLCN_NL_UCODE_HDR_OS_OVL_OFF_IND(N) \
111 (FLCN_NL_UCODE_HDR_APP_DATA_END_IND(N) + 1)
112#define FLCN_NL_UCODE_HDR_OS_OVL_SIZE_IND(N) \
113 (FLCN_NL_UCODE_HDR_APP_DATA_END_IND(N) + 2)
114
115/*Externs*/
116
117/*Structs*/
118
119/*!
120 * Light Secure Falcon Ucode Description Defines
121 * This stucture is prelim and may change as the ucode signing flow evolves.
122 */
123struct lsf_ucode_desc {
124 u8 prd_keys[2][16];
125 u8 dbg_keys[2][16];
126 u32 b_prd_present;
127 u32 b_dbg_present;
128 u32 falcon_id;
129};
130
131/*!
132 * Light Secure WPR Header
133 * Defines state allowing Light Secure Falcon bootstrapping.
134 *
135 * falcon_id - LS falcon ID
136 * lsb_offset - Offset into WPR region holding LSB header
137 * bootstrap_owner - Bootstrap OWNER (either PMU or SEC2)
138 * lazy_bootstrap - Skip bootstrapping by ACR
139 * status - Bootstrapping status
140 */
141struct lsf_wpr_header {
142 u32 falcon_id;
143 u32 lsb_offset;
144 u32 bootstrap_owner;
145 u32 lazy_bootstrap;
146 u32 status;
147};
148
149struct lsf_lsb_header {
150 struct lsf_ucode_desc signature;
151 u32 ucode_off;
152 u32 ucode_size;
153 u32 data_size;
154 u32 bl_code_size;
155 u32 bl_imem_off;
156 u32 bl_data_off;
157 u32 bl_data_size;
158 u32 flags;
159};
160
161/*!
162 * Structure used by the boot-loader to load the rest of the code. This has
163 * to be filled by host and copied into DMEM at offset provided in the
164 * hsflcn_bl_desc.bl_desc_dmem_load_off.
165 *
166 * signature - 16B signature for secure code. 0s if no secure code
167 * ctx_dma - CtxDma to be used by BL while loading code/data
168 * code_dma_base - 256B aligned Physical FB Address where code is located
169 * non_sec_code_off - Offset from code_dma_base where the nonSecure code is
170 * located. The offset must be multiple of 256 to help perf
171 * non_sec_code_size - The size of the nonSecure code part.
172 * sec_code_size - Offset from code_dma_base where the secure code is
173 * located. The offset must be multiple of 256 to help perf
174 * code_entry_point - Code entry point which will be invoked by BL after
175 * code is loaded.
176 * data_dma_base - 256B aligned Physical FB Address where data is located.
177 * data_size - Size of data block. Should be multiple of 256B
178 */
179struct flcn_bl_dmem_desc {
180 u32 signature[4]; /*Should be the first element..*/
181 u32 ctx_dma;
182 u32 code_dma_base;
183 u32 non_sec_code_off;
184 u32 non_sec_code_size;
185 u32 sec_code_off;
186 u32 sec_code_size;
187 u32 code_entry_point;
188 u32 data_dma_base;
189 u32 data_size;
190};
191
192/*!
193 * Legacy structure used by the current PMU/DPU bootloader.
194 */
195struct loader_config {
196 u32 dma_idx;
197 u32 code_dma_base; /*<! upper 32-bits of 40-bit dma address*/
198 u32 code_size_total;
199 u32 code_size_to_load;
200 u32 code_entry_point;
201 u32 data_dma_base; /*<! upper 32-bits of 40-bit dma address*/
202 u32 data_size; /*<! initialized data of the application */
203 u32 overlay_dma_base; /*<! upper 32-bits of the 40-bit dma address*/
204 u32 argc;
205 u32 argv;
206};
207
208/*!
209 * Union of all supported structures used by bootloaders.
210 */
211union flcn_bl_generic_desc {
212 struct flcn_bl_dmem_desc bl_dmem_desc;
213 struct loader_config loader_cfg;
214};
215
216struct flcn_ucode_img {
217 u32 *header; /*only some falcons have header*/
218 u32 *data;
219 struct pmu_ucode_desc *desc; /*only some falcons have descriptor*/
220 u32 data_size;
221 void *fw_ver; /*NV2080_CTRL_GPU_GET_FIRMWARE_VERSION_PARAMS struct*/
222 u8 load_entire_os_data; /* load the whole osData section at boot time.*/
223 struct lsf_ucode_desc *lsf_desc; /* NULL if not a light secure falcon.*/
224 u8 free_res_allocs;/*True if there a resources to freed by the client.*/
225 u32 flcn_inst;
226};
227
228/*!
229 * LSFM Managed Ucode Image
230 * next : Next image the list, NULL if last.
231 * wpr_header : WPR header for this ucode image
232 * lsb_header : LSB header for this ucode image
233 * bl_gen_desc : Bootloader generic desc structure for this ucode image
234 * bl_gen_desc_size : Sizeof bootloader desc structure for this ucode image
235 * full_ucode_size : Surface size required for final ucode image
236 * ucode_img : Ucode image info
237 */
238struct lsfm_managed_ucode_img {
239 struct lsfm_managed_ucode_img *next;
240 struct lsf_wpr_header wpr_header;
241 struct lsf_lsb_header lsb_header;
242 union flcn_bl_generic_desc bl_gen_desc;
243 u32 bl_gen_desc_size;
244 u32 full_ucode_size;
245 struct flcn_ucode_img ucode_img;
246};
247
248struct ls_flcn_mgr {
249 u16 managed_flcn_cnt;
250 u32 wpr_size;
251 u32 disable_mask;
252 struct lsfm_managed_ucode_img *ucode_img_list;
253 void *wpr_client_req_state;/*PACR_CLIENT_REQUEST_STATE originally*/
254};
255
256/*ACR related structs*/
257/*!
258 * start_addr - Starting address of region
259 * end_addr - Ending address of region
260 * region_id - Region ID
261 * read_mask - Read Mask
262 * write_mask - WriteMask
263 * client_mask - Bit map of all clients currently using this region
264 */
265struct flcn_acr_region_prop {
266 u32 start_addr;
267 u32 end_addr;
268 u32 region_id;
269 u32 read_mask;
270 u32 write_mask;
271 u32 client_mask;
272};
273
274/*!
275 * no_regions - Number of regions used.
276 * region_props - Region properties
277 */
278struct flcn_acr_regions {
279 u32 no_regions;
280 struct flcn_acr_region_prop region_props[T210_FLCN_ACR_MAX_REGIONS];
281};
282
283/*!
284 * reserved_dmem-When the bootstrap owner has done bootstrapping other falcons,
285 * and need to switch into LS mode, it needs to have its own
286 * actual DMEM image copied into DMEM as part of LS setup. If
287 * ACR desc is at location 0, it will definitely get overwritten
288 * causing data corruption. Hence we are reserving 0x200 bytes
289 * to give room for any loading data. NOTE: This has to be the
290 * first member always
291 * signature - Signature of ACR ucode.
292 * wpr_region_id - Region ID holding the WPR header and its details
293 * wpr_offset - Offset from the WPR region holding the wpr header
294 * regions - Region descriptors
295 * nonwpr_ucode_blob_start -stores non-WPR start where kernel stores ucode blob
296 * nonwpr_ucode_blob_end -stores non-WPR end where kernel stores ucode blob
297 */
298struct flcn_acr_desc {
299 u32 reserved_dmem[(LSF_BOOTSTRAP_OWNER_RESERVED_DMEM_SIZE/4)];
300 /*Always 1st*/
301 u32 wpr_region_id;
302 u32 wpr_offset;
303 struct flcn_acr_regions regions;
304 u32 nonwpr_ucode_blob_start;
305 u32 nonwpr_ucode_blob_size;
306};
307
308/*!
309 * The header used by RM to figure out code and data sections of bootloader.
310 *
311 * bl_code_off - Offset of code section in the image
312 * bl_code_size - Size of code section in the image
313 * bl_data_off - Offset of data section in the image
314 * bl_data_size - Size of data section in the image
315 */
316struct hsflcn_bl_img_hdr {
317 u32 bl_code_off;
318 u32 bl_code_size;
319 u32 bl_data_off;
320 u32 bl_data_size;
321};
322
323/*!
324 * The descriptor used by RM to figure out the requirements of boot loader.
325 *
326 * bl_start_tag - Starting tag of bootloader
327 * bl_desc_dmem_load_off - Dmem offset where _def_rm_flcn_bl_dmem_desc
328 to be loaded
329 * bl_img_hdr - Description of the image
330 */
331struct hsflcn_bl_desc {
332 u32 bl_start_tag;
333 u32 bl_desc_dmem_load_off;
334 struct hsflcn_bl_img_hdr bl_img_hdr;
335};
336
337struct bin_hdr {
338 u32 bin_magic; /* 0x10de */
339 u32 bin_ver; /* versioning of bin format */
340 u32 bin_size; /* entire image size including this header */
341 u32 header_offset; /* Header offset of executable binary metadata,
342 start @ offset- 0x100 */
343 u32 data_offset; /* Start of executable binary data, start @
344 offset- 0x200 */
345 u32 data_size; /* Size ofexecutable binary */
346};
347
348struct acr_fw_header {
349 u32 sig_dbg_offset;
350 u32 sig_dbg_size;
351 u32 sig_prod_offset;
352 u32 sig_prod_size;
353 u32 patch_loc;
354 u32 patch_sig;
355 u32 hdr_offset; /*this header points to acr_ucode_header_t210_load*/
356 u32 hdr_size; /*size of above header*/
357};
358
359struct acr_gm20b {
360 u64 ucode_blob_start;
361 u32 ucode_blob_size;
362 struct bin_hdr *bl_bin_hdr;
363 struct hsflcn_bl_desc *pmu_hsbl_desc;
364 struct bin_hdr *hsbin_hdr;
365 struct acr_fw_header *fw_hdr;
366};
367
368void gm20b_init_secure_pmu(struct gpu_ops *gops);
369int prepare_ucode_blob(struct gk20a *g);
370int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img);
371int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img);
372int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img *p_img);
373int gm20b_bootstrap_hs_flcn(struct gk20a *g);
374int gm20b_pmu_setup_sw(struct gk20a *g);
375int pmu_exec_gen_bl(struct gk20a *g, void *desc, u8 b_wait_for_halt);
376int pmu_wait_for_halt(struct gk20a *g, unsigned int timeout_us);
377#endif /*__ACR_GM20B_H_*/