From: Linus Walleij <linus.walleij@linaro.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>, linux-input@vger.kernel.org
Cc: Nikita Travkin <nikita@trvn.ru>,
Michael Srba <Michael.Srba@seznam.cz>,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 4/5] Input: zinitix - Read and cache device version numbers
Date: Sun, 10 Apr 2022 14:00:58 +0200 [thread overview]
Message-ID: <20220410120059.2583849-4-linus.walleij@linaro.org> (raw)
In-Reply-To: <20220410120059.2583849-1-linus.walleij@linaro.org>
The chip hardware revision, firmware version and regdata
revision is useful to know, so read this out and print it
the first time we open the device. 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>
---
drivers/input/touchscreen/zinitix.c | 37 +++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index f89dea49cf1f..ea807b972f26 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -35,6 +35,9 @@
#define ZINITIX_TOUCH_MODE 0x0010
#define ZINITIX_CHIP_REVISION 0x0011
+#define ZINITIX_CHIP_BT404 0x4040
+#define ZINITIX_CHIP_BT532 0x5320
+#define ZINITIX_CHIP_BT541 0x5410
#define ZINITIX_FIRMWARE_VERSION 0x0012
#define ZINITIX_USB_DETECT 0x116
@@ -147,6 +150,9 @@ struct bt541_ts_data {
struct touchscreen_properties prop;
struct regulator_bulk_data supplies[2];
u32 zinitix_mode;
+ u16 chip_revision;
+ u16 firmware_version;
+ u16 regdata_version;
};
static int zinitix_read_data(struct i2c_client *client,
@@ -191,11 +197,24 @@ 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;
int i;
int error;
+ static bool read_static = false;
error = zinitix_write_cmd(client, ZINITIX_SWRESET_CMD);
if (error) {
@@ -203,6 +222,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 (!read_static) {
+ 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_info(bt541->dev,
+ "chip revision %04x firmware version %04x regdata version %04x\n",
+ bt541->chip_revision, bt541->firmware_version,
+ bt541->regdata_version);
+ read_static = true;
+ }
+
error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, 0x0);
if (error) {
dev_err(bt541->dev,
--
2.35.1
next prev parent reply other threads:[~2022-04-10 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-10 12:00 [PATCH 1/5] Input: zinitix - Helper dev variable in probe() Linus Walleij
2022-04-10 12:00 ` [PATCH 2/5] Input: zinitix - Add dev variable in state Linus Walleij
2022-05-27 5:37 ` Dmitry Torokhov
2022-05-27 13:31 ` Linus Walleij
2022-04-10 12:00 ` [PATCH 3/5] Input: zinitix - Rename defines ZINITIX_* Linus Walleij
2022-05-27 5:48 ` Dmitry Torokhov
2022-04-10 12:00 ` Linus Walleij [this message]
2022-05-27 5:47 ` [PATCH 4/5] Input: zinitix - Read and cache device version numbers Dmitry Torokhov
2022-04-10 12:00 ` [PATCH 5/5] Input: zinitix - Support calibration Linus Walleij
2022-05-27 5:48 ` Dmitry Torokhov
2022-05-24 12:08 ` [PATCH 1/5] Input: zinitix - Helper dev variable in probe() Linus Walleij
2022-05-27 5:36 ` Dmitry Torokhov
2022-05-27 13:30 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220410120059.2583849-4-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=Michael.Srba@seznam.cz \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=nikita@trvn.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).