1 .. SPDX-License-Identifier: GPL-2.0
6 AMD Sensor Fusion Hub (SFH) is part of an SOC starting from Ryzen-based platforms.
7 The solution is working well on several OEM products. AMD SFH uses HID over PCIe bus.
8 In terms of architecture it resembles ISH, however the major difference is all
9 the HID reports are generated as part of the kernel driver.
16 ---------------------------------
17 | HID User Space Applications |
18 - -------------------------------
20 ---------------------------------------------
21 ---------------------------------
23 ---------------------------------
25 ---------------------------------
27 ---------------------------------
29 --------------------------------
31 | with HID Report Generator|
32 --------------------------------
34 --------------------------------
35 | AMD MP2 PCIe Driver |
36 --------------------------------
38 ---------------------------------------------
40 --------------------------------
42 --------------------------------
45 AMD HID Transport Layer
46 -----------------------
47 AMD SFH transport is also implemented as a bus. Each client application executing in the AMD MP2 is
48 registered as a device on this bus. Here, MP2 is an ARM core connected to x86 for processing
49 sensor data. The layer, which binds each device (AMD SFH HID driver) identifies the device type and
50 registers with the HID core. Transport layer attaches a constant "struct hid_ll_driver" object with
51 each device. Once a device is registered with HID core, the callbacks provided via this struct are
52 used by HID core to communicate with the device. AMD HID Transport layer implements the synchronous calls.
56 This layer is responsible to implement HID requests and descriptors. As firmware is OS agnostic, HID
57 client layer fills the HID request structure and descriptors. HID client layer is complex as it is
58 interface between MP2 PCIe layer and HID. HID client layer initializes the MP2 PCIe layer and holds
59 the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Based
60 on that allocates the DRAM address for each and every sensor and passes it to MP2-PCIe driver. On
61 enumeration of each sensor, client layer fills the HID Descriptor structure and HID input report
62 structure. HID Feature report structure is optional. The report descriptor structure varies from
67 MP2 PCIe Layer is responsible for making all transactions with the firmware over PCIe.
68 The connection establishment between firmware and PCIe happens here.
70 The communication between X86 and MP2 is split into three parts.
71 1. Command transfer via the C2P mailbox registers.
72 2. Data transfer via DRAM.
73 3. Supported sensor info via P2C registers.
75 Commands are sent to MP2 using C2P Mailbox registers. Writing into C2P Message registers generates
76 interrupt to MP2. The client layer allocates the physical memory and the same is sent to MP2 via
77 the PCI layer. MP2 firmware writes the command output to the access DRAM memory which the client
78 layer has allocated. Firmware always writes minimum of 32 bytes into DRAM. So as a protocol driver
79 shall allocate minimum of 32 bytes DRAM space.
81 Enumeration and Probing flow
82 ----------------------------
85 HID AMD AMD AMD -PCIe MP2
86 Core Transport Client layer layer FW
88 | | | on Boot Driver Loaded |
92 | | |---Get Number of sensors-> | |
96 | | | Loop(for No of Sensors) | |
97 | | |----------------------| | |
98 | | | Create HID Descriptor| | |
99 | | | Create Input report | | |
100 | | | Descriptor Map | | |
101 | | | the MP2 FW Index to | | |
102 | | | HID Index | | |
103 | | | Allocate the DRAM | Enable |
104 | | | address | Sensors |
105 | | |----------------------| | |
106 | | HID transport| | Enable |
107 | |<--Probe------| |---Sensor CMD--> |
111 | | by Populating| | |
117 |<------------- | | | |
120 Data Flow from Application to the AMD SFH Driver
121 ------------------------------------------------
132 |------------->| | | |
133 | | HID_get_input| | |
135 | |------------->|------------------------| | |
136 | | | Read the DRAM data for| | |
137 | | | requested sensor and | | |
138 | | | create the HID input | | |
140 | | |------------------------| | |
141 | |Data received | | |
142 | | in HID report| | |
143 To |<-------------|<-------------| | |
144 Applications| | | | |