vpu_boot_api.h 15 KB

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