1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2020-2025 Intel Corporation 4 */ 5 6 #ifndef __IVPU_FW_H__ 7 #define __IVPU_FW_H__ 8 9 #include "vpu_jsm_api.h" 10 11 #define FW_VERSION_HEADER_SIZE SZ_4K 12 #define FW_VERSION_STR_SIZE SZ_256 13 14 struct ivpu_device; 15 struct ivpu_bo; 16 struct vpu_boot_params; 17 18 struct ivpu_fw_info { 19 const struct firmware *file; 20 const char *name; 21 char version[FW_VERSION_STR_SIZE]; 22 struct ivpu_bo *mem_bp; 23 struct ivpu_bo *mem_fw_ver; 24 struct ivpu_bo *mem; 25 struct ivpu_bo *mem_shave_nn; 26 struct ivpu_bo *mem_log_crit; 27 struct ivpu_bo *mem_log_verb; 28 u64 boot_params_addr; 29 u64 boot_params_size; 30 u64 fw_version_addr; 31 u64 fw_version_size; 32 u64 runtime_addr; 33 u32 runtime_size; 34 u64 image_load_offset; 35 u32 image_size; 36 u32 shave_nn_size; 37 u64 entry_point; /* Cold or warm boot entry point for next boot */ 38 u64 cold_boot_entry_point; 39 u32 trace_level; 40 u32 trace_destination_mask; 41 u64 trace_hw_component_mask; 42 u32 dvfs_mode; 43 u32 primary_preempt_buf_size; 44 u32 secondary_preempt_buf_size; 45 u64 read_only_addr; 46 u32 read_only_size; 47 u32 sched_mode; 48 u64 last_heartbeat; 49 }; 50 51 bool ivpu_is_within_range(u64 addr, size_t size, struct ivpu_addr_range *range); 52 int ivpu_fw_init(struct ivpu_device *vdev); 53 void ivpu_fw_fini(struct ivpu_device *vdev); 54 void ivpu_fw_load(struct ivpu_device *vdev); 55 void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params *boot_params); 56 57 static inline bool ivpu_fw_is_cold_boot(struct ivpu_device *vdev) 58 { 59 return vdev->fw->entry_point == vdev->fw->cold_boot_entry_point; 60 } 61 62 static inline u32 ivpu_fw_preempt_buf_size(struct ivpu_device *vdev) 63 { 64 return vdev->fw->primary_preempt_buf_size + vdev->fw->secondary_preempt_buf_size; 65 } 66 67 #endif /* __IVPU_FW_H__ */ 68