From patchwork Tue Jan 26 23:41:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 75293 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0QNn4xf011749 for ; Tue, 26 Jan 2010 23:49:04 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o0QNgd5P006877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Jan 2010 17:42:39 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o0QNgb9s008882; Tue, 26 Jan 2010 17:42:37 -0600 (CST) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id CC0358062F; Tue, 26 Jan 2010 17:42:33 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 96DAE80632 for ; Tue, 26 Jan 2010 17:41:45 -0600 (CST) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id o0QNfjuv021556 for ; Tue, 26 Jan 2010 17:41:45 -0600 (CST) Received: from psmtp.com (na3sys009amx254.postini.com [74.125.149.138]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id o0QNfiXF032714 for ; Tue, 26 Jan 2010 17:41:44 -0600 Received: from source ([209.85.160.45]) by na3sys009amx254.postini.com ([74.125.148.10]) with SMTP; Tue, 26 Jan 2010 15:41:44 PST Received: by mail-pw0-f45.google.com with SMTP id 1so3413368pwj.24 for ; Tue, 26 Jan 2010 15:41:44 -0800 (PST) Received: by 10.141.187.13 with SMTP id o13mr6083513rvp.28.1264549304250; Tue, 26 Jan 2010 15:41:44 -0800 (PST) Received: from localhost (deeprootsystems.com [216.254.16.51]) by mx.google.com with ESMTPS id 21sm6145752pzk.7.2010.01.26.15.41.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 26 Jan 2010 15:41:43 -0800 (PST) From: Kevin Hilman To: Ben Dooks Subject: [PATCH 4/6] i2c: davinci: Add suspend/resume support Date: Tue, 26 Jan 2010 15:41:31 -0800 Message-Id: <1264549293-25556-5-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1264549293-25556-1-git-send-email-khilman@deeprootsystems.com> References: <1264549293-25556-1-git-send-email-khilman@deeprootsystems.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:86.82214/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 X-pstn-addresses: from [db-null] Cc: davinci-linux-open-source@linux.davincidsp.com, linux-i2c@vger.kernel.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index aacef7b..66b07bf 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -643,6 +643,41 @@ static int davinci_i2c_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int davinci_i2c_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev); + + /* put I2C into reset */ + davinci_i2c_reset_ctrl(i2c_dev, 0); + clk_disable(i2c_dev->clk); + + return 0; +} + +static int davinci_i2c_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev); + + clk_enable(i2c_dev->clk); + /* take I2C out of reset */ + davinci_i2c_reset_ctrl(i2c_dev, 1); + + return 0; +} + +static struct dev_pm_ops davinci_i2c_pm = { + .suspend = davinci_i2c_suspend, + .resume = davinci_i2c_resume, +}; + +#define davinci_i2c_pm_ops (&davinci_i2c_pm) +#else +#define davinci_i2c_pm_ops NULL +#endif + /* work with hotplug and coldplug */ MODULE_ALIAS("platform:i2c_davinci"); @@ -652,6 +687,7 @@ static struct platform_driver davinci_i2c_driver = { .driver = { .name = "i2c_davinci", .owner = THIS_MODULE, + .pm = davinci_i2c_pm_ops, }, };