atmel_mxt_ts - suspend patch and minor fixes
Subsystems (6)
PATCH 1/9 MAINTAINERS: Add maintainer for atmel_mxt_ts
In reply to Nick Dyer--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -1915,6 +1915,12 @@ W: http://atmelwlandriver.sourceforge.net/ S: Maintained F: drivers/net/wireless/atmel* +ATMEL MAXTOUCH DRIVER +M: Nick Dyer <[email protected]> +T: git git://github.com/atmel-maxtouch/linux.git +S: Supported +F: drivers/input/touchscreen/atmel_mxt_ts.c + ATTO EXPRESSSAS SAS/SATA RAID SCSI DRIVER M: Bradley Grove <[email protected]> L: [email protected]
Signature · 1 line
2.4.6
PATCH 7/9 Input: atmel_mxt_ts - disable interrupt for 50ms after reset
In reply to Nick DyerThe CHG/interrupt line is momentarily set (approximately 100 ms) as an input after power-up or reset for diagnostic purposes. This may cause spurious interrupts, so disable interrupt handler during this period.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/input/touchscreen/atmel_mxt_ts.c +8 -1
@@ -1098,7 +1098,9 @@ static int mxt_soft_reset(struct mxt_data *data)struct device *dev = &data->client->dev;int ret =0 ; -dev_info (dev,"Resetting chip\n" ); +dev_info (dev,"Resetting device\n" ); + +disable_irq (data->irq);reinit_completion (&data->reset_completion);
@@ -1106,6 +1108,11 @@ static int mxt_soft_reset(struct mxt_data *data)if (ret)return ret; +/* Ignore CHG line for 100ms after reset */ +msleep (100 ); + +enable_irq (data->irq); + ret =mxt_wait_for_completion (data, &data->reset_completion,MXT_RESET_TIMEOUT );if (ret)
Signature · 1 line
2.4.6
Hi Dmitry-
Here is the suspend patch for atmel_mxt_ts, again. I've tested it on Pixel 2 today. The code for T7 deep sleep has been widely used for years in our github version of the driver.
Also, several minor (but useful) fixes.
And I've added myself to MAINTAINERS because checkpatch.
best regards
Nick Dyer
PATCH 2/9 Input: atmel_mxt_ts - use deep sleep mode when stopped
The hardcoded 0x83 CTRL setting overrides other settings in that byte, enabling extra reporting that may not be useful on a particular platform.
Implement improved suspend mechanism via deep sleep. By writing zero to both the active and idle cycle times the maXTouch device can be put into a deep sleep mode, using minimal power. It is necessary to issue a calibrate command after the chip has spent any time in deep sleep, however a soft reset is unnecessary.
Use the old method on Chromebook Pixel via platform data option.
This patch also deals with the situation where the power configuration is zero on probe, which would mean that the device never wakes up to execute commands.
After a config download, the T7 power configuration may have changed so it is necessary to re-read it.
--- .../devicetree/bindings/input/atmel,maxtouch.txt | 5 + MAINTAINERS | 2 + drivers/input/touchscreen/atmel_mxt_ts.c | 120 +++++++++++++++++++-- drivers/platform/chrome/chromeos_laptop.c | 4 +- include/dt-bindings/input/atmel_mxt_ts.h | 21 ++++ include/linux/i2c/atmel_mxt_ts.h | 25 ----- include/linux/platform_data/atmel_mxt_ts.h | 27 +++++ 7 files changed, 167 insertions(+), 37 deletions(-) create mode 100644 include/dt-bindings/input/atmel_mxt_ts.h delete mode 100644 include/linux/i2c/atmel_mxt_ts.h create mode 100644 include/linux/platform_data/atmel_mxt_ts.h
Documentation/devicetree/bindings/input/atmel,maxtouch.txt +5 -0
@@ -22,6 +22,11 @@ Optional properties for main touchpad device: experiment to determine which bit corresponds to which input. Use KEY_RESERVED for unused padding values. +- atmel,suspend-mode: Select method used to suspend: + MXT_SUSPEND_DEEP_SLEEP - use T7 to suspend the device into deep sleep + MXT_SUSPEND_T9_CTRL - use T9.CTRL to turn off touch processing + Definitions are in <dt-bindings/input/atmel_mxt_ts.h>. + Example: touch@4b {
MAINTAINERS +2 -0
@@ -1920,6 +1920,8 @@ M: Nick Dyer <[email protected]> T: git git://github.com/atmel-maxtouch/linux.git S: Supported F: drivers/input/touchscreen/atmel_mxt_ts.c +F: include/dt-bindings/input/atmel_mxt_ts.h +F: include/linux/platform_data/atmel_mxt_ts.h ATTO EXPRESSSAS SAS/SATA RAID SCSI DRIVER M: Bradley Grove <[email protected]>
drivers/input/touchscreen/atmel_mxt_ts.c +109 -11
190 lines not on this page · raw message
drivers/platform/chrome/chromeos_laptop.c +3 -1
@@ -23,7 +23,7 @@#include <linux/dmi.h> #include <linux/i2c.h> -#include <linux/i2c/atmel_mxt_ts.h> +#include <linux/platform_data/atmel_mxt_ts.h> #include <linux/input.h> #include <linux/interrupt.h> #include <linux/module.h>
@@ -111,6 +111,7 @@ static struct mxt_platform_data atmel_224s_tp_platform_data = { .irqflags = IRQF_TRIGGER_FALLING, .t19_num_keys = ARRAY_SIZE(mxt_t19_keys), .t19_keymap = mxt_t19_keys, + .suspend_mode = MXT_SUSPEND_T9_CTRL, };static struct i2c_board_info atmel_224s_tp_device = {
@@ -121,6 +122,7 @@ static struct i2c_board_info atmel_224s_tp_device = {static struct mxt_platform_data atmel_1664s_platform_data = { .irqflags =IRQF_TRIGGER_FALLING , + .suspend_mode =MXT_SUSPEND_T9_CTRL , };static struct i2c_board_info atmel_1664s_device = {
include/dt-bindings/input/atmel_mxt_ts.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Atmel maXTouch Touchscreen driver +* +* Copyright (C) 2015 Atmel Corporation +* Author: Nick Dyer <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#ifndef __DT_BINDINGS_ATMEL_MXT_TS_H +#define __DT_BINDINGS_ATMEL_MXT_TS_H + +enum mxt_suspend_mode { +MXT_SUSPEND_DEEP_SLEEP =0 , +MXT_SUSPEND_T9_CTRL =1 , +}; + +#endif /* __DT_BINDINGS_ATMEL_MXT_TS_H */
include/linux/i2c/atmel_mxt_ts.h deleted +0 -25
@@ -1,25 +0,0 @@ -/* -* Atmel maXTouch Touchscreen driver -* -* Copyright (C) 2010 Samsung Electronics Co.Ltd -* Author: Joonyoung Shim <[email protected]> -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at your -* option) any later version. -*/ - -#ifndef __LINUX_ATMEL_MXT_TS_H -#define __LINUX_ATMEL_MXT_TS_H - -#include <linux/types.h> - -/* The platform data for the Atmel maXTouch touchscreen driver */ -struct mxt_platform_data { -unsigned long irqflags; -u8 t19_num_keys; -const unsigned int *t19_keymap; -}; - -#endif /* __LINUX_ATMEL_MXT_TS_H */
include/linux/platform_data/atmel_mxt_ts.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Atmel maXTouch Touchscreen driver +* +* Copyright (C) 2010 Samsung Electronics Co.Ltd +* Author: Joonyoung Shim <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#ifndef __LINUX_PLATFORM_DATA_ATMEL_MXT_TS_H +#define __LINUX_PLATFORM_DATA_ATMEL_MXT_TS_H + +#include <linux/types.h> +#include <dt-bindings/input/atmel_mxt_ts.h> + +/* The platform data for the Atmel maXTouch touchscreen driver */ +struct mxt_platform_data { +unsigned long irqflags; +u8 t19_num_keys; +const unsigned int *t19_keymap; +enum mxt_suspend_mode suspend_mode; +}; + +#endif /* __LINUX_PLATFORM_DATA_ATMEL_MXT_TS_H */
Signature · 1 line
2.4.6
PATCH 9/9 Input: atmel_mxt_ts - remove warning on zero T44 count
In reply to Nick Dyer--- drivers/input/touchscreen/atmel_mxt_ts.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +8 -9
@@ -938,16 +938,15 @@ static irqreturn_t mxt_process_messages_t44(struct mxt_data *data) count = data->msg_buf[0 ]; -if (count ==0 ) { -/* -* This condition is caused by the CHG line being configured -* in Mode 0. It results in unnecessary I2C operations but it -* is benign. -*/ -dev_dbg (dev,"Interrupt triggered but zero messages\n" ); +/* +* This condition may be caused by the CHG line being configured in +* Mode 0. It results in unnecessary I2C operations but it is benign. +*/ +if (count ==0 )return IRQ_NONE ; - }else if (count > data->max_reportid) { -dev_err (dev,"T44 count %d exceeded max report id\n" , count); + +if (count > data->max_reportid) { +dev_warn (dev,"T44 count %d exceeded max report id\n" , count); count = data->max_reportid; }
Signature · 1 line
2.4.6
PATCH 3/9 Input: atmel_mxt_ts - remove unused defines
In reply to Nick DyerMany of these values are out of date and they aren't used in the driver
- all they do is increase the size of the kernel source.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 66 +------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +1 -65
@@ -29,27 +29,13 @@#include <linux/slab.h> #include <asm/unaligned.h> -/* Version */ -#define MXT_VER_20 20 -#define MXT_VER_21 21 -#define MXT_VER_22 22 -/* Firmware files */ #define MXT_FW_NAME "maxtouch.fw"#define MXT_CFG_NAME "maxtouch.cfg"#define MXT_CFG_MAGIC "OBP_RAW V1"/* Registers */ -#define MXT_INFO 0x00 -#define MXT_FAMILY_ID 0x00 -#define MXT_VARIANT_ID 0x01 -#define MXT_VERSION 0x02 -#define MXT_BUILD 0x03 -#define MXT_MATRIX_X_SIZE 0x04 -#define MXT_MATRIX_Y_SIZE 0x05 -#define MXT_OBJECT_NUM 0x06#define MXT_OBJECT_START 0x07 -#define MXT_OBJECT_SIZE 6#define MXT_INFO_CHECKSUM_SIZE 3#define MXT_MAX_BLOCK_WRITE 256
@@ -111,15 +97,6 @@ struct t7_config {#define MXT_POWER_CFG_RUN 0#define MXT_POWER_CFG_DEEPSLEEP 1 -/* MXT_GEN_ACQUIRE_T8 field */ -#define MXT_ACQUIRE_CHRGTIME 0 -#define MXT_ACQUIRE_TCHDRIFT 2 -#define MXT_ACQUIRE_DRIFTST 3 -#define MXT_ACQUIRE_TCHAUTOCAL 4 -#define MXT_ACQUIRE_SYNC 5 -#define MXT_ACQUIRE_ATCHCALST 6 -#define MXT_ACQUIRE_ATCHCALSTHR 7 -/* MXT_TOUCH_MULTI_T9 field */ #define MXT_T9_CTRL 0#define MXT_T9_ORIENT 9
@@ -143,51 +120,10 @@ struct t9_range {/* MXT_TOUCH_MULTI_T9 orient */ #define MXT_T9_ORIENT_SWITCH (1 << 0) -/* MXT_PROCI_GRIPFACE_T20 field */ -#define MXT_GRIPFACE_CTRL 0 -#define MXT_GRIPFACE_XLOGRIP 1 -#define MXT_GRIPFACE_XHIGRIP 2 -#define MXT_GRIPFACE_YLOGRIP 3 -#define MXT_GRIPFACE_YHIGRIP 4 -#define MXT_GRIPFACE_MAXTCHS 5 -#define MXT_GRIPFACE_SZTHR1 7 -#define MXT_GRIPFACE_SZTHR2 8 -#define MXT_GRIPFACE_SHPTHR1 9 -#define MXT_GRIPFACE_SHPTHR2 10 -#define MXT_GRIPFACE_SUPEXTTO 11 - -/* MXT_PROCI_NOISE field */ -#define MXT_NOISE_CTRL 0 -#define MXT_NOISE_OUTFLEN 1 -#define MXT_NOISE_GCAFUL_LSB 3 -#define MXT_NOISE_GCAFUL_MSB 4 -#define MXT_NOISE_GCAFLL_LSB 5 -#define MXT_NOISE_GCAFLL_MSB 6 -#define MXT_NOISE_ACTVGCAFVALID 7 -#define MXT_NOISE_NOISETHR 8 -#define MXT_NOISE_FREQHOPSCALE 10 -#define MXT_NOISE_FREQ0 11 -#define MXT_NOISE_FREQ1 12 -#define MXT_NOISE_FREQ2 13 -#define MXT_NOISE_FREQ3 14 -#define MXT_NOISE_FREQ4 15 -#define MXT_NOISE_IDLEGCAFVALID 16 -/* MXT_SPT_COMMSCONFIG_T18 */ #define MXT_COMMS_CTRL 0#define MXT_COMMS_CMD 1 -/* MXT_SPT_CTECONFIG_T28 field */ -#define MXT_CTE_CTRL 0 -#define MXT_CTE_CMD 1 -#define MXT_CTE_MODE 2 -#define MXT_CTE_IDLEGCAFDEPTH 3 -#define MXT_CTE_ACTVGCAFDEPTH 4 -#define MXT_CTE_VOLTAGE 5 - -#define MXT_VOLTAGE_DEFAULT 2700000 -#define MXT_VOLTAGE_STEP 10000 -/* Define for MXT_GEN_COMMAND_T6 */ #define MXT_BOOT_VALUE 0xa5#define MXT_RESET_VALUE 0x01
@@ -1543,7 +1479,7 @@ static int mxt_get_info(struct mxt_data *data)int error;/* Read 7-byte info block starting at address 0 */ - error =__mxt_read_reg (client,MXT_INFO ,sizeof (*info), info); + error =__mxt_read_reg (client,0 ,sizeof (*info), info);if (error)return error;
Signature · 1 line
2.4.6
PATCH 4/9 Input: atmel_mxt_ts - move mxt_initialize after sysfs init
In reply to Nick DyerAn error in the sysfs init may otherwise interfere with the async return from the firmware loader
Add guards for sysfs functions
--- drivers/input/touchscreen/atmel_mxt_ts.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +16 -8
@@ -2092,6 +2092,10 @@ static ssize_t mxt_fw_version_show(struct device *dev, {struct mxt_data *data =dev_get_drvdata (dev);struct mxt_info *info = &data->info; + +if (!data->object_table) +return -EINVAL ; +return scnprintf (buf,PAGE_SIZE ,"%u.%u.%02X\n" , info->version >>4 , info->version &0xf , info->build); }
@@ -2102,6 +2106,10 @@ static ssize_t mxt_hw_version_show(struct device *dev, {struct mxt_data *data =dev_get_drvdata (dev);struct mxt_info *info = &data->info; + +if (!data->object_table) +return -EINVAL ; +return scnprintf (buf,PAGE_SIZE ,"%u.%u\n" , info->family_id, info->variant_id); }
@@ -2134,6 +2142,9 @@ static ssize_t mxt_object_show(struct device *dev,int error;u8 *obuf; +if (!data->object_table) +return -EINVAL ; +/* Pre-allocate buffer large enough to hold max sized object. */ obuf =kmalloc (256 ,GFP_KERNEL );if (!obuf)
@@ -2603,22 +2614,19 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)disable_irq (client->irq); - error =mxt_initialize (data); -if (error) - goto err_free_irq; - error =sysfs_create_group (&client->dev.kobj, &mxt_attr_group);if (error) {dev_err (&client->dev,"Failure %d creating sysfs group\n" , error); - goto err_free_object; + goto err_free_irq; } + error =mxt_initialize (data); +if (error) + goto err_free_irq; +return 0 ; -err_free_object: -mxt_free_input_device (data); -mxt_free_object_table (data); err_free_irq:free_irq (client->irq, data); err_free_mem:
Signature · 1 line
2.4.6
PATCH 5/9 Input: atmel_mxt_ts - suspend/resume causes panic if input_dev fails to init
In reply to Nick DyerFrom: Pan Xinhui <[email protected]>
input_dev may be NULL if mxt_initialize_input_device fails. But pm ops is still available and suspend/resume assumeinput_dev is not NULL. To fix this issue, we add a check if (!input_dev).
--- drivers/input/touchscreen/atmel_mxt_ts.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/touchscreen/atmel_mxt_ts.c +6 -0
@@ -2653,6 +2653,9 @@ static int __maybe_unused mxt_suspend(struct device *dev)struct mxt_data *data =i2c_get_clientdata (client);struct input_dev *input_dev = data->input_dev; +if (!input_dev) +return 0 ; +mutex_lock (&input_dev->mutex);if (input_dev->users)
@@ -2669,6 +2672,9 @@ static int __maybe_unused mxt_resume(struct device *dev)struct mxt_data *data =i2c_get_clientdata (client);struct input_dev *input_dev = data->input_dev; +if (!input_dev) +return 0 ; +mutex_lock (&input_dev->mutex);if (input_dev->users)
Signature · 1 line
2.4.6
PATCH 6/9 Input: atmel_mxt_ts - improve device tree parsing
In reply to Nick DyerUse function rather than loop, define np to reduce wrapping.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/input/touchscreen/atmel_mxt_ts.c +10 -15
@@ -2420,19 +2420,18 @@ static void mxt_input_close(struct input_dev *dev)static const struct mxt_platform_data *mxt_parse_dt (struct i2c_client *client) {struct mxt_platform_data *pdata; +struct device_node *np = client->dev.of_node;u32 *keymap; -u32 keycode; -int proplen, i, ret; +int proplen, ret; -if (!client->dev.of_node) +if (!np)return ERR_PTR (-ENOENT ); pdata =devm_kzalloc (&client->dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)return ERR_PTR (-ENOMEM ); -if (of_find_property (client->dev.of_node,"linux,gpio-keymap" , - &proplen)) { +if (of_find_property (np,"linux,gpio-keymap" , &proplen)) { pdata->t19_num_keys = proplen /sizeof (u32); keymap = devm_kzalloc(&client->dev,
@@ -2441,20 +2440,16 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)if (!keymap)return ERR_PTR (-ENOMEM ); -for (i =0 ; i < pdata->t19_num_keys; i++) { - ret =of_property_read_u32_index (client->dev.of_node, -"linux,gpio-keymap" , i, &keycode); -if (ret) - keycode =KEY_RESERVED ; - - keymap[i] = keycode; - } + ret =of_property_read_u32_array (np,"linux,gpio-keymap" , + keymap, pdata->t19_num_keys); +if (ret) +dev_warn (&client->dev, +"Couldn't read linux,gpio-keymap: %d\n" , ret); pdata->t19_keymap = keymap; } -of_property_read_u32 (client->dev.of_node,"atmel,suspend-mode" , - &pdata->suspend_mode); +of_property_read_u32 (np,"atmel,suspend-mode" , &pdata->suspend_mode);return pdata; }
Signature · 1 line
2.4.6
PATCH 8/9 Input: atmel_mxt_ts - initialise input slots with INPUT_MT_DIRECT
In reply to Nick DyerThis indicates the device coordinates should be directly mapped to screen. This is valid since scaling/flipping/rotation should be done by configuring the MXT device.
It also flags to Android using INPUT_PROP_DIRECT that the device should be treated as a touch screen by default, and removes the necessity for a default IDC file.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/input/touchscreen/atmel_mxt_ts.c +2 -0
@@ -1858,6 +1858,8 @@ static int mxt_initialize_input_device(struct mxt_data *data)if (pdata->t19_num_keys) {mxt_set_up_as_touchpad (input_dev, data); mt_flags |=INPUT_MT_POINTER ; + }else { + mt_flags |=INPUT_MT_DIRECT ; }/* For multi touch */
Signature · 1 line
2.4.6
Dmitry Torokhov
maintainerRe: [PATCH 4/9] Input: atmel_mxt_ts - move mxt_initialize after sysfs init
In reply to Nick DyerQuoted 2 lines · Nick Dyer
An error in the sysfs init may otherwise interfere with the async return from the firmware loader
In this case I'd rather we blocked accessing the device via sysfs until it is settled instead of returning intermittent -EINVAL.
Thanks.
Quoted 75 lines
Add guards for sysfs functions
Signed-off-by Nick Dyer <[email protected]>--- drivers/input/touchscreen/atmel_mxt_ts.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)drivers/input/touchscreen/atmel_mxt_ts.c +16
-8@@ -2092,6 +2092,10 @@ static ssize_t mxt_fw_version_show(struct device *dev, {struct mxt_data *data =dev_get_drvdata (dev);struct mxt_info *info = &data->info; + +if (!data->object_table) +return -EINVAL ; +return scnprintf (buf,PAGE_SIZE ,"%u.%u.%02X\n" , info->version >>4 , info->version &0xf , info->build); }@@ -2102,6 +2106,10 @@ static ssize_t mxt_hw_version_show(struct device *dev, {struct mxt_data *data =dev_get_drvdata (dev);struct mxt_info *info = &data->info; + +if (!data->object_table) +return -EINVAL ; +return scnprintf (buf,PAGE_SIZE ,"%u.%u\n" , info->family_id, info->variant_id); }@@ -2134,6 +2142,9 @@ static ssize_t mxt_object_show(struct device *dev,int error;u8 *obuf; +if (!data->object_table) +return -EINVAL ; +/* Pre-allocate buffer large enough to hold max sized object. */ obuf =kmalloc (256 ,GFP_KERNEL );if (!obuf)@@ -2603,22 +2614,19 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)disable_irq (client->irq); - error =mxt_initialize (data); -if (error) - goto err_free_irq; - error =sysfs_create_group (&client->dev.kobj, &mxt_attr_group);if (error) {dev_err (&client->dev,"Failure %d creating sysfs group\n" , error); - goto err_free_object; + goto err_free_irq; } + error =mxt_initialize (data); +if (error) + goto err_free_irq; +return 0 ; -err_free_object: -mxt_free_input_device (data); -mxt_free_object_table (data); err_free_irq:free_irq (client->irq, data); err_free_mem:Signature · 1 line
2.4.6
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerRe: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
In reply to Nick DyerQuoted 15 lines · Nick Dyer
The hardcoded
0x83CTRL setting overrides other settings in that byte, enabling extra reporting that may not be useful on a particular platform.Implement improved suspend mechanism via deep sleep. By writing zero to both the active and idle cycle times the maXTouch device can be put into a deep sleep mode, using minimal power. It is necessary to issue a calibrate command after the chip has spent any time in deep sleep, however a soft reset is unnecessary.
Use the old method on Chromebook Pixel via platform data option.
This patch also deals with the situation where the power configuration is zero on probe, which would mean that the device never wakes up to execute commands.
Quoted 8 lines
After a config download, the T7 power configuration may have changed so it is necessary to re-read it.
Signed-off-by Nick Dyer <[email protected]>Acked-by Benson Leung <[email protected]>Acked-by Yufeng Shen <[email protected]>--- .../devicetree/bindings/input/atmel,maxtouch.txt | 5 +
Since the T9 code is for compatibility with old Pixel only I do not think we should be adding it to device tree binding, at least not at the moment. I cut the device tree parsing out and default to deep sleep on DT-based systems.
Thanks.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerHi Nick,
Quoted 9 lines · Nick Dyer
Hi Dmitry-
Here is the suspend patch for
atmel_mxt_ts, again. I've tested it on Pixel 2 today. The code for T7 deep sleep has been widely used for years in our github version of the driver.Also, several minor (but useful) fixes.
And I've added myself to
MAINTAINERSbecause checkpatch.
Applied all but 4; 1 & 2 with minor edits.
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
In reply to Dmitry TorokhovQuoted 4 lines · Dmitry Torokhov
Since the T9 code is for compatibility with old Pixel only I do not think we should be adding it to device tree binding, at least not at the moment. I cut the device tree parsing out and default to deep sleep on DT-based systems. Thanks.
That sounds fair enough. We do need something like this eventually to support different suspend implementations (eg powering down via regulators).
Dmitry Torokhov
maintainerRe: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
Quoted 10 lines · Nick Dyer
Quoted 4 lines · Dmitry Torokhov
Since the T9 code is for compatibility with old Pixel only I do not think we should be adding it to device tree binding, at least not at the moment. I cut the device tree parsing out and default to deep sleep on DT-based systems. Thanks.
That sounds fair enough. We do need something like this eventually to support different suspend implementations (eg powering down via regulators).
That does not really need config I think: in ChromeOS tree wee key the behavior off presence of reset GPIO line: if it sis there (definied via ACPI, devicetree or board lookup code) then we assume we need to control the power up sequence with regulators, otherwise we put the controller into deep sleep mode.
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
In reply to Nick DyerHi Nick,
Quoted 15 lines · Nick Dyer
The hardcoded
0x83CTRL setting overrides other settings in that byte, enabling extra reporting that may not be useful on a particular platform.Implement improved suspend mechanism via deep sleep. By writing zero to both the active and idle cycle times the maXTouch device can be put into a deep sleep mode, using minimal power. It is necessary to issue a calibrate command after the chip has spent any time in deep sleep, however a soft reset is unnecessary.
Use the old method on Chromebook Pixel via platform data option.
This patch also deals with the situation where the power configuration is zero on probe, which would mean that the device never wakes up to execute commands.
Quoted 7 lines
After a config download, the T7 power configuration may have changed so it is necessary to re-read it.
Signed-off-by Nick Dyer <[email protected]>Acked-by Benson Leung <[email protected]>Acked-by Yufeng Shen <[email protected]>---
I am currently running v4.2-rc6, merged with Dmitry's and Jiri's tree. This patch completely kills my touchpad on the Pixel 2. No touch information is sent while the physical button still emits values. You said that you tested it on this laptop too, so I wonder why mine refuses to work.
It looks also that the deep sleep gets kept while rebooting a different kernel. If I reboot to the standard fedora kernel (without this patch), I still have the same problem, and I have to reboot under ChromeOS to get the touchpad back alive. Then, the Fedora kernel works just fine.
Any ideas why?
Cheers,
Benjamin
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
Quoted 5 lines · Benjamin Tissoires
I am currently running v4.2-rc6, merged with Dmitry's and Jiri's tree. This patch completely kills my touchpad on the Pixel 2. No touch information is sent while the physical button still emits values. You said that you tested it on this laptop too, so I wonder why mine refuses to work.
I'm just building that version to see if I can reproduce. Dmitry made some minor changes when he merged it, but I don't think it should have affected anything.
Are you able to send me some dmesg output with dyndbg=+pt enabled?
It would also be useful if you could compile mxt-app and try issuing a calibrate or reset command to see if that restores touch (let me know if you need instructions).
Quoted 5 lines
It looks also that the deep sleep gets kept while rebooting a different kernel. If I reboot to the standard fedora kernel (without this patch), I still have the same problem, and I have to reboot under ChromeOS to get the touchpad back alive. Then, the Fedora kernel works just fine.
That's unfortunate. In an ideal world the Fedora kernel driver should reset the touch controller or at least check the power settings, and it appears it's doing neither.
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
Quoted 11 lines · Nick Dyer
Quoted 5 lines · Benjamin Tissoires
I am currently running v4.2-rc6, merged with Dmitry's and Jiri's tree. This patch completely kills my touchpad on the Pixel 2. No touch information is sent while the physical button still emits values. You said that you tested it on this laptop too, so I wonder why mine refuses to work.
I'm just building that version to see if I can reproduce. Dmitry made some minor changes when he merged it, but I don't think it should have affected anything.
Quoted 5 lines
Are you able to send me some dmesg output with dyndbg=+pt enabled?
It would also be useful if you could compile mxt-app and try issuing a calibrate or reset command to see if that restores touch (let me know if you need instructions).
I've done some testing and I believe I'm able to reproduce your issue. It appears to be caused by a bad calibration, i.e. if I run the following command then the touchpad starts working:
sudo ./mxt-app -d i2c-dev:0-004a --calibrate
(it times out waiting for the calibration complete message when in i2c-dev mode, but that's expected)
Could you verify this at your end?
The patch under discussion sends a calibrate command as the input device is opened. However I can see that user space is opening/closing the device 3x in the space of about a second as X starts up, which may be confusing the firmware. It might be that we need to wait for the calibration to complete, I will try adding some code to do that.
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
Hi Nick,
Quoted 8 lines · Nick Dyer
Quoted 7 lines · Nick Dyer
Quoted 5 lines · Benjamin Tissoires
I am currently running v4.2-rc6, merged with Dmitry's and Jiri's tree. This patch completely kills my touchpad on the Pixel 2. No touch information is sent while the physical button still emits values. You said that you tested it on this laptop too, so I wonder why mine refuses to work.
Quoted 5 lines
Quoted 5 lines
I'm just building that version to see if I can reproduce. Dmitry made some minor changes when he merged it, but I don't think it should have affected anything.
Are you able to send me some dmesg output with dyndbg=+pt enabled?
I will do that after lunch if you still need them.
Quoted 10 lines
Quoted 4 lines
It would also be useful if you could compile mxt-app and try issuing a calibrate or reset command to see if that restores touch (let me know if you need instructions).
I've done some testing and I believe I'm able to reproduce your issue. It appears to be caused by a bad calibration, i.e. if I run the following command then the touchpad starts working:
sudo ./mxt-app -d i2c-dev:0-004a --calibrate
Yep, this works with the deep sleep patches applied. On the regular fedora kernel (without these patches, and after a boot with the kernel with the patches), it does not make the touchpad back alive, however, a reset with the mxt-app works.
Thanks for the fast work-around.
Quoted 11 lines
(it times out waiting for the calibration complete message when in i2c-dev mode, but that's expected)
Could you verify this at your end?
The patch under discussion sends a calibrate command as the input device is opened. However I can see that user space is opening/closing the device 3x in the space of about a second as X starts up, which may be confusing the firmware. It might be that we need to wait for the calibration to complete, I will try adding some code to do that.
Can't you start a worker on open which will keep a ref count on how many open/close you make and which would do the calibration in the background without blocking the user-space? This way, you will be able to guarantee that the calibration will end, and not be re-sent if there are several open/close in a raw.
Cheers,
Benjamin
Re: [PATCH 2/9] Input: atmel_mxt_ts - use deep sleep mode when stopped
Quoted 3 lines · Benjamin Tissoires
Quoted 1 line
Quoted 1 line
Are you able to send me some dmesg output with dyndbg=+pt enabled?
I will do that after lunch if you still need them.
Looks unnecessary given that the calibrate worked.
Quoted 8 lines
Quoted 1 line
sudo ./mxt-app -d i2c-dev:0-004a --calibrate
Yep, this works with the deep sleep patches applied. On the regular fedora kernel (without these patches, and after a boot with the kernel with the patches), it does not make the touchpad back alive, however, a reset with the mxt-app works.
Thanks for the fast work-around.
Thanks for testing this!
Quoted 11 lines
Quoted 5 lines
The patch under discussion sends a calibrate command as the input device is opened. However I can see that user space is opening/closing the device 3x in the space of about a second as X starts up, which may be confusing the firmware. It might be that we need to wait for the calibration to complete, I will try adding some code to do that.
Can't you start a worker on open which will keep a ref count on how many open/close you make and which would do the calibration in the background without blocking the user-space? This way, you will be able to guarantee that the calibration will end, and not be re-sent if there are several open/close in a raw.
Yes, something like that sounds sensible.