From patchwork Fri Aug 14 10:48:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 41370 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7EArFaT025527 for ; Fri, 14 Aug 2009 10:53:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbZHNKxW (ORCPT ); Fri, 14 Aug 2009 06:53:22 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754678AbZHNKxW (ORCPT ); Fri, 14 Aug 2009 06:53:22 -0400 Received: from rv-out-0506.google.com ([209.85.198.235]:8841 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753676AbZHNKxV (ORCPT ); Fri, 14 Aug 2009 06:53:21 -0400 Received: by rv-out-0506.google.com with SMTP id f6so428236rvb.1 for ; Fri, 14 Aug 2009 03:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=9qIbKMnaz3nvco/WGxUtOB1cGaO9MLljxMPDQI7GSbA=; b=bHciyEjt9siufNMZjxYiDy9XCJIbtOxz2KYBfj3WJW0Egi01P87AxC3c1C5tqGLJTM ALRlhp5C+019UroiC0oc8bh2jHzygeOxqYpFqcVAMY4uIDfAyaFjfW/d0O8yRpEDx03q f0J8ycxI01XqFhRVVBps5TvrbJxHDGmgpB7MQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=Nm5h0m+44NtxHX1Ua+BanqK3DWZO/7EZuuCOfGVGLmQbsrNv8jdEIt8O/vTo9s/EH5 uBhSBJnJxdp41rJqChRnRhsn0hQtYF54s5F56UDnj57tUDIRgSAuvGxR4vAkA51dsQIe +9fwYG2qpWfKl5Bo5/q31PsSKnXfBz9QRYHuo= Received: by 10.141.21.12 with SMTP id y12mr981929rvi.248.1250247203110; Fri, 14 Aug 2009 03:53:23 -0700 (PDT) Received: from rx1.opensource.se (mailhost.igel.co.jp [219.106.231.130]) by mx.google.com with ESMTPS id g22sm7905443rvb.42.2009.08.14.03.53.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 14 Aug 2009 03:53:22 -0700 (PDT) From: Magnus Damm To: linux-pm@lists.linux-foundation.org Cc: linux-sh@vger.kernel.org, gregkh@suse.de, rjw@sisk.pl, lethal@linux-sh.org, stern@rowland.harvard.edu, pavel@ucw.cz, Magnus Damm Date: Fri, 14 Aug 2009 19:48:59 +0900 Message-Id: <20090814104859.32396.79162.sendpatchset@rx1.opensource.se> In-Reply-To: <20090814104808.32396.50021.sendpatchset@rx1.opensource.se> References: <20090814104808.32396.50021.sendpatchset@rx1.opensource.se> Subject: [PATCH 02/05] i2c: Runtime PM for SuperH Mobile I2C Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch modifies the SuperH Mobile I2C driver to support Runtime PM. These changes is all that is needed for proper Runtime PM support in this driver. Driver callbacks for Runtime PM are empty because the device registers are always re-initialized after pm_runtime_get_sync(). Signed-off-by: Magnus Damm --- Changes from V2: - none Changes from V1: - use pm_runtime_get_sync() and pm_runtime_put_sync() - use pm_runtime_disable() - implement nop runtime pm functions for dev_pm_ops - no need for pm_runtime_set_suspended() drivers/i2c/busses/i2c-sh_mobile.c | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/i2c/busses/i2c-sh_mobile.c +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2009-07-31 00:55:42.000000000 +0900 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -165,7 +166,8 @@ static void activate_ch(struct sh_mobile u_int32_t denom; u_int32_t tmp; - /* Make sure the clock is enabled */ + /* Wake up device and enable clock */ + pm_runtime_get_sync(pd->dev); clk_enable(pd->clk); /* Get clock rate after clock is enabled */ @@ -213,8 +215,9 @@ static void deactivate_ch(struct sh_mobi /* Disable channel */ iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); - /* Disable clock */ + /* Disable clock and mark device as idle */ clk_disable(pd->clk); + pm_runtime_put_sync(pd->dev); } static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, @@ -572,6 +575,19 @@ static int sh_mobile_i2c_probe(struct pl goto err_irq; } + /* Enable Runtime PM for this device. + * + * Also tell the Runtime PM core to ignore children + * for this device since it is valid for us to suspend + * this I2C master driver even though the slave devices + * on the I2C bus may not be suspended. + * + * The state of the I2C hardware bus is unaffected by + * the Runtime PM state. + */ + pm_suspend_ignore_children(&dev->dev, true); + pm_runtime_enable(&dev->dev); + /* setup the private data */ adap = &pd->adap; i2c_set_adapdata(adap, pd); @@ -614,14 +630,33 @@ static int sh_mobile_i2c_remove(struct p iounmap(pd->reg); sh_mobile_i2c_hook_irqs(dev, 0); clk_put(pd->clk); + pm_runtime_disable(&dev->dev); kfree(pd); return 0; } +static int sh_mobile_i2c_runtime_nop(struct device *dev) +{ + /* Runtime PM callback shared between ->runtime_suspend() + * and ->runtime_resume(). Simply returns success. + * + * This driver re-initializes all registers after + * pm_runtime_get_sync() anyway so there is no need + * to save and restore registers here. + */ + return 0; +} + +static struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = { + .runtime_suspend = sh_mobile_i2c_runtime_nop, + .runtime_resume = sh_mobile_i2c_runtime_nop, +}; + static struct platform_driver sh_mobile_i2c_driver = { .driver = { .name = "i2c-sh_mobile", .owner = THIS_MODULE, + .pm = &sh_mobile_i2c_dev_pm_ops, }, .probe = sh_mobile_i2c_probe, .remove = sh_mobile_i2c_remove,