amd-sfh-hid.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. .. SPDX-License-Identifier: GPL-2.0
  2. AMD Sensor Fusion Hub
  3. =====================
  4. AMD Sensor Fusion Hub (SFH) is part of an SOC starting from Ryzen-based platforms.
  5. The solution is working well on several OEM products. AMD SFH uses HID over PCIe bus.
  6. In terms of architecture it resembles ISH, however the major difference is all
  7. the HID reports are generated as part of the kernel driver.
  8. Block Diagram
  9. -------------
  10. ::
  11. ---------------------------------
  12. | HID User Space Applications |
  13. - -------------------------------
  14. ---------------------------------------------
  15. ---------------------------------
  16. | HID Core |
  17. ---------------------------------
  18. ---------------------------------
  19. | AMD HID Transport |
  20. ---------------------------------
  21. --------------------------------
  22. | AMD HID Client |
  23. | with HID Report Generator|
  24. --------------------------------
  25. --------------------------------
  26. | AMD MP2 PCIe Driver |
  27. --------------------------------
  28. OS
  29. ---------------------------------------------
  30. Hardware + Firmware
  31. --------------------------------
  32. | SFH MP2 Processor |
  33. --------------------------------
  34. AMD HID Transport Layer
  35. -----------------------
  36. AMD SFH transport is also implemented as a bus. Each client application executing in the AMD MP2 is
  37. registered as a device on this bus. Here, MP2 is an ARM core connected to x86 for processing
  38. sensor data. The layer, which binds each device (AMD SFH HID driver) identifies the device type and
  39. registers with the HID core. Transport layer attaches a constant "struct hid_ll_driver" object with
  40. each device. Once a device is registered with HID core, the callbacks provided via this struct are
  41. used by HID core to communicate with the device. AMD HID Transport layer implements the synchronous calls.
  42. AMD HID Client Layer
  43. --------------------
  44. This layer is responsible to implement HID requests and descriptors. As firmware is OS agnostic, HID
  45. client layer fills the HID request structure and descriptors. HID client layer is complex as it is
  46. interface between MP2 PCIe layer and HID. HID client layer initializes the MP2 PCIe layer and holds
  47. the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Based
  48. on that allocates the DRAM address for each and every sensor and passes it to MP2-PCIe driver. On
  49. enumeration of each sensor, client layer fills the HID Descriptor structure and HID input report
  50. structure. HID Feature report structure is optional. The report descriptor structure varies from
  51. sensor to sensor.
  52. AMD MP2 PCIe layer
  53. ------------------
  54. MP2 PCIe Layer is responsible for making all transactions with the firmware over PCIe.
  55. The connection establishment between firmware and PCIe happens here.
  56. The communication between X86 and MP2 is split into three parts.
  57. 1. Command transfer via the C2P mailbox registers.
  58. 2. Data transfer via DRAM.
  59. 3. Supported sensor info via P2C registers.
  60. Commands are sent to MP2 using C2P Mailbox registers. Writing into C2P Message registers generates
  61. interrupt to MP2. The client layer allocates the physical memory and the same is sent to MP2 via
  62. the PCI layer. MP2 firmware writes the command output to the access DRAM memory which the client
  63. layer has allocated. Firmware always writes minimum of 32 bytes into DRAM. So as a protocol driver
  64. shall allocate minimum of 32 bytes DRAM space.
  65. Enumeration and Probing flow
  66. ----------------------------
  67. ::
  68. HID AMD AMD AMD -PCIe MP2
  69. Core Transport Client layer layer FW
  70. | | | | |
  71. | | | on Boot Driver Loaded |
  72. | | | | |
  73. | | | MP2-PCIe Int |
  74. | | | | |
  75. | | |---Get Number of sensors-> | |
  76. | | | Read P2C |
  77. | | | Register |
  78. | | | | |
  79. | | | Loop(for No of Sensors) | |
  80. | | |----------------------| | |
  81. | | | Create HID Descriptor| | |
  82. | | | Create Input report | | |
  83. | | | Descriptor Map | | |
  84. | | | the MP2 FW Index to | | |
  85. | | | HID Index | | |
  86. | | | Allocate the DRAM | Enable |
  87. | | | address | Sensors |
  88. | | |----------------------| | |
  89. | | HID transport| | Enable |
  90. | |<--Probe------| |---Sensor CMD--> |
  91. | | Create the | | |
  92. | | HID device | | |
  93. | | (MFD) | | |
  94. | | by Populating| | |
  95. | | the HID | | |
  96. | | ll_driver | | |
  97. | HID | | | |
  98. | add | | | |
  99. |Device | | | |
  100. |<------------- | | | |
  101. Data Flow from Application to the AMD SFH Driver
  102. ------------------------------------------------
  103. ::
  104. | | | | |
  105. | | | | |
  106. | | | | |
  107. | | | | |
  108. | | | | |
  109. |HID_req | | | |
  110. |get_report | | | |
  111. |------------->| | | |
  112. | | HID_get_input| | |
  113. | | report | | |
  114. | |------------->|------------------------| | |
  115. | | | Read the DRAM data for| | |
  116. | | | requested sensor and | | |
  117. | | | create the HID input | | |
  118. | | | report | | |
  119. | | |------------------------| | |
  120. | |Data received | | |
  121. | | in HID report| | |
  122. To |<-------------|<-------------| | |
  123. Applications| | | | |
  124. <-------| | | | |