-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'for-5.11/amd-sfh-hid' into for-linus
From Sandeep Singh. AMD SFH (Sensor Fusion Hub) is HID based driver.SFH FW is part of MP2 processor (MP2 which is an ARM core connected to x86 for processing sensor data) and it runs on MP2 where in the driver resides on X86. The driver functionalities are divided into three parts: 1: amd-mp2-pcie:- This part of the module will communicate with MP2 firmware. MP2 which is exposed as a PCI device to the X86, uses mailboxes to talk to MP2 firmware to send/receive commands. 2: Client Layer:- This part of the driver will use DRAM data and convert the data into HID format based on HID reports. 3: Transport layer :- This part of the driver the will communicate with HID core.Communication between devices and HID core is mostly done via HID reports In terms of architecture, it resembles like ISH (Intel Integrated Sensor Hub). However the major difference is all the hid reports are generated as part of the kernel driver. AMD SFH is integrated as a part of SoC, starting from 17h family of processors. The solution is working well on several OEM products. AMD SFH uses HID over PCIe bus.
- Loading branch information
Showing
15 changed files
with
1,883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
.. SPDX-License-Identifier: GPL-2.0 | ||
AMD Sensor Fusion Hub | ||
===================== | ||
AMD Sensor Fusion Hub (SFH) is part of an SOC starting from Ryzen based platforms. | ||
The solution is working well on several OEM products. AMD SFH uses HID over PCIe bus. | ||
In terms of architecture it resembles ISH, however the major difference is all | ||
the HID reports are generated as part of the kernel driver. | ||
|
||
1. Block Diagram | ||
================ | ||
|
||
:: | ||
|
||
--------------------------------- | ||
| HID User Space Applications | | ||
- ------------------------------- | ||
|
||
--------------------------------------------- | ||
--------------------------------- | ||
| HID Core | | ||
--------------------------------- | ||
|
||
--------------------------------- | ||
| AMD HID Transport | | ||
--------------------------------- | ||
|
||
-------------------------------- | ||
| AMD HID Client | | ||
| with HID Report Generator| | ||
-------------------------------- | ||
|
||
-------------------------------- | ||
| AMD MP2 PCIe Driver | | ||
-------------------------------- | ||
OS | ||
--------------------------------------------- | ||
Hardware + Firmware | ||
-------------------------------- | ||
| SFH MP2 Processor | | ||
-------------------------------- | ||
|
||
|
||
AMD HID Transport Layer | ||
----------------------- | ||
AMD SFH transport is also implemented as a bus. Each client application executing in the AMD MP2 is | ||
registered as a device on this bus. Here: MP2 which is an ARM core connected to x86 for processing | ||
sensor data. The layer, which binds each device (AMD SFH HID driver) identifies the device type and | ||
registers with the hid core. Transport layer attach a constant "struct hid_ll_driver" object with | ||
each device. Once a device is registered with HID core, the callbacks provided via this struct are | ||
used by HID core to communicate with the device. AMD HID Transport layer implements the synchronous calls. | ||
|
||
AMD HID Client Layer | ||
-------------------- | ||
This layer is responsible to implement HID request and descriptors. As firmware is OS agnostic, HID | ||
client layer fills the HID request structure and descriptors. HID client layer is complex as it is | ||
interface between MP2 PCIe layer and HID. HID client layer initialized the MP2 PCIe layer and holds | ||
the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Base | ||
on that allocates the DRAM address for each and every sensor and pass it to MP2-PCIe driver.On | ||
enumeration of each the sensor, client layer fills the HID Descriptor structure and HID input repor | ||
structure. HID Feature report structure is optional. The report descriptor structure varies from | ||
sensor to sensor. | ||
|
||
AMD MP2 PCIe layer | ||
------------------ | ||
MP2 PCIe Layer is responsible for making all transactions with the firmware over PCIe. | ||
The connection establishment between firmware and PCIe happens here. | ||
|
||
The communication between X86 and MP2 is split into three parts. | ||
1. Command transfer via the C2P mailbox registers. | ||
2. Data transfer via DRAM. | ||
3. Supported sensor info via P2C registers. | ||
|
||
Commands are sent to MP2 using C2P Mailbox registers. Writing into C2P Message registers generate | ||
interrupt to MP2. The client layer allocates the physical memory and the same is sent to MP2 via | ||
the PCI layer. MP2 firmware writes the command output to the access DRAM memory which the client | ||
layer has allocated. Firmware always writes minimum of 32 bytes into DRAM. So as a protocol driver | ||
shall allocate minimum of 32 bytes DRAM space. | ||
|
||
Enumeration and Probing flow | ||
---------------------------- | ||
:: | ||
|
||
HID AMD AMD AMD -PCIe MP2 | ||
Core Transport Client layer layer FW | ||
| | | | | | ||
| | | on Boot Driver Loaded | | ||
| | | | | | ||
| | | MP2-PCIe Int | | ||
| | | | | | ||
| | |---Get Number of sensors-> | | | ||
| | | Read P2C | | ||
| | | Register | | ||
| | | | | | ||
| | | Loop(for No of Sensors) | | | ||
| | |----------------------| | | | ||
| | | Create HID Descriptor| | | | ||
| | | Create Input report | | | | ||
| | | Descriptor Map | | | | ||
| | | the MP2 FW Index to | | | | ||
| | | HID Index | | | | ||
| | | Allocate the DRAM | Enable | | ||
| | | address | Sensors | | ||
| | |----------------------| | | | ||
| | HID transport| | Enable | | ||
| |<--Probe------| |---Sensor CMD--> | | ||
| | Create the | | | | ||
| | HID device | | | | ||
| | (MFD) | | | | ||
| | by Populating| | | | ||
| | the HID | | | | ||
| | ll_driver | | | | ||
| HID | | | | | ||
| add | | | | | ||
|Device | | | | | ||
|<------------- | | | | | ||
|
||
|
||
Data Flow from Application to the AMD SFH Driver | ||
------------------------------------------------ | ||
|
||
:: | ||
|
||
| | | | | | ||
| | | | | | ||
| | | | | | ||
| | | | | | ||
| | | | | | ||
|HID_req | | | | | ||
|get_report | | | | | ||
|------------->| | | | | ||
| | HID_get_input| | | | ||
| | report | | | | ||
| |------------->|------------------------| | | | ||
| | | Read the DRAM data for| | | | ||
| | | requested sensor and | | | | ||
| | | create the HID input | | | | ||
| | | report | | | | ||
| | |------------------------| | | | ||
| |Data received | | | | ||
| | in HID report| | | | ||
To |<-------------|<-------------| | | | ||
Applications| | | | | | ||
<-------| | | | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ Human Interface Devices (HID) | |
|
||
hid-alps | ||
intel-ish-hid | ||
amd-sfh-hid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
menu "AMD SFH HID Support" | ||
depends on X86_64 || COMPILE_TEST | ||
depends on PCI | ||
depends on HID | ||
|
||
config AMD_SFH_HID | ||
tristate "AMD Sensor Fusion Hub" | ||
help | ||
If you say yes to this option, support will be included for the | ||
AMD Sensor Fusion Hub. | ||
This driver will enable sensors functionality on AMD platforms | ||
starting from 17h family of RYZEN parts. | ||
|
||
This driver can also be built as a module. If so, the module will | ||
be called amd-sfh. | ||
Say Y or M here if you want to support AMD SFH. If unsure, say N. | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# | ||
# Makefile - AMD SFH HID drivers | ||
# Copyright (c) 2019-2020, Advanced Micro Devices, Inc. | ||
# | ||
# | ||
obj-$(CONFIG_AMD_SFH_HID) += amd_sfh.o | ||
amd_sfh-objs := amd_sfh_hid.o | ||
amd_sfh-objs += amd_sfh_client.o | ||
amd_sfh-objs += amd_sfh_pcie.o | ||
amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o | ||
|
||
ccflags-y += -I $(srctree)/$(src)/ |
Oops, something went wrong.