Skip to content

Commit de925e2

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: - AMD SFH (Sensor Fusion Hub) support (Sandeep Singh) - increase of maximum HID report size to 16KB in order to support some of the modern devices (Dean Camera) - control interface support for hidraw (Dean Camera) - Sony DS4 power and firmware reporting fixes (Roderick Colenbrander) - support for ghlive PS3/WII U dongles (Pascal Giard) * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (27 commits) HID: i2c-hid: add Vero K147 to descriptor override HID: ite: Add support for Acer S1002 keyboard-dock HID: sony: support for ghlive ps3/wii u dongles HID: hidraw: Add additional hidraw input/output report ioctls. HID: Increase HID maximum report size to 16KB HID: elecom: drop stray comment HID: mf: add support for 0079:1846 Mayflash/Dragonrise USB Gamecube Adapter HID: elecom: add support for EX-G M-XGL20DLBK wireless mouse HID: elecom: rewrite report based on model specific parameters HID: wacom: Constify attribute_groups HID: input: Fix fall-through warnings for Clang HID: usbhid: Fix fall-through warnings for Clang HID: logitech-hidpp: Add hid_device_id for V470 bluetooth mouse HID: intel-ish-hid: Remove unnecessary assignment to variable rv HID: sony: Workaround for DS4 dongle hotplug kernel crash. HID: sony: Don't use fw_version/hw_version for sysfs cleanup. HID: sony: Report more accurate DS4 power status. SFH: fix error return check for -ERESTARTSYS HID: SFH: Add documentation HID: hid-input: occasionally report stylus battery even if not changed ...
2 parents 62746f9 + 85a6947 commit de925e2

34 files changed

+2360
-95
lines changed

Documentation/hid/amd-sfh-hid.rst

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
4+
AMD Sensor Fusion Hub
5+
=====================
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.
10+
11+
1. Block Diagram
12+
================
13+
14+
::
15+
16+
---------------------------------
17+
| HID User Space Applications |
18+
- -------------------------------
19+
20+
---------------------------------------------
21+
---------------------------------
22+
| HID Core |
23+
---------------------------------
24+
25+
---------------------------------
26+
| AMD HID Transport |
27+
---------------------------------
28+
29+
--------------------------------
30+
| AMD HID Client |
31+
| with HID Report Generator|
32+
--------------------------------
33+
34+
--------------------------------
35+
| AMD MP2 PCIe Driver |
36+
--------------------------------
37+
OS
38+
---------------------------------------------
39+
Hardware + Firmware
40+
--------------------------------
41+
| SFH MP2 Processor |
42+
--------------------------------
43+
44+
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 which 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 attach 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.
53+
54+
AMD HID Client Layer
55+
--------------------
56+
This layer is responsible to implement HID request 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 initialized the MP2 PCIe layer and holds
59+
the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Base
60+
on that allocates the DRAM address for each and every sensor and pass it to MP2-PCIe driver.On
61+
enumeration of each the sensor, client layer fills the HID Descriptor structure and HID input repor
62+
structure. HID Feature report structure is optional. The report descriptor structure varies from
63+
sensor to sensor.
64+
65+
AMD MP2 PCIe layer
66+
------------------
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.
69+
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.
74+
75+
Commands are sent to MP2 using C2P Mailbox registers. Writing into C2P Message registers generate
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.
80+
81+
Enumeration and Probing flow
82+
----------------------------
83+
::
84+
85+
HID AMD AMD AMD -PCIe MP2
86+
Core Transport Client layer layer FW
87+
| | | | |
88+
| | | on Boot Driver Loaded |
89+
| | | | |
90+
| | | MP2-PCIe Int |
91+
| | | | |
92+
| | |---Get Number of sensors-> | |
93+
| | | Read P2C |
94+
| | | Register |
95+
| | | | |
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--> |
108+
| | Create the | | |
109+
| | HID device | | |
110+
| | (MFD) | | |
111+
| | by Populating| | |
112+
| | the HID | | |
113+
| | ll_driver | | |
114+
| HID | | | |
115+
| add | | | |
116+
|Device | | | |
117+
|<------------- | | | |
118+
119+
120+
Data Flow from Application to the AMD SFH Driver
121+
------------------------------------------------
122+
123+
::
124+
125+
| | | | |
126+
| | | | |
127+
| | | | |
128+
| | | | |
129+
| | | | |
130+
|HID_req | | | |
131+
|get_report | | | |
132+
|------------->| | | |
133+
| | HID_get_input| | |
134+
| | report | | |
135+
| |------------->|------------------------| | |
136+
| | | Read the DRAM data for| | |
137+
| | | requested sensor and | | |
138+
| | | create the HID input | | |
139+
| | | report | | |
140+
| | |------------------------| | |
141+
| |Data received | | |
142+
| | in HID report| | |
143+
To |<-------------|<-------------| | |
144+
Applications| | | | |
145+
<-------| | | | |

