xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp10b.c (revision d37cf9b63113f13d742713881ce691fc615d8b3b)
1e905736cSBen Skeggs /*
2e905736cSBen Skeggs  * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3e905736cSBen Skeggs  *
4e905736cSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5e905736cSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6e905736cSBen Skeggs  * to deal in the Software without restriction, including without limitation
7e905736cSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8e905736cSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9e905736cSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10e905736cSBen Skeggs  *
11e905736cSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12e905736cSBen Skeggs  * all copies or substantial portions of the Software.
13e905736cSBen Skeggs  *
14e905736cSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15e905736cSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16e905736cSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17e905736cSBen Skeggs  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18e905736cSBen Skeggs  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19e905736cSBen Skeggs  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20e905736cSBen Skeggs  * DEALINGS IN THE SOFTWARE.
21e905736cSBen Skeggs  */
22e905736cSBen Skeggs #include "priv.h"
2386ce2a71SBen Skeggs 
24989863d7SBen Skeggs #include <subdev/acr.h>
25989863d7SBen Skeggs 
2622dcda45SBen Skeggs #include <nvfw/flcn.h>
2786ce2a71SBen Skeggs #include <nvfw/pmu.h>
2886ce2a71SBen Skeggs 
2986ce2a71SBen Skeggs static int
gp10b_pmu_acr_bootstrap_multiple_falcons_cb(void * priv,struct nvfw_falcon_msg * hdr)3086ce2a71SBen Skeggs gp10b_pmu_acr_bootstrap_multiple_falcons_cb(void *priv,
31b448a266STimur Tabi 					    struct nvfw_falcon_msg *hdr)
3286ce2a71SBen Skeggs {
3386ce2a71SBen Skeggs 	struct nv_pmu_acr_bootstrap_multiple_falcons_msg *msg =
3486ce2a71SBen Skeggs 		container_of(hdr, typeof(*msg), msg.hdr);
3586ce2a71SBen Skeggs 	return msg->falcon_mask;
3686ce2a71SBen Skeggs }
3786ce2a71SBen Skeggs static int
gp10b_pmu_acr_bootstrap_multiple_falcons(struct nvkm_falcon * falcon,u32 mask)3886ce2a71SBen Skeggs gp10b_pmu_acr_bootstrap_multiple_falcons(struct nvkm_falcon *falcon, u32 mask)
3986ce2a71SBen Skeggs {
4086ce2a71SBen Skeggs 	struct nvkm_pmu *pmu = container_of(falcon, typeof(*pmu), falcon);
4186ce2a71SBen Skeggs 	struct nv_pmu_acr_bootstrap_multiple_falcons_cmd cmd = {
4286ce2a71SBen Skeggs 		.cmd.hdr.unit_id = NV_PMU_UNIT_ACR,
4386ce2a71SBen Skeggs 		.cmd.hdr.size = sizeof(cmd),
4486ce2a71SBen Skeggs 		.cmd.cmd_type = NV_PMU_ACR_CMD_BOOTSTRAP_MULTIPLE_FALCONS,
4586ce2a71SBen Skeggs 		.flags = NV_PMU_ACR_BOOTSTRAP_MULTIPLE_FALCONS_FLAGS_RESET_YES,
4686ce2a71SBen Skeggs 		.falcon_mask = mask,
4786ce2a71SBen Skeggs 		.wpr_lo = 0, /*XXX*/
4886ce2a71SBen Skeggs 		.wpr_hi = 0, /*XXX*/
4986ce2a71SBen Skeggs 	};
5086ce2a71SBen Skeggs 	int ret;
5186ce2a71SBen Skeggs 
5286ce2a71SBen Skeggs 	ret = nvkm_falcon_cmdq_send(pmu->hpq, &cmd.cmd.hdr,
5386ce2a71SBen Skeggs 				    gp10b_pmu_acr_bootstrap_multiple_falcons_cb,
5486ce2a71SBen Skeggs 				    &pmu->subdev, msecs_to_jiffies(1000));
5589b34254SThierry Reding 	if (ret >= 0) {
5689b34254SThierry Reding 		if (ret != cmd.falcon_mask)
5786ce2a71SBen Skeggs 			ret = -EIO;
5889b34254SThierry Reding 		else
5989b34254SThierry Reding 			ret = 0;
6089b34254SThierry Reding 	}
6189b34254SThierry Reding 
6286ce2a71SBen Skeggs 	return ret;
6386ce2a71SBen Skeggs }
6486ce2a71SBen Skeggs 
65989863d7SBen Skeggs static const struct nvkm_acr_lsf_func
66989863d7SBen Skeggs gp10b_pmu_acr = {
6722dcda45SBen Skeggs 	.flags = NVKM_ACR_LSF_DMACTL_REQ_CTX,
6822dcda45SBen Skeggs 	.bld_size = sizeof(struct loader_config),
6922dcda45SBen Skeggs 	.bld_write = gm20b_pmu_acr_bld_write,
7022dcda45SBen Skeggs 	.bld_patch = gm20b_pmu_acr_bld_patch,
71de088372SBen Skeggs 	.bootstrap_falcons = BIT_ULL(NVKM_ACR_LSF_PMU) |
72de088372SBen Skeggs 			     BIT_ULL(NVKM_ACR_LSF_FECS) |
73de088372SBen Skeggs 			     BIT_ULL(NVKM_ACR_LSF_GPCCS),
7486ce2a71SBen Skeggs 	.bootstrap_falcon = gm20b_pmu_acr_bootstrap_falcon,
7586ce2a71SBen Skeggs 	.bootstrap_multiple_falcons = gp10b_pmu_acr_bootstrap_multiple_falcons,
76989863d7SBen Skeggs };
77e905736cSBen Skeggs 
78*fbb770b9SAaron Kling #if IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC)
79989863d7SBen Skeggs MODULE_FIRMWARE("nvidia/gp10b/pmu/desc.bin");
80989863d7SBen Skeggs MODULE_FIRMWARE("nvidia/gp10b/pmu/image.bin");
81989863d7SBen Skeggs MODULE_FIRMWARE("nvidia/gp10b/pmu/sig.bin");
82989863d7SBen Skeggs #endif
83989863d7SBen Skeggs 
84989863d7SBen Skeggs static const struct nvkm_pmu_fwif
85989863d7SBen Skeggs gp10b_pmu_fwif[] = {
86ccdc0431SBen Skeggs 	{  0, gm20b_pmu_load, &gm20b_pmu, &gp10b_pmu_acr },
87ccdc0431SBen Skeggs 	{ -1, gm200_pmu_nofw, &gm20b_pmu },
88989863d7SBen Skeggs 	{}
89989863d7SBen Skeggs };
90989863d7SBen Skeggs 
91e905736cSBen Skeggs int
gp10b_pmu_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_pmu ** ppmu)92e4b15b4cSBen Skeggs gp10b_pmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
93e4b15b4cSBen Skeggs 	      struct nvkm_pmu **ppmu)
94e905736cSBen Skeggs {
95e4b15b4cSBen Skeggs 	return nvkm_pmu_new_(gp10b_pmu_fwif, device, type, inst, ppmu);
96e905736cSBen Skeggs }
97