From patchwork Fri Dec 3 15:05:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sundar Iyer X-Patchwork-Id: 378311 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 oB3F8Rvp009958 for ; Fri, 3 Dec 2010 15:08:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822Ab0LCPIO (ORCPT ); Fri, 3 Dec 2010 10:08:14 -0500 Received: from eu1sys200aog107.obsmtp.com ([207.126.144.123]:44121 "EHLO eu1sys200aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752159Ab0LCPHY (ORCPT ); Fri, 3 Dec 2010 10:07:24 -0500 Received: from source ([138.198.100.35]) (using TLSv1) by eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKTPkHpGUCnxaJl7nVsNBU1At27EOSrFmH@postini.com; Fri, 03 Dec 2010 15:07:23 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id ED9C91B0; Fri, 3 Dec 2010 15:07:13 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 9C6A7E6F; Fri, 3 Dec 2010 15:07:13 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 323CDA80A2; Fri, 3 Dec 2010 16:06:37 +0100 (CET) Received: from localhost (10.201.54.119) by exdcvycastm022.EQ1STM.local (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.2.254.0; Fri, 3 Dec 2010 16:06:42 +0100 From: Sundar Iyer To: , , , Cc: , , Sundar Iyer Subject: [PATCH 13/20] mfd/tc3589x: add suspend/resume support Date: Fri, 3 Dec 2010 20:35:46 +0530 Message-ID: <1291388753-14662-14-git-send-email-sundar.iyer@stericsson.com> X-Mailer: git-send-email 1.7.2.dirty In-Reply-To: <1291388753-14662-1-git-send-email-sundar.iyer@stericsson.com> References: <1291388753-14662-1-git-send-email-sundar.iyer@stericsson.com> MIME-Version: 1.0 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]); Fri, 03 Dec 2010 15:08:30 +0000 (UTC) diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index fd206fd..a7dd2b6 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c @@ -14,6 +14,9 @@ #include #include +#define TC3589x_CLKMODE_MODCTL_SLEEP 0x0 +#define TC3589x_CLKMODE_MODCTL_OPERATION (1 << 0) + /** * tc3589x_reg_read() - read a single TC3589x register * @tc3589x: Device to read from @@ -365,6 +368,42 @@ static int __devexit tc3589x_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM +static int tc3589x_suspend(struct device *dev) +{ + struct tc3589x *tc35892 = dev_get_drvdata(dev); + struct i2c_client *client = tc3589x->i2c; + int ret = 0; + + /* put the system to sleep mode */ + if (!device_may_wakeup(&client->dev)) + ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE, + TC3589x_CLKMODE_MODCTL_SLEEP); + + return ret; +} + +static int tc3589x_resume(struct device *dev) +{ + struct tc3589x *tc3589x = dev_get_drvdata(dev); + struct i2c_client *client = tc3589x->i2c; + int ret = 0; + + /* enable the system into operation */ + if (!device_may_wakeup(&client->dev)) + ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE, + TC3589x_CLKMODE_MODCTL_OPERATION); + + return ret; +} + + +static const struct dev_pm_ops tc3589x_dev_pm_ops = { + .suspend = tc3589x_suspend, + .resume = tc3589x_resume, +}; +#endif + static const struct i2c_device_id tc3589x_id[] = { { "tc3589x", 24 }, { } @@ -374,6 +413,9 @@ MODULE_DEVICE_TABLE(i2c, tc3589x_id); static struct i2c_driver tc3589x_driver = { .driver.name = "tc3589x", .driver.owner = THIS_MODULE, +#ifdef CONFIG_PM + .driver.pm = &tc3589x_dev_pm_ops, +#endif .probe = tc3589x_probe, .remove = __devexit_p(tc3589x_remove), .id_table = tc3589x_id,