From patchwork Tue Nov 9 02:15:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jooaun X-Patchwork-Id: 309952 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oA92G8VC031966 for ; Tue, 9 Nov 2010 02:16:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753724Ab0KICPx (ORCPT ); Mon, 8 Nov 2010 21:15:53 -0500 Received: from mail-gy0-f174.google.com ([209.85.160.174]:49374 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753818Ab0KICPv (ORCPT ); Mon, 8 Nov 2010 21:15:51 -0500 Received: by mail-gy0-f174.google.com with SMTP id 4so3965040gyh.19 for ; Mon, 08 Nov 2010 18:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=io/tfkUwFC+3jCIcRebIvkNpEQPefbK7XAAdICOt7wY=; b=XBhv3Fb4P30iodJAMVGAcly4y/vfyS9DxJDZCGHBgzufB7jenDsW66BLGnvy5r1t7e wtNmRwyEPK8M0zluogpfWhfn58sGa7ArLNXUp5HXIpcOomRE8gSnTMqkx9mWeABQ07fI z+CROqzXFtxG2QGvwrsobFm0wg5VD5n3QSxbk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=gCiAXlQbZMXf1v/9E4mLm4l2Q5rspb4B11B5JkLdiJawssQucVXkxp4/gwyH0bVt+P 11UBsgRoLBMfUwksjOZQSvGwuniMCv4RUHqsKchQlmFTFJLQn85tkx/oEzV7dJP0W3v8 tGETOj4Ac8CwO/2wiEgIxBSpUzvRSLmLLi8f4= Received: by 10.150.53.11 with SMTP id b11mr9752113yba.329.1289268950991; Mon, 08 Nov 2010 18:15:50 -0800 (PST) Received: from localhost.localdomain (203-206-227-95.perm.iinet.net.au [203.206.227.95]) by mx.google.com with ESMTPS id j27sm449455yha.30.2010.11.08.18.15.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Nov 2010 18:15:50 -0800 (PST) From: jooaun To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, raphaelpereira@gmail.com, jooaun Subject: [PATCH 3/8] qt2160: add PM support Date: Tue, 9 Nov 2010 13:15:06 +1100 Message-Id: <1289268911-32322-3-git-send-email-jasaw81@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1289268911-32322-1-git-send-email-jasaw81@gmail.com> References: <1289268911-32322-1-git-send-email-jasaw81@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Nov 2010 02:16:08 +0000 (UTC) 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)