From 23c6c62d2e23b1a8fc39bd5d47ca3a88669c7648 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:15:10 +0800 Subject: [PATCH 1/3] dt-bindings: input: touchscreen: apple,d221: Add the iPhone XS and XS Max The iPhone XS (D321) and XS Max (D331, D331p) carry the iPhone X's touch controller ("hid-transport,k1", hbpp-version 0x105, the same SPI configuration and Acorn power_ana in their ADTs). Give each board its compatible with the iPhone X's as the fallback. Assisted-by: LLM Signed-off-by: Henrik Klee --- .../touchscreen/apple,d221-touchscreen.yaml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/apple,d221-touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/apple,d221-touchscreen.yaml index 7a8a22fd4bbdb8..f2d44a0b261aa0 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/apple,d221-touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/apple,d221-touchscreen.yaml @@ -4,13 +4,13 @@ $id: http://devicetree.org/schemas/input/touchscreen/apple,d221-touchscreen.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Apple iPhone X and iPhone XR HIDSPI touchscreens +title: Apple iPhone X, XS and XR HIDSPI touchscreens maintainers: - Eduardo Martins description: - The touch controllers of the iPhone X (ADT "hid-transport,k1") and the + The touch controllers of the iPhone X and XS (ADT "hid-transport,k1") and the iPhone XR (ADT "hid-transport,spi") on an SPI bus. They start in an HBPP bootloader that loads the firmware from the host, then report touches over Apple's HIDSPI transport. The per-unit calibrations come from the ADT's @@ -23,7 +23,8 @@ allOf: - if: properties: compatible: - const: apple,d221-touchscreen + contains: + const: apple,d221-touchscreen then: properties: hv-supply: false @@ -44,9 +45,16 @@ allOf: properties: compatible: - enum: - - apple,d221-touchscreen - - apple,n841-touchscreen + oneOf: + - enum: + - apple,d221-touchscreen + - apple,n841-touchscreen + - items: + - enum: + - apple,d321-touchscreen + - apple,d331-touchscreen + - apple,d331p-touchscreen + - const: apple,d221-touchscreen reg: maxItems: 1 From 0796d812ad7453949afafaf4023df728bc1020fe Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:15:10 +0800 Subject: [PATCH 2/3] Input: apple_hidspi_ts: Add the iPhone XS and XS Max Their ADTs describe the iPhone X's controller: "hid-transport,k1", hbpp-version 0x105, the same SPI configuration, the analog supply from the Acorn display PMU and the PMGR touch clock. Drive them as the iPhone X, in SPI mode 3 with its 200 us CS delay, and require the firmware's surface descriptor instead of the iPhone X's measured fallback; the device tree gives the panel's size. Their firmware is loaded as apple/-touch-.bin (C1R1FC0,2 and C1R1FC0,3 on the XS, C1R1FC1,1 on both XS Max). kieroid's badapple drives the XS Max with the same pins, supply and 4 MHz clock. Assisted-by: LLM Signed-off-by: Henrik Klee --- drivers/input/touchscreen/apple_hidspi_ts.c | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/apple_hidspi_ts.c b/drivers/input/touchscreen/apple_hidspi_ts.c index c25c1cfb542499..cd1d29969a790a 100644 --- a/drivers/input/touchscreen/apple_hidspi_ts.c +++ b/drivers/input/touchscreen/apple_hidspi_ts.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Apple HIDSPI touchscreens: iPhone X ("hid-transport,k1") and iPhone XR + * Apple HIDSPI touchscreens: iPhone X and XS ("hid-transport,k1") and iPhone XR * ("hid-transport,spi"). * * The controller starts in its HBPP bootloader. The host loads the firmware @@ -1262,6 +1262,23 @@ static const struct ahts_variant ahts_d221 = { .max_sy = 13270, }; +/* + * iPhone XS, XS Max: the iPhone X's controller ("hid-transport,k1", + * hbpp-version 0x105, the same SPI configuration in the ADT and the Acorn + * PMU's power_ana), so the iPhone X's mode and CS delay. Its firmware's + * surface descriptor is required; the device tree gives the panel's size. + */ +static const struct ahts_variant ahts_xs = { + .name = "Apple iPhone XS Touchscreen", + .supplies = { "ana" }, + .clk = true, + .hbpp_mode = SPI_MODE_3, + .hbpp_version = 0x105, + .cs_delay_us = 200, + .max_x = 1124, + .max_y = 2435, +}; + /* * iPhone XR. The ADT's multi-touch node: hbpp-version 0x103, and * function-power_ana (hv), function-power_ldo (core) and function-clock_enable @@ -1298,6 +1315,9 @@ static const struct ahts_variant ahts_n841 = { static const struct of_device_id ahts_of_match[] = { { .compatible = "apple,d221-touchscreen", .data = &ahts_d221 }, { .compatible = "apple,n841-touchscreen", .data = &ahts_n841 }, + { .compatible = "apple,d321-touchscreen", .data = &ahts_xs }, + { .compatible = "apple,d331-touchscreen", .data = &ahts_xs }, + { .compatible = "apple,d331p-touchscreen", .data = &ahts_xs }, { } }; MODULE_DEVICE_TABLE(of, ahts_of_match); @@ -1305,6 +1325,9 @@ MODULE_DEVICE_TABLE(of, ahts_of_match); static const struct spi_device_id ahts_spi_id[] = { { "d221-touchscreen", (kernel_ulong_t)&ahts_d221 }, { "n841-touchscreen", (kernel_ulong_t)&ahts_n841 }, + { "d321-touchscreen", (kernel_ulong_t)&ahts_xs }, + { "d331-touchscreen", (kernel_ulong_t)&ahts_xs }, + { "d331p-touchscreen", (kernel_ulong_t)&ahts_xs }, { } }; MODULE_DEVICE_TABLE(spi, ahts_spi_id); @@ -1324,3 +1347,6 @@ MODULE_DESCRIPTION("Apple HIDSPI touchscreen (iPhone X, iPhone XR)"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("apple/d221-touch-*.bin"); MODULE_FIRMWARE("apple/n841-touch-*.bin"); +MODULE_FIRMWARE("apple/d321-touch-*.bin"); +MODULE_FIRMWARE("apple/d331-touch-*.bin"); +MODULE_FIRMWARE("apple/d331p-touch-*.bin"); From f39102d27998db086ab0b6cbcd707225d4b5d128 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:15:10 +0800 Subject: [PATCH 3/3] arm64: dts: apple: t8020-xs: Add the touchscreen Describe the XS family's touch controller from their ADTs (d321ap, d331ap, d331pap: /arm-io/spi1/multi-touch, alike on all three): SPI1 with chip select AP GPIO 67, reset AP GPIO 5, interrupt AOP GPIO 19 (level low), the PMGR touch clock, and the analog supply from the Acorn display PMU at I2C3 0x2a, as on the iPhone X. Each board names its firmware and its panel's size; touchscreen0 lets m1n1 pass the unit's calibration and personality. Assisted-by: LLM Signed-off-by: Henrik Klee --- arch/arm64/boot/dts/apple/t8020-d321.dts | 8 ++++ arch/arm64/boot/dts/apple/t8020-d331.dts | 8 ++++ arch/arm64/boot/dts/apple/t8020-d331p.dts | 8 ++++ arch/arm64/boot/dts/apple/t8020-xs.dtsi | 47 +++++++++++++++++++++++ 4 files changed, 71 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8020-d321.dts b/arch/arm64/boot/dts/apple/t8020-d321.dts index 6095e6162683a1..0aed1ab66f398c 100644 --- a/arch/arm64/boot/dts/apple/t8020-d321.dts +++ b/arch/arm64/boot/dts/apple/t8020-d321.dts @@ -25,3 +25,11 @@ &bluetooth0 { brcm,board-type = "apple,aladdink"; }; + +/* Firmware/D321_Multitouch.im4p; the panel's 1125 x 2436 pixels */ +&touchscreen { + compatible = "apple,d321-touchscreen", "apple,d221-touchscreen"; + firmware-name = "apple/d321-touch"; + touchscreen-size-x = <1125>; + touchscreen-size-y = <2436>; +}; diff --git a/arch/arm64/boot/dts/apple/t8020-d331.dts b/arch/arm64/boot/dts/apple/t8020-d331.dts index edf1f35f900610..d84425dcf38881 100644 --- a/arch/arm64/boot/dts/apple/t8020-d331.dts +++ b/arch/arm64/boot/dts/apple/t8020-d331.dts @@ -25,3 +25,11 @@ &bluetooth0 { brcm,board-type = "apple,geniek"; }; + +/* Firmware/D331_Multitouch.im4p; the panel's 1242 x 2688 pixels */ +&touchscreen { + compatible = "apple,d331-touchscreen", "apple,d221-touchscreen"; + firmware-name = "apple/d331-touch"; + touchscreen-size-x = <1242>; + touchscreen-size-y = <2688>; +}; diff --git a/arch/arm64/boot/dts/apple/t8020-d331p.dts b/arch/arm64/boot/dts/apple/t8020-d331p.dts index 09a5fe47b78771..7e8f09866a8c3a 100644 --- a/arch/arm64/boot/dts/apple/t8020-d331p.dts +++ b/arch/arm64/boot/dts/apple/t8020-d331p.dts @@ -25,3 +25,11 @@ &bluetooth0 { brcm,board-type = "apple,geniek"; }; + +/* Firmware/D331p_Multitouch.im4p; the panel's 1242 x 2688 pixels */ +&touchscreen { + compatible = "apple,d331p-touchscreen", "apple,d221-touchscreen"; + firmware-name = "apple/d331p-touch"; + touchscreen-size-x = <1242>; + touchscreen-size-y = <2688>; +}; diff --git a/arch/arm64/boot/dts/apple/t8020-xs.dtsi b/arch/arm64/boot/dts/apple/t8020-xs.dtsi index b1792a939aaf2f..efca69d1752f81 100644 --- a/arch/arm64/boot/dts/apple/t8020-xs.dtsi +++ b/arch/arm64/boot/dts/apple/t8020-xs.dtsi @@ -142,3 +142,50 @@ label = "Battery Current"; }; }; + +/* + * Touch (ADT /arm-io/spi1/multi-touch, "hid-transport,k1", hbpp-version + * 0x105): the iPhone X's controller, on SPI1 with chip select AP GPIO 67 + * (function-enable_cs), reset AP GPIO 5 (function-reset), its interrupt AOP + * GPIO 19 (interrupts 0x13, level low, interrupt group 6 as set_int_config + * gives it) and the PMGR touch clock (function-clock_enable, TCLK 24 MHz). + * Its analog supply is the Acorn display PMU at I2C3 0x2a (function-power_ana + * dpLE(0x6), function-power_pulldown), as on the iPhone X. Each board names + * its firmware and the panel's size; m1n1 passes the unit's calibration and + * firmware personality through touchscreen0. + */ +/ { + aliases { + touchscreen0 = &touchscreen; + }; +}; + +&i2c3 { + status = "okay"; + + pmic@2a { + compatible = "apple,acorn-pmic"; + reg = <0x2a>; + #address-cells = <1>; + #size-cells = <1>; + + touch_ana: regulator-touch-analog { + compatible = "apple,acorn-touch-analog-regulator"; + regulator-name = "touch-analog"; + }; + }; +}; + +&spi1 { + cs-gpios = <&pinctrl_ap 67 GPIO_ACTIVE_LOW>; + status = "okay"; + + touchscreen: touchscreen@0 { + reg = <0>; + spi-max-frequency = <4000000>; + interrupts-extended = <&pinctrl_aop 19 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pinctrl_ap 5 GPIO_ACTIVE_LOW>; + ana-supply = <&touch_ana>; + clocks = <&touchclk>; + }; +};