From c43e4f065124255e9b460f5506966d0b482e9257 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:09:54 -0600 Subject: [PATCH 01/17] soc: apple: mailbox: receive T6050 GPU mailboxes by polling The GPU ASC interrupt never reaches the AIC on the M5 Max. Mark both T6050 ASCWrap v6 hardware structs rx_poll_only so the v8 receive poller drives them. --- drivers/soc/apple/mailbox.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/mailbox.c b/drivers/soc/apple/mailbox.c index 689d79858ab2b..d9b8ad400c635 100644 --- a/drivers/soc/apple/mailbox.c +++ b/drivers/soc/apple/mailbox.c @@ -227,6 +227,8 @@ struct apple_mbox_hw { unsigned int num_ascwrap_v6_roles; /* T8152 GPU ASCWrap v8: wrapper + iop-vbar + post-office window + PSD. */ bool is_ascwrap_v8; + /* The mailbox interrupt never reaches the AIC: receive by polling. */ + bool rx_poll_only; /* Status word counts RX occupancy and free TX slots; paired transfers. */ bool counted_fifo; bool ap_initializes_mailboxes; @@ -279,7 +281,7 @@ static struct apple_mbox_priv *apple_mbox_to_priv(struct apple_mbox *mbox) /* Only providers allocated by apple_mbox_probe() have a receive poller. */ static bool apple_mbox_has_rx_poller(const struct apple_mbox *mbox) { - return mbox->hw->is_ascwrap_v8; + return mbox->hw->is_ascwrap_v8 || mbox->hw->rx_poll_only; } /* Both ASCWrap generations share the consumer lifecycle API below. */ @@ -1526,6 +1528,10 @@ static int apple_mbox_probe(struct platform_device *pdev) return -EINVAL; if (mbox->hw->counted_fifo && !IS_ENABLED(CONFIG_ARM64)) return -EOPNOTSUPP; + if (mbox->hw->rx_poll_only) { + priv->rx_poll_only = true; + INIT_DELAYED_WORK(&priv->rx_poll_work, apple_mbox_v8_rx_poll_work); + } if (mbox->hw->is_ascwrap_v6) { /* @@ -1916,6 +1922,7 @@ static const struct apple_mbox_hw apple_mbox_t6050_ascwrap_v6_hw = { .i2a_recv0 = APPLE_ASC_MBOX_I2A_RECV0, .i2a_recv1 = APPLE_ASC_MBOX_I2A_RECV1, .has_irq_controls = false, + .rx_poll_only = true, }; static const struct apple_mbox_hw apple_mbox_t6050_j775d_ascwrap_v6_hw = { @@ -1932,6 +1939,7 @@ static const struct apple_mbox_hw apple_mbox_t6050_j775d_ascwrap_v6_hw = { .i2a_recv0 = APPLE_ASC_MBOX_I2A_RECV0, .i2a_recv1 = APPLE_ASC_MBOX_I2A_RECV1, .has_irq_controls = false, + .rx_poll_only = true, }; /* From 51c488de5dfec5b651ec64d7edb1bb90ce27e984 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:18:57 -0600 Subject: [PATCH 02/17] HID: magicmouse: do not mark the MTP trackpad as a direct device The K114c multi-touch descriptor has a Digitizer-page field under a Mouse application. hid-input reads that as a pen and sets INPUT_PROP_DIRECT, and udev then tags the trackpad as a touchscreen instead of a touchpad. The pad is an indirect pointing device: clear the property. --- drivers/hid/hid-magicmouse.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index cc079c42c5803..473d6704ecb48 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -1586,6 +1586,12 @@ static int magicmouse_setup_input_mtp(struct input_dev *input, int mt_flags = 0; struct magicmouse_sc *msc = hid_get_drvdata(hdev); + /* + * The K114c descriptor puts a Digitizer-page field under a Mouse + * application. hid-input takes that for a pen and sets DIRECT, which + * makes udev call the pad a touchscreen. This is an indirect touchpad. + */ + __clear_bit(INPUT_PROP_DIRECT, input->propbit); __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); /* * An MTP trackpad is a pointer, never a direct-touch surface. The K116s From 46932fc1114d8a9527a3219d79f4b58d2afdc8ca Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:41:39 -0600 Subject: [PATCH 03/17] HID: magicmouse: drop the GD Mouse usages on dockchannel MTP devices --- drivers/hid/hid-magicmouse.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 473d6704ecb48..c39b23a6a5eb6 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -1756,6 +1756,15 @@ static int magicmouse_input_mapping(struct hid_device *hdev, if (!msc->input) msc->input = hi->input; + /* The dockchannel MTP descriptors (K114c and later) open with a GD + * Mouse collection by design; macOS consumes both halves. Mouse + * usages must not reach the input: libinput refuses a mouse+MT + * hybrid. The keyboard interface (GD Keyboard) is unaffected, and + * kiwi never probes here (type guard in magicmouse_probe). */ + if (hdev->bus == BUS_HOST && !strncmp(hdev->name, "Apple MTP", 9) && + field->application == HID_GD_MOUSE) + return -1; + /* Magic Trackpad does not give relative data after switching to MT */ if ((hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD || hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || From 11bac22814e4657fc8fec077c03ec5c1b581281b Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:20:59 -0600 Subject: [PATCH 04/17] HID: dockchannel-hid: clamp oversized Report Size items The multi-touch interface of the 14-inch M5 Max MacBook Pro (t6050) declares its raw touch report as a single Report Size item of 0x80000 bits. hid-core rejects any Report Size above 16384 with "invalid report_size 524288", so the trackpad never registered although the firmware, the interface and the keyboard all came up. hid-magicmouse consumes these reports in raw_event() and never uses the parsed field layout. Clamp each Report Size item in the copied descriptor to the hid-core limit before parsing, and log the clamp once per item. --- drivers/hid/dockchannel-hid/dockchannel-hid.c | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 9e0877ca2d496..8135fbce5fef4 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -1049,6 +1049,51 @@ static int dchid_create_interface(struct dchid_iface *iface) return queue_work(iface->dchid->new_iface_wq, &iface->create_work); } +/* hid-core rejects any Report Size above this (see hid_parser_global()). */ +#define DCHID_MAX_REPORT_SIZE 16384 + +/* + * The T6050 multi-touch firmware declares its raw touch report as one item of + * 0x80000 bits. The magicmouse driver reads those reports in raw_event() and + * never looks at the field layout, so clamp every Report Size item to what + * hid-core accepts instead of failing the whole interface. + */ +static void dchid_clamp_report_sizes(struct dchid_iface *iface, u8 *desc, size_t len) +{ + size_t i = 0; + + while (i < len) { + u8 prefix = desc[i]; + size_t n = prefix & 3; + u32 val = 0; + size_t j; + + if (prefix == 0xfe) { + if (i + 1 >= len) + return; + i += 3 + desc[i + 1]; + continue; + } + if (n == 3) + n = 4; + if (i + 1 + n > len) + return; + + if ((prefix & 0xfc) == 0x74 && n >= 2) { + for (j = 0; j < n; j++) + val |= (u32)desc[i + 1 + j] << (8 * j); + if (val > DCHID_MAX_REPORT_SIZE) { + dev_info(iface->dchid->dev, + "%s: clamping Report Size %u to %u\n", + iface->name, val, DCHID_MAX_REPORT_SIZE); + for (j = 0; j < n; j++) + desc[i + 1 + j] = (DCHID_MAX_REPORT_SIZE >> (8 * j)) & 0xff; + } + } + i += 1 + n; + } +} + static void dchid_handle_descriptor(struct dchid_iface *iface, void *hid_desc, size_t desc_len) { if (iface->hid) { @@ -1062,6 +1107,7 @@ static void dchid_handle_descriptor(struct dchid_iface *iface, void *hid_desc, s return; iface->hid_desc_len = desc_len; + dchid_clamp_report_sizes(iface, iface->hid_desc, desc_len); } static void dchid_handle_ready(struct dockchannel_hid *dchid, void *data, size_t length) From d3551d4ca54e4e7715f51e0c055fded79e36755a Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:58:27 -0600 Subject: [PATCH 05/17] HID: magicmouse: clamp the dockchannel MTP REPORT_SIZE to the hid core maximum The K114c MTP input descriptor is a raw buffer pipe: usage TouchPad with REPORT_SIZE 0x80000 bits (64 KiB), one field, no report id; macOS reads variable-length reports against it. hid core refuses any REPORT_SIZE above 16384 bits, aborts the whole parse (the invalid report_size 524288 probe failure), and the device ends up with zero registered reports - which is why finger reports raise the dockchannel interrupt yet nothing reaches hidraw or the input device. Walk the descriptor in report_fixup and rewrite any oversized REPORT_SIZE item in place to 16384 bits, keeping the item length stable. Real reports are far shorter, and hid core accepts reports shorter than the declared size. With the parse completing, the mouse usage drop and the C1FE-family report decode take over. Checked against the real K114c ADT descriptor bytes: exactly one item is clamped, the rest of the byte stream is unchanged. --- drivers/hid/hid-magicmouse.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index c39b23a6a5eb6..6d5a0cb02dfa7 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -2936,6 +2936,46 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc, rdesc[3] = 0x02; } + /* The K114c dockchannel MTP declares its input as a raw buffer pipe: + * REPORT_SIZE 0x80000 bits (64 KiB), one field, no report id. macOS + * reads variable-length reports against it. hid core refuses any + * REPORT_SIZE above 16384 bits and aborts the whole parse, so no + * report ever registers and every finger report is dropped before + * hidraw. Clamp the item to the hid core maximum; real reports are + * far shorter and hid core accepts reports shorter than declared. */ + if (hdev->bus == BUS_HOST && !strncmp(hdev->name, "Apple MTP", 9)) { + unsigned int i = 0; + + while (i < *rsize) { + __u8 b = rdesc[i]; + unsigned int len; + static const unsigned int lens[4] = { 0, 1, 2, 4 }; + + if ((b >> 2 & 3) == 3) { /* long item */ + i += 3 + rdesc[i + 1]; + continue; + } + len = lens[b & 3]; + if ((b >> 2 & 3) == 1 && (b >> 4) == 0x7 && len) { + __u32 v = 0; + unsigned int k; + + for (k = 0; k < len; k++) + v |= (__u32)rdesc[i + 1 + k] << (8 * k); + if (v > 16384) { + rdesc[i + 1] = 0x00; + rdesc[i + 2] = 0x40; + rdesc[i + 3] = 0x00; + rdesc[i + 4] = 0x00; + hid_info(hdev, + "clamped MTP REPORT_SIZE %u bits to 16384\n", + v); + } + } + i += 1 + len; + } + } + return rdesc; } From b8604c273888148c0f3bd1d2628058d99fe854e5 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:45:33 -0600 Subject: [PATCH 06/17] HID: dockchannel-hid: own reset and power lines for a power method 2 interface; claim kiwi A power method 2 interface drove only the shared multi-touch AFE reset line. The K114c touch-screen (kiwi) interface is power method 2 as well, but its reset and supply are NUB GPIO pins (ADT function-reset and function-power), so driving the AFE line for it would reset the trackpad. Read apple,reset-gpios and apple,power-gpios from the interface node; an interface without apple,reset-gpios keeps the AFE line. The supply is driven high when the interface is created and again before the reset is released. Booted on a K114c with power method 1 (the default), kiwi receives its firmware and then fails the comm reset command with 0xe00002c2 and never reports ready. The ADT says PowerMethod 2 for it. Also add hid-apple-mtp-kiwi. The kiwi HID device matches the wildcard BUS_HOST Apple entries of hid-apple and hid-magicmouse, so hid-generic stands off from it, and both drivers reject it in probe: no driver ever bound. The new driver claims it by name and exposes the raw report pipe on hidraw. The interface starts when hidraw is first opened. --- drivers/hid/Kconfig | 10 ++++ drivers/hid/Makefile | 1 + drivers/hid/dockchannel-hid/dockchannel-hid.c | 48 +++++++++++++++--- drivers/hid/hid-apple-mtp-kiwi.c | 50 +++++++++++++++++++ 4 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 drivers/hid/hid-apple-mtp-kiwi.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6f956d056b87c..89e88fca78a88 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -146,6 +146,16 @@ config HID_APPLE Say Y here if you want support for keyboards of Apple iBooks, PowerBooks, MacBooks, MacBook Pros and Apple Aluminum. +config HID_APPLE_MTP_KIWI + tristate "Apple MTP touch-screen (kiwi) interface" + depends on HID + help + Exposes the raw touch-screen report pipe of the kiwi interface of + the Apple dockchannel MTP on hidraw. + + This driver can also be built as a module. If so, it will be called + hid-apple-mtp-kiwi. + config HID_APPLE_MTP_HAPTIC tristate "Apple MTP Haptic Actuator support" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 3efe8ee1caddb..ba4942205143d 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_HID_ALPS) += hid-alps.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLE_MTP_HAPTIC) += hid-apple-mtp-haptic.o +obj-$(CONFIG_HID_APPLE_MTP_KIWI) += hid-apple-mtp-kiwi.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 8135fbce5fef4..993b2eb3c023b 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -195,6 +195,10 @@ struct dchid_iface { u32 keyboard_layout_id; u32 power_method; bool firmware_managed_reset; + + /* Power method 2: the line that resets this interface, and its optional supply. */ + struct gpio_desc *reset; + struct gpio_desc *power; }; struct dockchannel_hid { @@ -253,6 +257,7 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) u32 power_method = DCHID_POWER_METHOD_1; bool firmware_managed_reset = false; struct device_node *of_node = NULL; + struct gpio_desc *reset = NULL, *power = NULL; struct dchid_iface *iface; if (READ_ONCE(dchid->stopping)) @@ -294,11 +299,34 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) power_method, name); goto err_put_node; } - if (power_method == DCHID_POWER_METHOD_2 && - !firmware_managed_reset && !dchid->afe_reset) { - dev_err(dchid->dev, "Power method 2 for %s needs the AFE reset line\n", - name); - goto err_put_node; + if (power_method == DCHID_POWER_METHOD_2 && !firmware_managed_reset) { + struct fwnode_handle *fwnode = of_fwnode_handle(of_node); + + /* An interface with its own reset line (kiwi) does not share the AFE one. */ + reset = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,reset", + GPIOD_ASIS, "dchid-reset"); + if (IS_ERR(reset)) { + if (PTR_ERR(reset) != -ENOENT) { + dev_err(dchid->dev, "Reset line of %s: %pe\n", name, reset); + goto err_put_node; + } + reset = dchid->afe_reset; + } + if (!reset) { + dev_err(dchid->dev, "Power method 2 for %s needs a reset line\n", + name); + goto err_put_node; + } + + power = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,power", + GPIOD_OUT_HIGH, "dchid-power"); + if (IS_ERR(power)) { + if (PTR_ERR(power) != -ENOENT) { + dev_err(dchid->dev, "Power line of %s: %pe\n", name, power); + goto err_put_node; + } + power = NULL; + } } } @@ -314,6 +342,8 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) iface->of_node = of_node; iface->power_method = power_method; iface->firmware_managed_reset = firmware_managed_reset; + iface->reset = reset; + iface->power = power; iface->out_report = -1; init_completion(&iface->out_complete); init_completion(&iface->ready); @@ -595,13 +625,15 @@ static int dchid_pm2_set_power(struct dchid_iface *iface, u8 state) } else { bool off = state == DCHID_POWER_STATE_OFF; - ret = gpiod_set_value_cansleep(dchid->afe_reset, off); + if (!off && iface->power) + gpiod_set_value_cansleep(iface->power, 1); + ret = gpiod_set_value_cansleep(iface->reset, off); if (ret < 0) { - dev_err(dchid->dev, "%s: failed to %s the AFE reset: %d\n", + dev_err(dchid->dev, "%s: failed to %s the reset line: %d\n", iface->name, off ? "assert" : "release", ret); return ret; } - dev_dbg(dchid->dev, "%s: AFE reset %s\n", iface->name, + dev_dbg(dchid->dev, "%s: reset %s\n", iface->name, off ? "asserted" : "released"); /* * The sequence validated on J716s (M5 Pro, MTP firmware diff --git a/drivers/hid/hid-apple-mtp-kiwi.c b/drivers/hid/hid-apple-mtp-kiwi.c new file mode 100644 index 0000000000000..b0d686dc0ba13 --- /dev/null +++ b/drivers/hid/hid-apple-mtp-kiwi.c @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Apple MTP touch-screen (kiwi) interface. + * + * The kiwi interface of the dockchannel MTP carries its touches as a raw + * report pipe. No other HID driver may claim it: the Apple wildcard entries of + * hid-apple and hid-magicmouse make hid-generic stand off from every + * BUS_HOST Apple device, and both reject the interface in probe. This driver + * claims it by name and exposes the pipe on hidraw. The interface is started + * (firmware, reset) when hidraw is first opened. + */ + +#include +#include +#include + +#include "hid-ids.h" + +static bool kiwi_match(struct hid_device *hdev, bool ignore_special_drivers) +{ + return hdev->bus == BUS_HOST && !strcmp(hdev->name, "Apple MTP kiwi"); +} + +static int kiwi_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + int ret; + + ret = hid_parse(hdev); + if (ret) + return ret; + + return hid_hw_start(hdev, HID_CONNECT_HIDRAW); +} + +static const struct hid_device_id kiwi_devices[] = { + { HID_DEVICE(BUS_HOST, HID_GROUP_ANY, HOST_VENDOR_ID_APPLE, HID_ANY_ID) }, + { } +}; +MODULE_DEVICE_TABLE(hid, kiwi_devices); + +static struct hid_driver kiwi_driver = { + .name = "hid-apple-mtp-kiwi", + .id_table = kiwi_devices, + .match = kiwi_match, + .probe = kiwi_probe, +}; +module_hid_driver(kiwi_driver); + +MODULE_DESCRIPTION("Apple MTP touch-screen (kiwi) interface"); +MODULE_LICENSE("GPL"); From c0df9d3d359cf1701b799883b45f38545991d81d Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:39:05 -0600 Subject: [PATCH 07/17] arm64: dts: apple: t6050-k114c: enable the NUB GPIO block and the kiwi touch-screen interface The touch-screen reset and supply are NUB GPIO pins 25 and 26 (ADT function-reset and function-power). Describe the always-on nub_gpio power domain, give the NUB GPIO controller its gpio properties without interrupts, and give the kiwi interface its firmware name, power method 2 and the two lines. --- arch/arm64/boot/dts/apple/t6050-k114c.dts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-k114c.dts b/arch/arm64/boot/dts/apple/t6050-k114c.dts index 13ea865ba58e1..97ea77ab1111a 100644 --- a/arch/arm64/boot/dts/apple/t6050-k114c.dts +++ b/arch/arm64/boot/dts/apple/t6050-k114c.dts @@ -581,3 +581,23 @@ <&ps_atc2_cio_usb>, <&ps_atc2_cio_auss>, <&ps_atc2_pcie>; apple,pcie-tunnel = <&acio2_pcie_tunnel>; }; +/* The touchscreen (kiwi). Its reset and supply are NUB GPIO pins 25 and 26 (ADT + * function-reset and function-power), not the shared multi-touch AFE reset. + * The NUB GPIO block powers the touch controller; upstream wires its interrupts. + * the reset, as for the AFE one [INFERENCE]. + */ +&ps_nub_gpio { + status = "okay"; +}; + +&nub_gpio0 { + status = "okay"; +}; + +&kiwi { + firmware-name = "apple/tpkiwifw-k114c.bin"; + apple,power-method = <2>; + apple,reset-gpios = <&nub_gpio0 25 GPIO_ACTIVE_HIGH>; + apple,power-gpios = <&nub_gpio0 26 GPIO_ACTIVE_HIGH>; + status = "okay"; +}; From ce7c1475da367df646263fbcb28adf8c953f8728 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:57:48 -0600 Subject: [PATCH 08/17] HID: dockchannel-hid: request the interface reset line as an output gpiolib refuses to set the value of a line that is an input and returns -EPERM. The reset line of a power method 2 interface with its own line was requested with GPIOD_ASIS, so the first start of the kiwi interface failed with EPERM when hidraw was opened. Request it deasserted (low) instead. --- drivers/hid/dockchannel-hid/dockchannel-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 993b2eb3c023b..838d74f212b75 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -304,7 +304,7 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) /* An interface with its own reset line (kiwi) does not share the AFE one. */ reset = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,reset", - GPIOD_ASIS, "dchid-reset"); + GPIOD_OUT_LOW, "dchid-reset"); if (IS_ERR(reset)) { if (PTR_ERR(reset) != -ENOENT) { dev_err(dchid->dev, "Reset line of %s: %pe\n", name, reset); From e74bef6d61b77e337aa399f3702d51d9080a4ba9 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:01:13 -0600 Subject: [PATCH 09/17] Revert "HID: dockchannel-hid: request the interface reset line as an output" This reverts commit 8fca9108b1dc9dd2e137fe5cea4fb188b6678a1f. --- drivers/hid/dockchannel-hid/dockchannel-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 838d74f212b75..993b2eb3c023b 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -304,7 +304,7 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) /* An interface with its own reset line (kiwi) does not share the AFE one. */ reset = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,reset", - GPIOD_OUT_LOW, "dchid-reset"); + GPIOD_ASIS, "dchid-reset"); if (IS_ERR(reset)) { if (PTR_ERR(reset) != -ENOENT) { dev_err(dchid->dev, "Reset line of %s: %pe\n", name, reset); From 30c94fe6d0a2afb3a6c8abfa30f3977325d9f6bd Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:01:13 -0600 Subject: [PATCH 10/17] Revert "HID: dockchannel-hid: own reset and power lines for a power method 2 interface; claim kiwi" This reverts commit 91a826a04d01c4d0581b24bf65a665cd4799a072. --- drivers/hid/Kconfig | 10 ---- drivers/hid/Makefile | 1 - drivers/hid/dockchannel-hid/dockchannel-hid.c | 48 +++--------------- drivers/hid/hid-apple-mtp-kiwi.c | 50 ------------------- 4 files changed, 8 insertions(+), 101 deletions(-) delete mode 100644 drivers/hid/hid-apple-mtp-kiwi.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 89e88fca78a88..6f956d056b87c 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -146,16 +146,6 @@ config HID_APPLE Say Y here if you want support for keyboards of Apple iBooks, PowerBooks, MacBooks, MacBook Pros and Apple Aluminum. -config HID_APPLE_MTP_KIWI - tristate "Apple MTP touch-screen (kiwi) interface" - depends on HID - help - Exposes the raw touch-screen report pipe of the kiwi interface of - the Apple dockchannel MTP on hidraw. - - This driver can also be built as a module. If so, it will be called - hid-apple-mtp-kiwi. - config HID_APPLE_MTP_HAPTIC tristate "Apple MTP Haptic Actuator support" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index ba4942205143d..3efe8ee1caddb 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -30,7 +30,6 @@ obj-$(CONFIG_HID_ALPS) += hid-alps.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLE_MTP_HAPTIC) += hid-apple-mtp-haptic.o -obj-$(CONFIG_HID_APPLE_MTP_KIWI) += hid-apple-mtp-kiwi.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 993b2eb3c023b..8135fbce5fef4 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -195,10 +195,6 @@ struct dchid_iface { u32 keyboard_layout_id; u32 power_method; bool firmware_managed_reset; - - /* Power method 2: the line that resets this interface, and its optional supply. */ - struct gpio_desc *reset; - struct gpio_desc *power; }; struct dockchannel_hid { @@ -257,7 +253,6 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) u32 power_method = DCHID_POWER_METHOD_1; bool firmware_managed_reset = false; struct device_node *of_node = NULL; - struct gpio_desc *reset = NULL, *power = NULL; struct dchid_iface *iface; if (READ_ONCE(dchid->stopping)) @@ -299,34 +294,11 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) power_method, name); goto err_put_node; } - if (power_method == DCHID_POWER_METHOD_2 && !firmware_managed_reset) { - struct fwnode_handle *fwnode = of_fwnode_handle(of_node); - - /* An interface with its own reset line (kiwi) does not share the AFE one. */ - reset = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,reset", - GPIOD_ASIS, "dchid-reset"); - if (IS_ERR(reset)) { - if (PTR_ERR(reset) != -ENOENT) { - dev_err(dchid->dev, "Reset line of %s: %pe\n", name, reset); - goto err_put_node; - } - reset = dchid->afe_reset; - } - if (!reset) { - dev_err(dchid->dev, "Power method 2 for %s needs a reset line\n", - name); - goto err_put_node; - } - - power = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,power", - GPIOD_OUT_HIGH, "dchid-power"); - if (IS_ERR(power)) { - if (PTR_ERR(power) != -ENOENT) { - dev_err(dchid->dev, "Power line of %s: %pe\n", name, power); - goto err_put_node; - } - power = NULL; - } + if (power_method == DCHID_POWER_METHOD_2 && + !firmware_managed_reset && !dchid->afe_reset) { + dev_err(dchid->dev, "Power method 2 for %s needs the AFE reset line\n", + name); + goto err_put_node; } } @@ -342,8 +314,6 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) iface->of_node = of_node; iface->power_method = power_method; iface->firmware_managed_reset = firmware_managed_reset; - iface->reset = reset; - iface->power = power; iface->out_report = -1; init_completion(&iface->out_complete); init_completion(&iface->ready); @@ -625,15 +595,13 @@ static int dchid_pm2_set_power(struct dchid_iface *iface, u8 state) } else { bool off = state == DCHID_POWER_STATE_OFF; - if (!off && iface->power) - gpiod_set_value_cansleep(iface->power, 1); - ret = gpiod_set_value_cansleep(iface->reset, off); + ret = gpiod_set_value_cansleep(dchid->afe_reset, off); if (ret < 0) { - dev_err(dchid->dev, "%s: failed to %s the reset line: %d\n", + dev_err(dchid->dev, "%s: failed to %s the AFE reset: %d\n", iface->name, off ? "assert" : "release", ret); return ret; } - dev_dbg(dchid->dev, "%s: reset %s\n", iface->name, + dev_dbg(dchid->dev, "%s: AFE reset %s\n", iface->name, off ? "asserted" : "released"); /* * The sequence validated on J716s (M5 Pro, MTP firmware diff --git a/drivers/hid/hid-apple-mtp-kiwi.c b/drivers/hid/hid-apple-mtp-kiwi.c deleted file mode 100644 index b0d686dc0ba13..0000000000000 --- a/drivers/hid/hid-apple-mtp-kiwi.c +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Apple MTP touch-screen (kiwi) interface. - * - * The kiwi interface of the dockchannel MTP carries its touches as a raw - * report pipe. No other HID driver may claim it: the Apple wildcard entries of - * hid-apple and hid-magicmouse make hid-generic stand off from every - * BUS_HOST Apple device, and both reject the interface in probe. This driver - * claims it by name and exposes the pipe on hidraw. The interface is started - * (firmware, reset) when hidraw is first opened. - */ - -#include -#include -#include - -#include "hid-ids.h" - -static bool kiwi_match(struct hid_device *hdev, bool ignore_special_drivers) -{ - return hdev->bus == BUS_HOST && !strcmp(hdev->name, "Apple MTP kiwi"); -} - -static int kiwi_probe(struct hid_device *hdev, const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(hdev); - if (ret) - return ret; - - return hid_hw_start(hdev, HID_CONNECT_HIDRAW); -} - -static const struct hid_device_id kiwi_devices[] = { - { HID_DEVICE(BUS_HOST, HID_GROUP_ANY, HOST_VENDOR_ID_APPLE, HID_ANY_ID) }, - { } -}; -MODULE_DEVICE_TABLE(hid, kiwi_devices); - -static struct hid_driver kiwi_driver = { - .name = "hid-apple-mtp-kiwi", - .id_table = kiwi_devices, - .match = kiwi_match, - .probe = kiwi_probe, -}; -module_hid_driver(kiwi_driver); - -MODULE_DESCRIPTION("Apple MTP touch-screen (kiwi) interface"); -MODULE_LICENSE("GPL"); From fb69ae10a2f0dceb0608de2c6bf54e0fef4c4558 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:30:12 +0000 Subject: [PATCH 11/17] HID: apple-mtp-kiwi: add the MTP touch screen driver The touch screen of the M5 Pro MacBook Pro (k114c) sits behind the kiwi interface of the dockchannel MTP. The interface has a 29-byte HID descriptor with one opaque 16384-bit input blob, so the contacts are not described by HID. The chip reports a raw 82 column by 54 row capacitance image every 8.3 ms and does no contact detection itself. Claim the interface by name (hid-apple and hid-magicmouse already refuse BUS_HOST Apple interfaces that are not a keyboard or mouse), keep the raw pipe on hidraw, and register a direct multi-touch input device with 10 slots over the 3024x1986 panel. The driver: - skips the whole-image shift frames the chip sends every 2 s and removes a per-row mean from the others, - keeps a fixed-point baseline per cell (fast up when a finger left, slow drift otherwise), - takes 3x3 local maxima 250 counts below baseline, centroids them and tracks them frame to frame with a 2 frame miss debounce. Row 0 of the sensor is the bottom edge of the panel, so y is mirrored. Tested on a k114c (M5 Pro 14 inch): five taps at the corners and the centre, in that order, landed at the matching points on a test page, and evtest shows X/Y changing under a finger. The firmware load and power sequence of the interface are in a separate patch. Signed-off-by: Joshua Warren <816217+joshuawarren@users.noreply.github.com> --- drivers/hid/Kconfig | 11 + drivers/hid/Makefile | 1 + drivers/hid/hid-apple-mtp-kiwi.c | 370 +++++++++++++++++++++++++++++++ 3 files changed, 382 insertions(+) create mode 100644 drivers/hid/hid-apple-mtp-kiwi.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6f956d056b87c..bface8b26a144 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -156,6 +156,17 @@ config HID_APPLE_MTP_HAPTIC This driver can also be built as a module. If so, it will be called hid-apple-mtp-haptic. +config HID_APPLE_MTP_KIWI + tristate "Apple MTP touch screen (kiwi) support" + depends on HID + help + Support for the touch screen of Apple Silicon laptops that have one, + such as the MacBook Pro with a touch display. The driver turns the raw + capacitance image of the touch interface into multi-touch contacts. + + This driver can also be built as a module. If so, it will be called + hid-apple-mtp-kiwi. + config HID_APPLEIR tristate "Apple infrared receiver" depends on (USB_HID) diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 3efe8ee1caddb..ba4942205143d 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_HID_ALPS) += hid-alps.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLE_MTP_HAPTIC) += hid-apple-mtp-haptic.o +obj-$(CONFIG_HID_APPLE_MTP_KIWI) += hid-apple-mtp-kiwi.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o diff --git a/drivers/hid/hid-apple-mtp-kiwi.c b/drivers/hid/hid-apple-mtp-kiwi.c new file mode 100644 index 0000000000000..3994d773822b3 --- /dev/null +++ b/drivers/hid/hid-apple-mtp-kiwi.c @@ -0,0 +1,370 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Apple MTP touch-screen (kiwi) interface. + * + * The kiwi interface of the dockchannel MTP carries its touches as a raw + * report pipe. No other HID driver may claim it: the Apple wildcard entries of + * hid-apple and hid-magicmouse make hid-generic stand off from every + * BUS_HOST Apple device, and both reject the interface in probe. This driver + * claims it by name, keeps the pipe on hidraw, and registers a direct + * multi-touch input device. The interface is started (firmware, reset) when + * the first user opens hidraw or the input device. + * + * The 29-byte descriptor declares one opaque Digitizer/TouchScreen input blob + * (16384 bits), so the finger layout is not described by HID. Observed layout + * of the 17861-byte report (see the pull request description): + * + * 0..60 header. Byte 0 is 0x5a, bytes 1..6 are 01 02 00 20 18 00, + * bytes 7..10 are a u32 LE microsecond timer (8333 us per frame) + * 61..8916 54 rows x 82 columns of u16 LE raw capacitance, row major, + * row 0 at the bottom edge of the panel, + * idle level about 2500 (noise about 25 to 50 counts). A finger + * lowers the cells under it by 600..1300 counts. One cell is + * about 36.9 px on the 3024x1986 panel in both directions. + * 8917.. further sections that are not decoded yet + * + * Every 2 s four whole-image shifts arrive (about +658, +902, -445 and -126 + * counts, slightly different per row). Frames shifted by more than 200 counts + * are skipped and a per-row mean is removed from the rest. The raw image has no + * baseline, so the driver keeps one per cell, picks local maxima of + * (baseline - raw), and centroids 3x3. + */ + +#include +#include +#include +#include +#include + +#include "hid-ids.h" + +#define KIWI_HDR_LEN 61 +#define KIWI_COLS 82 +#define KIWI_ROWS 54 +#define KIWI_CELLS (KIWI_COLS * KIWI_ROWS) +#define KIWI_MIN_FRAME (KIWI_HDR_LEN + 2 * KIWI_CELLS) +#define KIWI_MAGIC 0x5a +#define KIWI_MAX_SLOTS 10 +/* eDP-1 panel of the k114c, 3024x1986. */ +#define KIWI_MAX_X 3023 +#define KIWI_MAX_Y 1985 +/* Panel is about 10 units per mm. */ +#define KIWI_RES 10 +#define KIWI_FP 256 +#define KIWI_GLITCH 200 /* mean shift of the 2 s reference frame is about 900 */ +#define KIWI_GLITCH_MAX 10 /* skipped frames in a row before the baseline is retaken */ +#define KIWI_MISS_MAX 2 +#define KIWI_MATCH_D2 (4 * KIWI_FP * 4 * KIWI_FP) + +#define KIWI_THRESHOLD 250 /* counts below baseline that make a touch */ + +struct kiwi_contact { + bool on; + int miss; + int x, y; /* 1/KIWI_FP cell, centre of cell 0 is KIWI_FP / 2 */ + int size; +}; + +struct kiwi { + struct input_dev *input; + bool have_base; + int bad; + s16 sig[KIWI_CELLS]; /* baseline minus raw, positive under a finger */ + s32 base[KIWI_CELLS]; + s32 fp[KIWI_CELLS]; + struct kiwi_contact cont[KIWI_MAX_SLOTS]; +}; + +static bool kiwi_match(struct hid_device *hdev, bool ignore_special_drivers) +{ + return hdev->bus == BUS_HOST && !strcmp(hdev->name, "Apple MTP kiwi"); +} + +/* + * Fixed point: base and fp are in 1/256 count. fp is baseline minus raw with the + * frame-wide shift removed, positive under a finger. + * Returns false for a frame that must be skipped (big reference frame). + * Besides the two big reference frames (+658 and +902 counts) every 2 s there is a + * -445 and a -126 count frame: the whole image moves, so remove the mean. + */ +static bool kiwi_load(struct kiwi *k, const u8 *data) +{ + s64 sum = 0; + s32 common; + int i, r, c; + + if (!k->have_base) { + for (i = 0; i < KIWI_CELLS; i++) + k->base[i] = get_unaligned_le16(data + KIWI_HDR_LEN + 2 * i) << 8; + k->have_base = true; + k->bad = 0; + return false; + } + for (i = 0; i < KIWI_CELLS; i++) { + k->fp[i] = k->base[i] - (get_unaligned_le16(data + KIWI_HDR_LEN + 2 * i) << 8); + sum += k->fp[i]; + } + common = div_s64(sum, KIWI_CELLS); + if (abs(common >> 8) > KIWI_GLITCH) { + if (++k->bad >= KIWI_GLITCH_MAX) + k->have_base = false; + return false; + } + k->bad = 0; + /* the shift differs a little from row to row, so remove it per row */ + for (r = 0; r < KIWI_ROWS; r++) { + s64 row = 0; + + for (c = 0; c < KIWI_COLS; c++) + row += k->fp[r * KIWI_COLS + c]; + common = div_s64(row, KIWI_COLS); + for (c = 0; c < KIWI_COLS; c++) { + i = r * KIWI_COLS + c; + k->fp[i] -= common; + k->sig[i] = clamp(k->fp[i] >> 8, -32768, 32767); + } + } + return true; +} + +/* Track the baseline: fast up when a finger left, slow drift otherwise. */ +static void kiwi_adapt(struct kiwi *k) +{ + int i; + + for (i = 0; i < KIWI_CELLS; i++) { + int s = k->sig[i]; + + if (s < -100) + k->base[i] -= k->fp[i] >> 3; + else if (s < 100) + k->base[i] -= k->fp[i] >> 10; + } +} + +static bool kiwi_is_peak(struct kiwi *k, int r, int c) +{ + int s = k->sig[r * KIWI_COLS + c]; + int dr, dc; + + for (dr = -1; dr <= 1; dr++) { + for (dc = -1; dc <= 1; dc++) { + int rr = r + dr, cc = c + dc, n; + + if ((!dr && !dc) || rr < 0 || rr >= KIWI_ROWS || cc < 0 || cc >= KIWI_COLS) + continue; + n = k->sig[rr * KIWI_COLS + cc]; + /* earlier in raster order must be strictly lower: one peak per plateau */ + if (((dr < 0) || (!dr && dc < 0)) ? n >= s : n > s) + return false; + } + } + return true; +} + +static void kiwi_centroid(struct kiwi *k, int r, int c, struct kiwi_contact *out) +{ + s64 w = 0, wx = 0, wy = 0; + int dr, dc, cells = 0; + + for (dr = -1; dr <= 1; dr++) { + for (dc = -1; dc <= 1; dc++) { + int rr = r + dr, cc = c + dc, s; + + if (rr < 0 || rr >= KIWI_ROWS || cc < 0 || cc >= KIWI_COLS) + continue; + s = k->sig[rr * KIWI_COLS + cc]; + if (s <= KIWI_THRESHOLD / 4) + continue; + w += s; + wx += (s64)s * cc; + wy += (s64)s * rr; + cells++; + } + } + out->x = (int)div64_s64(wx * KIWI_FP, w) + KIWI_FP / 2; + out->y = (int)div64_s64(wy * KIWI_FP, w) + KIWI_FP / 2; + out->size = cells; + out->on = true; + out->miss = 0; +} + +static int kiwi_find(struct kiwi *k, const struct kiwi_contact *c, u32 *claimed) +{ + int best = -1, best_d2 = KIWI_MATCH_D2, j; + + for (j = 0; j < KIWI_MAX_SLOTS; j++) { + int dx = k->cont[j].x - c->x, dy = k->cont[j].y - c->y, d2; + + if (!k->cont[j].on || (*claimed & BIT(j))) + continue; + d2 = dx * dx + dy * dy; + if (d2 < best_d2) { + best_d2 = d2; + best = j; + } + } + return best; +} + +static void kiwi_report(struct kiwi *k) +{ + struct input_dev *input = k->input; + int j; + + for (j = 0; j < KIWI_MAX_SLOTS; j++) { + struct kiwi_contact *c = &k->cont[j]; + int x, y; + + input_mt_slot(input, j); + input_mt_report_slot_state(input, MT_TOOL_FINGER, c->on); + if (!c->on) + continue; + x = div_s64((s64)c->x * (KIWI_MAX_X + 1), KIWI_COLS * KIWI_FP); + y = div_s64((s64)c->y * (KIWI_MAX_Y + 1), KIWI_ROWS * KIWI_FP); + /* Row 0 is the bottom edge of the panel. */ + x = clamp(x, 0, KIWI_MAX_X); + y = clamp(KIWI_MAX_Y - y, 0, KIWI_MAX_Y); + input_report_abs(input, ABS_MT_POSITION_X, x); + input_report_abs(input, ABS_MT_POSITION_Y, y); + input_report_abs(input, ABS_MT_TOUCH_MAJOR, c->size * 16); + } + input_mt_sync_frame(input); + input_sync(input); +} + +static void kiwi_track(struct kiwi *k, struct kiwi_contact *found, int n) +{ + u32 claimed = 0; + int i, j; + + for (i = 0; i < n; i++) { + j = kiwi_find(k, &found[i], &claimed); + if (j < 0) + continue; + claimed |= BIT(j); + k->cont[j] = found[i]; + found[i].on = false; /* consumed */ + } + for (j = 0; j < KIWI_MAX_SLOTS; j++) { + if (k->cont[j].on && !(claimed & BIT(j)) && ++k->cont[j].miss > KIWI_MISS_MAX) + k->cont[j].on = false; + } + for (i = 0; i < n; i++) { + if (!found[i].on) + continue; + for (j = 0; j < KIWI_MAX_SLOTS && k->cont[j].on; j++) + ; + if (j < KIWI_MAX_SLOTS) + k->cont[j] = found[i]; + } +} + +static void kiwi_frame(struct kiwi *k, const u8 *data) +{ + struct kiwi_contact found[KIWI_MAX_SLOTS]; + int r, c, n = 0; + + if (!kiwi_load(k, data)) + return; + for (r = 0; r < KIWI_ROWS && n < KIWI_MAX_SLOTS; r++) { + for (c = 0; c < KIWI_COLS && n < KIWI_MAX_SLOTS; c++) { + if (k->sig[r * KIWI_COLS + c] >= KIWI_THRESHOLD && kiwi_is_peak(k, r, c)) + kiwi_centroid(k, r, c, &found[n++]); + } + } + kiwi_adapt(k); + kiwi_track(k, found, n); + kiwi_report(k); +} + +static int kiwi_raw_event(struct hid_device *hdev, struct hid_report *report, + u8 *data, int size) +{ + struct kiwi *k = hid_get_drvdata(hdev); + + if (size >= KIWI_MIN_FRAME && data[0] == KIWI_MAGIC) + kiwi_frame(k, data); + return 0; +} + +static int kiwi_input_open(struct input_dev *input) +{ + struct kiwi *k = input_get_drvdata(input); + + k->have_base = false; + return hid_hw_open(to_hid_device(input->dev.parent)); +} + +static void kiwi_input_close(struct input_dev *input) +{ + hid_hw_close(to_hid_device(input->dev.parent)); +} + +static struct input_dev *kiwi_alloc_input(struct hid_device *hdev, struct kiwi *k) +{ + struct input_dev *input = devm_input_allocate_device(&hdev->dev); + + if (!input) + return NULL; + input->name = "Apple MTP touch screen"; + input->id.bustype = hdev->bus; + input->id.vendor = hdev->vendor; + input->id.product = hdev->product; + input->phys = hdev->phys; + input->dev.parent = &hdev->dev; + input->open = kiwi_input_open; + input->close = kiwi_input_close; + input_set_drvdata(input, k); + __set_bit(INPUT_PROP_DIRECT, input->propbit); + input_set_abs_params(input, ABS_MT_POSITION_X, 0, KIWI_MAX_X, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, KIWI_MAX_Y, 0, 0); + input_abs_set_res(input, ABS_MT_POSITION_X, KIWI_RES); + input_abs_set_res(input, ABS_MT_POSITION_Y, KIWI_RES); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); + if (input_mt_init_slots(input, KIWI_MAX_SLOTS, INPUT_MT_DIRECT)) + return NULL; + return input; +} + +static int kiwi_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + struct kiwi *kiwi; + int ret; + + kiwi = devm_kzalloc(&hdev->dev, sizeof(*kiwi), GFP_KERNEL); + if (!kiwi) + return -ENOMEM; + hid_set_drvdata(hdev, kiwi); + + ret = hid_parse(hdev); + if (ret) + return ret; + + kiwi->input = kiwi_alloc_input(hdev, kiwi); + if (!kiwi->input) + return -ENOMEM; + ret = input_register_device(kiwi->input); + if (ret) + return ret; + + return hid_hw_start(hdev, HID_CONNECT_HIDRAW); +} + +static const struct hid_device_id kiwi_devices[] = { + { HID_DEVICE(BUS_HOST, HID_GROUP_ANY, HOST_VENDOR_ID_APPLE, HID_ANY_ID) }, + { } +}; +MODULE_DEVICE_TABLE(hid, kiwi_devices); + +static struct hid_driver kiwi_driver = { + .name = "hid-apple-mtp-kiwi", + .id_table = kiwi_devices, + .match = kiwi_match, + .probe = kiwi_probe, + .raw_event = kiwi_raw_event, +}; +module_hid_driver(kiwi_driver); + +MODULE_DESCRIPTION("Apple MTP touch-screen (kiwi) interface"); +MODULE_LICENSE("GPL"); From 500da1f16b8d8e7fa70e9ae43cc8e44f4a016f28 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:48:42 +0000 Subject: [PATCH 12/17] HID: dockchannel-hid: bring up the kiwi (touch screen) interface The touch screen ("kiwi") of the M5 Pro MacBook Pro rides the same dockchannel MTP as the multi-touch interface and announces itself the same way, but it owns its power, clock and reset lines instead of sharing the AFE reset, and its 1.3 MB firmware image is written by the MTP bootloader over the touch IC SPI, which takes seconds rather than the 1 s the comm timeout allows. - A power method 2 interface may decode its own reset, power and clock lines from its device node; without its own reset line it keeps falling back to the shared AFE reset, so existing multi-touch boards are unchanged. - Announced GPIOs are tracked per interface (the MTP announces clock_24MHz_enable, display_sync, power and reset for kiwi) instead of failing on the second one, and a GPIO command is matched to its announced id. The kiwi clock and display_sync pads are pad functions in the device tree, not host GPIOs; their commands are refused as before and the chip starts without them. - While the kiwi firmware load is running, comm commands use a 10 s timeout, and the kiwi interface waits 10 s for its ready message. - The kiwi start sequence power-cycles the chip with a reset pulse (the reset line is active low in the device tree), settles 50 ms, sends the firmware and then runs the normal power method 2 transitions. This sequence is fixed code, not tunables. Compile tested against this tree with W=1; the bring-up sequence and timeouts are verified on hardware on a 7.2.11 based tree. Signed-off-by: Joshua Warren <816217+joshuawarren@users.noreply.github.com> --- drivers/hid/dockchannel-hid/dockchannel-hid.c | 217 +++++++++++++----- 1 file changed, 165 insertions(+), 52 deletions(-) diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 8135fbce5fef4..8443e5bf6ce0d 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -29,6 +29,9 @@ #define COMMAND_TIMEOUT_MS 1000 #define START_TIMEOUT_MS 2000 +/* The MTP bootloader writes the 1.3 MB kiwi image over the touch IC SPI: seconds, not 1 s. */ +#define KIWI_CMD_TIMEOUT_MS 10000 +#define KIWI_START_TIMEOUT_MS 10000 #define MAX_INTERFACES 16 @@ -180,8 +183,15 @@ struct dchid_iface { size_t hid_desc_len; struct gpio_desc *gpio; - char gpio_name[MAX_GPIO_NAME]; - int gpio_id; + /* The k114c MTP announces several GPIOs per interface (kiwi: + * clock_24MHz_enable, display_sync, power, reset). Track them all; + * gpio keeps the legacy single-GPIO semantics for existing paths. */ +#define MAX_IFACE_GPIOS 4 + struct gpio_desc *gpios[MAX_IFACE_GPIOS]; + char gpio_names[MAX_IFACE_GPIOS][MAX_GPIO_NAME]; + int gpio_ids[MAX_IFACE_GPIOS]; + int gpio_count; + bool gpios_requested; bool gpio_announced; struct mutex out_mutex; @@ -195,6 +205,11 @@ struct dchid_iface { u32 keyboard_layout_id; u32 power_method; bool firmware_managed_reset; + + /* Power method 2: the line that resets this interface, and its optional supply. */ + struct gpio_desc *reset; + struct gpio_desc *power; + struct gpio_desc *clock; }; struct dockchannel_hid { @@ -203,6 +218,8 @@ struct dockchannel_hid { struct device_link *helper_link; struct apple_smc *afe_smc; bool stopping; + /* The kiwi firmware load is running: comm commands get the long timeout */ + bool kiwi_loading; bool inherited_mtp; /* Between the system sleep suspend and resume callbacks */ bool suspended; @@ -253,6 +270,7 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) u32 power_method = DCHID_POWER_METHOD_1; bool firmware_managed_reset = false; struct device_node *of_node = NULL; + struct gpio_desc *reset = NULL, *power = NULL, *clock = NULL; struct dchid_iface *iface; if (READ_ONCE(dchid->stopping)) @@ -294,11 +312,44 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) power_method, name); goto err_put_node; } - if (power_method == DCHID_POWER_METHOD_2 && - !firmware_managed_reset && !dchid->afe_reset) { - dev_err(dchid->dev, "Power method 2 for %s needs the AFE reset line\n", - name); - goto err_put_node; + if (power_method == DCHID_POWER_METHOD_2 && !firmware_managed_reset) { + struct fwnode_handle *fwnode = of_fwnode_handle(of_node); + + /* An interface with its own reset line (kiwi) does not share the AFE one. */ + reset = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,reset", + GPIOD_OUT_LOW, "dchid-reset"); + if (IS_ERR(reset)) { + if (PTR_ERR(reset) != -ENOENT) { + dev_err(dchid->dev, "Reset line of %s: %pe\n", name, reset); + goto err_put_node; + } + reset = dchid->afe_reset; + } + if (!reset) { + dev_err(dchid->dev, "Power method 2 for %s needs a reset line\n", + name); + goto err_put_node; + } + + power = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,power", + GPIOD_OUT_HIGH, "dchid-power"); + if (IS_ERR(power)) { + if (PTR_ERR(power) != -ENOENT) { + dev_err(dchid->dev, "Power line of %s: %pe\n", name, power); + goto err_put_node; + } + power = NULL; + } + + clock = devm_fwnode_gpiod_get(dchid->dev, fwnode, "apple,clock", + GPIOD_OUT_HIGH, "dchid-clock"); + if (IS_ERR(clock)) { + if (PTR_ERR(clock) != -ENOENT) { + dev_err(dchid->dev, "Clock line of %s: %pe\n", name, clock); + goto err_put_node; + } + clock = NULL; + } } } @@ -314,6 +365,9 @@ dchid_get_interface(struct dockchannel_hid *dchid, int index, const char *name) iface->of_node = of_node; iface->power_method = power_method; iface->firmware_managed_reset = firmware_managed_reset; + iface->reset = reset; + iface->power = power; + iface->clock = clock; iface->out_report = -1; init_completion(&iface->out_complete); init_completion(&iface->ready); @@ -443,7 +497,10 @@ static int dchid_cmd(struct dchid_iface *iface, u32 type, u32 req, if (ret < 0) goto done; - if (!wait_for_completion_timeout(&iface->out_complete, msecs_to_jiffies(COMMAND_TIMEOUT_MS))) { + if (!wait_for_completion_timeout(&iface->out_complete, + msecs_to_jiffies(READ_ONCE(iface->dchid->kiwi_loading) ? + KIWI_CMD_TIMEOUT_MS : + COMMAND_TIMEOUT_MS))) { dev_err(iface->dchid->dev, "output report 0x%x to iface %d (%s) timed out\n", report_id, iface->index, iface->name); ret = -ETIMEDOUT; @@ -571,11 +628,23 @@ static int dchid_register_ring(struct dockchannel_hid *dchid) return ret; } +/* Drive an interface's own power, clock and reset lines to the OFF or ON state. */ +static int dchid_set_own_lines(struct dchid_iface *iface, u8 state) +{ + bool on = state == DCHID_POWER_STATE_ON; + + if (on && iface->power) + gpiod_set_value_cansleep(iface->power, on); + if (iface->clock) + gpiod_set_value_cansleep(iface->clock, on); + return gpiod_set_value_cansleep(iface->reset, !on); +} + /* - * Power method 2: announce the transition, drive the AFE reset line to the - * new state and confirm the transition. The reset is asserted for a power-off - * and held for 50 ms, and released for a power-on and given 50 ms to settle - * before the transition is confirmed. + * Power method 2: announce the transition, drive the interface's reset line + * to the new state and confirm the transition. The reset is asserted for a + * power-off and held for 50 ms, and released for a power-on before the + * transition is confirmed. */ static int dchid_pm2_set_power(struct dchid_iface *iface, u8 state) { @@ -595,21 +664,19 @@ static int dchid_pm2_set_power(struct dchid_iface *iface, u8 state) } else { bool off = state == DCHID_POWER_STATE_OFF; - ret = gpiod_set_value_cansleep(dchid->afe_reset, off); + ret = dchid_set_own_lines(iface, state); if (ret < 0) { - dev_err(dchid->dev, "%s: failed to %s the AFE reset: %d\n", + dev_err(dchid->dev, "%s: failed to %s the reset line: %d\n", iface->name, off ? "assert" : "release", ret); return ret; } - dev_dbg(dchid->dev, "%s: AFE reset %s\n", iface->name, - off ? "asserted" : "released"); /* - * The sequence validated on J716s (M5 Pro, MTP firmware - * 6320.86.1, "Touch MT ready" on 3 of 3 boots) also waits - * 50 ms after the release before HasChanged, as the - * firmware-managed path above does. + * The kiwi sequence was verified with a settle after power-off + * only; the shared AFE reset (multi-touch, sequence validated + * on J716s) settles after every transition. */ - fsleep(50 * USEC_PER_MSEC); + if (off || iface->reset == dchid->afe_reset) + fsleep(50 * USEC_PER_MSEC); } dchid_pm2_command(iface->index, state, true, msg); @@ -705,7 +772,7 @@ static int dchid_get_firmware(struct dchid_iface *iface, void **firmware, size_t static int dchid_request_gpio(struct dchid_iface *iface) { char prop_name[MAX_GPIO_NAME + 16]; - int ret; + int ret, g; if (iface->firmware_managed_reset) return -EINVAL; @@ -715,30 +782,42 @@ static int dchid_request_gpio(struct dchid_iface *iface) return -EOPNOTSUPP; } - if (iface->gpio) + if (iface->gpio_count && iface->gpios_requested) return 0; - - dev_dbg(iface->dchid->dev, "Requesting GPIO %s#%d: %s\n", - iface->name, iface->gpio_id, iface->gpio_name); - - /* A power method 2 interface holds its reset line from probe on. */ - if (iface->power_method == DCHID_POWER_METHOD_2 && - !strcmp(iface->gpio_name, "afe-reset")) { - iface->gpio = iface->dchid->afe_reset; + if (!iface->gpio_count && iface->gpio) return 0; - } - snprintf(prop_name, sizeof(prop_name), "apple,%s", iface->gpio_name); + for (g = 0; g < iface->gpio_count; g++) { + const char *name = iface->gpio_names[g]; - iface->gpio = devm_gpiod_get_index(iface->dchid->dev, prop_name, 0, GPIOD_OUT_LOW); + dev_dbg(iface->dchid->dev, "Requesting GPIO %s#%d: %s\n", + iface->name, iface->gpio_ids[g], name); - if (IS_ERR(iface->gpio)) { - ret = PTR_ERR(iface->gpio); - iface->gpio = NULL; - dev_err(iface->dchid->dev, "Failed to request GPIO %s-gpios: %d\n", - prop_name, ret); - return ret; + /* A power method 2 multi-touch holds its AFE reset line from + * probe on; the pm2 transitions drive it, not this path. */ + if (iface->power_method == DCHID_POWER_METHOD_2 && + !strcmp(name, "afe-reset")) { + iface->gpios[g] = iface->dchid->afe_reset; + if (g == 0) + iface->gpio = iface->dchid->afe_reset; + continue; + } + + snprintf(prop_name, sizeof(prop_name), "apple,%s", name); + iface->gpios[g] = devm_gpiod_get_index(iface->dchid->dev, prop_name, + 0, GPIOD_OUT_LOW); + if (IS_ERR(iface->gpios[g])) { + ret = PTR_ERR(iface->gpios[g]); + iface->gpios[g] = NULL; + dev_err(iface->dchid->dev, + "Failed to request GPIO %s-gpios: %d\n", + prop_name, ret); + return ret; + } + if (g == 0) + iface->gpio = iface->gpios[g]; } + iface->gpios_requested = true; return 0; } @@ -773,13 +852,29 @@ static int dchid_start_interface(struct dchid_iface *iface) goto err; } - /* Only multi-touch has firmware */ + /* Only multi-touch and kiwi have firmware */ if (fw && size) { + bool kiwi_own = !strcmp(iface->name, "kiwi") && + iface->power_method == DCHID_POWER_METHOD_2 && + !iface->firmware_managed_reset; + + WRITE_ONCE(iface->dchid->kiwi_loading, kiwi_own); + + /* The kiwi chip needs a full power cycle with a reset pulse + * before its firmware goes out (its reset line is active low + * in the device tree); the sequence is verified on hardware. */ + if (kiwi_own) { + dchid_set_own_lines(iface, DCHID_POWER_STATE_OFF); + fsleep(50 * USEC_PER_MSEC); + dchid_set_own_lines(iface, DCHID_POWER_STATE_ON); + fsleep(50 * USEC_PER_MSEC); + } /* Send firmware to the device */ dev_dbg(iface->dchid->dev, "Sending firmware for %s\n", iface->name); /* Retained MTP must see AFE reset throughout firmware upload. */ if (iface->dchid->inherited_mtp && + !kiwi_own && iface->power_method == DCHID_POWER_METHOD_2) { if (iface->firmware_managed_reset) { ret = -EINVAL; @@ -799,8 +894,9 @@ static int dchid_start_interface(struct dchid_iface *iface) /* After loading firmware, multi-touch needs a reset */ dev_dbg(iface->dchid->dev, "Resetting %s\n", iface->name); if (iface->power_method == DCHID_POWER_METHOD_2) { - /* The retained session is already off while reset is asserted. */ - if (!iface->dchid->inherited_mtp) { + /* The retained session is already off while reset is asserted; + * kiwi always power-cycles its own lines. */ + if (!iface->dchid->inherited_mtp || kiwi_own) { ret = dchid_pm2_set_power(iface, DCHID_POWER_STATE_OFF); if (ret < 0) goto err; @@ -816,9 +912,11 @@ static int dchid_start_interface(struct dchid_iface *iface) } } + WRITE_ONCE(iface->dchid->kiwi_loading, false); return 0; err: + WRITE_ONCE(iface->dchid->kiwi_loading, false); iface->starting = false; return ret; } @@ -859,7 +957,10 @@ static int dchid_open(struct hid_device *hdev) if (ret < 0) return ret; - if (!wait_for_completion_timeout(&iface->ready, msecs_to_jiffies(START_TIMEOUT_MS))) { + if (!wait_for_completion_timeout(&iface->ready, + msecs_to_jiffies(!strcmp(iface->name, "kiwi") ? + KIWI_START_TIMEOUT_MS : + START_TIMEOUT_MS))) { dev_err(iface->dchid->dev, "iface %s start timed out\n", iface->name); return -ETIMEDOUT; } @@ -1206,14 +1307,16 @@ static void dchid_handle_init(struct dockchannel_hid *dchid, void *data, size_t break; } - if (iface->gpio_announced) { + if (iface->gpio_count >= MAX_IFACE_GPIOS) { dev_err(dchid->dev, - "Cannot request more than one GPIO per interface!\n"); + "Too many GPIO requests for %s\n", iface->name); break; } - strscpy(iface->gpio_name, req->name, MAX_GPIO_NAME); - iface->gpio_id = req->id; + strscpy(iface->gpio_names[iface->gpio_count], req->name, + MAX_GPIO_NAME); + iface->gpio_ids[iface->gpio_count] = req->id; + iface->gpio_count++; iface->gpio_announced = true; break; } @@ -1260,6 +1363,9 @@ static void dchid_handle_init(struct dockchannel_hid *dchid, void *data, size_t static void dchid_handle_gpio(struct dockchannel_hid *dchid, void *data, size_t length) { + struct gpio_desc *cmd_gpio = NULL; + bool found = false; + unsigned int g; struct dchid_gpio_cmd *cmd = data; struct dchid_iface *iface; u32 retcode = 0xe000f00d; /* Give it a random Apple-style error code */ @@ -1282,7 +1388,14 @@ static void dchid_handle_gpio(struct dockchannel_hid *dchid, void *data, size_t if (dchid_request_gpio(iface) < 0) goto err; - if (!iface->gpio || cmd->gpio != iface->gpio_id) { + for (g = 0; g < iface->gpio_count; g++) { + if (iface->gpio_ids[g] == cmd->gpio) { + cmd_gpio = iface->gpios[g]; + found = true; + break; + } + } + if (!found) { dev_err(dchid->dev, "Got GPIO command for bad GPIO %s#%d\n", iface->name, cmd->gpio); goto err; @@ -1293,13 +1406,13 @@ static void dchid_handle_gpio(struct dockchannel_hid *dchid, void *data, size_t switch (cmd->cmd) { case 3: /* Pulse. */ - gpiod_set_value_cansleep(iface->gpio, 1); + gpiod_set_value_cansleep(cmd_gpio, 1); msleep(10); /* Random guess... */ - gpiod_set_value_cansleep(iface->gpio, 0); + gpiod_set_value_cansleep(cmd_gpio, 0); retcode = 0; break; default: - dev_err(dchid->dev, "Unknown GPIO command %d\n", cmd->cmd ); + dev_err(dchid->dev, "Unknown GPIO command %d\n", cmd->cmd); break; } From d3ba4d7a047e04a5bda7c3675e871742086f6f6c Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuawarren@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:57:48 -0600 Subject: [PATCH 13/17] pinctrl: apple: the GPIO mode field is four bits wide On the K114c the NUB GPIO block comes out of iBoot with bit 4 of the touch-screen reset and power pins set (0x474210, 0x474212 as read through /dev/mem). With that bit set, the DATA bit does not latch in output mode: writing 0x474213 reads back 0x474212, writing 0x474203 reads back 0x474203. direction_output wrote only bits 1-3 of the mode, so the pin stayed in a state where the driver's output value never took effect. Treat bits 1-4 as the mode, so that direction_output and direction_input clear bit 4. Modes 0-7 are unchanged, and a working output (the PERST# pin of the K114c, register 0x00076a03) has the bit clear. (cherry picked from commit 41e310ca6cb720704d3edec3950dd09101f5c517) --- drivers/pinctrl/pinctrl-apple-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c index 2f0c25e38c67f..d075383523757 100644 --- a/drivers/pinctrl/pinctrl-apple-gpio.c +++ b/drivers/pinctrl/pinctrl-apple-gpio.c @@ -61,7 +61,7 @@ struct apple_gpio_pinctrl { #define REG_GPIO(x) (4 * (x)) #define REG_GPIOx_DATA BIT(0) -#define REG_GPIOx_MODE GENMASK(3, 1) +#define REG_GPIOx_MODE GENMASK(4, 1) #define REG_GPIOx_OUT 1 #define REG_GPIOx_IN_IRQ_HI 2 #define REG_GPIOx_IN_IRQ_LO 3 From 9e34146567e36f20ce5c1f3d245a727da73c82bc Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:04:03 -0600 Subject: [PATCH 14/17] arm64: dts: apple: t6050-k114c: the kiwi reset line is active low --- arch/arm64/boot/dts/apple/t6050-k114c.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/apple/t6050-k114c.dts b/arch/arm64/boot/dts/apple/t6050-k114c.dts index 97ea77ab1111a..7826306f1ee73 100644 --- a/arch/arm64/boot/dts/apple/t6050-k114c.dts +++ b/arch/arm64/boot/dts/apple/t6050-k114c.dts @@ -597,7 +597,7 @@ &kiwi { firmware-name = "apple/tpkiwifw-k114c.bin"; apple,power-method = <2>; - apple,reset-gpios = <&nub_gpio0 25 GPIO_ACTIVE_HIGH>; + apple,reset-gpios = <&nub_gpio0 25 GPIO_ACTIVE_LOW>; apple,power-gpios = <&nub_gpio0 26 GPIO_ACTIVE_HIGH>; status = "okay"; }; From 581c5c99f92f0c99d30fb158295956109e4ebfdc Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:09:00 -0600 Subject: [PATCH 15/17] HID: dockchannel-hid: skip announced GPIOs the DT does not wire; kiwi lines only with its own reset --- drivers/hid/dockchannel-hid/dockchannel-hid.c | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/hid/dockchannel-hid/dockchannel-hid.c b/drivers/hid/dockchannel-hid/dockchannel-hid.c index 8443e5bf6ce0d..55a66bb066efa 100644 --- a/drivers/hid/dockchannel-hid/dockchannel-hid.c +++ b/drivers/hid/dockchannel-hid/dockchannel-hid.c @@ -809,6 +809,9 @@ static int dchid_request_gpio(struct dchid_iface *iface) if (IS_ERR(iface->gpios[g])) { ret = PTR_ERR(iface->gpios[g]); iface->gpios[g] = NULL; + /* An announced line the DT does not wire (a pad function): its commands are refused. */ + if (ret == -ENOENT) + continue; dev_err(iface->dchid->dev, "Failed to request GPIO %s-gpios: %d\n", prop_name, ret); @@ -827,6 +830,12 @@ static int dchid_start_interface(struct dchid_iface *iface) void *fw; size_t size; int ret; + /* Only a kiwi with its own reset line takes the long firmware timeout and the power + * cycle: without one it would pulse the AFE reset that the trackpad shares. */ + bool kiwi_own = !strcmp(iface->name, "kiwi") && + iface->power_method == DCHID_POWER_METHOD_2 && + !iface->firmware_managed_reset && + iface->reset != iface->dchid->afe_reset; if (iface->starting) { dev_warn(iface->dchid->dev, "Interface %s is already starting\n", iface->name); @@ -854,11 +863,8 @@ static int dchid_start_interface(struct dchid_iface *iface) /* Only multi-touch and kiwi have firmware */ if (fw && size) { - bool kiwi_own = !strcmp(iface->name, "kiwi") && - iface->power_method == DCHID_POWER_METHOD_2 && - !iface->firmware_managed_reset; - - WRITE_ONCE(iface->dchid->kiwi_loading, kiwi_own); + if (kiwi_own) + WRITE_ONCE(iface->dchid->kiwi_loading, true); /* The kiwi chip needs a full power cycle with a reset pulse * before its firmware goes out (its reset line is active low @@ -912,11 +918,13 @@ static int dchid_start_interface(struct dchid_iface *iface) } } - WRITE_ONCE(iface->dchid->kiwi_loading, false); + if (kiwi_own) + WRITE_ONCE(iface->dchid->kiwi_loading, false); return 0; err: - WRITE_ONCE(iface->dchid->kiwi_loading, false); + if (kiwi_own) + WRITE_ONCE(iface->dchid->kiwi_loading, false); iface->starting = false; return ret; } @@ -1400,6 +1408,11 @@ static void dchid_handle_gpio(struct dockchannel_hid *dchid, void *data, size_t iface->name, cmd->gpio); goto err; } + if (!cmd_gpio) { + dev_dbg(dchid->dev, "GPIO %s#%d is not wired in the DT: refused\n", + iface->name, cmd->gpio); + goto err; + } dev_dbg(dchid->dev, "GPIO command: %s#%d: %d\n", iface->name, cmd->gpio, cmd->cmd); From 6ec055196d1f9e67690fd42d0bc9c37765067f8e Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:09:00 -0600 Subject: [PATCH 16/17] arm64: dts: apple: t6050-k114c: kiwi pad functions (clock pin 22, display_sync pin 11) --- arch/arm64/boot/dts/apple/t6050-k114c.dts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-k114c.dts b/arch/arm64/boot/dts/apple/t6050-k114c.dts index 7826306f1ee73..414dc0c81fc48 100644 --- a/arch/arm64/boot/dts/apple/t6050-k114c.dts +++ b/arch/arm64/boot/dts/apple/t6050-k114c.dts @@ -601,3 +601,24 @@ apple,power-gpios = <&nub_gpio0 26 GPIO_ACTIVE_HIGH>; status = "okay"; }; + +/* + * The kiwi 24 MHz clock pad (NUB pin 22) and display_sync pad (AP pin 11) are pad + * functions, not host GPIOs: function 1 on each. + */ +&pinctrl_ap { + kiwi_dsync_pins: kiwi-dsync-pins { + pinmux = <0x1000b>; /* APPLE_PINMUX(11, 1) */ + }; +}; + +&nub_gpio0 { + kiwi_clk24_pins: kiwi-clk24-pins { + pinmux = <0x10016>; /* APPLE_PINMUX(22, 1) */ + }; +}; + +&mtp_hid { + pinctrl-0 = <&kiwi_clk24_pins>, <&kiwi_dsync_pins>; + pinctrl-names = "default"; +}; From 2dd590d33e471822694705614317b1c73cf325b7 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:23:52 -0600 Subject: [PATCH 17/17] dt-bindings: HID: dockchannel: kiwi carries its own power and reset lines The K114c touchscreen node uses power method 2 with its own reset and power gpios; declare them so CHECK_DTBS passes. The properties belong with the open dockchannel binding series and are dropped or reworked when it lands. --- .../bindings/input/apple,dockchannel-hid.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/input/apple,dockchannel-hid.yaml b/Documentation/devicetree/bindings/input/apple,dockchannel-hid.yaml index b6c9e727e5a67..821d54f68d590 100644 --- a/Documentation/devicetree/bindings/input/apple,dockchannel-hid.yaml +++ b/Documentation/devicetree/bindings/input/apple,dockchannel-hid.yaml @@ -241,6 +241,26 @@ properties: Name of the touchscreen firmware that the host sends to the coprocessor when the interface is first opened. + apple,power-method: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2] + default: 1 + description: + The power sequencing protocol of the coprocessor firmware, as + described above. Power method 2 for kiwi carries its own reset + and power lines instead of the shared AFE reset. + + apple,reset-gpios: + maxItems: 1 + description: + The touchscreen's own reset line, when it does not share the + AFE reset of the parent node. + + apple,power-gpios: + maxItems: 1 + description: + The touchscreen's optional supply enable line. + mtp: type: object additionalProperties: false