2021-01-17 23:50:27

by Alistair Francis

[permalink] [raw]
Subject: [PATCH 2/3] input/touchscreen: Add device tree support to wacom_i2c

Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis <[email protected]>
---
drivers/input/touchscreen/wacom_i2c.c | 38 +++++++++++++++++++++++++++
1 file changed, 38 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..54af2934ba17 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
+#include <linux/of.h>
#include <asm/unaligned.h>

#define WACOM_CMD_QUERY0 0x04
@@ -35,6 +36,13 @@ struct wacom_i2c {
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
+
+ bool flip_tilt_x;
+ bool flip_tilt_y;
+ bool flip_pos_x;
+ bool flip_pos_y;
+ bool flip_distance;
+ bool flip_pressure;
};

static int wacom_query_device(struct i2c_client *client,
@@ -144,6 +152,20 @@ static void wacom_i2c_close(struct input_dev *dev)
disable_irq(client->irq);
}

+#ifdef CONFIG_OF
+static void wacom_of_read(struct wacom_i2c *wac_i2c)
+{
+ struct i2c_client *client = wac_i2c->client;
+
+ wac_i2c->flip_tilt_x = of_property_read_bool(client->dev.of_node, "flip-tilt-x");
+ wac_i2c->flip_tilt_y = of_property_read_bool(client->dev.of_node, "flip-tilt-y");
+ wac_i2c->flip_pos_x = of_property_read_bool(client->dev.of_node, "flip-pos-x");
+ wac_i2c->flip_pos_y = of_property_read_bool(client->dev.of_node, "flip-pos-y");
+ wac_i2c->flip_distance = of_property_read_bool(client->dev.of_node, "flip-distance");
+ wac_i2c->flip_pressure = of_property_read_bool(client->dev.of_node, "flip-pressure");
+}
+#endif
+
static int wacom_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -214,6 +236,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
}

i2c_set_clientdata(client, wac_i2c);
+
+#ifdef CONFIG_OF
+ wacom_of_read(wac_i2c);
+#endif
+
return 0;

err_free_irq:
@@ -262,10 +289,21 @@ static const struct i2c_device_id wacom_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);

+#ifdef CONFIG_OF
+static const struct of_device_id wacom_i2c_of_match_table[] = {
+ { .compatible = "wacom,wacom-i2c" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+#endif
+
static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name = "wacom_i2c",
.pm = &wacom_i2c_pm,
+#ifdef CONFIG_OF
+ .of_match_table = of_match_ptr(wacom_i2c_of_match_table),
+#endif
},

.probe = wacom_i2c_probe,
--
2.29.2


2021-01-20 02:20:59

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 2/3] input/touchscreen: Add device tree support to wacom_i2c

On Sat, Jan 16, 2021 at 08:24:27PM -0800, Alistair Francis wrote:
> Allow the wacom-i2c device to be exposed via device tree.

The patch seems incomplete. I see we are reading and storing properties,
but we are not using them whatsoever, so I do not see the reason to have
this in this form.

Thanks.

--
Dmitry

2021-01-21 06:56:16

by Alistair Francis

[permalink] [raw]
Subject: Re: [PATCH 2/3] input/touchscreen: Add device tree support to wacom_i2c

On Tue, Jan 19, 2021 at 6:17 PM Dmitry Torokhov
<[email protected]> wrote:
>
> On Sat, Jan 16, 2021 at 08:24:27PM -0800, Alistair Francis wrote:
> > Allow the wacom-i2c device to be exposed via device tree.
>
> The patch seems incomplete. I see we are reading and storing properties,
> but we are not using them whatsoever, so I do not see the reason to have
> this in this form.

Good point. I am trying to split up the work, but I guess here I split
it up a little too much. I'm sending a v2 that should fix this.

Alistair

>
> Thanks.
>
> --
> Dmitry