Skip to content
Closed
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 @@ -96,7 +96,7 @@ properties:

apple,spi-full-duplex-descriptor:
type: boolean
description:
description: |
The SPI controller sets up full-duplex transfers of any length with
its descriptor registers, as iOS does on the A12 for this controller
(iPad 8); without it only transfers that fit the FIFO are. A device
Expand All @@ -113,6 +113,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
Expand Down Expand Up @@ -191,6 +202,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:
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/boot/dts/apple/t8015-8.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
Expand Down
5 changes: 0 additions & 5 deletions arch/arm64/boot/dts/apple/t8015-d20.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/boot/dts/apple/t8015-d201.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
44 changes: 36 additions & 8 deletions drivers/input/touchscreen/apple_z2_d21.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading