Skip to contentSkip to conversation

usb: kbd: Add 2024 Apple Magic Keyboard device IDs

PATCH In review Ryoya Tsujita 2 participants 2 messages Oct 10 – Oct 14

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: kbd: Add 2024 Apple Magic Keyboard device IDs

The 2024 USB-C Magic Keyboards (05ac:0320, 05ac:0321 and 05ac:0322) have a Device Management HID interface as interface 0 and the Boot Keyboard as interface 1. U-Boot only looks at interface 0 when matching a driver, so these keyboards are bound to the generic USB device driver and do not work as a console input device.

Match them by vendor and product ID so that usb_kbd binds to them. probe_usb_keyboard() already looks through all interfaces and uses the Boot Keyboard on interface 1.

Tested with a 05ac:0320 keyboard (US layout, no Touch ID) on qemu_arm64 with USB passthrough. Without this patch the device is bound to the generic driver and no usbkbd console device is registered; with it, usb_kbd is bound and keyboard input works.

05ac:0321 and 05ac:0322 are untested. The IDs are taken from Linux's drivers/hid/hid-ids.h.

---
 common/usb_kbd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
common/usb_kbd.c +15 -0
index 36107a3b278..25d8a0dff64 100644
@@ -30,6 +30,9 @@
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021			0x029c
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021	0x029a
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021		0x029f
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024			0x0320
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024	0x0321
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024		0x0322
 
 #define USB_VENDOR_ID_KEYCHRON	0x3434
 
@@ -724,6 +727,18 @@ static const struct usb_device_id kbd_id_table[] = {
 		USB_DEVICE(USB_VENDOR_ID_APPLE,
 			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
 	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024),
+	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024),
+	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024),
+	},
 	{ }		/* Terminating entry */
 };
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Ryoya Tsujita

The 2024 USB-C Magic Keyboards (05ac:0320, 05ac:0321 and 05ac:0322) have a Device Management HID interface as interface 0 and the Boot Keyboard as interface 1. U-Boot only looks at interface 0 when matching a driver, so these keyboards are bound to the generic USB device driver and do not work as a console input device.

Match them by vendor and product ID so that usb_kbd binds to them. probe_usb_keyboard() already looks through all interfaces and uses the Boot Keyboard on interface 1.

Tested with a 05ac:0320 keyboard (US layout, no Touch ID) on qemu_arm64 with USB passthrough. Without this patch the device is bound to the generic driver and no usbkbd console device is registered; with it, usb_kbd is bound and keyboard input works.

Quoted 4 lines

05ac:0321 and 05ac:0322 are untested. The IDs are taken from Linux's drivers/hid/hid-ids.h.

Quoted 37 lines
---
  common/usb_kbd.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
common/usb_kbd.c +15 -0
index 36107a3b278..25d8a0dff64 100644
@@ -30,6 +30,9 @@
  #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021			0x029c
  #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021	0x029a
  #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021		0x029f
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024			0x0320
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024	0x0321
+#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024		0x0322
 
  #define USB_VENDOR_ID_KEYCHRON	0x3434
 
@@ -724,6 +727,18 @@ static const struct usb_device_id kbd_id_table[] = {
  		USB_DEVICE(USB_VENDOR_ID_APPLE,
  			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
  	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024),
+	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2024),
+	},
+	{
+		USB_DEVICE(USB_VENDOR_ID_APPLE,
+			   USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2024),
+	},
  	{ }		/* Terminating entry */
  };