summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorCharles Wang <charles.goodix@gmail.com>2024-05-15 16:20:28 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2024-07-19 14:57:17 -0700
commit240801c5f4f64616569990f744a81448c3d314b6 (patch)
tree800df90ee97d0863a974cd577eb4897740a1454f /drivers/input/touchscreen
parent2f99ffd8d730caddadb5e0257ff8c3faf16c6ee6 (diff)
downloadlwn-240801c5f4f64616569990f744a81448c3d314b6.tar.gz
lwn-240801c5f4f64616569990f744a81448c3d314b6.zip
Input: goodix-berlin - add sysfs interface for reading and writing touch IC registers
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> Link: https://lore.kernel.org/r/20240514115135.21410-1-charles.goodix@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/goodix_berlin.h1
-rw-r--r--drivers/input/touchscreen/goodix_berlin_core.c43
-rw-r--r--drivers/input/touchscreen/goodix_berlin_i2c.c1
-rw-r--r--drivers/input/touchscreen/goodix_berlin_spi.c1
4 files changed, 46 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/goodix_berlin.h b/drivers/input/touchscreen/goodix_berlin.h
index 1fd77eb69c9a..38b6f9ddbdef 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 e7b41a926ef8..0bfca897ce5a 100644
--- a/drivers/input/touchscreen/goodix_berlin_core.c
+++ b/drivers/input/touchscreen/goodix_berlin_core.c
@@ -672,6 +672,49 @@ 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 device *dev = kobj_to_dev(kobj);
+ struct goodix_berlin_core *cd = dev_get_drvdata(dev);
+ int error;
+
+ error = regmap_raw_read(cd->regmap, 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 device *dev = kobj_to_dev(kobj);
+ struct goodix_berlin_core *cd = dev_get_drvdata(dev);
+ int error;
+
+ error = regmap_raw_write(cd->regmap, off, buf, count);
+
+ return error ? error : count;
+}
+
+static BIN_ATTR_ADMIN_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,
+};
+EXPORT_SYMBOL_GPL(goodix_berlin_groups);
+
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 2e7098078838..ad7a60d94338 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 82774a412956..a2d80e84391b 100644
--- a/drivers/input/touchscreen/goodix_berlin_spi.c
+++ b/drivers/input/touchscreen/goodix_berlin_spi.c
@@ -169,6 +169,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,