Skip to content

Commit 485daef

Browse files
committed
HID: apple: Bind Apple silicon SPI devices
Apple MacBook keyboards started using HID over SPI in 2015. With the addition of the SPI HID transport they can be supported by this driver. Support all product ids over with the Apple SPI vendor id for now. The Macbook Pro (M1, 13-inch, 2020) uses the same function key mapping as other Macbook Pros with touchbar and dedicated ESC key. Apple silicon Macbooks use the same function key mapping as the 2021 and later Magic Keyboards. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 628cea6 commit 485daef

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

drivers/hid/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ config HID_APPLE
129129
tristate "Apple {i,Power,Mac}Books"
130130
depends on LEDS_CLASS
131131
depends on NEW_LEDS
132-
default !EXPERT
132+
default !EXPERT || SPI_HID_APPLE
133133
help
134134
Support for some Apple devices which less or more break
135135
HID specification.

drivers/hid/hid-apple.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
498498
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
499499
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
500500
table = macbookair_fn_keys;
501+
else if (hid->bus == BUS_SPI)
502+
switch (hid->product) {
503+
case SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020:
504+
table = macbookpro_dedicated_esc_fn_keys;
505+
break;
506+
default:
507+
table = apple2021_fn_keys;
508+
break;
509+
}
501510
else if (hid->product < 0x21d || hid->product >= 0x300)
502511
table = powerbook_fn_keys;
503512
else
@@ -910,6 +919,10 @@ static int apple_probe(struct hid_device *hdev,
910919
struct apple_sc *asc;
911920
int ret;
912921

922+
if (id->bus == BUS_SPI && id->vendor == SPI_VENDOR_ID_APPLE &&
923+
hdev->type != HID_TYPE_SPI_KEYBOARD)
924+
return -ENODEV;
925+
913926
asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
914927
if (asc == NULL) {
915928
hid_err(hdev, "can't alloc apple descriptor\n");
@@ -1169,6 +1182,8 @@ static const struct hid_device_id apple_devices[] = {
11691182
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
11701183
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
11711184
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
1185+
{ HID_SPI_DEVICE(SPI_VENDOR_ID_APPLE, HID_ANY_ID),
1186+
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
11721187
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT),
11731188
.driver_data = APPLE_MAGIC_BACKLIGHT },
11741189

0 commit comments

Comments
 (0)