/* SPDX-License-Identifier: MIT */1/*2* Copyright (c) 2020-2024, Intel Corporation.3*/45#ifndef VPU_BOOT_API_H6#define VPU_BOOT_API_H78/*9* The below values will be used to construct the version info this way:10* fw_bin_header->api_version[VPU_BOOT_API_VER_ID] = (VPU_BOOT_API_VER_MAJOR << 16) |11* VPU_BOOT_API_VER_MINOR;12* VPU_BOOT_API_VER_PATCH will be ignored. KMD and compatibility is not affected if this changes13* This information is collected by using vpuip_2/application/vpuFirmware/make_std_fw_image.py14* If a header is missing this info we ignore the header, if a header is missing or contains15* partial info a build error will be generated.16*/1718/*19* Major version changes that break backward compatibility.20* Major version must start from 1 and can only be incremented.21*/22#define VPU_BOOT_API_VER_MAJOR 32324/*25* Minor version changes when API backward compatibility is preserved.26* Resets to 0 if Major version is incremented.27*/28#define VPU_BOOT_API_VER_MINOR 282930/*31* API header changed (field names, documentation, formatting) but API itself has not been changed32*/33#define VPU_BOOT_API_VER_PATCH 33435/*36* Index in the API version table37* Must be unique for each API38*/39#define VPU_BOOT_API_VER_INDEX 04041#pragma pack(push, 4)4243/*44* Firmware image header format45*/46#define VPU_FW_HEADER_SIZE 409647#define VPU_FW_HEADER_VERSION 0x148#define VPU_FW_VERSION_SIZE 3249#define VPU_FW_API_VER_NUM 165051struct vpu_firmware_header {52u32 header_version;53u32 image_format;54u64 image_load_address;55u32 image_size;56u64 entry_point;57u8 vpu_version[VPU_FW_VERSION_SIZE];58u32 compression_type;59u64 firmware_version_load_address;60u32 firmware_version_size;61u64 boot_params_load_address;62u32 api_version[VPU_FW_API_VER_NUM];63/* Size of memory require for firmware execution */64u32 runtime_size;65u32 shave_nn_fw_size;66/*67* Size of primary preemption buffer, assuming a 2-job submission queue.68* NOTE: host driver is expected to adapt size accordingly to actual69* submission queue size and device capabilities.70*/71u32 preemption_buffer_1_size;72/*73* Size of secondary preemption buffer, assuming a 2-job submission queue.74* NOTE: host driver is expected to adapt size accordingly to actual75* submission queue size and device capabilities.76*/77u32 preemption_buffer_2_size;78/*79* Maximum preemption buffer size that the FW can use: no need for the host80* driver to allocate more space than that specified by these fields.81* A value of 0 means no declared limit.82*/83u32 preemption_buffer_1_max_size;84u32 preemption_buffer_2_max_size;85/* Space reserved for future preemption-related fields. */86u32 preemption_reserved[4];87/* FW image read only section start address, 4KB aligned */88u64 ro_section_start_address;89/* FW image read only section size, 4KB aligned */90u32 ro_section_size;91u32 reserved;92};9394/*95* Firmware boot parameters format96*/9798#define VPU_BOOT_PLL_COUNT 399#define VPU_BOOT_PLL_OUT_COUNT 4100101/** Values for boot_type field */102#define VPU_BOOT_TYPE_COLDBOOT 0103#define VPU_BOOT_TYPE_WARMBOOT 1104105/** Value for magic filed */106#define VPU_BOOT_PARAMS_MAGIC 0x10000107108/** VPU scheduling mode. By default, OS scheduling is used. */109#define VPU_SCHEDULING_MODE_OS 0110#define VPU_SCHEDULING_MODE_HW 1111112enum VPU_BOOT_L2_CACHE_CFG_TYPE {113VPU_BOOT_L2_CACHE_CFG_UPA = 0,114VPU_BOOT_L2_CACHE_CFG_NN = 1,115VPU_BOOT_L2_CACHE_CFG_NUM = 2116};117118/** VPU MCA ECC signalling mode. By default, no signalling is used */119enum VPU_BOOT_MCA_ECC_SIGNAL_TYPE {120VPU_BOOT_MCA_ECC_NONE = 0,121VPU_BOOT_MCA_ECC_CORR = 1,122VPU_BOOT_MCA_ECC_FATAL = 2,123VPU_BOOT_MCA_ECC_BOTH = 3124};125126/**127* Logging destinations.128*129* Logging output can be directed to different logging destinations. This enum130* defines the list of logging destinations supported by the VPU firmware (NOTE:131* a specific VPU FW binary may support only a subset of such output132* destinations, depending on the target platform and compile options).133*/134enum vpu_trace_destination {135VPU_TRACE_DESTINATION_PIPEPRINT = 0x1,136VPU_TRACE_DESTINATION_VERBOSE_TRACING = 0x2,137VPU_TRACE_DESTINATION_NORTH_PEAK = 0x4,138};139140/*141* Processor bit shifts (for loggable HW components).142*/143#define VPU_TRACE_PROC_BIT_RESERVED 0144#define VPU_TRACE_PROC_BIT_LRT 1145#define VPU_TRACE_PROC_BIT_LNN 2146#define VPU_TRACE_PROC_BIT_SHV_0 3147#define VPU_TRACE_PROC_BIT_SHV_1 4148#define VPU_TRACE_PROC_BIT_SHV_2 5149#define VPU_TRACE_PROC_BIT_SHV_3 6150#define VPU_TRACE_PROC_BIT_SHV_4 7151#define VPU_TRACE_PROC_BIT_SHV_5 8152#define VPU_TRACE_PROC_BIT_SHV_6 9153#define VPU_TRACE_PROC_BIT_SHV_7 10154#define VPU_TRACE_PROC_BIT_SHV_8 11155#define VPU_TRACE_PROC_BIT_SHV_9 12156#define VPU_TRACE_PROC_BIT_SHV_10 13157#define VPU_TRACE_PROC_BIT_SHV_11 14158#define VPU_TRACE_PROC_BIT_SHV_12 15159#define VPU_TRACE_PROC_BIT_SHV_13 16160#define VPU_TRACE_PROC_BIT_SHV_14 17161#define VPU_TRACE_PROC_BIT_SHV_15 18162#define VPU_TRACE_PROC_BIT_ACT_SHV_0 19163#define VPU_TRACE_PROC_BIT_ACT_SHV_1 20164#define VPU_TRACE_PROC_BIT_ACT_SHV_2 21165#define VPU_TRACE_PROC_BIT_ACT_SHV_3 22166#define VPU_TRACE_PROC_NO_OF_HW_DEVS 23167168/* VPU 30xx HW component IDs are sequential, so define first and last IDs. */169#define VPU_TRACE_PROC_BIT_30XX_FIRST VPU_TRACE_PROC_BIT_LRT170#define VPU_TRACE_PROC_BIT_30XX_LAST VPU_TRACE_PROC_BIT_SHV_15171172struct vpu_boot_l2_cache_config {173u8 use;174u8 cfg;175};176177struct vpu_warm_boot_section {178u32 src;179u32 dst;180u32 size;181u32 core_id;182u32 is_clear_op;183};184185/*186* When HW scheduling mode is enabled, a present period is defined.187* It will be used by VPU to swap between normal and focus priorities188* to prevent starving of normal priority band (when implemented).189* Host must provide a valid value at boot time in190* `vpu_focus_present_timer_ms`. If the value provided by the host is not within the191* defined range a default value will be used. Here we define the min. and max.192* allowed values and the and default value of the present period. Units are milliseconds.193*/194#define VPU_PRESENT_CALL_PERIOD_MS_DEFAULT 50195#define VPU_PRESENT_CALL_PERIOD_MS_MIN 16196#define VPU_PRESENT_CALL_PERIOD_MS_MAX 10000197198/**199* Macros to enable various power profiles within the NPU.200* To be defined as part of 32 bit mask.201*/202#define POWER_PROFILE_SURVIVABILITY 0x1203204/**205* Enum for dvfs_mode boot param.206*/207enum vpu_governor {208VPU_GOV_DEFAULT = 0, /* Default Governor for the system */209VPU_GOV_MAX_PERFORMANCE = 1, /* Maximum performance governor */210VPU_GOV_ON_DEMAND = 2, /* On Demand frequency control governor */211VPU_GOV_POWER_SAVE = 3, /* Power save governor */212VPU_GOV_ON_DEMAND_PRIORITY_AWARE = 4 /* On Demand priority based governor */213};214215struct vpu_boot_params {216u32 magic;217u32 vpu_id;218u32 vpu_count;219u32 pad0[5];220/* Clock frequencies: 0x20 - 0xFF */221u32 frequency;222u32 pll[VPU_BOOT_PLL_COUNT][VPU_BOOT_PLL_OUT_COUNT];223u32 perf_clk_frequency;224u32 pad1[42];225/* Memory regions: 0x100 - 0x1FF */226u64 ipc_header_area_start;227u32 ipc_header_area_size;228u64 shared_region_base;229u32 shared_region_size;230u64 ipc_payload_area_start;231u32 ipc_payload_area_size;232u64 global_aliased_pio_base;233u32 global_aliased_pio_size;234u32 autoconfig;235struct vpu_boot_l2_cache_config cache_defaults[VPU_BOOT_L2_CACHE_CFG_NUM];236u64 global_memory_allocator_base;237u32 global_memory_allocator_size;238/**239* ShaveNN FW section VPU base address240* On VPU2.7 HW this address must be within 2GB range starting from L2C_PAGE_TABLE base241*/242u64 shave_nn_fw_base;243u64 save_restore_ret_address; /* stores the address of FW's restore entry point */244u32 pad2[43];245/* IRQ re-direct numbers: 0x200 - 0x2FF */246s32 watchdog_irq_mss;247s32 watchdog_irq_nce;248/* ARM -> VPU doorbell interrupt. ARM is notifying VPU of async command or compute job. */249u32 host_to_vpu_irq;250/* VPU -> ARM job done interrupt. VPU is notifying ARM of compute job completion. */251u32 job_done_irq;252/* VPU -> ARM IRQ line to use to request MMU update. */253u32 mmu_update_request_irq;254/* ARM -> VPU IRQ line to use to notify of MMU update completion. */255u32 mmu_update_done_irq;256/* ARM -> VPU IRQ line to use to request power level change. */257u32 set_power_level_irq;258/* VPU -> ARM IRQ line to use to notify of power level change completion. */259u32 set_power_level_done_irq;260/* VPU -> ARM IRQ line to use to notify of VPU idle state change */261u32 set_vpu_idle_update_irq;262/* VPU -> ARM IRQ line to use to request counter reset. */263u32 metric_query_event_irq;264/* ARM -> VPU IRQ line to use to notify of counter reset completion. */265u32 metric_query_event_done_irq;266/* VPU -> ARM IRQ line to use to notify of preemption completion. */267u32 preemption_done_irq;268/* Padding. */269u32 pad3[52];270/* Silicon information: 0x300 - 0x3FF */271u32 host_version_id;272u32 si_stepping;273u64 device_id;274u64 feature_exclusion;275u64 sku;276/** PLL ratio for minimum clock frequency */277u32 min_freq_pll_ratio;278/** PLL ratio for maximum clock frequency */279u32 max_freq_pll_ratio;280/**281* Initial log level threshold (messages with log level severity less than282* the threshold will not be logged); applies to every enabled logging283* destination and loggable HW component. See 'mvLog_t' enum for acceptable284* values.285* TODO: EISW-33556: Move log level definition (mvLog_t) to this file.286*/287u32 default_trace_level;288u32 boot_type;289u64 punit_telemetry_sram_base;290u64 punit_telemetry_sram_size;291u32 vpu_telemetry_enable;292u64 crit_tracing_buff_addr;293u32 crit_tracing_buff_size;294u64 verbose_tracing_buff_addr;295u32 verbose_tracing_buff_size;296u64 verbose_tracing_sw_component_mask; /* TO BE REMOVED */297/**298* Mask of destinations to which logging messages are delivered; bitwise OR299* of values defined in vpu_trace_destination enum.300*/301u32 trace_destination_mask;302/**303* Mask of hardware components for which logging is enabled; bitwise OR of304* bits defined by the VPU_TRACE_PROC_BIT_* macros.305*/306u64 trace_hw_component_mask;307/** Mask of trace message formats supported by the driver */308u64 tracing_buff_message_format_mask;309u64 trace_reserved_1[2];310/**311* Period at which the VPU reads the temp sensor values into MMIO, on312* platforms where that is necessary (in ms). 0 to disable reads.313*/314u32 temp_sensor_period_ms;315/** PLL ratio for efficient clock frequency */316u32 pn_freq_pll_ratio;317/**318* DVFS Mode:319* 0 - Default, DVFS mode selected by the firmware320* 1 - Max Performance321* 2 - On Demand322* 3 - Power Save323* 4 - On Demand Priority Aware324*/325u32 dvfs_mode;326/**327* Depending on DVFS Mode:328* On-demand: Default if 0.329* Bit 0-7 - uint8_t: Highest residency percent330* Bit 8-15 - uint8_t: High residency percent331* Bit 16-23 - uint8_t: Low residency percent332* Bit 24-31 - uint8_t: Lowest residency percent333* Bit 32-35 - unsigned 4b: PLL Ratio increase amount on highest residency334* Bit 36-39 - unsigned 4b: PLL Ratio increase amount on high residency335* Bit 40-43 - unsigned 4b: PLL Ratio decrease amount on low residency336* Bit 44-47 - unsigned 4b: PLL Ratio decrease amount on lowest frequency337* Bit 48-55 - uint8_t: Period (ms) for residency decisions338* Bit 56-63 - uint8_t: Averaging windows (as multiples of period. Max: 30 decimal)339* Power Save/Max Performance: Unused340*/341u64 dvfs_param;342/**343* D0i3 delayed entry344* Bit0: Disable CPU state save on D0i2 entry flow.345* 0: Every D0i2 entry saves state. Save state IPC message ignored.346* 1: IPC message required to save state on D0i3 entry flow.347*/348u32 d0i3_delayed_entry;349/* Time spent by VPU in D0i3 state */350u64 d0i3_residency_time_us;351/* Value of VPU perf counter at the time of entering D0i3 state . */352u64 d0i3_entry_vpu_ts;353/*354* The system time of the host operating system in microseconds.355* E.g the number of microseconds since 1st of January 1970, or whatever356* date the host operating system uses to maintain system time.357* This value will be used to track system time on the VPU.358* The KMD is required to update this value on every VPU reset.359*/360u64 system_time_us;361u32 pad4[2];362/*363* The delta between device monotonic time and the current value of the364* HW timestamp register, in ticks. Written by the firmware during boot.365* Can be used by the KMD to calculate device time.366*/367u64 device_time_delta_ticks;368u32 pad7[14];369/* Warm boot information: 0x400 - 0x43F */370u32 warm_boot_sections_count;371u32 warm_boot_start_address_reference;372u32 warm_boot_section_info_address_offset;373u32 pad5[13];374/* Power States transitions timestamps: 0x440 - 0x46F*/375struct {376/* VPU_IDLE -> VPU_ACTIVE transition initiated timestamp */377u64 vpu_active_state_requested;378/* VPU_IDLE -> VPU_ACTIVE transition completed timestamp */379u64 vpu_active_state_achieved;380/* VPU_ACTIVE -> VPU_IDLE transition initiated timestamp */381u64 vpu_idle_state_requested;382/* VPU_ACTIVE -> VPU_IDLE transition completed timestamp */383u64 vpu_idle_state_achieved;384/* VPU_IDLE -> VPU_STANDBY transition initiated timestamp */385u64 vpu_standby_state_requested;386/* VPU_IDLE -> VPU_STANDBY transition completed timestamp */387u64 vpu_standby_state_achieved;388} power_states_timestamps;389/* VPU scheduling mode. Values defined by VPU_SCHEDULING_MODE_* macros. */390u32 vpu_scheduling_mode;391/* Present call period in milliseconds. */392u32 vpu_focus_present_timer_ms;393/* VPU ECC Signaling */394u32 vpu_uses_ecc_mca_signal;395/* Values defined by POWER_PROFILE* macros */396u32 power_profile;397/* Microsecond value for DCT active cycle */398u32 dct_active_us;399/* Microsecond value for DCT inactive cycle */400u32 dct_inactive_us;401/* Unused/reserved: 0x488 - 0xFFF */402u32 pad6[734];403};404405/* Magic numbers set between host and vpu to detect corruption of tracing init */406#define VPU_TRACING_BUFFER_CANARY (0xCAFECAFE)407408/* Tracing buffer message format definitions */409#define VPU_TRACING_FORMAT_STRING 0410#define VPU_TRACING_FORMAT_MIPI 2411/*412* Header of the tracing buffer.413* The below defined header will be stored at the beginning of414* each allocated tracing buffer, followed by a series of 256b415* of ASCII trace message entries.416*/417struct vpu_tracing_buffer_header {418/**419* Magic number set by host to detect corruption420* @see VPU_TRACING_BUFFER_CANARY421*/422u32 host_canary_start;423/* offset from start of buffer for trace entries */424u32 read_index;425/* keeps track of wrapping on the reader side */426u32 read_wrap_count;427u32 pad_to_cache_line_size_0[13];428/* End of first cache line */429430/**431* Magic number set by host to detect corruption432* @see VPU_TRACING_BUFFER_CANARY433*/434u32 vpu_canary_start;435/* offset from start of buffer from write start */436u32 write_index;437/* counter for buffer wrapping */438u32 wrap_count;439/* legacy field - do not use */440u32 reserved_0;441/**442* Size of the log buffer include this header (@header_size) and space443* reserved for all messages. If @alignment` is greater that 0 the @Size444* must be multiple of @Alignment.445*/446u32 size;447/* Header version */448u16 header_version;449/* Header size */450u16 header_size;451/*452* Format of the messages in the trace buffer453* 0 - null terminated string454* 1 - size + null terminated string455* 2 - MIPI-SysT encoding456*/457u32 format;458/*459* Message alignment460* 0 - messages are place 1 after another461* n - every message starts and multiple on offset462*/463u32 alignment; /* 64, 128, 256 */464/* Name of the logging entity, i.e "LRT", "LNN", "SHV0", etc */465char name[16];466u32 pad_to_cache_line_size_1[4];467/* End of second cache line */468};469470#pragma pack(pop)471472#endif473474475