linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jooaun <jasaw81@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, raphaelpereira@gmail.com,
	jooaun <jasaw81@gmail.com>
Subject: [PATCH 3/8] qt2160: add PM support
Date: Tue,  9 Nov 2010 13:15:06 +1100	[thread overview]
Message-ID: <1289268911-32322-3-git-send-email-jasaw81@gmail.com> (raw)
In-Reply-To: <1289268911-32322-1-git-send-email-jasaw81@gmail.com>

Add power management support.
Signed-off-by: Joo Aun Saw <jasaw81@gmail.com>
---
 drivers/input/keyboard/qt2160.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index dcd05cd..6439e40 100755
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -43,6 +43,7 @@
 #define QT2160_CMD_SUBVER     7
 #define QT2160_CMD_CALIBRATE  10
 #define QT2160_CMD_RESET      11
+#define QT2160_CMD_LP_MODE    12
 #define QT2160_CMD_BURST_REP  13
 #define QT2160_CMD_NEG_DRIFT  15
 #define QT2160_CMD_POS_DRIFT  16
@@ -66,6 +67,9 @@
 
 #define QT2160_CYCLE_INTERVAL	(2*HZ)
 
+#define QT2160_LP_MODE_DEFAULT_VALUE	(1)
+#define QT2160_LP_MODE_SLEEP_VALUE	(0)
+
 #define QT2160_SLIDE_RESOLUTION	(8)
 #define QT2160_SLIDE_HYSTERESIS	(10)
 #define QT2160_SLIDE_MAX_VALUE	(0xFF)
@@ -529,6 +533,34 @@ static int __devexit qt2160_remove(struct i2c_client *client)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int qt2160_suspend(struct i2c_client *client, pm_message_t message)
+{
+	int error;
+
+	error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
+					  QT2160_LP_MODE_SLEEP_VALUE);
+	if (error)
+		dev_err(&client->dev, "could not write power config\n");
+	return error;
+}
+
+static int qt2160_resume(struct i2c_client *client)
+{
+	int error;
+	u8 lp_mode_val = QT2160_LP_MODE_DEFAULT_VALUE;
+
+	error = i2c_smbus_write_byte_data(client, QT2160_CMD_LP_MODE,
+					  lp_mode_val);
+	if (error)
+		dev_err(&client->dev, "could not write power config\n");
+	return error;
+}
+#else
+#define qt2160_suspend NULL
+#define qt2160_resume  NULL
+#endif
+
 static const struct i2c_device_id qt2160_idtable[] = {
 	{ "qt2160", 0, },
 	{ }
@@ -545,6 +577,8 @@ static struct i2c_driver qt2160_driver = {
 	.id_table	= qt2160_idtable,
 	.probe		= qt2160_probe,
 	.remove		= __devexit_p(qt2160_remove),
+	.suspend	= qt2160_suspend,
+	.resume		= qt2160_resume,
 };
 
 static int __init qt2160_init(void)
-- 
1.7.0.4


  parent reply	other threads:[~2010-11-09  2:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09  2:15 [PATCH 1/8] qt2160: add slider support jooaun
2010-11-09  2:15 ` [PATCH 2/8] qt2160: configurable key sensitivity jooaun
2010-11-09  2:43   ` jooaun
2010-11-09  2:15 ` jooaun [this message]
2010-11-09  2:15 ` [PATCH 4/8] qt2160: add configurable power mode jooaun
2010-11-09  2:15 ` [PATCH 5/8] qt2160: fix starting of device calibration jooaun
2010-11-09  2:15 ` [PATCH 6/8] qt2160: only read device when Change pin is active jooaun
2010-11-09  2:45   ` jooaun
2010-11-09  2:15 ` [PATCH 7/8] qt2160: optional interrupt flag jooaun
2010-11-09  2:46   ` jooaun
2010-11-09  2:15 ` [PATCH 8/8] qt2160: add hardware reset jooaun
2010-11-09  2:47   ` jooaun

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=1289268911-32322-3-git-send-email-jasaw81@gmail.com \
    --to=jasaw81@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=raphaelpereira@gmail.com \
    /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).