* [PATCH v2 0/2] Input: zinitix - Handle chip revisions for touchkeys
@ 2024-08-30 14:04 Linus Walleij
2024-08-30 14:04 ` [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers Linus Walleij
2024-08-30 14:04 ` [PATCH v2 2/2] Input: zinitix - Varying icon status registers Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2024-08-30 14:04 UTC (permalink / raw)
To: Dmitry Torokhov, Nikita Travkin; +Cc: linux-input, Linus Walleij
The registers containing the touchkey status varies between
different chip revisions for the Zinitix touchscreens.
This series address the problem by reading out some chip
revision and firmware data so we can take different runtime
paths in different chip versions.
Also read out firmware and register version as this may
prove helpful to similar situations in the future.
This applies on top of Nikitas series to handle touchkeys
that was recently merged.
After this my BT404 touchkeys work.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v2:
- Move the variable keeping track of versioning info being
read into the per-device state.
- Link to v1: https://lore.kernel.org/r/20240806-zinitix-tk-versions-v1-0-63ef79c7f2a1@linaro.org
---
Linus Walleij (2):
Input: zinitix - Read and cache device version numbers
Input: zinitix - Varying icon status registers
drivers/input/touchscreen/zinitix.c | 59 +++++++++++++++++++++++++++++++++++--
1 file changed, 57 insertions(+), 2 deletions(-)
---
base-commit: 669e9cb5f59903fbb1649660f3cb04e5217a7e58
change-id: 20240806-zinitix-tk-versions-9b18b20ebaad
Best regards,
--
Linus Walleij <linus.walleij@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers
2024-08-30 14:04 [PATCH v2 0/2] Input: zinitix - Handle chip revisions for touchkeys Linus Walleij
@ 2024-08-30 14:04 ` Linus Walleij
2024-09-01 2:07 ` Dmitry Torokhov
2024-08-30 14:04 ` [PATCH v2 2/2] Input: zinitix - Varying icon status registers Linus Walleij
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2024-08-30 14:04 UTC (permalink / raw)
To: Dmitry Torokhov, Nikita Travkin; +Cc: linux-input, Linus Walleij
The chip hardware revision, firmware version and regdata
revision is needed to discern because for example touchkeys
are handled by different registers on different versions of
the chip. Example output from BT404:
Zinitix-TS 3-0020: chip revision 4040 firmware version 0088
regdata version 0004
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Move read status into the per-device struct.
---
drivers/input/touchscreen/zinitix.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index 1df93c96f6bf..e47e0bff80db 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -150,6 +150,10 @@ struct bt541_ts_data {
u32 zinitix_mode;
u32 keycodes[MAX_SUPPORTED_BUTTON_NUM];
int num_keycodes;
+ bool read_versioninfo;
+ u16 chip_revision;
+ u16 firmware_version;
+ u16 regdata_version;
};
static int zinitix_read_data(struct i2c_client *client,
@@ -194,6 +198,18 @@ static int zinitix_write_cmd(struct i2c_client *client, u16 reg)
return 0;
}
+static u16 zinitix_get_u16_reg(struct bt541_ts_data *bt541, u16 vreg)
+{
+ struct i2c_client *client = bt541->client;
+ int error;
+ __le16 val;
+
+ error = zinitix_read_data(client, vreg, (void *)&val, 2);
+ if (error)
+ return U8_MAX;
+ return le16_to_cpu(val);
+}
+
static int zinitix_init_touch(struct bt541_ts_data *bt541)
{
struct i2c_client *client = bt541->client;
@@ -207,6 +223,24 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541)
return error;
}
+ /*
+ * Read and cache the chip revision and firmware version the first time
+ * we get here.
+ */
+ if (!bt541->read_versioninfo) {
+ bt541->chip_revision = zinitix_get_u16_reg(bt541,
+ ZINITIX_CHIP_REVISION);
+ bt541->firmware_version = zinitix_get_u16_reg(bt541,
+ ZINITIX_FIRMWARE_VERSION);
+ bt541->regdata_version = zinitix_get_u16_reg(bt541,
+ ZINITIX_DATA_VERSION_REG);
+ dev_dbg(&client->dev,
+ "chip revision %04x firmware version %04x regdata version %04x\n",
+ bt541->chip_revision, bt541->firmware_version,
+ bt541->regdata_version);
+ bt541->read_versioninfo = true;
+ }
+
error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, 0x0);
if (error) {
dev_err(&client->dev,
--
2.46.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] Input: zinitix - Varying icon status registers
2024-08-30 14:04 [PATCH v2 0/2] Input: zinitix - Handle chip revisions for touchkeys Linus Walleij
2024-08-30 14:04 ` [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers Linus Walleij
@ 2024-08-30 14:04 ` Linus Walleij
2024-09-01 2:09 ` Dmitry Torokhov
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2024-08-30 14:04 UTC (permalink / raw)
To: Dmitry Torokhov, Nikita Travkin; +Cc: linux-input, Linus Walleij
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>
---
ChangeLog v1->v2:
- No changes
---
drivers/input/touchscreen/zinitix.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index e47e0bff80db..b6b380f5aed5 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -35,7 +35,13 @@
#define ZINITIX_DEBUG_REG 0x0115 /* 0~7 */
#define ZINITIX_TOUCH_MODE 0x0010
+
#define ZINITIX_CHIP_REVISION 0x0011
+#define ZINITIX_CHIP_BTX0X_MASK 0xF0F0
+#define ZINITIX_CHIP_BT4X2 0x4020
+#define ZINITIX_CHIP_BT4X3 0x4030
+#define ZINITIX_CHIP_BT4X4 0x4040
+
#define ZINITIX_FIRMWARE_VERSION 0x0012
#define ZINITIX_USB_DETECT 0x116
@@ -63,7 +69,11 @@
#define ZINITIX_Y_RESOLUTION 0x00C1
#define ZINITIX_POINT_STATUS_REG 0x0080
-#define ZINITIX_ICON_STATUS_REG 0x00AA
+
+#define ZINITIX_BT4X2_ICON_STATUS_REG 0x009A
+#define ZINITIX_BT4X3_ICON_STATUS_REG 0x00A0
+#define ZINITIX_BT4X4_ICON_STATUS_REG 0x00A0
+#define ZINITIX_BT5XX_ICON_STATUS_REG 0x00AA
#define ZINITIX_POINT_COORD_REG (ZINITIX_POINT_STATUS_REG + 2)
@@ -425,7 +435,18 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
}
if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) {
- error = zinitix_read_data(bt541->client, ZINITIX_ICON_STATUS_REG,
+ u16 iconstatus;
+
+ if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X2)
+ iconstatus = ZINITIX_BT4X2_ICON_STATUS_REG;
+ else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X3)
+ iconstatus = ZINITIX_BT4X3_ICON_STATUS_REG;
+ else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X4)
+ iconstatus = ZINITIX_BT4X4_ICON_STATUS_REG;
+ else
+ iconstatus = ZINITIX_BT5XX_ICON_STATUS_REG;
+
+ error = zinitix_read_data(bt541->client, iconstatus,
&icon_events, sizeof(icon_events));
if (error) {
dev_err(&client->dev, "Failed to read icon events\n");
--
2.46.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers
2024-08-30 14:04 ` [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers Linus Walleij
@ 2024-09-01 2:07 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2024-09-01 2:07 UTC (permalink / raw)
To: Linus Walleij; +Cc: Nikita Travkin, linux-input
Hi Linus,
On Fri, Aug 30, 2024 at 04:04:27PM +0200, Linus Walleij wrote:
> The chip hardware revision, firmware version and regdata
> revision is needed to discern because for example touchkeys
> are handled by different registers on different versions of
> the chip. Example output from BT404:
>
> Zinitix-TS 3-0020: chip revision 4040 firmware version 0088
> regdata version 0004
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Move read status into the per-device struct.
Thanks for making this change.
> ---
> drivers/input/touchscreen/zinitix.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
> index 1df93c96f6bf..e47e0bff80db 100644
> --- a/drivers/input/touchscreen/zinitix.c
> +++ b/drivers/input/touchscreen/zinitix.c
> @@ -150,6 +150,10 @@ struct bt541_ts_data {
> u32 zinitix_mode;
> u32 keycodes[MAX_SUPPORTED_BUTTON_NUM];
> int num_keycodes;
> + bool read_versioninfo;
I renamed this to "have_versioninfo" and applied.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] Input: zinitix - Varying icon status registers
2024-08-30 14:04 ` [PATCH v2 2/2] Input: zinitix - Varying icon status registers Linus Walleij
@ 2024-09-01 2:09 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2024-09-01 2:09 UTC (permalink / raw)
To: Linus Walleij; +Cc: Nikita Travkin, linux-input
On Fri, Aug 30, 2024 at 04:04:28PM +0200, Linus Walleij wrote:
> 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>
> ---
> ChangeLog v1->v2:
> - No changes
> ---
> drivers/input/touchscreen/zinitix.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
> index e47e0bff80db..b6b380f5aed5 100644
> --- a/drivers/input/touchscreen/zinitix.c
> +++ b/drivers/input/touchscreen/zinitix.c
> @@ -35,7 +35,13 @@
> #define ZINITIX_DEBUG_REG 0x0115 /* 0~7 */
>
> #define ZINITIX_TOUCH_MODE 0x0010
> +
> #define ZINITIX_CHIP_REVISION 0x0011
> +#define ZINITIX_CHIP_BTX0X_MASK 0xF0F0
> +#define ZINITIX_CHIP_BT4X2 0x4020
> +#define ZINITIX_CHIP_BT4X3 0x4030
> +#define ZINITIX_CHIP_BT4X4 0x4040
> +
> #define ZINITIX_FIRMWARE_VERSION 0x0012
>
> #define ZINITIX_USB_DETECT 0x116
> @@ -63,7 +69,11 @@
> #define ZINITIX_Y_RESOLUTION 0x00C1
>
> #define ZINITIX_POINT_STATUS_REG 0x0080
> -#define ZINITIX_ICON_STATUS_REG 0x00AA
> +
> +#define ZINITIX_BT4X2_ICON_STATUS_REG 0x009A
> +#define ZINITIX_BT4X3_ICON_STATUS_REG 0x00A0
> +#define ZINITIX_BT4X4_ICON_STATUS_REG 0x00A0
> +#define ZINITIX_BT5XX_ICON_STATUS_REG 0x00AA
>
> #define ZINITIX_POINT_COORD_REG (ZINITIX_POINT_STATUS_REG + 2)
>
> @@ -425,7 +435,18 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
> }
>
> if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) {
> - error = zinitix_read_data(bt541->client, ZINITIX_ICON_STATUS_REG,
> + u16 iconstatus;
> +
> + if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X2)
> + iconstatus = ZINITIX_BT4X2_ICON_STATUS_REG;
> + else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X3)
> + iconstatus = ZINITIX_BT4X3_ICON_STATUS_REG;
> + else if ((bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) == ZINITIX_CHIP_BT4X4)
> + iconstatus = ZINITIX_BT4X4_ICON_STATUS_REG;
> + else
> + iconstatus = ZINITIX_BT5XX_ICON_STATUS_REG;
This does not need to be re-calculated every interrupt. I move this into
zinitix_init_touch() and turned into a switch, and applied.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-01 2:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 14:04 [PATCH v2 0/2] Input: zinitix - Handle chip revisions for touchkeys Linus Walleij
2024-08-30 14:04 ` [PATCH v2 1/2] Input: zinitix - Read and cache device version numbers Linus Walleij
2024-09-01 2:07 ` Dmitry Torokhov
2024-08-30 14:04 ` [PATCH v2 2/2] Input: zinitix - Varying icon status registers Linus Walleij
2024-09-01 2:09 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).