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 | |
Michal Wajdeczko | 56ffc74 | 2017-10-17 09:44:49 +0000 | [diff] [blame] | 28 | struct drm_printer; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 29 | struct drm_i915_private; |
Michal Wajdeczko | 4502e9e | 2017-10-16 14:47:21 +0000 | [diff] [blame] | 30 | struct i915_vma; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 31 | |
Michal Wajdeczko | f1e86ce | 2017-10-16 14:47:20 +0000 | [diff] [blame] | 32 | /* Home of GuC, HuC and DMC firmwares */ |
Michal Wajdeczko | 1e913d2 | 2017-10-16 14:47:19 +0000 | [diff] [blame] | 33 | #define INTEL_UC_FIRMWARE_URL "https://01.org/linuxgraphics/downloads/firmware" |
| 34 | |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 35 | enum intel_uc_fw_status { |
| 36 | INTEL_UC_FIRMWARE_FAIL = -1, |
| 37 | INTEL_UC_FIRMWARE_NONE = 0, |
| 38 | INTEL_UC_FIRMWARE_PENDING, |
| 39 | INTEL_UC_FIRMWARE_SUCCESS |
| 40 | }; |
| 41 | |
| 42 | enum intel_uc_fw_type { |
| 43 | INTEL_UC_FW_TYPE_GUC, |
| 44 | INTEL_UC_FW_TYPE_HUC |
| 45 | }; |
| 46 | |
| 47 | /* |
| 48 | * This structure encapsulates all the data needed during the process |
| 49 | * of fetching, caching, and loading the firmware image into the uC. |
| 50 | */ |
| 51 | struct intel_uc_fw { |
| 52 | const char *path; |
| 53 | size_t size; |
| 54 | struct drm_i915_gem_object *obj; |
| 55 | enum intel_uc_fw_status fetch_status; |
| 56 | enum intel_uc_fw_status load_status; |
| 57 | |
Michal Wajdeczko | d9e2e01 | 2017-10-16 14:47:13 +0000 | [diff] [blame] | 58 | /* |
| 59 | * The firmware build process will generate a version header file with major and |
| 60 | * minor version defined. The versions are built into CSS header of firmware. |
| 61 | * i915 kernel driver set the minimal firmware version required per platform. |
| 62 | */ |
Joonas Lahtinen | faf6548 | 2017-10-06 11:49:40 +0300 | [diff] [blame] | 63 | u16 major_ver_wanted; |
| 64 | u16 minor_ver_wanted; |
| 65 | u16 major_ver_found; |
| 66 | u16 minor_ver_found; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 67 | |
| 68 | enum intel_uc_fw_type type; |
Joonas Lahtinen | faf6548 | 2017-10-06 11:49:40 +0300 | [diff] [blame] | 69 | u32 header_size; |
| 70 | u32 header_offset; |
| 71 | u32 rsa_size; |
| 72 | u32 rsa_offset; |
| 73 | u32 ucode_size; |
| 74 | u32 ucode_offset; |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static inline |
| 78 | const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) |
| 79 | { |
| 80 | switch (status) { |
| 81 | case INTEL_UC_FIRMWARE_FAIL: |
| 82 | return "FAIL"; |
| 83 | case INTEL_UC_FIRMWARE_NONE: |
| 84 | return "NONE"; |
| 85 | case INTEL_UC_FIRMWARE_PENDING: |
| 86 | return "PENDING"; |
| 87 | case INTEL_UC_FIRMWARE_SUCCESS: |
| 88 | return "SUCCESS"; |
| 89 | } |
| 90 | return "<invalid>"; |
| 91 | } |
| 92 | |
| 93 | static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type) |
| 94 | { |
| 95 | switch (type) { |
| 96 | case INTEL_UC_FW_TYPE_GUC: |
| 97 | return "GuC"; |
| 98 | case INTEL_UC_FW_TYPE_HUC: |
| 99 | return "HuC"; |
| 100 | } |
| 101 | return "uC"; |
| 102 | } |
| 103 | |
Michal Wajdeczko | 959a3b6 | 2017-10-04 18:13:43 +0000 | [diff] [blame] | 104 | static inline |
| 105 | void intel_uc_fw_init(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type) |
| 106 | { |
| 107 | uc_fw->path = NULL; |
| 108 | uc_fw->fetch_status = INTEL_UC_FIRMWARE_NONE; |
| 109 | uc_fw->load_status = INTEL_UC_FIRMWARE_NONE; |
| 110 | uc_fw->type = type; |
| 111 | } |
| 112 | |
Michal Wajdeczko | 0dd940c | 2017-12-06 13:53:11 +0000 | [diff] [blame] | 113 | static inline bool intel_uc_fw_is_selected(struct intel_uc_fw *uc_fw) |
| 114 | { |
| 115 | return uc_fw->path != NULL; |
| 116 | } |
| 117 | |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 118 | void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, |
| 119 | struct intel_uc_fw *uc_fw); |
Michal Wajdeczko | 4502e9e | 2017-10-16 14:47:21 +0000 | [diff] [blame] | 120 | int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, |
| 121 | int (*xfer)(struct intel_uc_fw *uc_fw, |
| 122 | struct i915_vma *vma)); |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 123 | void intel_uc_fw_fini(struct intel_uc_fw *uc_fw); |
Michal Wajdeczko | 7d41ef3 | 2017-10-26 17:36:55 +0000 | [diff] [blame] | 124 | void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p); |
Michal Wajdeczko | a16b431 | 2017-10-04 15:33:25 +0000 | [diff] [blame] | 125 | |
| 126 | #endif |