Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 
0004 AMD Sensor Fusion Hub
0005 =====================
0006 AMD Sensor Fusion Hub (SFH) is part of an SOC starting from Ryzen-based platforms.
0007 The solution is working well on several OEM products. AMD SFH uses HID over PCIe bus.
0008 In terms of architecture it resembles ISH, however the major difference is all
0009 the HID reports are generated as part of the kernel driver.
0010 
0011 Block Diagram
0012 -------------
0013 
0014 ::
0015 
0016         ---------------------------------
0017         |  HID User Space Applications  |
0018         - -------------------------------
0019 
0020     ---------------------------------------------
0021          ---------------------------------
0022         |               HID Core          |
0023          ---------------------------------
0024 
0025          ---------------------------------
0026         |     AMD HID Transport           |
0027          ---------------------------------
0028 
0029          --------------------------------
0030         |             AMD HID Client     |
0031         |       with HID Report Generator|
0032          --------------------------------
0033 
0034          --------------------------------
0035         |     AMD MP2 PCIe Driver        |
0036          --------------------------------
0037     OS
0038     ---------------------------------------------
0039     Hardware + Firmware
0040          --------------------------------
0041          |     SFH MP2 Processor         |
0042          --------------------------------
0043 
0044 
0045 AMD HID Transport Layer
0046 -----------------------
0047 AMD SFH transport is also implemented as a bus. Each client application executing in the AMD MP2 is
0048 registered as a device on this bus. Here, MP2 is an ARM core connected to x86 for processing
0049 sensor data. The layer, which binds each device (AMD SFH HID driver) identifies the device type and
0050 registers with the HID core. Transport layer attaches a constant "struct hid_ll_driver" object with
0051 each device. Once a device is registered with HID core, the callbacks provided via this struct are
0052 used by HID core to communicate with the device. AMD HID Transport layer implements the synchronous calls.
0053 
0054 AMD HID Client Layer
0055 --------------------
0056 This layer is responsible to implement HID requests and descriptors. As firmware is OS agnostic, HID
0057 client layer fills the HID request structure and descriptors. HID client layer is complex as it is
0058 interface between MP2 PCIe layer and HID. HID client layer initializes the MP2 PCIe layer and holds
0059 the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Based
0060 on that allocates the DRAM address for each and every sensor and passes it to MP2-PCIe driver. On
0061 enumeration of each sensor, client layer fills the HID Descriptor structure and HID input report
0062 structure. HID Feature report structure is optional. The report descriptor structure varies from
0063 sensor to sensor.
0064 
0065 AMD MP2 PCIe layer
0066 ------------------
0067 MP2 PCIe Layer is responsible for making all transactions with the firmware over PCIe.
0068 The connection establishment between firmware and PCIe happens here.
0069 
0070 The communication between X86 and MP2 is split into three parts.
0071 1. Command transfer via the C2P mailbox registers.
0072 2. Data transfer via DRAM.
0073 3. Supported sensor info via P2C registers.
0074 
0075 Commands are sent to MP2 using C2P Mailbox registers. Writing into C2P Message registers generates
0076 interrupt to MP2. The client layer allocates the physical memory and the same is sent to MP2 via
0077 the PCI layer. MP2 firmware writes the command output to the access DRAM memory which the client
0078 layer has allocated. Firmware always writes minimum of 32 bytes into DRAM. So as a protocol driver
0079 shall allocate minimum of 32 bytes DRAM space.
0080 
0081 Enumeration and Probing flow
0082 ----------------------------
0083 ::
0084 
0085        HID             AMD            AMD                       AMD -PCIe             MP2
0086        Core         Transport      Client layer                   layer                FW
0087         |               |              |                           |                 |
0088         |               |              |                 on Boot Driver Loaded       |
0089         |               |              |                           |                 |
0090         |               |              |                        MP2-PCIe Int         |
0091         |               |              |                           |                 |
0092         |               |              |---Get Number of sensors-> |                 |
0093         |               |              |                       Read P2C              |
0094         |               |              |                        Register             |
0095         |               |              |                           |                 |
0096         |               |              | Loop(for No of Sensors)   |                 |
0097         |               |              |----------------------|    |                 |
0098         |               |              | Create HID Descriptor|    |                 |
0099         |               |              | Create Input  report |    |                 |
0100         |               |              |  Descriptor Map      |    |                 |
0101         |               |              |  the MP2 FW Index to |    |                 |
0102         |               |              |   HID Index          |    |                 |
0103         |               |              | Allocate the DRAM    |  Enable              |
0104         |               |              |        address       |  Sensors             |
0105         |               |              |----------------------|    |                 |
0106         |               | HID transport|                           |    Enable       |
0107         |               |<--Probe------|                           |---Sensor CMD--> |
0108         |               | Create the   |                           |                 |
0109         |               | HID device   |                           |                 |
0110         |               |    (MFD)     |                           |                 |
0111         |               | by Populating|                           |                 |
0112         |               |  the HID     |                           |                 |
0113         |               |  ll_driver   |                           |                 |
0114         | HID           |              |                           |                 |
0115         |  add          |              |                           |                 |
0116         |Device         |              |                           |                 |
0117         |<------------- |              |                           |                 |
0118 
0119 
0120 Data Flow from Application to the AMD SFH Driver
0121 ------------------------------------------------
0122 
0123 ::
0124 
0125                 |              |              |                           |                 |
0126                 |              |              |                           |                 |
0127                 |              |              |                           |                 |
0128                 |              |              |                           |                 |
0129                 |              |              |                           |                 |
0130                 |HID_req       |              |                           |                 |
0131                 |get_report    |              |                           |                 |
0132                 |------------->|              |                           |                 |
0133                 |              | HID_get_input|                           |                 |
0134                 |              |  report      |                           |                 |
0135                 |              |------------->|------------------------|  |                 |
0136                 |              |              |  Read the DRAM data for|  |                 |
0137                 |              |              |  requested sensor and  |  |                 |
0138                 |              |              |  create the HID input  |  |                 |
0139                 |              |              |  report                |  |                 |
0140                 |              |              |------------------------|  |                 |
0141                 |              |Data received |                           |                 |
0142                 |              | in HID report|                           |                 |
0143     To          |<-------------|<-------------|                           |                 |
0144     Applications|              |              |                           |                 |
0145         <-------|              |              |                           |                 |