vpu_boot_api.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (c) 2020-2024, Intel Corporation.
  4. */
  5. #ifndef VPU_BOOT_API_H
  6. #define VPU_BOOT_API_H
  7. /*
  8. * The below values will be used to construct the version info this way:
  9. * fw_bin_header->api_version[VPU_BOOT_API_VER_ID] = (VPU_BOOT_API_VER_MAJOR << 16) |
  10. * VPU_BOOT_API_VER_MINOR;
  11. * VPU_BOOT_API_VER_PATCH will be ignored. KMD and compatibility is not affected if this changes
  12. * This information is collected by using vpuip_2/application/vpuFirmware/make_std_fw_image.py
  13. * If a header is missing this info we ignore the header, if a header is missing or contains
  14. * partial info a build error will be generated.
  15. */
  16. /*
  17. * Major version changes that break backward compatibility.
  18. * Major version must start from 1 and can only be incremented.
  19. */
  20. #define VPU_BOOT_API_VER_MAJOR 3
  21. /*
  22. * Minor version changes when API backward compatibility is preserved.
  23. * Resets to 0 if Major version is incremented.
  24. */
  25. #define VPU_BOOT_API_VER_MINOR 28
  26. /*
  27. * API header changed (field names, documentation, formatting) but API itself has not been changed
  28. */
  29. #define VPU_BOOT_API_VER_PATCH 3
  30. /*
  31. * Index in the API version table
  32. * Must be unique for each API
  33. */
  34. #define VPU_BOOT_API_VER_INDEX 0
  35. #pragma pack(push, 4)
  36. /*
  37. * Firmware image header format
  38. */
  39. #define VPU_FW_HEADER_SIZE 4096
  40. #define VPU_FW_HEADER_VERSION 0x1
  41. #define VPU_FW_VERSION_SIZE 32
  42. #define VPU_FW_API_VER_NUM 16
  43. struct vpu_firmware_header {
  44. u32 header_version;
  45. u32 image_format;
  46. u64 image_load_address;
  47. u32 image_size;
  48. u64 entry_point;
  49. u8 vpu_version[VPU_FW_VERSION_SIZE];
  50. u32 compression_type;
  51. u64 firmware_version_load_address;
  52. u32 firmware_version_size;
  53. u64 boot_params_load_address;
  54. u32 api_version[VPU_FW_API_VER_NUM];
  55. /* Size of memory require for firmware execution */
  56. u32 runtime_size;
  57. u32 shave_nn_fw_size;
  58. /*
  59. * Size of primary preemption buffer, assuming a 2-job submission queue.
  60. * NOTE: host driver is expected to adapt size accordingly to actual
  61. * submission queue size and device capabilities.
  62. */
  63. u32 preemption_buffer_1_size;
  64. /*
  65. * Size of secondary preemption buffer, assuming a 2-job submission queue.
  66. * NOTE: host driver is expected to adapt size accordingly to actual
  67. * submission queue size and device capabilities.
  68. */
  69. u32 preemption_buffer_2_size;
  70. /*
  71. * Maximum preemption buffer size that the FW can use: no need for the host
  72. * driver to allocate more space than that specified by these fields.
  73. * A value of 0 means no declared limit.
  74. */
  75. u32 preemption_buffer_1_max_size;
  76. u32 preemption_buffer_2_max_size;
  77. /* Space reserved for future preemption-related fields. */
  78. u32 preemption_reserved[4];
  79. /* FW image read only section start address, 4KB aligned */
  80. u64 ro_section_start_address;
  81. /* FW image read only section size, 4KB aligned */
  82. u32 ro_section_size;
  83. u32 reserved;
  84. };
  85. /*
  86. * Firmware boot parameters format
  87. */
  88. #define VPU_BOOT_PLL_COUNT 3
  89. #define VPU_BOOT_PLL_OUT_COUNT 4
  90. /** Values for boot_type field */
  91. #define VPU_BOOT_TYPE_COLDBOOT 0
  92. #define VPU_BOOT_TYPE_WARMBOOT 1
  93. /** Value for magic filed */
  94. #define VPU_BOOT_PARAMS_MAGIC 0x10000
  95. /** VPU scheduling mode. By default, OS scheduling is used. */
  96. #define VPU_SCHEDULING_MODE_OS 0
  97. #define VPU_SCHEDULING_MODE_HW 1
  98. enum VPU_BOOT_L2_CACHE_CFG_TYPE {
  99. VPU_BOOT_L2_CACHE_CFG_UPA = 0,
  100. VPU_BOOT_L2_CACHE_CFG_NN = 1,
  101. VPU_BOOT_L2_CACHE_CFG_NUM = 2
  102. };
  103. /** VPU MCA ECC signalling mode. By default, no signalling is used */
  104. enum VPU_BOOT_MCA_ECC_SIGNAL_TYPE {
  105. VPU_BOOT_MCA_ECC_NONE = 0,
  106. VPU_BOOT_MCA_ECC_CORR = 1,
  107. VPU_BOOT_MCA_ECC_FATAL = 2,
  108. VPU_BOOT_MCA_ECC_BOTH = 3
  109. };
  110. /**
  111. * Logging destinations.
  112. *
  113. * Logging output can be directed to different logging destinations. This enum
  114. * defines the list of logging destinations supported by the VPU firmware (NOTE:
  115. * a specific VPU FW binary may support only a subset of such output
  116. * destinations, depending on the target platform and compile options).
  117. */
  118. enum vpu_trace_destination {
  119. VPU_TRACE_DESTINATION_PIPEPRINT = 0x1,
  120. VPU_TRACE_DESTINATION_VERBOSE_TRACING = 0x2,
  121. VPU_TRACE_DESTINATION_NORTH_PEAK = 0x4,
  122. };
  123. /*
  124. * Processor bit shifts (for loggable HW components).
  125. */
  126. #define VPU_TRACE_PROC_BIT_RESERVED 0
  127. #define VPU_TRACE_PROC_BIT_LRT 1
  128. #define VPU_TRACE_PROC_BIT_LNN 2
  129. #define VPU_TRACE_PROC_BIT_SHV_0 3
  130. #define VPU_TRACE_PROC_BIT_SHV_1 4
  131. #define VPU_TRACE_PROC_BIT_SHV_2 5
  132. #define VPU_TRACE_PROC_BIT_SHV_3 6
  133. #define VPU_TRACE_PROC_BIT_SHV_4 7
  134. #define VPU_TRACE_PROC_BIT_SHV_5 8
  135. #define VPU_TRACE_PROC_BIT_SHV_6 9
  136. #define VPU_TRACE_PROC_BIT_SHV_7 10
  137. #define VPU_TRACE_PROC_BIT_SHV_8 11
  138. #define VPU_TRACE_PROC_BIT_SHV_9 12
  139. #define VPU_TRACE_PROC_BIT_SHV_10 13
  140. #define VPU_TRACE_PROC_BIT_SHV_11 14
  141. #define VPU_TRACE_PROC_BIT_SHV_12 15
  142. #define VPU_TRACE_PROC_BIT_SHV_13 16
  143. #define VPU_TRACE_PROC_BIT_SHV_14 17
  144. #define VPU_TRACE_PROC_BIT_SHV_15 18
  145. #define VPU_TRACE_PROC_BIT_ACT_SHV_0 19
  146. #define VPU_TRACE_PROC_BIT_ACT_SHV_1 20
  147. #define VPU_TRACE_PROC_BIT_ACT_SHV_2 21
  148. #define VPU_TRACE_PROC_BIT_ACT_SHV_3 22
  149. #define VPU_TRACE_PROC_NO_OF_HW_DEVS 23
  150. /* VPU 30xx HW component IDs are sequential, so define first and last IDs. */
  151. #define VPU_TRACE_PROC_BIT_30XX_FIRST VPU_TRACE_PROC_BIT_LRT
  152. #define VPU_TRACE_PROC_BIT_30XX_LAST VPU_TRACE_PROC_BIT_SHV_15
  153. struct vpu_boot_l2_cache_config {
  154. u8 use;
  155. u8 cfg;
  156. };
  157. struct vpu_warm_boot_section {
  158. u32 src;
  159. u32 dst;
  160. u32 size;
  161. u32 core_id;
  162. u32 is_clear_op;
  163. };
  164. /*
  165. * When HW scheduling mode is enabled, a present period is defined.
  166. * It will be used by VPU to swap between normal and focus priorities
  167. * to prevent starving of normal priority band (when implemented).
  168. * Host must provide a valid value at boot time in
  169. * `vpu_focus_present_timer_ms`. If the value provided by the host is not within the
  170. * defined range a default value will be used. Here we define the min. and max.
  171. * allowed values and the and default value of the present period. Units are milliseconds.
  172. */
  173. #define VPU_PRESENT_CALL_PERIOD_MS_DEFAULT 50
  174. #define VPU_PRESENT_CALL_PERIOD_MS_MIN 16
  175. #define VPU_PRESENT_CALL_PERIOD_MS_MAX 10000
  176. /**
  177. * Macros to enable various power profiles within the NPU.
  178. * To be defined as part of 32 bit mask.
  179. */
  180. #define POWER_PROFILE_SURVIVABILITY 0x1
  181. /**
  182. * Enum for dvfs_mode boot param.
  183. */
  184. enum vpu_governor {
  185. VPU_GOV_DEFAULT = 0, /* Default Governor for the system */
  186. VPU_GOV_MAX_PERFORMANCE = 1, /* Maximum performance governor */
  187. VPU_GOV_ON_DEMAND = 2, /* On Demand frequency control governor */
  188. VPU_GOV_POWER_SAVE = 3, /* Power save governor */
  189. VPU_GOV_ON_DEMAND_PRIORITY_AWARE = 4 /* On Demand priority based governor */
  190. };
  191. struct vpu_boot_params {
  192. u32 magic;
  193. u32 vpu_id;
  194. u32 vpu_count;
  195. u32 pad0[5];
  196. /* Clock frequencies: 0x20 - 0xFF */
  197. u32 frequency;
  198. u32 pll[VPU_BOOT_PLL_COUNT][VPU_BOOT_PLL_OUT_COUNT];
  199. u32 perf_clk_frequency;
  200. u32 pad1[42];
  201. /* Memory regions: 0x100 - 0x1FF */
  202. u64 ipc_header_area_start;
  203. u32 ipc_header_area_size;
  204. u64 shared_region_base;
  205. u32 shared_region_size;
  206. u64 ipc_payload_area_start;
  207. u32 ipc_payload_area_size;
  208. u64 global_aliased_pio_base;
  209. u32 global_aliased_pio_size;
  210. u32 autoconfig;
  211. struct vpu_boot_l2_cache_config cache_defaults[VPU_BOOT_L2_CACHE_CFG_NUM];
  212. u64 global_memory_allocator_base;
  213. u32 global_memory_allocator_size;
  214. /**
  215. * ShaveNN FW section VPU base address
  216. * On VPU2.7 HW this address must be within 2GB range starting from L2C_PAGE_TABLE base
  217. */
  218. u64 shave_nn_fw_base;
  219. u64 save_restore_ret_address; /* stores the address of FW's restore entry point */
  220. u32 pad2[43];
  221. /* IRQ re-direct numbers: 0x200 - 0x2FF */
  222. s32 watchdog_irq_mss;
  223. s32 watchdog_irq_nce;
  224. /* ARM -> VPU doorbell interrupt. ARM is notifying VPU of async command or compute job. */
  225. u32 host_to_vpu_irq;
  226. /* VPU -> ARM job done interrupt. VPU is notifying ARM of compute job completion. */
  227. u32 job_done_irq;
  228. /* VPU -> ARM IRQ line to use to request MMU update. */
  229. u32 mmu_update_request_irq;
  230. /* ARM -> VPU IRQ line to use to notify of MMU update completion. */
  231. u32 mmu_update_done_irq;
  232. /* ARM -> VPU IRQ line to use to request power level change. */
  233. u32 set_power_level_irq;
  234. /* VPU -> ARM IRQ line to use to notify of power level change completion. */
  235. u32 set_power_level_done_irq;
  236. /* VPU -> ARM IRQ line to use to notify of VPU idle state change */
  237. u32 set_vpu_idle_update_irq;
  238. /* VPU -> ARM IRQ line to use to request counter reset. */
  239. u32 metric_query_event_irq;
  240. /* ARM -> VPU IRQ line to use to notify of counter reset completion. */
  241. u32 metric_query_event_done_irq;
  242. /* VPU -> ARM IRQ line to use to notify of preemption completion. */
  243. u32 preemption_done_irq;
  244. /* Padding. */
  245. u32 pad3[52];
  246. /* Silicon information: 0x300 - 0x3FF */
  247. u32 host_version_id;
  248. u32 si_stepping;
  249. u64 device_id;
  250. u64 feature_exclusion;
  251. u64 sku;
  252. /** PLL ratio for minimum clock frequency */
  253. u32 min_freq_pll_ratio;
  254. /** PLL ratio for maximum clock frequency */
  255. u32 max_freq_pll_ratio;
  256. /**
  257. * Initial log level threshold (messages with log level severity less than
  258. * the threshold will not be logged); applies to every enabled logging
  259. * destination and loggable HW component. See 'mvLog_t' enum for acceptable
  260. * values.
  261. * TODO: EISW-33556: Move log level definition (mvLog_t) to this file.
  262. */
  263. u32 default_trace_level;
  264. u32 boot_type;
  265. u64 punit_telemetry_sram_base;
  266. u64 punit_telemetry_sram_size;
  267. u32 vpu_telemetry_enable;
  268. u64 crit_tracing_buff_addr;
  269. u32 crit_tracing_buff_size;
  270. u64 verbose_tracing_buff_addr;
  271. u32 verbose_tracing_buff_size;
  272. u64 verbose_tracing_sw_component_mask; /* TO BE REMOVED */
  273. /**
  274. * Mask of destinations to which logging messages are delivered; bitwise OR
  275. * of values defined in vpu_trace_destination enum.
  276. */
  277. u32 trace_destination_mask;
  278. /**
  279. * Mask of hardware components for which logging is enabled; bitwise OR of
  280. * bits defined by the VPU_TRACE_PROC_BIT_* macros.
  281. */
  282. u64 trace_hw_component_mask;
  283. /** Mask of trace message formats supported by the driver */
  284. u64 tracing_buff_message_format_mask;
  285. u64 trace_reserved_1[2];
  286. /**
  287. * Period at which the VPU reads the temp sensor values into MMIO, on
  288. * platforms where that is necessary (in ms). 0 to disable reads.
  289. */
  290. u32 temp_sensor_period_ms;
  291. /** PLL ratio for efficient clock frequency */
  292. u32 pn_freq_pll_ratio;
  293. /**
  294. * DVFS Mode:
  295. * 0 - Default, DVFS mode selected by the firmware
  296. * 1 - Max Performance
  297. * 2 - On Demand
  298. * 3 - Power Save
  299. * 4 - On Demand Priority Aware
  300. */
  301. u32 dvfs_mode;
  302. /**
  303. * Depending on DVFS Mode:
  304. * On-demand: Default if 0.
  305. * Bit 0-7 - uint8_t: Highest residency percent
  306. * Bit 8-15 - uint8_t: High residency percent
  307. * Bit 16-23 - uint8_t: Low residency percent
  308. * Bit 24-31 - uint8_t: Lowest residency percent
  309. * Bit 32-35 - unsigned 4b: PLL Ratio increase amount on highest residency
  310. * Bit 36-39 - unsigned 4b: PLL Ratio increase amount on high residency
  311. * Bit 40-43 - unsigned 4b: PLL Ratio decrease amount on low residency
  312. * Bit 44-47 - unsigned 4b: PLL Ratio decrease amount on lowest frequency
  313. * Bit 48-55 - uint8_t: Period (ms) for residency decisions
  314. * Bit 56-63 - uint8_t: Averaging windows (as multiples of period. Max: 30 decimal)
  315. * Power Save/Max Performance: Unused
  316. */
  317. u64 dvfs_param;
  318. /**
  319. * D0i3 delayed entry
  320. * Bit0: Disable CPU state save on D0i2 entry flow.
  321. * 0: Every D0i2 entry saves state. Save state IPC message ignored.
  322. * 1: IPC message required to save state on D0i3 entry flow.
  323. */
  324. u32 d0i3_delayed_entry;
  325. /* Time spent by VPU in D0i3 state */
  326. u64 d0i3_residency_time_us;
  327. /* Value of VPU perf counter at the time of entering D0i3 state . */
  328. u64 d0i3_entry_vpu_ts;
  329. /*
  330. * The system time of the host operating system in microseconds.
  331. * E.g the number of microseconds since 1st of January 1970, or whatever
  332. * date the host operating system uses to maintain system time.
  333. * This value will be used to track system time on the VPU.
  334. * The KMD is required to update this value on every VPU reset.
  335. */
  336. u64 system_time_us;
  337. u32 pad4[2];
  338. /*
  339. * The delta between device monotonic time and the current value of the
  340. * HW timestamp register, in ticks. Written by the firmware during boot.
  341. * Can be used by the KMD to calculate device time.
  342. */
  343. u64 device_time_delta_ticks;
  344. u32 pad7[14];
  345. /* Warm boot information: 0x400 - 0x43F */
  346. u32 warm_boot_sections_count;
  347. u32 warm_boot_start_address_reference;
  348. u32 warm_boot_section_info_address_offset;
  349. u32 pad5[13];
  350. /* Power States transitions timestamps: 0x440 - 0x46F*/
  351. struct {
  352. /* VPU_IDLE -> VPU_ACTIVE transition initiated timestamp */
  353. u64 vpu_active_state_requested;
  354. /* VPU_IDLE -> VPU_ACTIVE transition completed timestamp */
  355. u64 vpu_active_state_achieved;
  356. /* VPU_ACTIVE -> VPU_IDLE transition initiated timestamp */
  357. u64 vpu_idle_state_requested;
  358. /* VPU_ACTIVE -> VPU_IDLE transition completed timestamp */
  359. u64 vpu_idle_state_achieved;
  360. /* VPU_IDLE -> VPU_STANDBY transition initiated timestamp */
  361. u64 vpu_standby_state_requested;
  362. /* VPU_IDLE -> VPU_STANDBY transition completed timestamp */
  363. u64 vpu_standby_state_achieved;
  364. } power_states_timestamps;
  365. /* VPU scheduling mode. Values defined by VPU_SCHEDULING_MODE_* macros. */
  366. u32 vpu_scheduling_mode;
  367. /* Present call period in milliseconds. */
  368. u32 vpu_focus_present_timer_ms;
  369. /* VPU ECC Signaling */
  370. u32 vpu_uses_ecc_mca_signal;
  371. /* Values defined by POWER_PROFILE* macros */
  372. u32 power_profile;
  373. /* Microsecond value for DCT active cycle */
  374. u32 dct_active_us;
  375. /* Microsecond value for DCT inactive cycle */
  376. u32 dct_inactive_us;
  377. /* Unused/reserved: 0x488 - 0xFFF */
  378. u32 pad6[734];
  379. };
  380. /* Magic numbers set between host and vpu to detect corruption of tracing init */
  381. #define VPU_TRACING_BUFFER_CANARY (0xCAFECAFE)
  382. /* Tracing buffer message format definitions */
  383. #define VPU_TRACING_FORMAT_STRING 0
  384. #define VPU_TRACING_FORMAT_MIPI 2
  385. /*
  386. * Header of the tracing buffer.
  387. * The below defined header will be stored at the beginning of
  388. * each allocated tracing buffer, followed by a series of 256b
  389. * of ASCII trace message entries.
  390. */
  391. struct vpu_tracing_buffer_header {
  392. /**
  393. * Magic number set by host to detect corruption
  394. * @see VPU_TRACING_BUFFER_CANARY
  395. */
  396. u32 host_canary_start;
  397. /* offset from start of buffer for trace entries */
  398. u32 read_index;
  399. /* keeps track of wrapping on the reader side */
  400. u32 read_wrap_count;
  401. u32 pad_to_cache_line_size_0[13];
  402. /* End of first cache line */
  403. /**
  404. * Magic number set by host to detect corruption
  405. * @see VPU_TRACING_BUFFER_CANARY
  406. */
  407. u32 vpu_canary_start;
  408. /* offset from start of buffer from write start */
  409. u32 write_index;
  410. /* counter for buffer wrapping */
  411. u32 wrap_count;
  412. /* legacy field - do not use */
  413. u32 reserved_0;
  414. /**
  415. * Size of the log buffer include this header (@header_size) and space
  416. * reserved for all messages. If @alignment` is greater that 0 the @Size
  417. * must be multiple of @Alignment.
  418. */
  419. u32 size;
  420. /* Header version */
  421. u16 header_version;
  422. /* Header size */
  423. u16 header_size;
  424. /*
  425. * Format of the messages in the trace buffer
  426. * 0 - null terminated string
  427. * 1 - size + null terminated string
  428. * 2 - MIPI-SysT encoding
  429. */
  430. u32 format;
  431. /*
  432. * Message alignment
  433. * 0 - messages are place 1 after another
  434. * n - every message starts and multiple on offset
  435. */
  436. u32 alignment; /* 64, 128, 256 */
  437. /* Name of the logging entity, i.e "LRT", "LNN", "SHV0", etc */
  438. char name[16];
  439. u32 pad_to_cache_line_size_1[4];
  440. /* End of second cache line */
  441. };
  442. #pragma pack(pop)
  443. #endif