mbox series

[v2,0/3] Support wakeup methods of Atmel maXTouch controllers

Message ID 20201205054749.26487-1-digetx@gmail.com
Headers show
Series Support wakeup methods of Atmel maXTouch controllers | expand

Message

Dmitry Osipenko Dec. 5, 2020, 5:47 a.m. UTC
Some Atmel maXTouch controllers, like mXT1386 and mXT3432S1 for example,
have a WAKE line that needs to be asserted in order to wake controller
from a deep sleep, otherwise it will be unusable. This series implements
support for the wakeup methods in accordance to the mXT1386 datasheet [1],
see page 29 (chapter "5.8 WAKE Line").

The mXT1386 is a widely used controller found on many older Android tablet
devices. Touchscreen on Acer A500 tablet now works properly after this
series.

This patchset is a continuation of the work originally started by
Jiada Wang [2].

[1] https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
[2] https://patchwork.kernel.org/project/linux-input/list/?series=357875

Changelog:

v2: - Fixed copy-paste bug in the code.

Dmitry Osipenko (3):
  dt-bindings: input: atmel_mxt_ts: Document atmel,wakeup-method and
    wake-GPIO
  Input: atmel_mxt_ts - support wakeup methods
  ARM: tegra: acer-a500: Add atmel,wakeup-method property

 .../bindings/input/atmel,maxtouch.yaml        | 26 +++++++++
 .../boot/dts/tegra20-acer-a500-picasso.dts    |  3 +
 drivers/input/touchscreen/atmel_mxt_ts.c      | 55 +++++++++++++++++++
 include/dt-bindings/input/atmel-maxtouch.h    | 10 ++++
 4 files changed, 94 insertions(+)
 create mode 100644 include/dt-bindings/input/atmel-maxtouch.h

Comments

Linus Walleij Dec. 6, 2020, 3:20 p.m. UTC | #1
On Sat, Dec 5, 2020 at 6:48 AM Dmitry Osipenko <digetx@gmail.com> wrote:

> According to datasheets, chips like mXT1386 have a WAKE line, it is used
> to wake the chip up from deep sleep mode before communicating with it via
> the I2C-compatible interface.
>
> If the WAKE line is connected to a GPIO line, the line must be asserted
> 25 ms before the host attempts to communicate with the controller. If the
> WAKE line is connected to the SCL pin, the controller will send a NACK on
> the first attempt to address it, the host must then retry 25 ms later.
>
> Implement the wake-up methods in the driver. Touchscreen now works
> properly on devices like Acer A500 tablet, fixing problems like this:
>
>  atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>  atmel_mxt_ts 0-004c: Trying alternate bootloader address
>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>  atmel_mxt_ts: probe of 0-004c failed with error -121
>
> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

OK looks interesting!

> +       /* Request the WAKE line as asserted so controller won't sleep */
> +       data->wake_gpio = devm_gpiod_get_optional(&client->dev,
> +                                                 "wake", GPIOD_OUT_HIGH);
> +       if (IS_ERR(data->wake_gpio)) {
> +               error = PTR_ERR(data->wake_gpio);
> +               dev_err(&client->dev, "Failed to get wake gpio: %d\n", error);
> +               return error;
> +       }

That is a bit brutal, don't you think? Now you force the controller
to be on at all times. Even across suspend/resume.

Shouldn't the same patch drive this low in mxt_suspend()
and driver it high + wait 25 ms in mxt_resume()?
Waiting 25ms in mxt_resume() is chill, it is anyway on the
slowpath.

Yours,
Linus Walleij
Dmitry Osipenko Dec. 6, 2020, 7:42 p.m. UTC | #2
06.12.2020 18:20, Linus Walleij пишет:
> On Sat, Dec 5, 2020 at 6:48 AM Dmitry Osipenko <digetx@gmail.com> wrote:
> 
>> According to datasheets, chips like mXT1386 have a WAKE line, it is used
>> to wake the chip up from deep sleep mode before communicating with it via
>> the I2C-compatible interface.
>>
>> If the WAKE line is connected to a GPIO line, the line must be asserted
>> 25 ms before the host attempts to communicate with the controller. If the
>> WAKE line is connected to the SCL pin, the controller will send a NACK on
>> the first attempt to address it, the host must then retry 25 ms later.
>>
>> Implement the wake-up methods in the driver. Touchscreen now works
>> properly on devices like Acer A500 tablet, fixing problems like this:
>>
>>  atmel_mxt_ts 0-004c: __mxt_read_reg: i2c transfer failed (-121)
>>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>>  atmel_mxt_ts 0-004c: Trying alternate bootloader address
>>  atmel_mxt_ts 0-004c: mxt_bootloader_read: i2c recv failed (-121)
>>  atmel_mxt_ts: probe of 0-004c failed with error -121
>>
>> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> 
> OK looks interesting!
> 
>> +       /* Request the WAKE line as asserted so controller won't sleep */
>> +       data->wake_gpio = devm_gpiod_get_optional(&client->dev,
>> +                                                 "wake", GPIOD_OUT_HIGH);
>> +       if (IS_ERR(data->wake_gpio)) {
>> +               error = PTR_ERR(data->wake_gpio);
>> +               dev_err(&client->dev, "Failed to get wake gpio: %d\n", error);
>> +               return error;
>> +       }
> 
> That is a bit brutal, don't you think? Now you force the controller
> to be on at all times. Even across suspend/resume.

Still it's better than a disfunctional hardware :)

> Shouldn't the same patch drive this low in mxt_suspend()
> and driver it high + wait 25 ms in mxt_resume()?
> Waiting 25ms in mxt_resume() is chill, it is anyway on the
> slowpath.

I don't have hardware which uses the wake-gpio in order to test that it
works properly, hence wanted to keep it minimal. But indeed sounds like
toggling the GPIO in suspend/resume should be okay to do. Alright, I'll
improve it in the v3. Thank you!