2021-07-08 12:01:55

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 0/9] Add Wacom I2C support to rM2

Add support to the reMarkable2 (rM2) for the Wacom I2C device.

This is based on the reMarkable Linux fork and with this series I am
able to probe the Wacom digitiser.

v7:
- Fx the compatible name and documentation

Alistair Francis (9):
dt-bindings: Add Wacom to vendor bindings
dt-bindings: touchscreen: Initial commit of wacom,i2c
Input: wacom_i2c - Add device tree support to wacom_i2c
Input: wacom_i2c - Add touchscren properties
Input: wacom_i2c - Add support for distance and tilt x/y
Input: wacom_i2c - Clean up the query device fields
Input: wacom_i2c - Add support for vdd regulator
ARM: imx_v6_v7_defconfig: Enable Wacom I2C
ARM: dts: imx7d: remarkable2: add wacom digitizer device

.../input/touchscreen/wacom,generic.yaml | 48 ++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +++++++
arch/arm/configs/imx_v6_v7_defconfig | 1 +
drivers/input/touchscreen/wacom_i2c.c | 155 ++++++++++++++----
5 files changed, 233 insertions(+), 34 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

--
2.31.1


2021-07-08 12:01:58

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 1/9] dt-bindings: Add Wacom to vendor bindings

Signed-off-by: Alistair Francis <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: [email protected]
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 2bbc27aae977..0199728d2eaf 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1244,6 +1244,8 @@ patternProperties:
description: Vision Optical Technology Co., Ltd.
"^vxt,.*":
description: VXT Ltd
+ "^wacom,.*":
+ description: Wacom Co., Ltd
"^wand,.*":
description: Wandbord (Technexion)
"^waveshare,.*":
--
2.31.1

2021-07-08 12:01:58

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 9/9] ARM: dts: imx7d: remarkable2: add wacom digitizer device

Enable the wacom_i2c touchscreen for the reMarkable2.

Signed-off-by: Alistair Francis <[email protected]>
---
arch/arm/boot/dts/imx7d-remarkable2.dts | 61 +++++++++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d-remarkable2.dts b/arch/arm/boot/dts/imx7d-remarkable2.dts
index 89cbf13097a4..cc33b53ae6ba 100644
--- a/arch/arm/boot/dts/imx7d-remarkable2.dts
+++ b/arch/arm/boot/dts/imx7d-remarkable2.dts
@@ -34,6 +34,19 @@ reg_brcm: regulator-brcm {
startup-delay-us = <150>;
};

