sdb.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * This is the official version 1.1 of sdb.h
  4. */
  5. #ifndef __SDB_H__
  6. #define __SDB_H__
  7. #ifdef __KERNEL__
  8. #include <linux/types.h>
  9. #else
  10. #include <stdint.h>
  11. #endif
  12. /*
  13. * All structures are 64 bytes long and are expected
  14. * to live in an array, one for each interconnect.
  15. * Most fields of the structures are shared among the
  16. * various types, and most-specific fields are at the
  17. * beginning (for alignment reasons, and to keep the
  18. * magic number at the head of the interconnect record
  19. */
  20. /* Product, 40 bytes at offset 24, 8-byte aligned
  21. *
  22. * device_id is vendor-assigned; version is device-specific,
  23. * date is hex (e.g 0x20120501), name is UTF-8, blank-filled
  24. * and not terminated with a 0 byte.
  25. */
  26. struct sdb_product {
  27. uint64_t vendor_id; /* 0x18..0x1f */
  28. uint32_t device_id; /* 0x20..0x23 */
  29. uint32_t version; /* 0x24..0x27 */
  30. uint32_t date; /* 0x28..0x2b */
  31. uint8_t name[19]; /* 0x2c..0x3e */
  32. uint8_t record_type; /* 0x3f */
  33. };
  34. /*
  35. * Component, 56 bytes at offset 8, 8-byte aligned
  36. *
  37. * The address range is first to last, inclusive
  38. * (for example 0x100000 - 0x10ffff)
  39. */
  40. struct sdb_component {
  41. uint64_t addr_first; /* 0x08..0x0f */
  42. uint64_t addr_last; /* 0x10..0x17 */
  43. struct sdb_product product; /* 0x18..0x3f */
  44. };
  45. /* Type of the SDB record */
  46. enum sdb_record_type {
  47. sdb_type_interconnect = 0x00,
  48. sdb_type_device = 0x01,
  49. sdb_type_bridge = 0x02,
  50. sdb_type_integration = 0x80,
  51. sdb_type_repo_url = 0x81,
  52. sdb_type_synthesis = 0x82,
  53. sdb_type_empty = 0xFF,
  54. };
  55. /* Type 0: interconnect (first of the array)
  56. *
  57. * sdb_records is the length of the table including this first
  58. * record, version is 1. The bus type is enumerated later.
  59. */
  60. #define SDB_MAGIC 0x5344422d /* "SDB-" */
  61. struct sdb_interconnect {
  62. uint32_t sdb_magic; /* 0x00-0x03 */
  63. uint16_t sdb_records; /* 0x04-0x05 */
  64. uint8_t sdb_version; /* 0x06 */
  65. uint8_t sdb_bus_type; /* 0x07 */
  66. struct sdb_component sdb_component; /* 0x08-0x3f */
  67. };
  68. /* Type 1: device
  69. *
  70. * class is 0 for "custom device", other values are
  71. * to be standardized; ABI version is for the driver,
  72. * bus-specific bits are defined by each bus (see below)
  73. */
  74. struct sdb_device {
  75. uint16_t abi_class; /* 0x00-0x01 */
  76. uint8_t abi_ver_major; /* 0x02 */
  77. uint8_t abi_ver_minor; /* 0x03 */
  78. uint32_t bus_specific; /* 0x04-0x07 */
  79. struct sdb_component sdb_component; /* 0x08-0x3f */
  80. };
  81. /* Type 2: bridge
  82. *
  83. * child is the address of the nested SDB table
  84. */
  85. struct sdb_bridge {
  86. uint64_t sdb_child; /* 0x00-0x07 */
  87. struct sdb_component sdb_component; /* 0x08-0x3f */
  88. };
  89. /* Type 0x80: integration
  90. *
  91. * all types with bit 7 set are meta-information, so
  92. * software can ignore the types it doesn't know. Here we
  93. * just provide product information for an aggregate device
  94. */
  95. struct sdb_integration {
  96. uint8_t reserved[24]; /* 0x00-0x17 */
  97. struct sdb_product product; /* 0x08-0x3f */
  98. };
  99. /* Type 0x81: Top module repository url
  100. *
  101. * again, an informative field that software can ignore
  102. */
  103. struct sdb_repo_url {
  104. uint8_t repo_url[63]; /* 0x00-0x3e */
  105. uint8_t record_type; /* 0x3f */
  106. };
  107. /* Type 0x82: Synthesis tool information
  108. *
  109. * this informative record
  110. */
  111. struct sdb_synthesis {
  112. uint8_t syn_name[16]; /* 0x00-0x0f */
  113. uint8_t commit_id[16]; /* 0x10-0x1f */
  114. uint8_t tool_name[8]; /* 0x20-0x27 */
  115. uint32_t tool_version; /* 0x28-0x2b */
  116. uint32_t date; /* 0x2c-0x2f */
  117. uint8_t user_name[15]; /* 0x30-0x3e */
  118. uint8_t record_type; /* 0x3f */
  119. };
  120. /* Type 0xff: empty
  121. *
  122. * this allows keeping empty slots during development,
  123. * so they can be filled later with minimal efforts and
  124. * no misleading description is ever shipped -- hopefully.
  125. * It can also be used to pad a table to a desired length.
  126. */
  127. struct sdb_empty {
  128. uint8_t reserved[63]; /* 0x00-0x3e */
  129. uint8_t record_type; /* 0x3f */
  130. };
  131. /* The type of bus, for bus-specific flags */
  132. enum sdb_bus_type {
  133. sdb_wishbone = 0x00,
  134. sdb_data = 0x01,
  135. };
  136. #define SDB_WB_WIDTH_MASK 0x0f
  137. #define SDB_WB_ACCESS8 0x01
  138. #define SDB_WB_ACCESS16 0x02
  139. #define SDB_WB_ACCESS32 0x04
  140. #define SDB_WB_ACCESS64 0x08
  141. #define SDB_WB_LITTLE_ENDIAN 0x80
  142. #define SDB_DATA_READ 0x04
  143. #define SDB_DATA_WRITE 0x02
  144. #define SDB_DATA_EXEC 0x01
  145. #endif /* __SDB_H__ */