diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2016-10-27 01:25:02 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2017-03-07 02:05:12 -0500 |
commit | bb5ec9c9dd1cc71bbae37a31229d72ffab9b6df4 (patch) | |
tree | 5a6cc8f59484a15050b2cd0ebdee58b9ffde5174 | |
parent | 7579e22f38ffe0acf0c4daea0932847023450ac7 (diff) |
drm/nouveau/secboot: support PMU LS firmware
Add the PMU bootloader generator and PMU LS ops that will enable proper
PMU operation if the PMU falcon is designated as managed.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c | 80 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c | 54 |
2 files changed, 134 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c index a937c34bc28f..a5d881438c1f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r352.c | |||
@@ -1011,6 +1011,85 @@ acr_r352_ls_gpccs_func = { | |||
1011 | .lhdr_flags = LSF_FLAG_FORCE_PRIV_LOAD, | 1011 | .lhdr_flags = LSF_FLAG_FORCE_PRIV_LOAD, |
1012 | }; | 1012 | }; |
1013 | 1013 | ||
1014 | |||
1015 | |||
1016 | /** | ||
1017 | * struct acr_r352_pmu_bl_desc - PMU DMEM bootloader descriptor | ||
1018 | * @dma_idx: DMA context to be used by BL while loading code/data | ||
1019 | * @code_dma_base: 256B-aligned Physical FB Address where code is located | ||
1020 | * @total_code_size: total size of the code part in the ucode | ||
1021 | * @code_size_to_load: size of the code part to load in PMU IMEM. | ||
1022 | * @code_entry_point: entry point in the code. | ||
1023 | * @data_dma_base: Physical FB address where data part of ucode is located | ||
1024 | * @data_size: Total size of the data portion. | ||
1025 | * @overlay_dma_base: Physical Fb address for resident code present in ucode | ||
1026 | * @argc: Total number of args | ||
1027 | * @argv: offset where args are copied into PMU's DMEM. | ||
1028 | * | ||
1029 | * Structure used by the PMU bootloader to load the rest of the code | ||
1030 | */ | ||
1031 | struct acr_r352_pmu_bl_desc { | ||
1032 | u32 dma_idx; | ||
1033 | u32 code_dma_base; | ||
1034 | u32 code_size_total; | ||
1035 | u32 code_size_to_load; | ||
1036 | u32 code_entry_point; | ||
1037 | u32 data_dma_base; | ||
1038 | u32 data_size; | ||
1039 | u32 overlay_dma_base; | ||
1040 | u32 argc; | ||
1041 | u32 argv; | ||
1042 | u16 code_dma_base1; | ||
1043 | u16 data_dma_base1; | ||
1044 | u16 overlay_dma_base1; | ||
1045 | }; | ||
1046 | |||
1047 | /** | ||
1048 | * acr_r352_generate_pmu_bl_desc() - populate a DMEM BL descriptor for PMU LS image | ||
1049 | * | ||
1050 | */ | ||
1051 | static void | ||
1052 | acr_r352_generate_pmu_bl_desc(const struct nvkm_acr *acr, | ||
1053 | const struct ls_ucode_img *img, u64 wpr_addr, | ||
1054 | void *_desc) | ||
1055 | { | ||
1056 | const struct ls_ucode_img_desc *pdesc = &img->ucode_desc; | ||
1057 | const struct nvkm_pmu *pmu = acr->subdev->device->pmu; | ||
1058 | struct acr_r352_pmu_bl_desc *desc = _desc; | ||
1059 | u64 base; | ||
1060 | u64 addr_code; | ||
1061 | u64 addr_data; | ||
1062 | u32 addr_args; | ||
1063 | |||
1064 | base = wpr_addr + img->ucode_off + pdesc->app_start_offset; | ||
1065 | addr_code = (base + pdesc->app_resident_code_offset) >> 8; | ||
1066 | addr_data = (base + pdesc->app_resident_data_offset) >> 8; | ||
1067 | addr_args = pmu->falcon->data.limit; | ||
1068 | addr_args -= NVKM_MSGQUEUE_CMDLINE_SIZE; | ||
1069 | |||
1070 | desc->dma_idx = FALCON_DMAIDX_UCODE; | ||
1071 | desc->code_dma_base = lower_32_bits(addr_code); | ||
1072 | desc->code_dma_base1 = upper_32_bits(addr_code); | ||
1073 | desc->code_size_total = pdesc->app_size; | ||
1074 | desc->code_size_to_load = pdesc->app_resident_code_size; | ||
1075 | desc->code_entry_point = pdesc->app_imem_entry; | ||
1076 | desc->data_dma_base = lower_32_bits(addr_data); | ||
1077 | desc->data_dma_base1 = upper_32_bits(addr_data); | ||
1078 | desc->data_size = pdesc->app_resident_data_size; | ||
1079 | desc->overlay_dma_base = lower_32_bits(addr_code); | ||
1080 | desc->overlay_dma_base1 = upper_32_bits(addr_code); | ||
1081 | desc->argc = 1; | ||
1082 | desc->argv = addr_args; | ||
1083 | } | ||
1084 | |||
1085 | static const struct acr_r352_ls_func | ||
1086 | acr_r352_ls_pmu_func = { | ||
1087 | .load = acr_ls_ucode_load_pmu, | ||
1088 | .generate_bl_desc = acr_r352_generate_pmu_bl_desc, | ||
1089 | .bl_desc_size = sizeof(struct acr_r352_pmu_bl_desc), | ||
1090 | .post_run = acr_ls_pmu_post_run, | ||
1091 | }; | ||
1092 | |||
1014 | const struct acr_r352_func | 1093 | const struct acr_r352_func |
1015 | acr_r352_func = { | 1094 | acr_r352_func = { |
1016 | .fixup_hs_desc = acr_r352_fixup_hs_desc, | 1095 | .fixup_hs_desc = acr_r352_fixup_hs_desc, |
@@ -1022,6 +1101,7 @@ acr_r352_func = { | |||
1022 | .ls_func = { | 1101 | .ls_func = { |
1023 | [NVKM_SECBOOT_FALCON_FECS] = &acr_r352_ls_fecs_func, | 1102 | [NVKM_SECBOOT_FALCON_FECS] = &acr_r352_ls_fecs_func, |
1024 | [NVKM_SECBOOT_FALCON_GPCCS] = &acr_r352_ls_gpccs_func, | 1103 | [NVKM_SECBOOT_FALCON_GPCCS] = &acr_r352_ls_gpccs_func, |
1104 | [NVKM_SECBOOT_FALCON_PMU] = &acr_r352_ls_pmu_func, | ||
1025 | }, | 1105 | }, |
1026 | }; | 1106 | }; |
1027 | 1107 | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c index 8561037d4cb7..1ed23e77e4e9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/acr_r361.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include "acr_r352.h" | 23 | #include "acr_r352.h" |
24 | 24 | ||
25 | #include <engine/falcon.h> | 25 | #include <engine/falcon.h> |
26 | #include <core/msgqueue.h> | ||
27 | #include <subdev/pmu.h> | ||
26 | 28 | ||
27 | /** | 29 | /** |
28 | * struct acr_r361_flcn_bl_desc - DMEM bootloader descriptor | 30 | * struct acr_r361_flcn_bl_desc - DMEM bootloader descriptor |
@@ -116,6 +118,57 @@ acr_r361_ls_gpccs_func = { | |||
116 | .lhdr_flags = LSF_FLAG_FORCE_PRIV_LOAD, | 118 | .lhdr_flags = LSF_FLAG_FORCE_PRIV_LOAD, |
117 | }; | 119 | }; |
118 | 120 | ||
121 | struct acr_r361_pmu_bl_desc { | ||
122 | u32 reserved; | ||
123 | u32 dma_idx; | ||
124 | struct flcn_u64 code_dma_base; | ||
125 | u32 total_code_size; | ||
126 | u32 code_size_to_load; | ||
127 | u32 code_entry_point; | ||
128 | struct flcn_u64 data_dma_base; | ||
129 | u32 data_size; | ||
130 | struct flcn_u64 overlay_dma_base; | ||
131 | u32 argc; | ||
132 | u32 argv; | ||
133 | }; | ||
134 | |||
135 | static void | ||
136 | acr_r361_generate_pmu_bl_desc(const struct nvkm_acr *acr, | ||
137 | const struct ls_ucode_img *img, u64 wpr_addr, | ||
138 | void *_desc) | ||
139 | { | ||
140 | const struct ls_ucode_img_desc *pdesc = &img->ucode_desc; | ||
141 | const struct nvkm_pmu *pmu = acr->subdev->device->pmu; | ||
142 | struct acr_r361_pmu_bl_desc *desc = _desc; | ||
143 | u64 base, addr_code, addr_data; | ||
144 | u32 addr_args; | ||
145 | |||
146 | base = wpr_addr + img->ucode_off + pdesc->app_start_offset; | ||
147 | addr_code = base + pdesc->app_resident_code_offset; | ||
148 | addr_data = base + pdesc->app_resident_data_offset; | ||
149 | addr_args = pmu->falcon->data.limit; | ||
150 | addr_args -= NVKM_MSGQUEUE_CMDLINE_SIZE; | ||
151 | |||
152 | desc->dma_idx = FALCON_DMAIDX_UCODE; | ||
153 | desc->code_dma_base = u64_to_flcn64(addr_code); | ||
154 | desc->total_code_size = pdesc->app_size; | ||
155 | desc->code_size_to_load = pdesc->app_resident_code_size; | ||
156 | desc->code_entry_point = pdesc->app_imem_entry; | ||
157 | desc->data_dma_base = u64_to_flcn64(addr_data); | ||
158 | desc->data_size = pdesc->app_resident_data_size; | ||
159 | desc->overlay_dma_base = u64_to_flcn64(addr_code); | ||
160 | desc->argc = 1; | ||
161 | desc->argv = addr_args; | ||
162 | } | ||
163 | |||
164 | const struct acr_r352_ls_func | ||
165 | acr_r361_ls_pmu_func = { | ||
166 | .load = acr_ls_ucode_load_pmu, | ||
167 | .generate_bl_desc = acr_r361_generate_pmu_bl_desc, | ||
168 | .bl_desc_size = sizeof(struct acr_r361_pmu_bl_desc), | ||
169 | .post_run = acr_ls_pmu_post_run, | ||
170 | }; | ||
171 | |||
119 | const struct acr_r352_func | 172 | const struct acr_r352_func |
120 | acr_r361_func = { | 173 | acr_r361_func = { |
121 | .fixup_hs_desc = acr_r352_fixup_hs_desc, | 174 | .fixup_hs_desc = acr_r352_fixup_hs_desc, |
@@ -127,6 +180,7 @@ acr_r361_func = { | |||
127 | .ls_func = { | 180 | .ls_func = { |
128 | [NVKM_SECBOOT_FALCON_FECS] = &acr_r361_ls_fecs_func, | 181 | [NVKM_SECBOOT_FALCON_FECS] = &acr_r361_ls_fecs_func, |
129 | [NVKM_SECBOOT_FALCON_GPCCS] = &acr_r361_ls_gpccs_func, | 182 | [NVKM_SECBOOT_FALCON_GPCCS] = &acr_r361_ls_gpccs_func, |
183 | [NVKM_SECBOOT_FALCON_PMU] = &acr_r361_ls_pmu_func, | ||
130 | }, | 184 | }, |
131 | }; | 185 | }; |
132 | 186 | ||