* [PATCH v2] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
@ 2024-05-13 12:33 Charles Wang
2024-05-13 21:33 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Charles Wang @ 2024-05-13 12:33 UTC (permalink / raw)
To: hadess, hdegoede, dmitry.torokhov, neil.armstrong
Cc: hughsient, broonie, jeff, linux-input, linux-kernel,
charles.goodix
Export a sysfs interface that would allow reading and writing touchscreen
IC registers. With this interface many things can be done in usersapce
such as firmware updates. An example tool that utilizes this interface
for performing firmware updates can be found at [1].
[1] https://github.com/goodix/fwupdate_for_berlin_linux
Signed-off-by: Charles Wang <charles.goodix@gmail.com>
---
Changes in v2:
- use dev_groups to manager device attributes.
- use dev_get_regmap to make show/store functions generic.
- v1: https://lore.kernel.org/all/20240506114752.47204-1-charles.goodix@gmail.com/
---
drivers/input/touchscreen/goodix_berlin.h | 1 +
.../input/touchscreen/goodix_berlin_core.c | 42 +++++++++++++++++++
drivers/input/touchscreen/goodix_berlin_i2c.c | 1 +
drivers/input/touchscreen/goodix_berlin_spi.c | 1 +
4 files changed, 45 insertions(+)
diff --git a/drivers/input/touchscreen/goodix_berlin.h b/drivers/input/touchscreen/goodix_berlin.h
index 1fd77eb69..38b6f9ddb 100644
--- a/drivers/input/touchscreen/goodix_berlin.h
+++ b/drivers/input/touchscreen/goodix_berlin.h
@@ -20,5 +20,6 @@ int goodix_berlin_probe(struct device *dev, int irq, const struct input_id *id,
struct regmap *regmap);
extern const struct dev_pm_ops goodix_berlin_pm_ops;
+extern const struct attribute_group *goodix_berlin_groups[];
#endif
diff --git a/drivers/input/touchscreen/goodix_berlin_core.c b/drivers/input/touchscreen/goodix_berlin_core.c
index e7b41a926..e90fccfc4 100644
--- a/drivers/input/touchscreen/goodix_berlin_core.c
+++ b/drivers/input/touchscreen/goodix_berlin_core.c
@@ -672,6 +672,48 @@ static void goodix_berlin_power_off_act(void *data)
goodix_berlin_power_off(cd);
}
+static ssize_t registers_read(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct regmap *regmap;
+ int error;
+
+ regmap = dev_get_regmap(kobj_to_dev(kobj), NULL);
+ error = regmap_raw_read(regmap, (unsigned int)off,
+ buf, count);
+
+ return error ? error : count;
+}
+
+static ssize_t registers_write(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
+{
+ struct regmap *regmap;
+ int error;
+
+ regmap = dev_get_regmap(kobj_to_dev(kobj), NULL);
+ error = regmap_raw_write(regmap, (unsigned int)off,
+ buf, count);
+
+ return error ? error : count;
+}
+
+BIN_ATTR_RW(registers, 0);
+
+static struct bin_attribute *goodix_berlin_bin_attrs[] = {
+ &bin_attr_registers,
+ NULL,
+};
+
+static const struct attribute_group goodix_berlin_attr_group = {
+ .bin_attrs = goodix_berlin_bin_attrs,
+};
+
+const struct attribute_group *goodix_berlin_groups[] = {
+ &goodix_berlin_attr_group,
+ NULL,
+};
+
int goodix_berlin_probe(struct device *dev, int irq, const struct input_id *id,
struct regmap *regmap)
{
diff --git a/drivers/input/touchscreen/goodix_berlin_i2c.c b/drivers/input/touchscreen/goodix_berlin_i2c.c
index 6ed9aa808..b5f48315c 100644
--- a/drivers/input/touchscreen/goodix_berlin_i2c.c
+++ b/drivers/input/touchscreen/goodix_berlin_i2c.c
@@ -64,6 +64,7 @@ static struct i2c_driver goodix_berlin_i2c_driver = {
.name = "goodix-berlin-i2c",
.of_match_table = goodix_berlin_i2c_of_match,
.pm = pm_sleep_ptr(&goodix_berlin_pm_ops),
+ .dev_groups = goodix_berlin_groups,
},
.probe = goodix_berlin_i2c_probe,
.id_table = goodix_berlin_i2c_id,
diff --git a/drivers/input/touchscreen/goodix_berlin_spi.c b/drivers/input/touchscreen/goodix_berlin_spi.c
index 4cc557da0..fe5739097 100644
--- a/drivers/input/touchscreen/goodix_berlin_spi.c
+++ b/drivers/input/touchscreen/goodix_berlin_spi.c
@@ -167,6 +167,7 @@ static struct spi_driver goodix_berlin_spi_driver = {
.name = "goodix-berlin-spi",
.of_match_table = goodix_berlin_spi_of_match,
.pm = pm_sleep_ptr(&goodix_berlin_pm_ops),
+ .dev_groups = goodix_berlin_groups,
},
.probe = goodix_berlin_spi_probe,
.id_table = goodix_berlin_spi_ids,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
2024-05-13 12:33 [PATCH v2] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers Charles Wang
@ 2024-05-13 21:33 ` Dmitry Torokhov
2024-05-14 11:41 ` Charles Wang
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2024-05-13 21:33 UTC (permalink / raw)
To: Charles Wang
Cc: hadess, hdegoede, neil.armstrong, hughsient, broonie, jeff,
linux-input, linux-kernel
Hi Charles,
On Mon, May 13, 2024 at 08:33:37PM +0800, Charles Wang wrote:
> +
> +const struct attribute_group *goodix_berlin_groups[] = {
> + &goodix_berlin_attr_group,
> + NULL,
> +};
This symbol needs to be exportedsymbol needs to be exported..
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
2024-05-13 21:33 ` Dmitry Torokhov
@ 2024-05-14 11:41 ` Charles Wang
0 siblings, 0 replies; 3+ messages in thread
From: Charles Wang @ 2024-05-14 11:41 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: hadess, hdegoede, neil.armstrong, hughsient, broonie, jeff,
linux-input, linux-kernel
On Mon, May 13, 2024 at 02:33:15PM -0700, Dmitry Torokhov wrote:
> Hi Charles,
>
> On Mon, May 13, 2024 at 08:33:37PM +0800, Charles Wang wrote:
> > +
> > +const struct attribute_group *goodix_berlin_groups[] = {
> > + &goodix_berlin_attr_group,
> > + NULL,
> > +};
>
> This symbol needs to be exportedsymbol needs to be exported..
>
Ack
Thanks
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-14 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-13 12:33 [PATCH v2] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers Charles Wang
2024-05-13 21:33 ` Dmitry Torokhov
2024-05-14 11:41 ` Charles Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox