Skip to content

Commit 5278bb4

Browse files
Linus Walleijdtor
authored andcommitted
Input: zinitix - read and cache device version numbers
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> Link: https://lore.kernel.org/r/20240830-zinitix-tk-versions-v2-1-90eae6817eda@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 092b7d4 commit 5278bb4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

drivers/input/touchscreen/zinitix.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ struct bt541_ts_data {
150150
u32 zinitix_mode;
151151
u32 keycodes[MAX_SUPPORTED_BUTTON_NUM];
152152
int num_keycodes;
153+
bool have_versioninfo;
154+
u16 chip_revision;
155+
u16 firmware_version;
156+
u16 regdata_version;
153157
};
154158

155159
static int zinitix_read_data(struct i2c_client *client,
@@ -194,6 +198,19 @@ static int zinitix_write_cmd(struct i2c_client *client, u16 reg)
194198
return 0;
195199
}
196200

201+
static u16 zinitix_get_u16_reg(struct bt541_ts_data *bt541, u16 vreg)
202+
{
203+
struct i2c_client *client = bt541->client;
204+
int error;
205+
__le16 val;
206+
207+
error = zinitix_read_data(client, vreg, (void *)&val, 2);
208+
if (error)
209+
return U8_MAX;
210+
211+
return le16_to_cpu(val);
212+
}
213+
197214
static int zinitix_init_touch(struct bt541_ts_data *bt541)
198215
{
199216
struct i2c_client *client = bt541->client;
@@ -207,6 +224,25 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541)
207224
return error;
208225
}
209226

227+
/*
228+
* Read and cache the chip revision and firmware version the first time
229+
* we get here.
230+
*/
231+
if (!bt541->have_versioninfo) {
232+
bt541->chip_revision = zinitix_get_u16_reg(bt541,
233+
ZINITIX_CHIP_REVISION);
234+
bt541->firmware_version = zinitix_get_u16_reg(bt541,
235+
ZINITIX_FIRMWARE_VERSION);
236+
bt541->regdata_version = zinitix_get_u16_reg(bt541,
237+
ZINITIX_DATA_VERSION_REG);
238+
bt541->have_versioninfo = true;
239+
240+
dev_dbg(&client->dev,
241+
"chip revision %04x firmware version %04x regdata version %04x\n",
242+
bt541->chip_revision, bt541->firmware_version,
243+
bt541->regdata_version);
244+
}
245+
210246
error = zinitix_write_u16(client, ZINITIX_INT_ENABLE_FLAG, 0x0);
211247
if (error) {
212248
dev_err(&client->dev,

0 commit comments

Comments
 (0)