xref: /linux/drivers/gpu/drm/nouveau/nvkm/falcon/ga100.c (revision 8e1bb4a41aa78d6105e59186af3dcd545fc66e70)
1 /*
2  * Copyright 2021 Red Hat Inc.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #include "priv.h"
23 
24 void
25 ga100_flcn_intr_retrigger(struct nvkm_falcon *falcon)
26 {
27 	nvkm_falcon_wr32(falcon, 0x3e8, 0x00000001);
28 }
29 
30 int
31 ga100_flcn_fw_signature(struct nvkm_falcon_fw *fw, u32 *src_base_src)
32 {
33 	struct nvkm_falcon *falcon = fw->falcon;
34 	struct nvkm_device *device = falcon->owner->device;
35 	u32 reg_fuse_version;
36 	int idx;
37 
38 	FLCN_DBG(falcon, "brom: %08x %08x", fw->engine_id, fw->ucode_id);
39 	FLCN_DBG(falcon, "fuse_version: %d", fw->fuse_ver);
40 
41 	if (fw->engine_id & 0x00000001) {
42 		reg_fuse_version = nvkm_rd32(device, 0x824140 + (fw->ucode_id - 1) * 4);
43 	} else
44 	if (fw->engine_id & 0x00000004) {
45 		reg_fuse_version = nvkm_rd32(device, 0x824100 + (fw->ucode_id - 1) * 4);
46 	} else
47 	if (fw->engine_id & 0x00000400) {
48 		reg_fuse_version = nvkm_rd32(device, 0x8241c0 + (fw->ucode_id - 1) * 4);
49 	} else {
50 		WARN_ON(1);
51 		return -ENOSYS;
52 	}
53 
54 	FLCN_DBG(falcon, "reg_fuse_version: %08x", reg_fuse_version);
55 	if (reg_fuse_version) {
56 		reg_fuse_version = fls(reg_fuse_version);
57 		FLCN_DBG(falcon, "reg_fuse_version: %d", reg_fuse_version);
58 
59 		if (WARN_ON(fw->fuse_ver < reg_fuse_version))
60 			return -EINVAL;
61 
62 		idx = fw->fuse_ver - reg_fuse_version;
63 	} else {
64 		idx = fw->sig_nr - 1;
65 	}
66 
67 	return idx;
68 }
69