Search code examples
embedded-linuxi2cdevice-tree

Linux Device Tree: Touch controller failing i2c test


Context

I am using an i.MX6 ULL application processor with a Goodix 9271 touch-screen display. The display has been added to the device tree and is working correctly. I now wanted to add the touch controller, which is connected to my application processor via I²C. I therefore added

  1. A new node under my I²C node which adds the controller as a device on the bus.
  2. A new pin control group for the application processor to interface with the touch controller

I have enumerated them here:

/* #1: Device node on the I2C bus */
&i2c1 {
    clock_frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c1>;
    status = "okay";

    /* Awesome new touch controller */
    gt9271_ts@5d {
        compatible = "goodix,gt9271";          /* Device tree binding */ 
        reg = <0x5d>;                          /* I2C bus address */
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gt9271_ts_gpio>; /* Custom pinctrl group node */
        interrupt-parent = <&gpio4>;
        interrupts = <16,0>;                   /* GPIO 4 + pin 16 + active high */       
        reset-gpios = <&gpio4 12 0>;           /* GPIO 4 + Pin 12 + active high */
        touchscreen-size-x = <1200>;
        touchscreen-size-y = <800>;
        touchscreen-inverted-x;
        touchscreen-inverted-y;
    };

    /* ... */
};

/* #2: Pin control group */
&iomuxc {

    pinctrl_gt9271_ts_gpio: gt9271_ts_gpiogrp {
        fsl,pins = <
            MX6UL_PAD_NAND_DQS__GPIO4_IO16        0x80000000 /* Interrupt */
            MX6UL_PAD_NAND_READY_B__GPIO4_IO12    0x80000000 /* Reset */
        >;
    };

    /* ... */
};

Explanation: bus address

The device data sheet, available here, indicates that two slave addresses are supported: 0xBA/0xBB and 0x28/0x29. The device is set to use 0xBA/0xBB adjusted for 7-bit addressing as recommended in this binding, (so the address assigned in the node is actually 0x5d).

Explanation: control pins

The I²C reset and interrupt are connected (respectively) to GPIO 4, pin 16, and GPIO 4, pin 12. These are reserved for NAND but NAND is not being used with this processor so the pins are free.

Problem

Unfortunately, the touchscreen controller configuration I have added is failing on boot with an I²C related message. I am greeted on boot with the following:

[    2.118110] Goodix-TS 0-005d: 0-005d supply AVDD28 not found, using dummy regulator
[    2.126059] Goodix-TS 0-005d: 0-005d supply VDDIO not found, using dummy regulator
[    2.134510] Goodix-TS 0-005d: i2c test failed attempt 1: -6
[    2.177733] Goodix-TS 0-005d: i2c test failed attempt 2: -6
[    2.217377] Goodix-TS 0-005d: I2C communication failure: -6

I have attempted to search the error code (-6) but find sparse to non-existent search results online. I've checked that the connector is physically there and it seems to be.

What steps might I take to diagnose such an error code?


Solution

  • The solution is as follows:

    1. The documentation states that I should include the property in the format irq-gpios. I previously thought I only needed the interrupts property. After adding irq-gpios = <&gpio4 16 0>;, the device passed the I2C test.
    2. I disabled touchscreen-inverted-x;, and touchscreen-inverted-y; by removing those lines. I had incorrectly assumed I needed to do that originally.

    Verdict:

    Try to follow the documentation precisely.