Documentation/hid/hidraw.rst

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,49 @@ HIDIOCGFEATURE(len):
123123
This ioctl will request a feature report from the device using the control
124124
endpoint. The first byte of the supplied buffer should be set to the report
125125
number of the requested report. For devices which do not use numbered
126-
reports, set the first byte to 0. The report will be returned starting at
127-
the first byte of the buffer (ie: the report number is not returned).
126+
reports, set the first byte to 0. The returned report buffer will contain the
127+
report number in the first byte, followed by the report data read from the
128+
device. For devices which do not use numbered reports, the report data will
129+
begin at the first byte of the returned buffer.
130+
131+
HIDIOCSINPUT(len):
132+
Send an Input Report
133+
134+
This ioctl will send an input report to the device, using the control endpoint.
135+
In most cases, setting an input HID report on a device is meaningless and has
136+
no effect, but some devices may choose to use this to set or reset an initial
137+
state of a report. The format of the buffer issued with this report is identical
138+
to that of HIDIOCSFEATURE.
139+
140+
HIDIOCGINPUT(len):
141+
Get an Input Report
142+
143+
This ioctl will request an input report from the device using the control
144+
endpoint. This is slower on most devices where a dedicated In endpoint exists
145+
for regular input reports, but allows the host to request the value of a
146+
specific report number. Typically, this is used to request the initial states of
147+
an input report of a device, before an application listens for normal reports via
148+
the regular device read() interface. The format of the buffer issued with this report
149+
is identical to that of HIDIOCGFEATURE.
150+
151+
HIDIOCSOUTPUT(len):
152+
Send an Output Report
153+
154+
This ioctl will send an output report to the device, using the control endpoint.
155+
This is slower on most devices where a dedicated Out endpoint exists for regular
156+
output reports, but is added for completeness. Typically, this is used to set
157+
the initial states of an output report of a device, before an application sends
158+
updates via the regular device write() interface. The format of the buffer issued
159+
with this report is identical to that of HIDIOCSFEATURE.
160+
161+
HIDIOCGOUTPUT(len):
162+
Get an Output Report
163+
164+
This ioctl will request an output report from the device using the control
165+
endpoint. Typically, this is used to retrive the initial state of
166+
an output report of a device, before an application updates it as necessary either
167+
via a HIDIOCSOUTPUT request, or the regular device write() interface. The format
168+
of the buffer issued with this report is identical to that of HIDIOCGFEATURE.
128169

129170
Example
130171
-------

Documentation/hid/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ Human Interface Devices (HID)
1616

1717
hid-alps
1818
intel-ish-hid
19+
amd-sfh-hid

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,14 @@ S: Supported
956956
F: arch/arm64/boot/dts/amd/amd-seattle-xgbe*.dtsi
957957
F: drivers/net/ethernet/amd/xgbe/
958958

959+
AMD SENSOR FUSION HUB DRIVER
960+
M: Nehal Shah <[email protected]>
961+
M: Sandeep Singh <[email protected]>
962+
963+
S: Maintained
964+
F: Documentation/hid/amd-sfh*
965+
F: drivers/hid/amd-sfh-hid/
966+
959967
AMS AS73211 DRIVER
960968
M: Christian Eggers <[email protected]>
961969

drivers/hid/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ config HID_SONY
907907
* Buzz controllers
908908
* Sony PS3 Blue-ray Disk Remote Control (Bluetooth)
909909
* Logitech Harmony adapter for Sony Playstation 3 (Bluetooth)
910+
* Guitar Hero Live PS3 and Wii U guitar dongles
910911

911912
config SONY_FF
912913
bool "Sony PS2/3/4 accessories force feedback support"
@@ -1183,4 +1184,6 @@ source "drivers/hid/i2c-hid/Kconfig"
11831184

11841185
source "drivers/hid/intel-ish-hid/Kconfig"
11851186

1187+
source "drivers/hid/amd-sfh-hid/Kconfig"
1188+
11861189
endmenu

drivers/hid/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,5 @@ obj-$(CONFIG_I2C_HID) += i2c-hid/
142142

143143
obj-$(CONFIG_INTEL_ISH_HID) += intel-ish-hid/
144144
obj-$(INTEL_ISH_FIRMWARE_DOWNLOADER) += intel-ish-hid/
145+
146+
obj-$(CONFIG_AMD_SFH_HID) += amd-sfh-hid/

drivers/hid/amd-sfh-hid/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
menu "AMD SFH HID Support"
3+
depends on X86_64 || COMPILE_TEST
4+
depends on PCI
5+
depends on HID
6+
7+
config AMD_SFH_HID
8+
tristate "AMD Sensor Fusion Hub"
9+
help
10+
If you say yes to this option, support will be included for the
11+
AMD Sensor Fusion Hub.
12+
This driver will enable sensors functionality on AMD platforms
13+
starting from 17h family of RYZEN parts.
14+
15+
This driver can also be built as a module. If so, the module will
16+
be called amd-sfh.
17+
Say Y or M here if you want to support AMD SFH. If unsure, say N.
18+
endmenu

drivers/hid/amd-sfh-hid/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# Makefile - AMD SFH HID drivers
4+
# Copyright (c) 2019-2020, Advanced Micro Devices, Inc.
5+
#
6+
#
7+
obj-$(CONFIG_AMD_SFH_HID) += amd_sfh.o
8+
amd_sfh-objs := amd_sfh_hid.o
9+
amd_sfh-objs += amd_sfh_client.o
10+
amd_sfh-objs += amd_sfh_pcie.o
11+
amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o
12+
13+
ccflags-y += -I $(srctree)/$(src)/

0 commit comments

Comments
 (0)