From d29705247b3bc8981b1d4f14f0d340eb2ff5fe4c Mon Sep 17 00:00:00 2001 From: MasadaIV <6883111+MasadaIV@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:43:20 -0800 Subject: [PATCH 1/6] dt-bindings: input: apple,z2: describe D20/D201 touch personalities Allow the bootloader-supplied personality and document variant firmware- name prefixes. Restrict the supported personality values only for D20 and D201. Assisted-by: LLM Signed-off-by: MasadaIV <6883111+MasadaIV@users.noreply.github.com> --- .../touchscreen/apple,z2-multitouch.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml index 95ca972ee2dab3..1d0701c8de31b4 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml @@ -120,6 +120,17 @@ properties: firmware-name: maxItems: 1 + description: + Firmware file name. For D20 and D201 this is a prefix; the driver + appends -c1f5d-3.bin or -c1f5d-4.bin according to the personality + supplied by the bootloader. + + apple,hid-merge-personality: + $ref: /schemas/types.yaml#/definitions/string + description: + Touch firmware personality from this unit's Apple Device Tree. + The bootloader supplies it together with the calibration, so it can + be absent from the static DTB. D20/D201 require it at driver probe. apple,z2-cal-blob: $ref: /schemas/types.yaml#/definitions/uint8-array @@ -198,6 +209,16 @@ required: - touchscreen-size-y allOf: + - if: + properties: + compatible: + enum: + - apple,d20-touchscreen + - apple,d201-touchscreen + then: + properties: + apple,hid-merge-personality: + enum: ["C1F5D,3", "C1F5D,4"] - if: properties: compatible: From e47f777d651e0717e1acf4607ac11f8d3bec484c Mon Sep 17 00:00:00 2001 From: MasadaIV <6883111+MasadaIV@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:43:27 -0800 Subject: [PATCH 2/6] Input: apple_z2: select D20/D201 touch personalities and HBPP framing Choose the distinct public firmware variant from the boot personality. Honor explicitly declared 0x103 full-word calibration framing while preserving legacy containers and other boards. Assisted-by: LLM Signed-off-by: MasadaIV <6883111+MasadaIV@users.noreply.github.com> --- drivers/input/touchscreen/apple_z2_d21.h | 44 +++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/apple_z2_d21.h b/drivers/input/touchscreen/apple_z2_d21.h index 8fd4d98d1d5e17..1d35a4e65be848 100644 --- a/drivers/input/touchscreen/apple_z2_d21.h +++ b/drivers/input/touchscreen/apple_z2_d21.h @@ -129,6 +129,7 @@ static int apple_z2_d21_smc_rw(struct apple_smc *smc, smc_key key, #define APPLE_Z2_D21_FW_CONFIG_CPHA BIT(3) #define APPLE_Z2_D21_FW_CONFIG_CPOL BIT(4) #define APPLE_Z2_D21_FW_CONFIG_BOOT_TIMEOUT BIT(8) +#define APPLE_Z2_D21_FW_CONFIG_HBPP_VERSION BIT(11) enum apple_z2_d21_protocol_state { APPLE_Z2_D21_STATE_OFF, @@ -197,6 +198,7 @@ struct apple_z2_d21 { unsigned int z2_inter_packet_delay_us; unsigned int z2_cs_delay_us; unsigned int boot_timeout_ms; + u32 hbpp_version; s16 sensor_max_x; s16 sensor_min_x; s16 sensor_max_y; @@ -2978,15 +2980,10 @@ static const u8 *apple_z2_d21_build_iphone7_cal(struct apple_z2_d21 *z2, put_unaligned_be16(0x18e1, blob_data); put_unaligned_be16(APPLE_Z2_D21_HBPP_CMD_BLOB, blob_data + 2); - /* - * The length field counts the payload words less one. Apple's own - * container for this part stores its firmware blobs that way (63592 - * bytes carries 15897, 17312 carries 4327), and the calibration packet - * shares the framing. Sending the plain word count makes the packet one - * word too long, so the controller reads into the trailing checksum and - * rejects every calibration blob. + /* Legacy containers retain their minus-one framing. A container that + * explicitly declares HBPP 0x103 uses the full payload word count. */ - put_unaligned_be16(words - 1, blob_data + 4); + put_unaligned_be16(words - (z2->hbpp_version >= 0x104), blob_data + 4); put_unaligned_be16(address, blob_data + 6); put_unaligned_be16(address >> 16, blob_data + 8); header_checksum = 0; @@ -3234,6 +3231,13 @@ static int apple_z2_d21_apply_fw_config(struct apple_z2_d21 *z2, const u8 *data, cpha = apple_z2_d21_fw_config_word(data, 4); cpol = apple_z2_d21_fw_config_word(data, 5); boot_timeout = apple_z2_d21_fw_config_word(data, 9); + if (valid & APPLE_Z2_D21_FW_CONFIG_HBPP_VERSION) { + u32 version = apple_z2_d21_fw_config_word(data, 10); + + if (version != 0x103 && version != 0x104) + return -EINVAL; + z2->hbpp_version = version; + } if ((valid & APPLE_Z2_D21_FW_CONFIG_MIN_DMA) && min_dma) { if (apple_z2_d21_uses_iphone_protocol(z2)) { if (min_dma > APPLE_Z2_D21_RX_BUF_SIZE) @@ -5355,6 +5359,8 @@ static int apple_z2_d21_probe(struct spi_device *spi, z2->spidev = spi; z2->variant = info->variant; + /* Preserve existing containers that do not declare HBPP framing. */ + z2->hbpp_version = 0x104; z2->boot_timeout_ms = 20; if (apple_z2_d21_uses_iphone_protocol(z2)) { z2->z2_inter_packet_delay_us = 1000; @@ -5509,6 +5515,28 @@ static int apple_z2_d21_probe(struct spi_device *spi, error = device_property_read_string(dev, "firmware-name", &z2->fw_name); if (error) return dev_err_probe(dev, error, "unable to get firmware name\n"); + if (apple_z2_d21_is_d20(z2) || apple_z2_d21_is_d201(z2)) { + const char *personality; + const char *suffix; + + error = device_property_read_string(dev, "apple,hid-merge-personality", + &personality); + if (error) + return dev_err_probe(dev, error, "missing touch personality\n"); + if (!strcmp(personality, "C1F5D,3")) + suffix = "c1f5d-3.bin"; + else if (!strcmp(personality, "C1F5D,4")) + suffix = "c1f5d-4.bin"; + else + return dev_err_probe(dev, -EINVAL, "unsupported touch personality\n"); + + z2->fw_name = devm_kasprintf(dev, GFP_KERNEL, "%s-%s", + z2->fw_name, suffix); + if (!z2->fw_name) + return -ENOMEM; + dev_info(dev, "touch personality %s, firmware %s\n", + personality, z2->fw_name); + } if (apple_z2_d21_uses_iphone_protocol(z2)) { static const struct { const char *name; From 94c484aab01f00439ae1ce6be974ef385003b15c Mon Sep 17 00:00:00 2001 From: MasadaIV <6883111+MasadaIV@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:43:35 -0800 Subject: [PATCH 3/6] arm64: dts: apple: use firmware prefixes for D20 and D201 touch Let the driver append the variant selected from the boot personality. Remove the D20 override so it inherits the shared iPhone 8 prefix. The iPhone 8 Plus keeps its separate firmware filename. Assisted-by: LLM Signed-off-by: MasadaIV <6883111+MasadaIV@users.noreply.github.com> --- arch/arm64/boot/dts/apple/t8015-8.dtsi | 2 +- arch/arm64/boot/dts/apple/t8015-d20.dts | 5 ----- arch/arm64/boot/dts/apple/t8015-d201.dts | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8015-8.dtsi b/arch/arm64/boot/dts/apple/t8015-8.dtsi index 29b6cd81aa4810..5aa49413269bb9 100644 --- a/arch/arm64/boot/dts/apple/t8015-8.dtsi +++ b/arch/arm64/boot/dts/apple/t8015-8.dtsi @@ -59,7 +59,7 @@ reset-gpios = <&pinctrl_ap 33 GPIO_ACTIVE_LOW>; hv-supply = <&touch_hv>; clocks = <&touchclk>; - firmware-name = "apple/dfrmtfw-d20-c1f5d-3.bin"; + firmware-name = "apple/dfrmtfw-d20"; touchscreen-size-x = <750>; touchscreen-size-y = <1334>; }; diff --git a/arch/arm64/boot/dts/apple/t8015-d20.dts b/arch/arm64/boot/dts/apple/t8015-d20.dts index 8f418f3eec168c..f0b20bacf07fa7 100644 --- a/arch/arm64/boot/dts/apple/t8015-d20.dts +++ b/arch/arm64/boot/dts/apple/t8015-d20.dts @@ -13,11 +13,6 @@ model = "Apple iPhone 8 (Global)"; }; -/* The ADT personality is C1F5D,3; use the D20 mtprops-derived container. */ -&touchscreen { - firmware-name = "apple/dfrmtfw-d20-c1f5d-3.bin"; -}; - /* The D20's Wi-Fi module, as its ADT's wlan module-instance names it */ &wifi0 { brcm,board-type = "apple,apolloe"; diff --git a/arch/arm64/boot/dts/apple/t8015-d201.dts b/arch/arm64/boot/dts/apple/t8015-d201.dts index 58e2b193df39de..b1b58527fb165f 100644 --- a/arch/arm64/boot/dts/apple/t8015-d201.dts +++ b/arch/arm64/boot/dts/apple/t8015-d201.dts @@ -14,10 +14,10 @@ }; -/* Same C1F5D,3 personality; pinctrl/PMIC phandle numbers differ in the ADT. */ +/* The bootloader supplies this unit's C1F5D personality and calibration. */ &touchscreen { compatible = "apple,d201-touchscreen"; - firmware-name = "apple/dfrmtfw-d201-c1f5d-3.bin"; + firmware-name = "apple/dfrmtfw-d201"; }; /* The D201's Wi-Fi module, as its ADT's wlan module-instance names it */ From c0d3b73ad97dfb34f1c9e98679ad18a316fcef9e Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:37:19 +0800 Subject: [PATCH 4/6] dt-bindings: input: apple,z2: add apple,firmware-prefix A board whose controllers come with more than one firmware personality names the start of its firmware files; the unit's personality, which the bootloader passes as apple,hid-merge-personality, completes the name. firmware-name stays a complete file name, the one used when the bootloader passes no personality. This replaces the D20/D201-only prefix meaning of firmware-name and the list of personalities, so a new personality needs no binding change. Assisted-by: LLM Signed-off-by: Henrik Klee --- .../touchscreen/apple,z2-multitouch.yaml | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml index 1d0701c8de31b4..5cbefdbcb865d5 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml @@ -121,16 +121,24 @@ properties: firmware-name: maxItems: 1 description: - Firmware file name. For D20 and D201 this is a prefix; the driver - appends -c1f5d-3.bin or -c1f5d-4.bin according to the personality - supplied by the bootloader. + Firmware file name. With apple,firmware-prefix, the file used when + the bootloader passes no personality. + + apple,firmware-prefix: + $ref: /schemas/types.yaml#/definitions/string + description: + Start of the firmware file names on a board whose controllers come + with more than one firmware personality. The driver loads + -.bin, the personality in lower case with its + comma as a dash (C1F5D,4 gives -c1f5d-4.bin), and leaves the + touchscreen off if that file is missing. apple,hid-merge-personality: $ref: /schemas/types.yaml#/definitions/string description: Touch firmware personality from this unit's Apple Device Tree. - The bootloader supplies it together with the calibration, so it can - be absent from the static DTB. D20/D201 require it at driver probe. + The bootloader supplies it together with the calibration, so it is + absent from the static DTB. apple,z2-cal-blob: $ref: /schemas/types.yaml#/definitions/uint8-array @@ -209,16 +217,6 @@ required: - touchscreen-size-y allOf: - - if: - properties: - compatible: - enum: - - apple,d20-touchscreen - - apple,d201-touchscreen - then: - properties: - apple,hid-merge-personality: - enum: ["C1F5D,3", "C1F5D,4"] - if: properties: compatible: From 1bf8a4a152841b75e6483a0f25ffc833e6134223 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:37:19 +0800 Subject: [PATCH 5/6] Input: apple_z2: pick the personality firmware on every board Build the firmware name from apple,firmware-prefix and the personality the bootloader passes on every board and in both the shared and the D21 backends, not only on the D20 and D201, and accept any personality instead of a fixed list: a personality is one more file in the firmware recipe, with no kernel change. When the bootloader passes no personality, load firmware-name as before rather than leaving the touchscreen off. When it passes one without a file, the load fails and the log names the missing file; the unit never gets another personality's firmware. Assisted-by: LLM Signed-off-by: Henrik Klee --- drivers/input/touchscreen/apple_z2.c | 47 ++++++++++++++++++++++++ drivers/input/touchscreen/apple_z2_d21.h | 25 ++----------- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/drivers/input/touchscreen/apple_z2.c b/drivers/input/touchscreen/apple_z2.c index 76e68d797a39af..a915a920cd1135 100644 --- a/drivers/input/touchscreen/apple_z2.c +++ b/drivers/input/touchscreen/apple_z2.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -23,11 +24,54 @@ #include #include #include +#include #include #include #include #include +/* + * Apple's touch firmware comes in variants ("personalities"), and each + * unit's ADT names the one its controller needs; m1n1 passes that on as + * apple,hid-merge-personality. Where a board's IPSW carries more than one, + * the device tree names the files' common start in apple,firmware-prefix, + * and a unit's file is -.bin, the personality in lower + * case with its comma as a dash (C1F5D,4: -c1f5d-4.bin). If that + * file is missing, the touchscreen stays off and the log names it: a unit + * never gets another personality's firmware. + * + * Without apple,firmware-prefix, or when the bootloader passes no + * personality, firmware-name is the file, as before. + */ +static const char *apple_z2_fw_name(struct device *dev, const char *fw_name) +{ + const char *prefix, *personality, *c; + char *name, *p; + + if (device_property_read_string(dev, "apple,firmware-prefix", &prefix)) + return fw_name; + if (device_property_read_string(dev, "apple,hid-merge-personality", + &personality)) { + dev_info(dev, "no touch personality from the bootloader, loading %s\n", + fw_name); + return fw_name; + } + for (c = personality; *c; c++) + if (!isalnum(*c) && *c != ',' && *c != '-') + break; + if (*c || c == personality) { + dev_err(dev, "bad touch personality \"%s\"\n", personality); + return ERR_PTR(-EINVAL); + } + name = devm_kasprintf(dev, GFP_KERNEL, "%s-%s.bin", prefix, personality); + if (!name) + return ERR_PTR(-ENOMEM); + for (p = name + strlen(prefix) + 1; *p; p++) + *p = *p == ',' ? '-' : tolower(*p); + dev_info(dev, "touch personality %s: %s\n", personality, name); + return name; +} + #include "apple_z2_n61.h" #include "apple_z2_j72.h" #include "apple_z2_d21.h" @@ -6207,6 +6251,9 @@ static int apple_z2_probe(struct spi_device *spi) error = device_property_read_string(dev, "firmware-name", &z2->fw_name); if (error) return dev_err_probe(dev, error, "unable to get firmware name\n"); + z2->fw_name = apple_z2_fw_name(dev, z2->fw_name); + if (IS_ERR(z2->fw_name)) + return PTR_ERR(z2->fw_name); if (apple_z2_is_iphone7_plus(z2)) { static const struct { const char *name; diff --git a/drivers/input/touchscreen/apple_z2_d21.h b/drivers/input/touchscreen/apple_z2_d21.h index 1d35a4e65be848..58935a72e4cf12 100644 --- a/drivers/input/touchscreen/apple_z2_d21.h +++ b/drivers/input/touchscreen/apple_z2_d21.h @@ -5515,28 +5515,9 @@ static int apple_z2_d21_probe(struct spi_device *spi, error = device_property_read_string(dev, "firmware-name", &z2->fw_name); if (error) return dev_err_probe(dev, error, "unable to get firmware name\n"); - if (apple_z2_d21_is_d20(z2) || apple_z2_d21_is_d201(z2)) { - const char *personality; - const char *suffix; - - error = device_property_read_string(dev, "apple,hid-merge-personality", - &personality); - if (error) - return dev_err_probe(dev, error, "missing touch personality\n"); - if (!strcmp(personality, "C1F5D,3")) - suffix = "c1f5d-3.bin"; - else if (!strcmp(personality, "C1F5D,4")) - suffix = "c1f5d-4.bin"; - else - return dev_err_probe(dev, -EINVAL, "unsupported touch personality\n"); - - z2->fw_name = devm_kasprintf(dev, GFP_KERNEL, "%s-%s", - z2->fw_name, suffix); - if (!z2->fw_name) - return -ENOMEM; - dev_info(dev, "touch personality %s, firmware %s\n", - personality, z2->fw_name); - } + z2->fw_name = apple_z2_fw_name(dev, z2->fw_name); + if (IS_ERR(z2->fw_name)) + return PTR_ERR(z2->fw_name); if (apple_z2_d21_uses_iphone_protocol(z2)) { static const struct { const char *name; From 9f7da387fc1e457331e5658b758342f9a3c488b7 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 3 Dec 2026 05:37:19 +0800 Subject: [PATCH 6/6] arm64: dts: apple: t8015: personality touch firmware for iPhone 8 and 8 Plus Both iPhone 8 sizes come with two touch firmware personalities in their IPSW: D20.mtprops has C1F5D,3 and C1F5D,4, D21.mtprops C1F5E,3 and C1F5E,4. Name the files' prefix so the driver loads the one the unit's ADT asks for. firmware-name is the file without a personality from the bootloader, as before: C1F5D,3 on the iPhone 8, C1F5E,4 (the tested one) on the iPhone 8 Plus. Assisted-by: LLM Signed-off-by: Henrik Klee --- arch/arm64/boot/dts/apple/t8015-8.dtsi | 3 ++- arch/arm64/boot/dts/apple/t8015-8plus.dtsi | 9 ++++++--- arch/arm64/boot/dts/apple/t8015-d201.dts | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8015-8.dtsi b/arch/arm64/boot/dts/apple/t8015-8.dtsi index 5aa49413269bb9..e34843e12dbcf3 100644 --- a/arch/arm64/boot/dts/apple/t8015-8.dtsi +++ b/arch/arm64/boot/dts/apple/t8015-8.dtsi @@ -59,7 +59,8 @@ reset-gpios = <&pinctrl_ap 33 GPIO_ACTIVE_LOW>; hv-supply = <&touch_hv>; clocks = <&touchclk>; - firmware-name = "apple/dfrmtfw-d20"; + firmware-name = "apple/dfrmtfw-d20-c1f5d-3.bin"; + apple,firmware-prefix = "apple/dfrmtfw-d20"; touchscreen-size-x = <750>; touchscreen-size-y = <1334>; }; diff --git a/arch/arm64/boot/dts/apple/t8015-8plus.dtsi b/arch/arm64/boot/dts/apple/t8015-8plus.dtsi index f5e252976d68ed..3b9caf84b58f4c 100644 --- a/arch/arm64/boot/dts/apple/t8015-8plus.dtsi +++ b/arch/arm64/boot/dts/apple/t8015-8plus.dtsi @@ -9,13 +9,16 @@ #include "t8015-8.dtsi" /* - * The D21 and D211 ADTs carry the same touch node: personality C1F5E,3, - * the same pins, power and clock functions. Their IPSW has one multitouch - * file, D21.mtprops, whose C1F5E,4 entry is the controller firmware. + * The D21 and D211 ADTs carry the same touch node: the same pins, power + * and clock functions. Their IPSW has one multitouch file, D21.mtprops, + * with a C1F5E,3 and a C1F5E,4 firmware; the unit's ADT personality picks + * one (the IPSW's ADT says C1F5E,3, the boot ADT of each unit says which + * its controller needs). C1F5E,4 is the one tested. */ &touchscreen { compatible = "apple,d21-touchscreen"; firmware-name = "apple/dfrmtfw-d21-c1f5e-4.bin"; + apple,firmware-prefix = "apple/dfrmtfw-d21"; touchscreen-size-x = <1080>; touchscreen-size-y = <1920>; }; diff --git a/arch/arm64/boot/dts/apple/t8015-d201.dts b/arch/arm64/boot/dts/apple/t8015-d201.dts index b1b58527fb165f..5fa310dc5e00f6 100644 --- a/arch/arm64/boot/dts/apple/t8015-d201.dts +++ b/arch/arm64/boot/dts/apple/t8015-d201.dts @@ -17,7 +17,8 @@ /* The bootloader supplies this unit's C1F5D personality and calibration. */ &touchscreen { compatible = "apple,d201-touchscreen"; - firmware-name = "apple/dfrmtfw-d201"; + firmware-name = "apple/dfrmtfw-d201-c1f5d-3.bin"; + apple,firmware-prefix = "apple/dfrmtfw-d201"; }; /* The D201's Wi-Fi module, as its ADT's wlan module-instance names it */