graph.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ======
  3. Graphs
  4. ======
  5. _DSD
  6. ====
  7. _DSD (Device Specific Data) [dsd-guide] is a predefined ACPI device
  8. configuration object that can be used to convey information on
  9. hardware features which are not specifically covered by the ACPI
  10. specification [acpi]. There are two _DSD extensions that are relevant
  11. for graphs: property [dsd-guide] and hierarchical data extensions. The
  12. property extension provides generic key-value pairs whereas the
  13. hierarchical data extension supports nodes with references to other
  14. nodes, forming a tree. The nodes in the tree may contain properties as
  15. defined by the property extension. The two extensions together provide
  16. a tree-like structure with zero or more properties (key-value pairs)
  17. in each node of the tree.
  18. The data structure may be accessed at runtime by using the device_*
  19. and fwnode_* functions defined in include/linux/fwnode.h .
  20. Fwnode represents a generic firmware node object. It is independent on
  21. the firmware type. In ACPI, fwnodes are _DSD hierarchical data
  22. extensions objects. A device's _DSD object is represented by an
  23. fwnode.
  24. The data structure may be referenced to elsewhere in the ACPI tables
  25. by using a hard reference to the device itself and an index to the
  26. hierarchical data extension array on each depth.
  27. Ports and endpoints
  28. ===================
  29. The port and endpoint concepts are very similar to those in Devicetree
  30. [devicetree, graph-bindings]. A port represents an interface in a device, and
  31. an endpoint represents a connection to that interface. Also see [data-node-ref]
  32. for generic data node references.
  33. All port nodes are located under the device's "_DSD" node in the hierarchical
  34. data extension tree. The data extension related to each port node must begin
  35. with "port" and must be followed by the "@" character and the number of the
  36. port as its key. The target object it refers to should be called "PRTX", where
  37. "X" is the number of the port. An example of such a package would be::
  38. Package() { "port@4", "PRT4" }
  39. Further on, endpoints are located under the port nodes. The hierarchical
  40. data extension key of the endpoint nodes must begin with
  41. "endpoint" and must be followed by the "@" character and the number of the
  42. endpoint. The object it refers to should be called "EPXY", where "X" is the
  43. number of the port and "Y" is the number of the endpoint. An example of such a
  44. package would be::
  45. Package() { "endpoint@0", "EP40" }
  46. Each port node contains a property extension key "port", the value of which is
  47. the number of the port. Each endpoint is similarly numbered with a property
  48. extension key "reg", the value of which is the number of the endpoint. Port
  49. numbers must be unique within a device and endpoint numbers must be unique
  50. within a port. If a device object may only has a single port, then the number
  51. of that port shall be zero. Similarly, if a port may only have a single
  52. endpoint, the number of that endpoint shall be zero.
  53. The endpoint reference uses property extension with "remote-endpoint" property
  54. name followed by a reference in the same package. Such references consist of
  55. the remote device reference, the first package entry of the port data extension
  56. reference under the device and finally the first package entry of the endpoint
  57. data extension reference under the port. Individual references thus appear as::
  58. Package() { device, "port@X", "endpoint@Y" }
  59. In the above example, "X" is the number of the port and "Y" is the number of
  60. the endpoint.
  61. The references to endpoints must be always done both ways, to the
  62. remote endpoint and back from the referred remote endpoint node.
  63. A simple example of this is show below::
  64. Scope (\_SB.PCI0.I2C2)
  65. {
  66. Device (CAM0)
  67. {
  68. Name (_DSD, Package () {
  69. ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
  70. Package () {
  71. Package () { "compatible", Package () { "nokia,smia" } },
  72. },
  73. ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
  74. Package () {
  75. Package () { "port@0", "PRT0" },
  76. }
  77. })
  78. Name (PRT0, Package() {
  79. ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
  80. Package () {
  81. Package () { "reg", 0 },
  82. },
  83. ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
  84. Package () {
  85. Package () { "endpoint@0", "EP00" },
  86. }
  87. })
  88. Name (EP00, Package() {
  89. ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
  90. Package () {
  91. Package () { "reg", 0 },
  92. Package () { "remote-endpoint", Package() { \_SB.PCI0.ISP, "port@4", "endpoint@0" } },
  93. }
  94. })
  95. }
  96. }
  97. Scope (\_SB.PCI0)
  98. {
  99. Device (ISP)
  100. {
  101. Name (_DSD, Package () {
  102. ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
  103. Package () {
  104. Package () { "port@4", "PRT4" },
  105. }
  106. })
  107. Name (PRT4, Package() {
  108. ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
  109. Package () {
  110. Package () { "reg", 4 }, /* CSI-2 port number */
  111. },
  112. ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
  113. Package () {
  114. Package () { "endpoint@0", "EP40" },
  115. }
  116. })
  117. Name (EP40, Package() {
  118. ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
  119. Package () {
  120. Package () { "reg", 0 },
  121. Package () { "remote-endpoint", Package () { \_SB.PCI0.I2C2.CAM0, "port@0", "endpoint@0" } },
  122. }
  123. })
  124. }
  125. }
  126. Here, the port 0 of the "CAM0" device is connected to the port 4 of
  127. the "ISP" device and vice versa.
  128. References
  129. ==========
  130. [acpi] Advanced Configuration and Power Interface Specification.
  131. https://uefi.org/specifications/ACPI/6.4/, referenced 2021-11-30.
  132. [data-node-ref] Documentation/firmware-guide/acpi/dsd/data-node-references.rst
  133. [devicetree] Devicetree. https://www.devicetree.org, referenced 2016-10-03.
  134. [dsd-guide] DSD Guide.
  135. https://github.com/UEFI/DSD-Guide/blob/main/dsd-guide.adoc, referenced
  136. 2021-11-30.
  137. [dsd-rules] _DSD Device Properties Usage Rules.
  138. Documentation/firmware-guide/acpi/DSD-properties-rules.rst
  139. [graph-bindings] Common bindings for device graphs (Devicetree).
  140. https://github.com/devicetree-org/dt-schema/blob/main/schemas/graph.yaml,
  141. referenced 2021-11-30.