Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <eduardo@martins.ws>

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
Expand All @@ -23,7 +23,8 @@ allOf:
- if:
properties:
compatible:
const: apple,d221-touchscreen
contains:
const: apple,d221-touchscreen
then:
properties:
hv-supply: false
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/apple/t8020-d321.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/apple/t8020-d331.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/apple/t8020-d331p.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
47 changes: 47 additions & 0 deletions arch/arm64/boot/dts/apple/t8020-xs.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};
28 changes: 27 additions & 1 deletion drivers/input/touchscreen/apple_hidspi_ts.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1298,13 +1315,19 @@ 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);

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);
Expand All @@ -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");
Loading