]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.h
031bd09fd50a4bd6d8299736fbc6b51de3acfdb7
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / nouveau / nvkm / subdev / secboot / acr_r352.h
1 /*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22 #ifndef __NVKM_SECBOOT_ACR_R352_H__
23 #define __NVKM_SECBOOT_ACR_R352_H__
24
25 #include "acr.h"
26
27 struct ls_ucode_img;
28
29 #define ACR_R352_MAX_APPS 8
30
31 struct hsf_load_header_app {
32 u32 sec_code_off;
33 u32 sec_code_size;
34 };
35
36 /**
37 * struct hsf_load_header - HS firmware load header
38 */
39 struct hsf_load_header {
40 u32 non_sec_code_off;
41 u32 non_sec_code_size;
42 u32 data_dma_base;
43 u32 data_size;
44 u32 num_apps;
45 struct hsf_load_header_app app[0];
46 };
47
48 /**
49 * struct acr_r352_ls_func - manages a single LS firmware
50 *
51 * @load: load the external firmware into a ls_ucode_img
52 * @generate_bl_desc: function called on a block of bl_desc_size to generate the
53 * proper bootloader descriptor for this LS firmware
54 * @bl_desc_size: size of the bootloader descriptor
55 */
56 struct acr_r352_ls_func {
57 int (*load)(const struct nvkm_subdev *, struct ls_ucode_img *);
58 void (*generate_bl_desc)(const struct nvkm_acr *,
59 const struct ls_ucode_img *, u64, void *);
60 u32 bl_desc_size;
61 };
62
63 /**
64 * struct acr_r352_func - manages nuances between ACR versions
65 *
66 * @generate_hs_bl_desc: function called on a block of bl_desc_size to generate
67 * the proper HS bootloader descriptor
68 * @hs_bl_desc_size: size of the HS bootloader descriptor
69 */
70 struct acr_r352_func {
71 void (*generate_hs_bl_desc)(const struct hsf_load_header *, void *,
72 u64);
73 u32 hs_bl_desc_size;
74
75 const struct acr_r352_ls_func *ls_func[NVKM_SECBOOT_FALCON_END];
76 };
77
78 /**
79 * struct acr_r352 - ACR data for driver release 352 (and beyond)
80 */
81 struct acr_r352 {
82 struct nvkm_acr base;
83 const struct acr_r352_func *func;
84
85 /*
86 * HS FW - lock WPR region (dGPU only) and load LS FWs
87 * on Tegra the HS FW copies the LS blob into the fixed WPR instead
88 */
89 struct nvkm_gpuobj *load_blob;
90 struct {
91 struct hsf_load_header load_bl_header;
92 struct hsf_load_header_app __load_apps[ACR_R352_MAX_APPS];
93 };
94
95 /* HS FW - unlock WPR region (dGPU only) */
96 struct nvkm_gpuobj *unload_blob;
97 struct {
98 struct hsf_load_header unload_bl_header;
99 struct hsf_load_header_app __unload_apps[ACR_R352_MAX_APPS];
100 };
101
102 /* HS bootloader */
103 void *hsbl_blob;
104
105 /* LS FWs, to be loaded by the HS ACR */
106 struct nvkm_gpuobj *ls_blob;
107
108 /* Firmware already loaded? */
109 bool firmware_ok;
110
111 /* To keep track of the state of all managed falcons */
112 enum {
113 /* In non-secure state, no firmware loaded, no privileges*/
114 NON_SECURE = 0,
115 /* In low-secure mode and ready to be started */
116 RESET,
117 /* In low-secure mode and running */
118 RUNNING,
119 } falcon_state[NVKM_SECBOOT_FALCON_END];
120 };
121 #define acr_r352(acr) container_of(acr, struct acr_r352, base)
122
123 struct nvkm_acr *acr_r352_new_(const struct acr_r352_func *,
124 enum nvkm_secboot_falcon, unsigned long);
125
126 #endif