1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2014-2019 Intel Corporation 4 */ 5 6 #ifndef _INTEL_HUC_H_ 7 #define _INTEL_HUC_H_ 8 9 #include "i915_reg_defs.h" 10 #include "i915_sw_fence.h" 11 #include "intel_uc_fw.h" 12 #include "intel_huc_fw.h" 13 14 #include <linux/notifier.h> 15 #include <linux/hrtimer.h> 16 17 struct bus_type; 18 19 enum intel_huc_delayed_load_status { 20 INTEL_HUC_WAITING_ON_GSC = 0, 21 INTEL_HUC_WAITING_ON_PXP, 22 INTEL_HUC_DELAYED_LOAD_ERROR, 23 }; 24 25 struct intel_huc { 26 /* Generic uC firmware management */ 27 struct intel_uc_fw fw; 28 29 /* HuC-specific additions */ 30 struct { 31 i915_reg_t reg; 32 u32 mask; 33 u32 value; 34 } status; 35 36 struct { 37 struct i915_sw_fence fence; 38 struct hrtimer timer; 39 struct notifier_block nb; 40 enum intel_huc_delayed_load_status status; 41 } delayed_load; 42 }; 43 44 int intel_huc_sanitize(struct intel_huc *huc); 45 void intel_huc_init_early(struct intel_huc *huc); 46 int intel_huc_init(struct intel_huc *huc); 47 void intel_huc_fini(struct intel_huc *huc); 48 void intel_huc_suspend(struct intel_huc *huc); 49 int intel_huc_auth(struct intel_huc *huc); 50 int intel_huc_wait_for_auth_complete(struct intel_huc *huc); 51 int intel_huc_check_status(struct intel_huc *huc); 52 void intel_huc_update_auth_status(struct intel_huc *huc); 53 bool intel_huc_is_authenticated(struct intel_huc *huc); 54 55 void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus); 56 void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus); 57 58 static inline bool intel_huc_is_supported(struct intel_huc *huc) 59 { 60 return intel_uc_fw_is_supported(&huc->fw); 61 } 62 63 static inline bool intel_huc_is_wanted(struct intel_huc *huc) 64 { 65 return intel_uc_fw_is_enabled(&huc->fw); 66 } 67 68 static inline bool intel_huc_is_used(struct intel_huc *huc) 69 { 70 GEM_BUG_ON(__intel_uc_fw_status(&huc->fw) == INTEL_UC_FIRMWARE_SELECTED); 71 return intel_uc_fw_is_available(&huc->fw); 72 } 73 74 static inline bool intel_huc_is_loaded_by_gsc(const struct intel_huc *huc) 75 { 76 return huc->fw.loaded_via_gsc; 77 } 78 79 static inline bool intel_huc_wait_required(struct intel_huc *huc) 80 { 81 return intel_huc_is_used(huc) && intel_huc_is_loaded_by_gsc(huc) && 82 !intel_huc_is_authenticated(huc); 83 } 84 85 void intel_huc_load_status(struct intel_huc *huc, struct drm_printer *p); 86 87 #endif 88