167e7c6cfSBen Skeggs /*
267e7c6cfSBen Skeggs * Copyright 2019 Red Hat Inc.
367e7c6cfSBen Skeggs *
467e7c6cfSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
567e7c6cfSBen Skeggs * copy of this software and associated documentation files (the "Software"),
667e7c6cfSBen Skeggs * to deal in the Software without restriction, including without limitation
767e7c6cfSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
867e7c6cfSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
967e7c6cfSBen Skeggs * Software is furnished to do so, subject to the following conditions:
1067e7c6cfSBen Skeggs *
1167e7c6cfSBen Skeggs * The above copyright notice and this permission notice shall be included in
1267e7c6cfSBen Skeggs * all copies or substantial portions of the Software.
1367e7c6cfSBen Skeggs *
1467e7c6cfSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1567e7c6cfSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1667e7c6cfSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1767e7c6cfSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1867e7c6cfSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1967e7c6cfSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2067e7c6cfSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
2167e7c6cfSBen Skeggs */
2267e7c6cfSBen Skeggs #include "priv.h"
2367e7c6cfSBen Skeggs
2422dcda45SBen Skeggs #include <subdev/mmu.h>
2522dcda45SBen Skeggs
2622dcda45SBen Skeggs #include <nvfw/flcn.h>
2722dcda45SBen Skeggs
28*2541626cSBen Skeggs int
gp108_acr_hsfw_load_bld(struct nvkm_falcon_fw * fw)29*2541626cSBen Skeggs gp108_acr_hsfw_load_bld(struct nvkm_falcon_fw *fw)
3022dcda45SBen Skeggs {
3122dcda45SBen Skeggs struct flcn_bl_dmem_desc_v2 hsdesc = {
3222dcda45SBen Skeggs .ctx_dma = FALCON_DMAIDX_VIRT,
33*2541626cSBen Skeggs .code_dma_base = fw->vma->addr,
34*2541626cSBen Skeggs .non_sec_code_off = fw->nmem_base,
35*2541626cSBen Skeggs .non_sec_code_size = fw->nmem_size,
36*2541626cSBen Skeggs .sec_code_off = fw->imem_base,
37*2541626cSBen Skeggs .sec_code_size = fw->imem_size,
3822dcda45SBen Skeggs .code_entry_point = 0,
39*2541626cSBen Skeggs .data_dma_base = fw->vma->addr + fw->dmem_base_img,
40*2541626cSBen Skeggs .data_size = fw->dmem_size,
4122dcda45SBen Skeggs .argc = 0,
4222dcda45SBen Skeggs .argv = 0,
4322dcda45SBen Skeggs };
4422dcda45SBen Skeggs
45*2541626cSBen Skeggs flcn_bl_dmem_desc_v2_dump(fw->falcon->user, &hsdesc);
4622dcda45SBen Skeggs
47*2541626cSBen Skeggs return nvkm_falcon_pio_wr(fw->falcon, (u8 *)&hsdesc, 0, 0, DMEM, 0, sizeof(hsdesc), 0, 0);
4822dcda45SBen Skeggs }
4922dcda45SBen Skeggs
50*2541626cSBen Skeggs const struct nvkm_falcon_fw_func
51*2541626cSBen Skeggs gp108_acr_hsfw_0 = {
52*2541626cSBen Skeggs .signature = gm200_flcn_fw_signature,
53*2541626cSBen Skeggs .reset = gm200_flcn_fw_reset,
54*2541626cSBen Skeggs .load = gm200_flcn_fw_load,
55*2541626cSBen Skeggs .load_bld = gp108_acr_hsfw_load_bld,
56*2541626cSBen Skeggs .boot = gm200_flcn_fw_boot,
5722dcda45SBen Skeggs };
5822dcda45SBen Skeggs
5967e7c6cfSBen Skeggs MODULE_FIRMWARE("nvidia/gp108/acr/unload_bl.bin");
6067e7c6cfSBen Skeggs MODULE_FIRMWARE("nvidia/gp108/acr/ucode_unload.bin");
6167e7c6cfSBen Skeggs
6222dcda45SBen Skeggs static const struct nvkm_acr_hsf_fwif
6322dcda45SBen Skeggs gp108_acr_unload_fwif[] = {
64*2541626cSBen Skeggs { 0, gm200_acr_hsfw_ctor, &gp108_acr_hsfw_0, NVKM_ACR_HSF_PMU, 0x1d, 0x00000010 },
6522dcda45SBen Skeggs {}
6622dcda45SBen Skeggs };
6722dcda45SBen Skeggs
68*2541626cSBen Skeggs const struct nvkm_falcon_fw_func
6922dcda45SBen Skeggs gp108_acr_load_0 = {
70*2541626cSBen Skeggs .signature = gm200_flcn_fw_signature,
71*2541626cSBen Skeggs .reset = gm200_flcn_fw_reset,
72*2541626cSBen Skeggs .setup = gp102_acr_load_setup,
73*2541626cSBen Skeggs .load = gm200_flcn_fw_load,
74*2541626cSBen Skeggs .load_bld = gp108_acr_hsfw_load_bld,
75*2541626cSBen Skeggs .boot = gm200_flcn_fw_boot,
7622dcda45SBen Skeggs };
7722dcda45SBen Skeggs
7867e7c6cfSBen Skeggs MODULE_FIRMWARE("nvidia/gp108/acr/bl.bin");
7967e7c6cfSBen Skeggs MODULE_FIRMWARE("nvidia/gp108/acr/ucode_load.bin");
8067e7c6cfSBen Skeggs
8122dcda45SBen Skeggs static const struct nvkm_acr_hsf_fwif
8222dcda45SBen Skeggs gp108_acr_load_fwif[] = {
83*2541626cSBen Skeggs { 0, gm200_acr_hsfw_ctor, &gp108_acr_load_0, NVKM_ACR_HSF_SEC2, 0, 0x00000010 },
8422dcda45SBen Skeggs {}
8522dcda45SBen Skeggs };
8622dcda45SBen Skeggs
8767e7c6cfSBen Skeggs static const struct nvkm_acr_func
8867e7c6cfSBen Skeggs gp108_acr = {
8922dcda45SBen Skeggs .load = gp108_acr_load_fwif,
9022dcda45SBen Skeggs .unload = gp108_acr_unload_fwif,
9122dcda45SBen Skeggs .wpr_parse = gp102_acr_wpr_parse,
9222dcda45SBen Skeggs .wpr_layout = gp102_acr_wpr_layout,
9322dcda45SBen Skeggs .wpr_alloc = gp102_acr_wpr_alloc,
9422dcda45SBen Skeggs .wpr_build = gp102_acr_wpr_build,
9522dcda45SBen Skeggs .wpr_patch = gp102_acr_wpr_patch,
9622dcda45SBen Skeggs .wpr_check = gm200_acr_wpr_check,
9722dcda45SBen Skeggs .init = gm200_acr_init,
9867e7c6cfSBen Skeggs };
9967e7c6cfSBen Skeggs
10067e7c6cfSBen Skeggs static const struct nvkm_acr_fwif
10167e7c6cfSBen Skeggs gp108_acr_fwif[] = {
10267e7c6cfSBen Skeggs { 0, gp102_acr_load, &gp108_acr },
10390e9cf74SBen Skeggs { -1, gm200_acr_nofw, &gm200_acr },
10467e7c6cfSBen Skeggs {}
10567e7c6cfSBen Skeggs };
10667e7c6cfSBen Skeggs
10767e7c6cfSBen Skeggs int
gp108_acr_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_acr ** pacr)108c288b4deSBen Skeggs gp108_acr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
109c288b4deSBen Skeggs struct nvkm_acr **pacr)
11067e7c6cfSBen Skeggs {
111c288b4deSBen Skeggs return nvkm_acr_new_(gp108_acr_fwif, device, type, inst, pacr);
11267e7c6cfSBen Skeggs }
113