1 /* $NetBSD: intel_huc_fw.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $ */
2
3 // SPDX-License-Identifier: MIT
4 /*
5 * Copyright © 2014-2019 Intel Corporation
6 */
7
8 #include <sys/cdefs.h>
9 __KERNEL_RCSID(0, "$NetBSD: intel_huc_fw.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $");
10
11 #include "gt/intel_gt.h"
12 #include "intel_huc_fw.h"
13 #include "i915_drv.h"
14
15 /**
16 * intel_huc_fw_init_early() - initializes HuC firmware struct
17 * @huc: intel_huc struct
18 *
19 * On platforms with HuC selects firmware for uploading
20 */
intel_huc_fw_init_early(struct intel_huc * huc)21 void intel_huc_fw_init_early(struct intel_huc *huc)
22 {
23 struct intel_gt *gt = huc_to_gt(huc);
24 struct intel_uc *uc = >->uc;
25 struct drm_i915_private *i915 = gt->i915;
26
27 intel_uc_fw_init_early(&huc->fw, INTEL_UC_FW_TYPE_HUC,
28 intel_uc_uses_guc(uc),
29 INTEL_INFO(i915)->platform, INTEL_REVID(i915));
30 }
31
32 /**
33 * intel_huc_fw_upload() - load HuC uCode to device
34 * @huc: intel_huc structure
35 *
36 * Called from intel_uc_init_hw() during driver load, resume from sleep and
37 * after a GPU reset. Note that HuC must be loaded before GuC.
38 *
39 * The firmware image should have already been fetched into memory, so only
40 * check that fetch succeeded, and then transfer the image to the h/w.
41 *
42 * Return: non-zero code on error
43 */
intel_huc_fw_upload(struct intel_huc * huc)44 int intel_huc_fw_upload(struct intel_huc *huc)
45 {
46 /* HW doesn't look at destination address for HuC, so set it to 0 */
47 return intel_uc_fw_upload(&huc->fw, 0, HUC_UKERNEL);
48 }
49