diff mbox series

[v5,1/2] dt-bindings: input/touchscreen: add bindings for msg2638

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

Checks

Context Check Description
robh/checkpatch success
robh/dt-meta-schema success
robh/dtbs-check success

Commit Message

Vincent Knecht Feb. 16, 2021, 4:36 p.m. UTC
This adds dts bindings for the mstar msg2638 touchscreen.

Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
---
Changed in v5: nothing
Changed in v4:
- don't use wildcards in compatible strings (Rob H)
- rename from msg26xx to msg2638
- rename example pinctrl-0 to &ts_int_reset_default for consistency
Changed in v3:
- added `touchscreen-size-x: true` and `touchscreen-size-y: true` properties
Changed in v2:
- changed M-Star to MStar in title line
- changed reset gpio to active-low in example section
---
 .../input/touchscreen/mstar,msg2638.yaml      | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/mstar,msg2638.yaml

Comments

Linus Walleij March 2, 2021, 8:50 a.m. UTC | #1
On Tue, Feb 16, 2021 at 5:38 PM Vincent Knecht
<vincent.knecht@mailoo.org> wrote:

> This adds dts bindings for the mstar msg2638 touchscreen.
>
> Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>

This looks good to me:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij March 2, 2021, 9 a.m. UTC | #2
Hi Vincent,

thanks for your patch!

On Tue, Feb 16, 2021 at 5:38 PM Vincent Knecht
<vincent.knecht@mailoo.org> wrote:

> Add support for the msg2638 touchscreen IC from MStar.
> This driver reuses zinitix.c structure, while the checksum and irq handler
> functions are based on out-of-tree driver for Alcatel Idol 3 (4.7").
>
> Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
> ---
> Changed in v5:
> - use gpiod_set_value_cansleep() (Stephan G)
> - use msleep/usleep_range() rathen than mdelay() (Stephan G)

(...)

> +#include <linux/delay.h>
> +#include <linux/gpio.h>

Please only include
#include <linux/gpio/consumer.h>

> +#define CHIP_ON_DELAY                  15 // ms
> +#define FIRMWARE_ON_DELAY              50 // ms
> +#define RESET_DELAY_MIN                        10000 // µs
> +#define RESET_DELAY_MAX                        11000 // µs

Rename the defines with _MS and _US suffixes so you don't
need the comments, CHIP_ON_DELAY_MS etc.

> +static int msg2638_init_regulators(struct msg2638_ts_data *msg2638)
> +{
> +       struct i2c_client *client = msg2638->client;
> +       int error;

I usually prefer a short name like "err" (cognitive load) but your choice.

> +static u8 msg2638_checksum(u8 *data, u32 length)
> +{
> +       s32 sum = 0;
> +       u32 i;
> +
> +       for (i = 0; i < length; i++)
> +               sum += data[i];
> +
> +       return (u8)((-sum) & 0xFF);
> +}

Interesting checksum algoritm.

> +static int msg2638_start(struct msg2638_ts_data *msg2638)
> +{
> +       int error;
> +
> +       error = regulator_bulk_enable(ARRAY_SIZE(msg2638->supplies),
> +                                     msg2638->supplies);
> +       if (error) {
> +               dev_err(&msg2638->client->dev, "Failed to enable regulators: %d\n", error);
> +               return error;
> +       }
> +
> +       msleep(CHIP_ON_DELAY);
> +
> +       msg2638_power_on(msg2638);

Maybe move enable_irq() here from power on to mirror
the stop() function below?

> +#ifdef CONFIG_OF
> +static const struct of_device_id msg2638_of_match[] = {
> +       { .compatible = "mstar,msg2638" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, msg2638_of_match);
> +#endif

I think these #ifdefs are not needed anymore. We just have struct of_device_id
available at all times.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/input/touchscreen/mstar,msg2638.yaml b/Documentation/devicetree/bindings/input/touchscreen/mstar,msg2638.yaml
new file mode 100644
index 000000000000..12f44d9e4d41
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/mstar,msg2638.yaml
@@ -0,0 +1,69 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/mstar,msg2638.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MStar msg2638 touchscreen controller Bindings
+
+maintainers:
+  - Vincent Knecht <vincent.knecht@mailoo.org>
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+    const: mstar,msg2638
+
+  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
+
+  touchscreen-size-x: true
+  touchscreen-size-y: true
+
+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,msg2638";
+        reg = <0x26>;
+        interrupt-parent = <&msmgpio>;
+        interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+        reset-gpios = <&msmgpio 100 GPIO_ACTIVE_LOW>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&ts_int_reset_default>;
+        vdd-supply = <&pm8916_l17>;
+        vddio-supply = <&pm8916_l5>;
+        touchscreen-size-x = <720>;
+        touchscreen-size-y = <1280>;
+      };
+    };
+
+...