Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014-2017 Intel Corporation |
| 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 (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #ifndef _INTEL_UC_FW_H_ |
| 26 | #define _INTEL_UC_FW_H_ |
| 27 | |
| 28 | struct drm_i915_private; |
| 29 | |
Michal Wajdeczko | f1e86ce | 2017-10-16 14:47:20 +0000 | [diff] [blame^] | 30 | /* Home of GuC, HuC and DMC firmwares */ |
Michal Wajdeczko | 1e913d2 | 2017-10-16 14:47:19 +0000 | [diff] [blame] | 31 | #define INTEL_UC_FIRMWARE_URL "https://01.org/linuxgraphics/downloads/firmware" |
| 32 | |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 33 | enum intel_uc_fw_status { |
| 34 | INTEL_UC_FIRMWARE_FAIL = -1, |
| 35 | INTEL_UC_FIRMWARE_NONE = 0, |
| 36 | INTEL_UC_FIRMWARE_PENDING, |
| 37 | INTEL_UC_FIRMWARE_SUCCESS |
| 38 | }; |
| 39 | |
| 40 | enum intel_uc_fw_type { |
| 41 | INTEL_UC_FW_TYPE_GUC, |
| 42 | INTEL_UC_FW_TYPE_HUC |
| 43 | }; |
| 44 | |
| 45 | /* |
| 46 | * This structure encapsulates all the data needed during the process |
| 47 | * of fetching, caching, and loading the firmware image into the uC. |
| 48 | */ |
| 49 | struct intel_uc_fw { |
| 50 | const char *path; |
| 51 | size_t size; |
| 52 | struct drm_i915_gem_object *obj; |
| 53 | enum intel_uc_fw_status fetch_status; |
| 54 | enum intel_uc_fw_status load_status; |
| 55 | |
Michal Wajdeczko | d9e2e01 | 2017-10-16 14:47:13 +0000 | [diff] [blame] | 56 | /* |
| 57 | * The firmware build process will generate a version header file with major and |
| 58 | * minor version defined. The versions are built into CSS header of firmware. |
| 59 | * i915 kernel driver set the minimal firmware version required per platform. |
| 60 | */ |
Joonas Lahtinen | faf6548 | 2017-10-06 11:49:40 +0300 | [diff] [blame] | 61 | u16 major_ver_wanted; |
| 62 | u16 minor_ver_wanted; |
| 63 | u16 major_ver_found; |
| 64 | u16 minor_ver_found; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 65 | |
| 66 | enum intel_uc_fw_type type; |
Joonas Lahtinen | faf6548 | 2017-10-06 11:49:40 +0300 | [diff] [blame] | 67 | u32 header_size; |
| 68 | u32 header_offset; |
| 69 | u32 rsa_size; |
| 70 | u32 rsa_offset; |
| 71 | u32 ucode_size; |
| 72 | u32 ucode_offset; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static inline |
| 76 | const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) |
| 77 | { |
| 78 | switch (status) { |
| 79 | case INTEL_UC_FIRMWARE_FAIL: |
| 80 | return "FAIL"; |
| 81 | case INTEL_UC_FIRMWARE_NONE: |
| 82 | return "NONE"; |
| 83 | case INTEL_UC_FIRMWARE_PENDING: |
| 84 | return "PENDING"; |
| 85 | case INTEL_UC_FIRMWARE_SUCCESS: |
| 86 | return "SUCCESS"; |
| 87 | } |
| 88 | return "<invalid>"; |
| 89 | } |
| 90 | |
| 91 | static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type) |
| 92 | { |
| 93 | switch (type) { |
| 94 | case INTEL_UC_FW_TYPE_GUC: |
| 95 | return "GuC"; |
| 96 | case INTEL_UC_FW_TYPE_HUC: |
| 97 | return "HuC"; |
| 98 | } |
| 99 | return "uC"; |
| 100 | } |
| 101 | |
Michal Wajdeczko | 959a3b6 | 2017-10-04 18:13:43 +0000 | [diff] [blame] | 102 | static inline |
| 103 | void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type) |
| 104 | { |
| 105 | uc_fw->path = NULL; |
| 106 | uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE; |
| 107 | uc_fw->load_status = INTEL_UC_FIRMWARE_NONE; |
| 108 | uc_fw->type = type; |
| 109 | } |
| 110 | |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 111 | void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, |
| 112 | struct intel_uc_fw *uc_fw); |
| 113 | void intel_uc_fw_fini(struct intel_uc_fw *uc_fw); |
| 114 | |
| 115 | #endif |