// SPDX-License-Identifier: GPL-2.0-only OR MIT/* Copyright (c) 2023 Imagination Technologies Ltd. */#include"pvr_ccb.h"#include"pvr_device.h"#include"pvr_device_info.h"#include"pvr_fw.h"#include"pvr_fw_info.h"#include"pvr_fw_startstop.h"#include"pvr_fw_trace.h"#include"pvr_gem.h"#include"pvr_power.h"#include"pvr_rogue_fwif_dev_info.h"#include"pvr_rogue_heap_config.h"#include"pvr_vm.h"#include<drm/drm_drv.h>#include<drm/drm_managed.h>#include<drm/drm_mm.h>#include<linux/clk.h>#include<linux/firmware.h>#include<linux/math.h>#include<linux/minmax.h>#include<linux/sizes.h>#define FW_MAX_SUPPORTED_MAJOR_VERSION 1#define FW_BOOT_TIMEOUT_USEC 5000000/* Config heap occupies top 192k of the firmware heap. */#define PVR_ROGUE_FW_CONFIG_HEAP_GRANULARITY SZ_64K#define PVR_ROGUE_FW_CONFIG_HEAP_SIZE (3 * PVR_ROGUE_FW_CONFIG_HEAP_GRANULARITY)/* Main firmware allocations should come from the remainder of the heap. */#define PVR_ROGUE_FW_MAIN_HEAP_BASE ROGUE_FW_HEAP_BASE/* Offsets from start of configuration area of FW heap. */#define PVR_ROGUE_FWIF_CONNECTION_CTL_OFFSET 0#define PVR_ROGUE_FWIF_OSINIT_OFFSET \ (PVR_ROGUE_FWIF_CONNECTION_CTL_OFFSET + PVR_ROGUE_FW_CONFIG_HEAP_GRANULARITY)#define PVR_ROGUE_FWIF_SYSINIT_OFFSET \ (PVR_ROGUE_FWIF_OSINIT_OFFSET + PVR_ROGUE_FW_CONFIG_HEAP_GRANULARITY)#define PVR_ROGUE_FAULT_PAGE_SIZE SZ_4K#define PVR_SYNC_OBJ_SIZE sizeof(u32)conststructpvr_fw_layout_entry*pvr_fw_find_layout_entry(structpvr_device*pvr_dev,enumpvr_fw_section_idid){conststructpvr_fw_layout_entry*layout_entries=pvr_dev->fw_dev.layout_entries;u32num_layout_entries=pvr_dev->fw_dev.header->layout_entry_num;u32entry;for(entry=