+ reg_digitizer: regulator-digitizer {
+ compatible = "regulator-fixed";
+ regulator-name = "VDD_3V3_DIGITIZER";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ pinctrl-names = "default", "sleep";
+ pinctrl-0 = <&pinctrl_digitizer_reg>;
+ pinctrl-1 = <&pinctrl_digitizer_reg>;
+ gpio = <&gpio1 6 GPIO_ACTIVE_HIGH>;
+ enable-active-high;
+ startup-delay-us = <100000>; /* 100 ms */
+ };
+
wifi_pwrseq: wifi_pwrseq {
compatible = "mmc-pwrseq-simple";
pinctrl-names = "default";
@@ -51,6 +64,28 @@ &clks {
assigned-clock-rates = <0>, <32768>;
};

+&i2c1 {
+ clock-frequency = <400000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c1>;
+ status = "okay";
+
+ wacom_digitizer: digitizer@9 {
+ compatible = "wacom,i2c-30";
+ reg = <0x09>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_wacom>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
+ flip-tilt-x;
+ flip-tilt-y;
+ flip-pos-x;
+ flip-pos-y;
+ flip-distance;
+ vdd-supply = <&reg_digitizer>;
+ };
+};
+
&snvs_pwrkey {
status = "okay";
};
@@ -117,6 +152,25 @@ &wdog1 {
fsl,ext-reset-output;
};

+&iomuxc_lpsr {
+ pinctrl_digitizer_reg: digitizerreggrp {
+ fsl,pins = <
+ /* DIGITIZER_PWR_EN */
+ MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6 0x14
+ >;
+ };
+
+ pinctrl_wacom: wacomgrp {
+ fsl,pins = <
+ /*MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5 0x00000014 /* FWE */
+ MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x00000074 /* PDCTB */
+ MX7D_PAD_LPSR_GPIO1_IO01__GPIO1_IO1 0x00000034 /* WACOM INT */
+ /*MX7D_PAD_LPSR_GPIO1_IO06__GPIO1_IO6 0x00000014 /* WACOM PWR ENABLE */
+ /*MX7D_PAD_LPSR_GPIO1_IO00__GPIO1_IO0 0x00000074 /* WACOM RESET */
+ >;
+ };
+};
+
&iomuxc {
pinctrl_brcm_reg: brcmreggrp {
fsl,pins = <
@@ -125,6 +179,13 @@ MX7D_PAD_SAI1_TX_BCLK__GPIO6_IO13 0x14
>;
};

+ pinctrl_i2c1: i2c1grp {
+ fsl,pins = <
+ MX7D_PAD_I2C1_SDA__I2C1_SDA 0x4000007f
+ MX7D_PAD_I2C1_SCL__I2C1_SCL 0x4000007f
+ >;
+ };
+
pinctrl_uart1: uart1grp {
fsl,pins = <
MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX 0x79
--
2.31.1

2021-07-08 12:02:54

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 7/9] Input: wacom_i2c - Add support for vdd regulator

Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

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

diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index 49d1c15e623c..df77b17835e4 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
#include <linux/irq.h>
#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
+#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/of.h>
#include <asm/unaligned.h>
@@ -59,6 +60,7 @@ struct wacom_i2c {
struct input_dev *input;
struct touchscreen_properties props;
struct wacom_features features;
+ struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -222,11 +224,24 @@ static int wacom_i2c_probe(struct i2c_client *client,
if (error)
return error;

+ wac_i2c->vdd = regulator_get(&client->dev, "vdd");
+ if (IS_ERR(wac_i2c->vdd))
+ return PTR_ERR(wac_i2c->vdd);
+
+ error = regulator_enable(wac_i2c->vdd);
+ if (error) {
+ regulator_put(wac_i2c->vdd);
+ return error;
+ }
+
wac_i2c->client = client;

input = devm_input_allocate_device(dev);
- if (!input)
+ if (!input) {
+ regulator_disable(wac_i2c->vdd);
+ regulator_put(wac_i2c->vdd);
return -ENOMEM;
+ }

wac_i2c->input = input;

@@ -261,6 +276,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
IRQF_ONESHOT, "wacom_i2c", wac_i2c);
if (error) {
dev_err(dev, "Failed to request IRQ: %d\n", error);
+ regulator_disable(wac_i2c->vdd);
+ regulator_put(wac_i2c->vdd);
return error;
}

@@ -270,6 +287,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
error = input_register_device(wac_i2c->input);
if (error) {
dev_err(dev, "Failed to register input device: %d\n", error);
+ regulator_disable(wac_i2c->vdd);
+ regulator_put(wac_i2c->vdd);
return error;
}

--
2.31.1

2021-07-08 12:03:25

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 6/9] Input: wacom_i2c - Clean up the query device fields

Improve the query device fields to be more verbose.

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

diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index e2449a4fa2e3..49d1c15e623c 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
#include <linux/irq.h>
#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
+#include <linux/reset.h>
#include <linux/of.h>
#include <asm/unaligned.h>

-#define WACOM_CMD_QUERY0 0x04
-#define WACOM_CMD_QUERY1 0x00
-#define WACOM_CMD_QUERY2 0x33
-#define WACOM_CMD_QUERY3 0x02
-#define WACOM_CMD_THROW0 0x05
-#define WACOM_CMD_THROW1 0x00
+// Registers
+#define WACOM_COMMAND_LSB 0x04
+#define WACOM_COMMAND_MSB 0x00
+
+#define WACOM_DATA_LSB 0x05
+#define WACOM_DATA_MSB 0x00
+
+// Report types
+#define REPORT_FEATURE 0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT 0x02
+
+// Power settings
+#define POWER_ON 0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT 2
+#define WACOM_SHINONOME_REPORT 26
+
+#define WACOM_QUERY_REPORT 3
#define WACOM_QUERY_SIZE 22

#define WACOM_DISTANCE_TILT_VERSION 0x30
@@ -51,27 +68,30 @@ static int wacom_query_device(struct i2c_client *client,
struct wacom_features *features)
{
int ret;
- u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
- WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
- u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+
+ u8 get_query_data_cmd[] = {
+ WACOM_COMMAND_LSB,
+ WACOM_COMMAND_MSB,
+ REPORT_FEATURE | WACOM_QUERY_REPORT,
+ OPCODE_GET_REPORT,
+ WACOM_DATA_LSB,
+ WACOM_DATA_MSB,
+ };
+
struct i2c_msg msgs[] = {
+ // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
- .len = sizeof(cmd1),
- .buf = cmd1,
- },
- {
- .addr = client->addr,
- .flags = 0,
- .len = sizeof(cmd2),
- .buf = cmd2,
+ .len = sizeof(get_query_data_cmd),
+ .buf = get_query_data_cmd,
},
+ // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
- .len = sizeof(data),
+ .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
@@ -99,9 +119,13 @@ static int wacom_query_device(struct i2c_client *client,
}

dev_dbg(&client->dev,
- "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+ "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+ "distance: %d, phys distance: %d, "
+ "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
- features->pressure_max, features->fw_version);
+ features->pressure_max, features->fw_version,
+ features->distance_max, features->distance_physical_max,
+ features->tilt_x_max, features->tilt_y_max);

return 0;
}
--
2.31.1

2021-07-08 12:03:54

by Alistair Francis

[permalink] [raw]
Subject: [PATCH v7 8/9] ARM: imx_v6_v7_defconfig: Enable Wacom I2C

Enable the Wacom I2C in the imx defconfig as it is used by the
reMarkable2 tablet.

Signed-off-by: Alistair Francis <[email protected]>
---
arch/arm/configs/imx_v6_v7_defconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 70928cc48939..cd80e85d37cf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -174,6 +174,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
CONFIG_TOUCHSCREEN_EGALAX=y
CONFIG_TOUCHSCREEN_GOODIX=y
CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
CONFIG_TOUCHSCREEN_MAX11801=y
CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
CONFIG_TOUCHSCREEN_EDT_FT5X06=y
--
2.31.1

2021-07-12 17:22:53

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v7 1/9] dt-bindings: Add Wacom to vendor bindings

On Thu, 08 Jul 2021 21:58:45 +1000, Alistair Francis wrote:
> Signed-off-by: Alistair Francis <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: [email protected]
> ---
> Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>

Acked-by: Rob Herring <[email protected]>