diff mbox series

[1/2] dt-bindings: input/touchscreen: add bindings for msg26xx

Message ID 20210120180119.849588-1-vincent.knecht@mailoo.org
State Superseded
Headers show
Series [1/2] dt-bindings: input/touchscreen: add bindings for msg26xx | expand

Commit Message

Vincent Knecht Jan. 20, 2021, 6:01 p.m. UTC
This adds dts bindings for the mstar msg26xx touchscreen.

Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
---
 .../input/touchscreen/mstar,msg26xx.yaml      | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/mstar,msg26xx.yaml

Comments

Dmitry Torokhov Jan. 21, 2021, 7:03 a.m. UTC | #1
Hi Vincent,

On Wed, Jan 20, 2021 at 07:01:08PM +0100, Vincent Knecht wrote:
> +struct packet {

> +	u8	y_high : 4;

> +	u8	x_high : 4;


This will not work on big endian devices as order of bitfields changes.
I'd recommended treating contact packet as sequence of bytes and parse,
i.e.

	x = ((buf[0] & 0x0f) << 8) | buf[1];
	x = ((buf[0] & 0xf0) << 4) | buf[2];
	...

> +	u8	x_low;

> +	u8	y_low;

> +	u8	pressure;

> +};

> +

> +

> +static void mstar_power_on(struct msg26xx_ts_data *msg26xx)

> +{

> +	gpiod_set_value(msg26xx->reset_gpiod, 0);

> +	mdelay(10);

> +	gpiod_set_value(msg26xx->reset_gpiod, 1);

> +	mdelay(FIRMWARE_ON_DELAY);


I am pretty sure this is incorrect. You are saying that you release the
reset line, wait a bit, and then assert it. gpiod is a logical API, with
0 being inactive and 1 being active, and here you want to activate the
reset line, wait appropriate time, release it, and wait for the device
to initialize. What does the datasheet say about reset GPIO polarity?

Thanks.

-- 
Dmitry
Vincent Knecht Jan. 21, 2021, 11:32 a.m. UTC | #2
Hi Dmitry!

Le mercredi 20 janvier 2021 à 23:03 -0800, Dmitry Torokhov a écrit :
> Hi Vincent,

> 

> On Wed, Jan 20, 2021 at 07:01:08PM +0100, Vincent Knecht wrote:

> > +struct packet {

> > +       u8      y_high : 4;

> > +       u8      x_high : 4;

> 

> This will not work on big endian devices as order of bitfields changes.

> I'd recommended treating contact packet as sequence of bytes and parse,

> i.e.

> 

>         x = ((buf[0] & 0x0f) << 8) | buf[1];

>         x = ((buf[0] & 0xf0) << 4) | buf[2];

>         ...


Ok, will change in v2

> > +       u8      x_low;

> > +       u8      y_low;

> > +       u8      pressure;

> > +};

> > +

> > +

> > +static void mstar_power_on(struct msg26xx_ts_data *msg26xx)

> > +{

> > +       gpiod_set_value(msg26xx->reset_gpiod, 0);

> > +       mdelay(10);

> > +       gpiod_set_value(msg26xx->reset_gpiod, 1);

> > +       mdelay(FIRMWARE_ON_DELAY);

> 

> I am pretty sure this is incorrect. You are saying that you release the

> reset line, wait a bit, and then assert it. gpiod is a logical API, with

> 0 being inactive and 1 being active, and here you want to activate the

> reset line, wait appropriate time, release it, and wait for the device

> to initialize. What does the datasheet say about reset GPIO polarity?

> 

> Thanks.


I don't have any datasheet, only downstream code and dts for my device...
After changing this function to assert then deassert and also the reset gpio
polarity in my dts, it works as intended.
I'll send a v2 shortly, also changing the example section in bindings to
reflect the dts change I had to make (plus a minor change in title).

Thank you for the review!
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/input/touchscreen/mstar,msg26xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/mstar,msg26xx.yaml
new file mode 100644
index 000000000000..50e1c8495cd6
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/mstar,msg26xx.yaml
@@ -0,0 +1,66 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/mstar,msg26xx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: M-Star msg26xx touchscreen controller Bindings
+
+maintainers:
+  - Vincent Knecht <vincent.knecht@mailoo.org>
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+    const: mstar,msg26xx
+
+  reg:
+    const: 0x26
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  vdd-supply:
+    description: Power supply regulator for the chip
+
+  vddio-supply:
+    description: Power supply regulator for the I2C bus
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - reset-gpios
+  - touchscreen-size-x
+  - touchscreen-size-y
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      touchscreen@26 {
+        compatible = "mstar,msg26xx";
+        reg = <0x26>;
+        interrupt-parent = <&msmgpio>;
+        interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+        reset-gpios = <&msmgpio 100 GPIO_ACTIVE_HIGH>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&ts_int_active>;
+        vdd-supply = <&pm8916_l17>;
+        vddio-supply = <&pm8916_l5>;
+        touchscreen-size-x = <720>;
+        touchscreen-size-y = <1280>;
+      };
+    };
+
+...