Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: st1232 - read firmware version and revision

According to the data sheet, the st1332 contains a firmware, which may
be updated. The version and revision of the firmware may be read from
the registers of the device.

Read the firmware version and revision and report it to the log when
probing the device.

Suggested-by: Khalid Talash <ktalash@topcon.com>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Link: https://patch.msgid.link/20260123-input-st1232-firmware-version-v1-1-32df7eefdafe@pengutronix.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Michael Tretter and committed by
Dmitry Torokhov
004703ba 6075dd69

+37 -1
+37 -1
drivers/input/touchscreen/st1232.c
··· 15 15 #include <linux/i2c.h> 16 16 #include <linux/input.h> 17 17 #include <linux/input/mt.h> 18 + #include <linux/input/touch-overlay.h> 18 19 #include <linux/input/touchscreen.h> 19 20 #include <linux/interrupt.h> 20 21 #include <linux/module.h> ··· 23 22 #include <linux/pm_qos.h> 24 23 #include <linux/slab.h> 25 24 #include <linux/types.h> 26 - #include <linux/input/touch-overlay.h> 25 + #include <asm/byteorder.h> 27 26 28 27 #define ST1232_TS_NAME "st1232-ts" 29 28 #define ST1633_TS_NAME "st1633-ts" 29 + 30 + #define REG_FIRMWARE_VERSION 0x00 31 + #define REG_FIRMWARE_REVISION_3 0x0C 30 32 31 33 #define REG_STATUS 0x01 /* Device Status | Error Code */ 32 34 ··· 65 61 struct list_head touch_overlay_list; 66 62 int read_buf_len; 67 63 u8 *read_buf; 64 + u8 fw_version; 65 + u32 fw_revision; 68 66 }; 69 67 70 68 static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg, ··· 114 108 } 115 109 116 110 return -ENXIO; 111 + } 112 + 113 + static int st1232_ts_read_fw_version(struct st1232_ts_data *ts, 114 + u8 *fw_version, u32 *fw_revision) 115 + { 116 + int error; 117 + 118 + /* select firmware version register */ 119 + error = st1232_ts_read_data(ts, REG_FIRMWARE_VERSION, 1); 120 + if (error) 121 + return error; 122 + *fw_version = ts->read_buf[0]; 123 + 124 + /* select firmware revision register */ 125 + error = st1232_ts_read_data(ts, REG_FIRMWARE_REVISION_3, 4); 126 + if (error) 127 + return error; 128 + *fw_revision = le32_to_cpup((__le32 *)ts->read_buf); 129 + 130 + return 0; 117 131 } 118 132 119 133 static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x, ··· 324 298 error = st1232_ts_wait_ready(ts); 325 299 if (error) 326 300 return error; 301 + 302 + /* Read firmware version from the chip */ 303 + error = st1232_ts_read_fw_version(ts, &ts->fw_version, &ts->fw_revision); 304 + if (error) { 305 + dev_err(&client->dev, 306 + "Failed to read firmware version: %d\n", error); 307 + return error; 308 + } 309 + dev_dbg(&client->dev, "Detected firmware version %u, rev %08x\n", 310 + ts->fw_version, ts->fw_revision); 327 311 328 312 if (ts->chip_info->have_z) 329 313 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,