pvr_fw_info.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
  2. /* Copyright (c) 2023 Imagination Technologies Ltd. */
  3. #ifndef PVR_FW_INFO_H
  4. #define PVR_FW_INFO_H
  5. #include <linux/bits.h>
  6. #include <linux/sizes.h>
  7. #include <linux/types.h>
  8. /*
  9. * Firmware binary block unit in bytes.
  10. * Raw data stored in FW binary will be aligned to this size.
  11. */
  12. #define FW_BLOCK_SIZE SZ_4K
  13. /* Maximum number of entries in firmware layout table. */
  14. #define PVR_FW_INFO_MAX_NUM_ENTRIES 8
  15. enum pvr_fw_section_id {
  16. META_CODE = 0,
  17. META_PRIVATE_DATA,
  18. META_COREMEM_CODE,
  19. META_COREMEM_DATA,
  20. MIPS_CODE,
  21. MIPS_EXCEPTIONS_CODE,
  22. MIPS_BOOT_CODE,
  23. MIPS_PRIVATE_DATA,
  24. MIPS_BOOT_DATA,
  25. MIPS_STACK,
  26. RISCV_UNCACHED_CODE,
  27. RISCV_CACHED_CODE,
  28. RISCV_PRIVATE_DATA,
  29. RISCV_COREMEM_CODE,
  30. RISCV_COREMEM_DATA,
  31. };
  32. enum pvr_fw_section_type {
  33. NONE = 0,
  34. FW_CODE,
  35. FW_DATA,
  36. FW_COREMEM_CODE,
  37. FW_COREMEM_DATA,
  38. };
  39. /*
  40. * FW binary format with FW info attached:
  41. *
  42. * Contents Offset
  43. * +-----------------+
  44. * | | 0
  45. * | |
  46. * | Original binary |
  47. * | file |
  48. * | (.ldr/.elf) |
  49. * | |
  50. * | |
  51. * +-----------------+
  52. * | Device info | FILE_SIZE - 4K - device_info_size
  53. * +-----------------+
  54. * | FW info header | FILE_SIZE - 4K
  55. * +-----------------+
  56. * | |
  57. * | FW layout table |
  58. * | |
  59. * +-----------------+
  60. * FILE_SIZE
  61. */
  62. #define PVR_FW_INFO_VERSION 3
  63. #define PVR_FW_FLAGS_OPEN_SOURCE BIT(0)
  64. /** struct pvr_fw_info_header - Firmware header */
  65. struct pvr_fw_info_header {
  66. /** @info_version: FW info header version. */
  67. u32 info_version;
  68. /** @header_len: Header length. */
  69. u32 header_len;
  70. /** @layout_entry_num: Number of entries in the layout table. */
  71. u32 layout_entry_num;
  72. /** @layout_entry_size: Size of an entry in the layout table. */
  73. u32 layout_entry_size;
  74. /** @bvnc: GPU ID supported by firmware. */
  75. aligned_u64 bvnc;
  76. /** @fw_page_size: Page size of processor on which firmware executes. */
  77. u32 fw_page_size;
  78. /** @flags: Compatibility flags. */
  79. u32 flags;
  80. /** @fw_version_major: Firmware major version number. */
  81. u16 fw_version_major;
  82. /** @fw_version_minor: Firmware minor version number. */
  83. u16 fw_version_minor;
  84. /** @fw_version_build: Firmware build number. */
  85. u32 fw_version_build;
  86. /** @device_info_size: Size of device info structure. */
  87. u32 device_info_size;
  88. /** @padding: Padding. */
  89. u32 padding;
  90. };
  91. /**
  92. * struct pvr_fw_layout_entry - Entry in firmware layout table, describing a
  93. * section of the firmware image
  94. */
  95. struct pvr_fw_layout_entry {
  96. /** @id: Section ID. */
  97. enum pvr_fw_section_id id;
  98. /** @type: Section type. */
  99. enum pvr_fw_section_type type;
  100. /** @base_addr: Base address of section in FW address space. */
  101. u32 base_addr;
  102. /** @max_size: Maximum size of section, in bytes. */
  103. u32 max_size;
  104. /** @alloc_size: Allocation size of section, in bytes. */
  105. u32 alloc_size;
  106. /** @alloc_offset: Allocation offset of section. */
  107. u32 alloc_offset;
  108. };
  109. /**
  110. * struct pvr_fw_device_info_header - Device information header.
  111. */
  112. struct pvr_fw_device_info_header {
  113. /** @brn_mask_size: BRN mask size (in u64s). */
  114. u64 brn_mask_size;
  115. /** @ern_mask_size: ERN mask size (in u64s). */
  116. u64 ern_mask_size;
  117. /** @feature_mask_size: Feature mask size (in u64s). */
  118. u64 feature_mask_size;
  119. /** @feature_param_size: Feature parameter size (in u64s). */
  120. u64 feature_param_size;
  121. };
  122. #endif /* PVR_FW_INFO_H */