Skip to content

Commit 0839f2c

Browse files
committed
WIP: HID: transport: spi: add Apple SPI transport
Keyboard and trackpad of Apple Sillicon SoCs (M1, M1 Pro/Max) laptops are are HID devices connected via SPI. This is the same protocol as implemented by applespi.c. It was not noticed that protocol is a transport for HID. Adding support for ACPI based Intel MacBooks will be done in a separate commit. How HID is mapped in this protocol is not yet fully understood. Microsoft has a specification for HID over SPI [1] incompatible with the transport protocol used by Apple. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/hid-over-spi Contains "HID: transport: spi: apple: Increase receive buffer size" The SPI receive buffer is passed directly to hid_input_report() if it contains a complete report. It is then passed to hid_report_raw_event() which computes the expected report size and memsets the "missing trailing data up to HID_MAX_BUFFER_SIZE (16K) or hid_ll_driver.max_buffer_size (if set) to zero. Co-developed-by: Hector Martin <marcan@marcan.st> Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 3b2fcb0 commit 0839f2c

7 files changed

Lines changed: 1420 additions & 0 deletions

File tree

drivers/hid/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,4 +1446,6 @@ endif # HID
14461446

14471447
source "drivers/hid/usbhid/Kconfig"
14481448

1449+
source "drivers/hid/spi-hid/Kconfig"
1450+
14491451
endif # HID_SUPPORT

drivers/hid/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ obj-$(CONFIG_INTEL_ISH_HID) += intel-ish-hid/
173173

174174
obj-$(CONFIG_AMD_SFH_HID) += amd-sfh-hid/
175175

176+
obj-$(CONFIG_SPI_HID_APPLE_CORE) += spi-hid/
177+
176178
obj-$(CONFIG_SURFACE_HID_CORE) += surface-hid/
177179

178180
obj-$(CONFIG_INTEL_THC_HID) += intel-thc-hid/

drivers/hid/spi-hid/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
menu "SPI HID support"
3+
depends on SPI
4+
5+
config SPI_HID_APPLE_OF
6+
tristate "HID over SPI transport layer for Apple Silicon SoCs"
7+
depends on INPUT && OF
8+
select SPI_HID_APPLE_CORE
9+
help
10+
Say Y here if you use Apple Silicon based laptop. The keyboard and
11+
touchpad are HID based devices connected via SPI.
12+
13+
If unsure, say N.
14+
15+
This support is also available as a module. If so, the module
16+
will be called spi-hid-apple-of. It will also build/depend on the
17+
module spi-hid-apple.
18+
19+
endmenu
20+
21+
config SPI_HID_APPLE_CORE
22+
tristate
23+
select HID
24+
select CRC16

drivers/hid/spi-hid/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Makefile for SPI HID tarnsport drivers
4+
#
5+
6+
obj-$(CONFIG_SPI_HID_APPLE_CORE) += spi-hid-apple.o
7+
8+
spi-hid-apple-objs = spi-hid-apple-core.o
9+
10+
obj-$(CONFIG_SPI_HID_APPLE_OF) += spi-hid-apple-of.o

0 commit comments

Comments
 (0)