요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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.
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 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 attaches 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 requests 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 initializes the MP2 PCIe layer and holds
the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Based
on that allocates the DRAM address for each and every sensor and passes it to MP2-PCIe driver. On
enumeration of each sensor, client layer fills the HID Descriptor structure and HID input report
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 generates
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| | | | |
<-------| | | | |
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
AMD Sensor Fusion Hub architecture
1-44AMD Sensor Fusion Hub(SFH)는 Ryzen 기반 platform부터 SoC의 일부로 제공되며 여러 OEM 제품에서 사용됩니다. AMD SFH는 PCIe bus 위에서 HID를 사용합니다.
Architecture는 Intel Sensor Hub(ISH)와 비슷하지만 모든 HID report가 kernel driver에서 생성된다는 점이 가장 큰 차이입니다.
원문의 block diagram은 OS와 hardware/firmware 경계를 기준으로 HID userspace application, HID core, AMD HID transport, HID report generator를 포함한 AMD HID client, AMD MP2 PCIe driver, SFH MP2 processor를 위에서 아래로 연결합니다.
원문의 ASCII block diagram을 계층별로 재구성했습니다.
Sensor data가 MP2에서 HID application으로 올라오는 계층입니다.
.. 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.
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와 client layer
45-64AMD SFH transport도 bus로 구현됩니다. AMD MP2에서 실행되는 각 client application은 이 bus의 device로 등록됩니다. MP2는 sensor data를 처리하기 위해 x86에 연결된 ARM core입니다.
각 device에 bind하는 AMD SFH HID driver는 device type을 식별하고 HID core에 등록합니다. Transport layer는 각 device에 고정된 `struct hid_ll_driver` object를 연결합니다. HID core 등록 이후에는 이 구조체의 callback으로 device와 통신하며 AMD HID transport는 synchronous call을 구현합니다.
AMD HID client layer는 HID request와 descriptor를 구현합니다. Firmware가 OS-agnostic이므로 client layer가 HID request structure와 descriptor를 채웁니다.
Client layer는 MP2 PCIe와 HID 사이의 interface이므로 복잡합니다. MP2 PCIe layer를 초기화하고 instance를 보유하며, MP2-PCIe를 통해 연결된 sensor 수를 확인합니다. 각 sensor에 DRAM address를 할당하고 MP2-PCIe driver에 전달합니다.
Sensor를 enumerate할 때 client layer가 HID Descriptor와 HID input report structure를 채웁니다. HID Feature report는 선택 사항이며 report descriptor는 sensor마다 다릅니다.
HID bus와 report 생성의 역할을 구분합니다.
MP2 sensor를 HID core device로 노출합니다.
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 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 attaches 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 requests 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 initializes the MP2 PCIe layer and holds
the instance of MP2 layer. It identifies the number of sensors connected using MP2-PCIe layer. Based
on that allocates the DRAM address for each and every sensor and passes it to MP2-PCIe driver. On
enumeration of each sensor, client layer fills the HID Descriptor structure and HID input report
structure. HID Feature report structure is optional. The report descriptor structure varies from
sensor to sensor.
MP2 PCIe 통신과 sensor enumeration
65-119AMD MP2 PCIe layer는 PCIe를 통한 firmware transaction 전체와 firmware-PCIe connection establishment를 담당합니다.
x86과 MP2 통신은 세 부분입니다. Command는 C2P mailbox register로 보내고, data는 DRAM으로 전달하며, 지원 sensor 정보는 P2C register에서 읽습니다.
C2P message register에 쓰면 MP2 interrupt가 발생합니다. Client layer가 physical memory를 할당해 PCIe layer를 통해 MP2에 전달하고, MP2 firmware는 command output을 이 DRAM에 기록합니다. Firmware는 항상 최소 32byte를 쓰므로 protocol driver도 최소 32byte DRAM 공간을 할당해야 합니다.
부팅 후 MP2-PCIe driver가 load되고 interrupt가 준비되면 client layer가 sensor 수를 요청합니다. PCIe layer는 P2C register를 읽어 응답합니다.
Client layer는 sensor 수만큼 반복하면서 HID descriptor와 input report를 만들고 MP2 firmware index를 HID index에 mapping합니다. Sensor별 DRAM address를 할당한 뒤 enable 요청을 PCIe layer에 전달하고, PCIe layer는 firmware에 `Enable Sensor` command를 보냅니다.
그다음 HID transport가 probe되어 `hid_ll_driver`를 채운 MFD HID device를 생성하고 HID core에 `HID add Device`를 수행합니다.
원문의 통신 세 경로입니다.
원문의 sequence diagram을 단계별로 재구성했습니다.
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 generates
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 | | | |
|<------------- | | | |
Application에서 AMD SFH driver로의 data flow
120-145Application이 HID core에 `HID_req get_report`를 요청하면 HID core는 AMD HID transport에 전달합니다.
Transport는 client layer에 `HID_get_input report`를 요청합니다. Client layer는 요청된 sensor의 DRAM data를 읽어 HID input report를 생성합니다.
생성한 HID report가 transport와 HID core를 거쳐 application으로 반환됩니다.
원문의 sequence diagram participant와 역할입니다.
Application 요청이 sensor report로 돌아오는 흐름입니다.
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| | | | |
<-------| | | | |
요약·해설
amd-sfh-hid.rst:1-145AMD SFH의 HID transport·client·MP2 PCIe 계층과 report data flow를 설명합니다.
Source와 관련 구현·규격입니다.