Skip to content

Commit dac9738

Browse files
Linus Walleijdtor
authored andcommitted
Input: zinitix - varying icon status registers
The different revisions of the Zinitix BTXXX touchscreens place the icon status register (to read out touchkey status) in different places. Use the chip revision bits to discern between the different versions at runtime. This makes touchkeys work on the BT404 on the Samsung Codina GT-I8160 mobile phone. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20240830-zinitix-tk-versions-v2-2-90eae6817eda@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 5278bb4 commit dac9738

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

drivers/input/touchscreen/zinitix.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
#define ZINITIX_DEBUG_REG 0x0115 /* 0~7 */
3636

3737
#define ZINITIX_TOUCH_MODE 0x0010
38+
3839
#define ZINITIX_CHIP_REVISION 0x0011
40+
#define ZINITIX_CHIP_BTX0X_MASK 0xF0F0
41+
#define ZINITIX_CHIP_BT4X2 0x4020
42+
#define ZINITIX_CHIP_BT4X3 0x4030
43+
#define ZINITIX_CHIP_BT4X4 0x4040
44+
3945
#define ZINITIX_FIRMWARE_VERSION 0x0012
4046

4147
#define ZINITIX_USB_DETECT 0x116
@@ -63,7 +69,11 @@
6369
#define ZINITIX_Y_RESOLUTION 0x00C1
6470

6571
#define ZINITIX_POINT_STATUS_REG 0x0080
66-
#define ZINITIX_ICON_STATUS_REG 0x00AA
72+
73+
#define ZINITIX_BT4X2_ICON_STATUS_REG 0x009A
74+
#define ZINITIX_BT4X3_ICON_STATUS_REG 0x00A0
75+
#define ZINITIX_BT4X4_ICON_STATUS_REG 0x00A0
76+
#define ZINITIX_BT5XX_ICON_STATUS_REG 0x00AA
6777

6878
#define ZINITIX_POINT_COORD_REG (ZINITIX_POINT_STATUS_REG + 2)
6979

@@ -154,6 +164,7 @@ struct bt541_ts_data {
154164
u16 chip_revision;
155165
u16 firmware_version;
156166
u16 regdata_version;
167+
u16 icon_status_reg;
157168
};
158169

159170
static int zinitix_read_data(struct i2c_client *client,
@@ -241,6 +252,28 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541)
241252
"chip revision %04x firmware version %04x regdata version %04x\n",
242253
bt541->chip_revision, bt541->firmware_version,
243254
bt541->regdata_version);
255+
256+
/*
257+
* Determine the "icon" status register which varies by the
258+
* chip.
259+
*/
260+
switch (bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) {
261+
case ZINITIX_CHIP_BT4X2:
262+
bt541->icon_status_reg = ZINITIX_BT4X2_ICON_STATUS_REG;
263+
break;
264+
265+
case ZINITIX_CHIP_BT4X3:
266+
bt541->icon_status_reg = ZINITIX_BT4X3_ICON_STATUS_REG;
267+
break;
268+
269+
case ZINITIX_CHIP_BT4X4:
270+
bt541->icon_status_reg = ZINITIX_BT4X4_ICON_STATUS_REG;
271+
break;
272+
273+
default:
274+
bt541->icon_status_reg = ZINITIX_BT5XX_ICON_STATUS_REG;
275+
break;
276+
}
244277
}
245278

246279
error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, 0x0);
@@ -427,7 +460,7 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
427460
}
428461

429462
if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) {
430-
error = zinitix_read_data(bt541->client, ZINITIX_ICON_STATUS_REG,
463+
error = zinitix_read_data(bt541->client, bt541->icon_status_reg,
431464
&icon_events, sizeof(icon_events));
432465
if (error) {
433466
dev_err(&client->dev, "Failed to read icon events\n");

0 commit comments

Comments
 (0)