* [PATCH 0/2] Input: st1232 - add support for firmware version
@ 2026-01-23 16:28 Michael Tretter
2026-01-23 16:28 ` [PATCH 1/2] Input: st1232 - read firmware version and revision Michael Tretter
2026-01-23 16:28 ` [PATCH 2/2] Input: st1232 - expose firmware version via sysfs Michael Tretter
0 siblings, 2 replies; 6+ messages in thread
From: Michael Tretter @ 2026-01-23 16:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, kernel, Michael Tretter, Khalid Talash
The st1332 runs a firmware and reports the version and revision of the
firmware via the registers of the device.
Read the firmware version and revision from the respective registers,
print it to the log and report it via sysfs.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Michael Tretter (2):
Input: st1232 - read firmware version and revision
Input: st1232 - expose firmware version via sysfs
drivers/input/touchscreen/st1232.c | 66 ++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
---
base-commit: c072629f05d7bca1148ab17690d7922a31423984
change-id: 20260123-input-st1232-firmware-version-05cdf03d85c4
Best regards,
--
Michael Tretter <m.tretter@pengutronix.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Input: st1232 - read firmware version and revision
2026-01-23 16:28 [PATCH 0/2] Input: st1232 - add support for firmware version Michael Tretter
@ 2026-01-23 16:28 ` Michael Tretter
2026-02-05 9:17 ` Dmitry Torokhov
2026-01-23 16:28 ` [PATCH 2/2] Input: st1232 - expose firmware version via sysfs Michael Tretter
1 sibling, 1 reply; 6+ messages in thread
From: Michael Tretter @ 2026-01-23 16:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, kernel, Michael Tretter, Khalid Talash
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>
---
drivers/input/touchscreen/st1232.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 9b3901eec0a5..3362ee83b21d 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -22,11 +22,15 @@
#include <linux/pm_qos.h>
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/unaligned.h>
#include <linux/input/touch-overlay.h>
#define ST1232_TS_NAME "st1232-ts"
#define ST1633_TS_NAME "st1633-ts"
+#define REG_FIRMWARE_VERSION 0x00
+#define REG_FIRMWARE_REVISION_3 0x0C
+
#define REG_STATUS 0x01 /* Device Status | Error Code */
#define STATUS_NORMAL 0x00
@@ -61,6 +65,8 @@ struct st1232_ts_data {
struct list_head touch_overlay_list;
int read_buf_len;
u8 *read_buf;
+ u8 fw_version;
+ u32 fw_revision;
};
static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg,
@@ -110,6 +116,26 @@ static int st1232_ts_wait_ready(struct st1232_ts_data *ts)
return -ENXIO;
}
+static int st1232_ts_read_fw_version(struct st1232_ts_data *ts,
+ u8 *fw_version, u32 *fw_revision)
+{
+ int error;
+
+ /* select firmware version register */
+ error = st1232_ts_read_data(ts, REG_FIRMWARE_VERSION, 1);
+ if (error)
+ return error;
+ *fw_version = ts->read_buf[0];
+
+ /* select firmware revision register */
+ error = st1232_ts_read_data(ts, REG_FIRMWARE_REVISION_3, 4);
+ if (error)
+ return error;
+ *fw_revision = get_unaligned_le32(ts->read_buf);
+
+ return 0;
+}
+
static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
u16 *max_y)
{
@@ -299,6 +325,17 @@ static int st1232_ts_probe(struct i2c_client *client)
if (error)
return error;
+ /* Read firmware version from the chip */
+ error = st1232_ts_read_fw_version(ts,
+ &ts->fw_version, &ts->fw_revision);
+ if (error) {
+ dev_err(&client->dev,
+ "Failed to read firmware version: %d\n", error);
+ return error;
+ }
+ dev_dbg(&client->dev, "Detected firmware version %u, rev %08x\n",
+ ts->fw_version, ts->fw_revision);
+
if (ts->chip_info->have_z)
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
ts->chip_info->max_area, 0, 0);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Input: st1232 - expose firmware version via sysfs
2026-01-23 16:28 [PATCH 0/2] Input: st1232 - add support for firmware version Michael Tretter
2026-01-23 16:28 ` [PATCH 1/2] Input: st1232 - read firmware version and revision Michael Tretter
@ 2026-01-23 16:28 ` Michael Tretter
1 sibling, 0 replies; 6+ messages in thread
From: Michael Tretter @ 2026-01-23 16:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, kernel, Michael Tretter, Khalid Talash
Allow user space programs to read the firmware version and revision of
the touch controller from the sysfs.
Suggested-by: Khalid Talash <ktalash@topcon.com>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
drivers/input/touchscreen/st1232.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 3362ee83b21d..0da7f2cec60d 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -69,6 +69,34 @@ struct st1232_ts_data {
u32 fw_revision;
};
+static ssize_t fw_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct st1232_ts_data *st1232_ts = i2c_get_clientdata(client);
+
+ return sysfs_emit(buf, "%u\n", st1232_ts->fw_version);
+}
+
+static ssize_t fw_revision_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct st1232_ts_data *st1232_ts = i2c_get_clientdata(client);
+
+ return sysfs_emit(buf, "%08x\n", st1232_ts->fw_revision);
+}
+
+static DEVICE_ATTR_RO(fw_version);
+static DEVICE_ATTR_RO(fw_revision);
+
+static struct attribute *st1232_attrs[] = {
+ &dev_attr_fw_version.attr,
+ &dev_attr_fw_revision.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(st1232);
+
static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg,
unsigned int n)
{
@@ -445,6 +473,7 @@ static struct i2c_driver st1232_ts_driver = {
.driver = {
.name = ST1232_TS_NAME,
.of_match_table = st1232_ts_dt_ids,
+ .dev_groups = st1232_groups,
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
.pm = pm_sleep_ptr(&st1232_ts_pm_ops),
},
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: st1232 - read firmware version and revision
2026-01-23 16:28 ` [PATCH 1/2] Input: st1232 - read firmware version and revision Michael Tretter
@ 2026-02-05 9:17 ` Dmitry Torokhov
2026-02-06 14:50 ` Michael Tretter
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2026-02-05 9:17 UTC (permalink / raw)
To: Michael Tretter; +Cc: linux-input, kernel, Khalid Talash
Hi Michael,
On Fri, Jan 23, 2026 at 05:28:55PM +0100, Michael Tretter wrote:
> +static int st1232_ts_read_fw_version(struct st1232_ts_data *ts,
> + u8 *fw_version, u32 *fw_revision)
> +{
> + int error;
> +
> + /* select firmware version register */
> + error = st1232_ts_read_data(ts, REG_FIRMWARE_VERSION, 1);
> + if (error)
> + return error;
> + *fw_version = ts->read_buf[0];
> +
> + /* select firmware revision register */
> + error = st1232_ts_read_data(ts, REG_FIRMWARE_REVISION_3, 4);
> + if (error)
> + return error;
> + *fw_revision = get_unaligned_le32(ts->read_buf);
Why unaligned? You are not reading at an offset and allocated memory is
cache line aligned.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: st1232 - read firmware version and revision
2026-02-05 9:17 ` Dmitry Torokhov
@ 2026-02-06 14:50 ` Michael Tretter
2026-03-18 11:42 ` Michael Tretter
0 siblings, 1 reply; 6+ messages in thread
From: Michael Tretter @ 2026-02-06 14:50 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, kernel, Khalid Talash
Hi Dmitry,
On Thu, 05 Feb 2026 01:17:17 -0800, Dmitry Torokhov wrote:
> Hi Michael,
>
> On Fri, Jan 23, 2026 at 05:28:55PM +0100, Michael Tretter wrote:
> > +static int st1232_ts_read_fw_version(struct st1232_ts_data *ts,
> > + u8 *fw_version, u32 *fw_revision)
> > +{
> > + int error;
> > +
> > + /* select firmware version register */
> > + error = st1232_ts_read_data(ts, REG_FIRMWARE_VERSION, 1);
> > + if (error)
> > + return error;
> > + *fw_version = ts->read_buf[0];
> > +
> > + /* select firmware revision register */
> > + error = st1232_ts_read_data(ts, REG_FIRMWARE_REVISION_3, 4);
> > + if (error)
> > + return error;
> > + *fw_revision = get_unaligned_le32(ts->read_buf);
>
> Why unaligned? You are not reading at an offset and allocated memory is
> cache line aligned.
I copied what other touchscreen drivers were doing to read the version,
but missed that they either read at an offset or use a buffer on the
stack.
Should I send a v2 or can you change this to le32_to_cpu() while
applying the patch?
Thanks!
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Input: st1232 - read firmware version and revision
2026-02-06 14:50 ` Michael Tretter
@ 2026-03-18 11:42 ` Michael Tretter
0 siblings, 0 replies; 6+ messages in thread
From: Michael Tretter @ 2026-03-18 11:42 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, kernel, Khalid Talash
On Fri, 06 Feb 2026 15:50:13 +0100, Michael Tretter wrote:
> On Thu, 05 Feb 2026 01:17:17 -0800, Dmitry Torokhov wrote:
> > On Fri, Jan 23, 2026 at 05:28:55PM +0100, Michael Tretter wrote:
> > > +static int st1232_ts_read_fw_version(struct st1232_ts_data *ts,
> > > + u8 *fw_version, u32 *fw_revision)
> > > +{
> > > + int error;
> > > +
> > > + /* select firmware version register */
> > > + error = st1232_ts_read_data(ts, REG_FIRMWARE_VERSION, 1);
> > > + if (error)
> > > + return error;
> > > + *fw_version = ts->read_buf[0];
> > > +
> > > + /* select firmware revision register */
> > > + error = st1232_ts_read_data(ts, REG_FIRMWARE_REVISION_3, 4);
> > > + if (error)
> > > + return error;
> > > + *fw_revision = get_unaligned_le32(ts->read_buf);
> >
> > Why unaligned? You are not reading at an offset and allocated memory is
> > cache line aligned.
>
> I copied what other touchscreen drivers were doing to read the version,
> but missed that they either read at an offset or use a buffer on the
> stack.
>
> Should I send a v2 or can you change this to le32_to_cpu() while
> applying the patch?
I just sent a v2.
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-18 11:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 16:28 [PATCH 0/2] Input: st1232 - add support for firmware version Michael Tretter
2026-01-23 16:28 ` [PATCH 1/2] Input: st1232 - read firmware version and revision Michael Tretter
2026-02-05 9:17 ` Dmitry Torokhov
2026-02-06 14:50 ` Michael Tretter
2026-03-18 11:42 ` Michael Tretter
2026-01-23 16:28 ` [PATCH 2/2] Input: st1232 - expose firmware version via sysfs Michael Tretter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox