linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Nick Dyer <nick@shmanahar.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Henrik Rydberg <rydberg@bitmath.org>,
	Arthur Demchenkov <spinal.by@gmail.com>,
	Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>,
	Merlijn Wajer <merlijn@wizzup.org>, Pavel Machek <pavel@ucw.cz>,
	Sebastian Reichel <sre@kernel.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org
Subject: [PATCH 2/3] Input: atmel_mxt_ts - add idle power config
Date: Wed, 18 Mar 2020 16:09:37 -0700	[thread overview]
Message-ID: <20200318230938.31573-2-tony@atomide.com> (raw)
In-Reply-To: <20200318230938.31573-1-tony@atomide.com>

We can save few tens of mW of power during runtime. Let's add a new idle
power config where we minimize the active time and maximize the idle time.

Then we can use the new idle setting based on runtime PM autosuspend in
the following patch.

Let's also start using enum mxt_power_cfg while at it.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -97,8 +97,11 @@ struct t7_config {
 	u8 active;
 } __packed;
 
-#define MXT_POWER_CFG_RUN		0
-#define MXT_POWER_CFG_DEEPSLEEP		1
+enum mxt_power_cfg {
+	MXT_POWER_CFG_RUN,
+	MXT_POWER_CFG_IDLE,
+	MXT_POWER_CFG_DEEPSLEEP,
+};
 
 /* MXT_TOUCH_MULTI_T9 field */
 #define MXT_T9_CTRL		0
@@ -2155,17 +2158,31 @@ static int mxt_initialize(struct mxt_data *data)
 	return 0;
 }
 
-static int mxt_set_t7_power_cfg(struct mxt_data *data, u8 sleep)
+/*
+ * Note that active value 0 forces the controller to idle so 1 is the shortest
+ * active periiod with interrupts still working. Idle value of 255 blocks idle
+ * completely so 254 is the maximum idle time we can use.
+ */
+static int mxt_set_t7_power_cfg(struct mxt_data *data,
+				enum mxt_power_cfg config)
 {
 	struct device *dev = &data->client->dev;
 	int error;
 	struct t7_config *new_config;
 	struct t7_config deepsleep = { .active = 0, .idle = 0 };
+	struct t7_config idle = { .active = 1, .idle = 254 };
 
-	if (sleep == MXT_POWER_CFG_DEEPSLEEP)
+	switch (config) {
+	case MXT_POWER_CFG_IDLE:
+		new_config = &idle;
+		break;
+	case MXT_POWER_CFG_DEEPSLEEP:
 		new_config = &deepsleep;
-	else
+		break;
+	default:
 		new_config = &data->t7_cfg;
+		break;
+	}
 
 	error = __mxt_write_reg(data->client, data->T7_address,
 				sizeof(data->t7_cfg), new_config);
-- 
2.25.1

  reply	other threads:[~2020-03-18 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 23:09 [PATCH 1/3] Input: atmel_mxt_ts - use runtime PM instead of custom functions Tony Lindgren
2020-03-18 23:09 ` Tony Lindgren [this message]
2020-03-18 23:09 ` [PATCH 3/3] Input: atmel_mxt_ts - use runtime PM autosuspend for idle config Tony Lindgren
2020-03-20 19:00   ` Tony Lindgren
2020-09-08  8:51 ` [PATCH 1/3] Input: atmel_mxt_ts - use runtime PM instead of custom functions Pavel Machek
2020-09-09  6:04   ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200318230938.31573-2-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=nick@shmanahar.org \
    --cc=pavel@ucw.cz \
    --cc=rydberg@bitmath.org \
    --cc=spinal.by@gmail.com \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).